Skip to content

Commit

Permalink
fixed lint errors in claim/utils/icacallbacks/mint/icaoracle/intercha…
Browse files Browse the repository at this point in the history
…inquery
  • Loading branch information
sampocs committed Aug 23, 2024
1 parent c176fe6 commit af9debb
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 27 deletions.
2 changes: 1 addition & 1 deletion utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func Int64ToCoinString(amount int64, denom string) string {

func ValidateAdminAddress(address string) error {
if !Admins[address] {
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, fmt.Sprintf("address (%s) is not an admin", address))
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "address (%s) is not an admin", address)
}
return nil
}
Expand Down
12 changes: 6 additions & 6 deletions x/claim/keeper/claim.go
Original file line number Diff line number Diff line change
Expand Up @@ -849,13 +849,13 @@ func (k Keeper) DeleteAirdropAndEpoch(ctx sdk.Context, identifier string) error
func (k Keeper) UpdateAirdropAddress(ctx sdk.Context, existingStrideAddress string, newStrideAddress string, airdropId string) error {
airdrop := k.GetAirdropByIdentifier(ctx, airdropId)
if airdrop == nil {
return errorsmod.Wrapf(types.ErrAirdropNotFound, fmt.Sprintf("airdrop not found for identifier %s", airdropId))
return errorsmod.Wrapf(types.ErrAirdropNotFound, "airdrop not found for identifier %s", airdropId)
}

// verify that the strideAddress is valid
_, err := sdk.AccAddressFromBech32(newStrideAddress)
if err != nil {
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, fmt.Sprintf("invalid stride address %s", newStrideAddress))
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid stride address %s", newStrideAddress)
}

// note: existingAccAddress will be a STRIDE address with the same coin type as existingAddress
Expand All @@ -865,26 +865,26 @@ func (k Keeper) UpdateAirdropAddress(ctx sdk.Context, existingStrideAddress stri
existingAccAddress, err := sdk.AccAddressFromBech32(existingStrideAddress)
if err != nil {
return errorsmod.Wrapf(types.ErrClaimNotFound,
fmt.Sprintf("error getting claim record for address %s on airdrop %s", existingStrideAddress, airdropId))
"error getting claim record for address %s on airdrop %s", existingStrideAddress, airdropId)
}
claimRecord, err := k.GetClaimRecord(ctx, existingAccAddress, airdrop.AirdropIdentifier)
if (err != nil) || (claimRecord.Address == "") {
return errorsmod.Wrapf(types.ErrClaimNotFound,
fmt.Sprintf("error getting claim record for address %s on airdrop %s", existingStrideAddress, airdropId))
"error getting claim record for address %s on airdrop %s", existingStrideAddress, airdropId)
}

claimRecord.Address = newStrideAddress
err = k.SetClaimRecord(ctx, claimRecord) // this does NOT delete the old record, because claims are indexed by address
if err != nil {
return errorsmod.Wrapf(types.ErrModifyingClaimRecord,
fmt.Sprintf("error setting claim record from address %s to address %s on airdrop %s", existingStrideAddress, newStrideAddress, airdropId))
"error setting claim record from address %s to address %s on airdrop %s", existingStrideAddress, newStrideAddress, airdropId)
}

// this deletes the old record
err = k.DeleteClaimRecord(ctx, existingAccAddress, airdrop.AirdropIdentifier)
if err != nil {
return errorsmod.Wrapf(types.ErrModifyingClaimRecord,
fmt.Sprintf("error deleting claim record for address %s on airdrop %s", existingStrideAddress, airdropId))
"error deleting claim record for address %s on airdrop %s", existingStrideAddress, airdropId)
}

return nil
Expand Down
10 changes: 3 additions & 7 deletions x/icacallbacks/ibc_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,8 @@ func (im IBCModule) OnAcknowledgementPacket(

ackResponse, err := UnpackAcknowledgementResponse(ctx, im.keeper.Logger(ctx), acknowledgement, true)
if err != nil {
errMsg := fmt.Sprintf("Unable to unpack message data from acknowledgement, Sequence %d, from %s %s, to %s %s: %s",
modulePacket.Sequence, modulePacket.SourceChannel, modulePacket.SourcePort, modulePacket.DestinationChannel, modulePacket.DestinationPort, err.Error())
im.keeper.Logger(ctx).Error(errMsg)
return errorsmod.Wrapf(types.ErrInvalidAcknowledgement, errMsg)
return errorsmod.Wrapf(err, "unable to unpack message data from acknowledgement, Sequence %d, from %s %s, to %s %s",
modulePacket.Sequence, modulePacket.SourceChannel, modulePacket.SourcePort, modulePacket.DestinationChannel, modulePacket.DestinationPort)
}

ackInfo := fmt.Sprintf("sequence #%d, from %s %s, to %s %s",
Expand All @@ -123,10 +121,8 @@ func (im IBCModule) OnAcknowledgementPacket(
)

if err := im.keeper.CallRegisteredICACallback(ctx, modulePacket, ackResponse); err != nil {
errMsg := fmt.Sprintf("Unable to call registered ICACallback from OnAcknowledgePacket | Sequence %d, from %s %s, to %s %s",
return errorsmod.Wrapf(err, "unable to call registered ICACallback from OnAcknowledgePacket | Sequence %d, from %s %s, to %s %s",
modulePacket.Sequence, modulePacket.SourceChannel, modulePacket.SourcePort, modulePacket.DestinationChannel, modulePacket.DestinationPort)
im.keeper.Logger(ctx).Error(errMsg)
return errorsmod.Wrapf(types.ErrCallbackFailed, errMsg)
}
return nil
}
Expand Down
4 changes: 1 addition & 3 deletions x/icacallbacks/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ func (k Keeper) CallRegisteredICACallback(ctx sdk.Context, packet channeltypes.P
return nil
}
if err := callback.CallbackFunc(ctx, packet, ackResponse, callbackData.CallbackArgs); err != nil {
errMsg := fmt.Sprintf("Error occured while calling ICACallback (%s) | err: %s", callbackData.CallbackId, err.Error())
k.Logger(ctx).Error(errMsg)
return errorsmod.Wrapf(types.ErrCallbackFailed, errMsg)
return errorsmod.Wrapf(err, "failed to invoke icacallback %s", callbackData.CallbackId)
}

// remove the callback data
Expand Down
2 changes: 1 addition & 1 deletion x/icaoracle/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func DefaultGenesis() *GenesisState {
// failure.
func (gs GenesisState) Validate() error {
if err := gs.Params.Validate(); err != nil {
return errorsmod.Wrapf(ErrInvalidGenesisState, err.Error())
return errorsmod.Wrapf(err, "invalid genesis state")
}
for _, oracle := range gs.Oracles {
if oracle.ChainId == "" {
Expand Down
6 changes: 3 additions & 3 deletions x/interchainquery/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ func (k *Keeper) SubmitICQRequest(ctx sdk.Context, query types.Query, forceUniqu
// In the query response, this will be used to verify that the query wasn't historical
connection, found := k.IBCKeeper.ConnectionKeeper.GetConnection(ctx, query.ConnectionId)
if !found {
return errorsmod.Wrapf(connectiontypes.ErrConnectionNotFound, query.ConnectionId)
return errorsmod.Wrapf(connectiontypes.ErrConnectionNotFound, "%s", query.ConnectionId)
}
clientState, found := k.IBCKeeper.ClientKeeper.GetClientState(ctx, connection.ClientId)
if !found {
return errorsmod.Wrapf(clienttypes.ErrClientNotFound, connection.ClientId)
return errorsmod.Wrapf(clienttypes.ErrClientNotFound, "%s", connection.ClientId)
}
query.SubmissionHeight = clientState.GetLatestHeight().GetRevisionHeight()

Expand All @@ -96,7 +96,7 @@ func (k *Keeper) RetryICQRequest(ctx sdk.Context, query types.Query) error {

// Submit a new query (with a new ID)
if err := k.SubmitICQRequest(ctx, query, true); err != nil {
return errorsmod.Wrapf(err, types.ErrFailedToRetryQuery.Error())
return errorsmod.Wrapf(err, "failed to retry query")
}

return nil
Expand Down
10 changes: 4 additions & 6 deletions x/mint/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,7 @@ func (k Keeper) DistributeMintedCoin(ctx sdk.Context, mintedCoin sdk.Coin) error
// allocate pool allocation ratio to strategic reserve
strategicReserveAddress, err := sdk.AccAddressFromBech32(StrategicReserveAddress)
if err != nil {
errMsg := fmt.Sprintf("invalid strategic reserve address: %s", StrategicReserveAddress)
k.Logger(ctx).Error(errMsg)
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, errMsg)
return errorsmod.Wrapf(err, "invalid strategic reserve address: %s", StrategicReserveAddress)
}
strategicReserveProportion := k.GetProportions(ctx, mintedCoin, proportions.StrategicReserve)
strategicReserveCoins := sdk.NewCoins(strategicReserveProportion)
Expand Down Expand Up @@ -196,9 +194,9 @@ func (k Keeper) DistributeMintedCoin(ctx sdk.Context, mintedCoin sdk.Coin) error
remainingBal := remainingCoins.AmountOf(sdk.DefaultBondDenom)
thresh := sdk.NewDec(5).Quo(sdk.NewDec(100))
if sdk.NewDecFromInt(remainingBal).Quo(sdk.NewDecFromInt(mintedCoin.Amount)).GT(thresh) {
errMsg := fmt.Sprintf("Failed to divvy up mint module rewards fully -- remaining coins should be LT 5pct of total, instead are %#v/%#v", remainingCoins, remainingBal)
k.Logger(ctx).Error(errMsg)
return errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, errMsg)
return errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds,
"Failed to divvy up mint module rewards fully -- remaining coins should be LT 5pct of total, instead are %#v/%#v",
remainingCoins, remainingBal)
}

err = k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, k.feeCollectorName, stakingIncentivesCoins)
Expand Down

0 comments on commit af9debb

Please sign in to comment.