diff --git a/x/authz/module/module.go b/x/authz/module/module.go index 1b2f2933..74ecc960 100644 --- a/x/authz/module/module.go +++ b/x/authz/module/module.go @@ -3,6 +3,7 @@ package authz import ( "context" "encoding/json" + "fmt" abci "github.com/cometbft/cometbft/abci/types" "github.com/grpc-ecosystem/grpc-gateway/runtime" @@ -69,7 +70,9 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config sdkclient.TxEn // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the authz module. func (a AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx sdkclient.Context, mux *runtime.ServeMux) { - authz.RegisterQueryHandlerClient(context.Background(), mux, authz.NewQueryClient(clientCtx)) + if err := authz.RegisterQueryHandlerClient(context.Background(), mux, authz.NewQueryClient(clientCtx)); err != nil { + panic(fmt.Sprintf("could not register gRPC query service: %v", err)) + } } // GetQueryCmd returns the cli query commands for the authz module diff --git a/x/bank/keeper/keeper.go b/x/bank/keeper/keeper.go index ba8ad633..00bf6fde 100644 --- a/x/bank/keeper/keeper.go +++ b/x/bank/keeper/keeper.go @@ -34,6 +34,9 @@ type BaseKeeper struct { // GetPaginatedTotalSupply queries for the supply, ignoring 0 coins, with a given pagination func (k BaseKeeper) GetPaginatedTotalSupply(ctx sdk.Context, pagination *query.PageRequest) (sdk.Coins, *query.PageResponse, error) { issuers, err := k.mk.GetIssuers(ctx) + if err != nil { + return nil, nil, err + } supply := sdk.NewCoins() diff --git a/x/distribution/keeper/allocation.go b/x/distribution/keeper/allocation.go index 6ce08ecc..4391feaa 100644 --- a/x/distribution/keeper/allocation.go +++ b/x/distribution/keeper/allocation.go @@ -29,7 +29,9 @@ func (k Keeper) beforeAllocateTokens(ctx sdk.Context) error { // bondedVotes is a list of (validator address, validator voted on last block flag) for all // validators in the bonded set. func (k Keeper) AllocateTokens(ctx sdk.Context, totalPreviousPower int64, bondedVotes []abci.VoteInfo) { - k.beforeAllocateTokens(ctx) + if err := k.beforeAllocateTokens(ctx); err != nil { + panic(err) + } // fetch and clear the collected fees for distribution, since this is // called in BeginBlock, collected fees will be from the previous block diff --git a/x/distribution/keeper/params.go b/x/distribution/keeper/params.go index d72c122d..a923cc17 100644 --- a/x/distribution/keeper/params.go +++ b/x/distribution/keeper/params.go @@ -56,5 +56,7 @@ func (k Keeper) GetRewardWeights(ctx sdk.Context) []customtypes.RewardWeight { func (k Keeper) SetRewardWeights(ctx sdk.Context, rewardWeights []customtypes.RewardWeight) { params := k.GetParams(ctx) params.RewardWeights = rewardWeights - k.SetParams(ctx, params) + if err := k.SetParams(ctx, params); err != nil { + panic(err) + } } diff --git a/x/gov/genesis.go b/x/gov/genesis.go index d05bf7e4..0302ac15 100644 --- a/x/gov/genesis.go +++ b/x/gov/genesis.go @@ -13,7 +13,9 @@ import ( // InitGenesis - store genesis parameters func InitGenesis(ctx sdk.Context, ak types.AccountKeeper, bk types.BankKeeper, k *keeper.Keeper, data *v1.GenesisState) { k.SetProposalID(ctx, data.StartingProposalId) - k.SetParams(ctx, *data.Params) + if err := k.SetParams(ctx, *data.Params); err != nil { + panic(err) + } // check if the deposits pool account exists moduleAcc := k.GetGovernanceAccount(ctx) diff --git a/x/ibc/nft-transfer/keeper/genesis.go b/x/ibc/nft-transfer/keeper/genesis.go index 5cfeb130..93fbbcbe 100644 --- a/x/ibc/nft-transfer/keeper/genesis.go +++ b/x/ibc/nft-transfer/keeper/genesis.go @@ -27,7 +27,9 @@ func (k Keeper) InitGenesis(ctx sdk.Context, state types.GenesisState) { } } - k.SetParams(ctx, state.Params) + if err := k.SetParams(ctx, state.Params); err != nil { + panic(err) + } } // ExportGenesis exports ibc-transfer module's portID and denom trace info into its genesis state. diff --git a/x/ibc/nft-transfer/module.go b/x/ibc/nft-transfer/module.go index f1a28d71..f37249f5 100644 --- a/x/ibc/nft-transfer/module.go +++ b/x/ibc/nft-transfer/module.go @@ -64,7 +64,9 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the ibc-transfer module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + panic(fmt.Sprintf("could not register gRPC query service: %v", err)) + } } // GetTxCmd implements AppModuleBasic interface diff --git a/x/ibc/nft-transfer/types/trace.go b/x/ibc/nft-transfer/types/trace.go index 2882d19a..7b49a9d7 100644 --- a/x/ibc/nft-transfer/types/trace.go +++ b/x/ibc/nft-transfer/types/trace.go @@ -83,7 +83,7 @@ func extractPathAndBaseFromFullClassId(fullClassIdItems []string) (string, strin length := len(fullClassIdItems) for i := 0; i < length; i = i + 2 { - // The IBC specification does not guarentee the expected format of the + // The IBC specification does not guarantee the expected format of the // destination port or destination channel identifier. A short term solution // to determine base class id is to expect the channel identifier to be the // one ibc-go specifies. A longer term solution is to separate the path and base diff --git a/x/ibc/perm/module.go b/x/ibc/perm/module.go index 979df113..0e2f05fc 100644 --- a/x/ibc/perm/module.go +++ b/x/ibc/perm/module.go @@ -62,7 +62,9 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the ibc-transfer module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + panic(fmt.Sprintf("could not register gRPC gateway routes: %v", err)) + } } // GetTxCmd implements AppModuleBasic interface diff --git a/x/ibc/testing/events.go b/x/ibc/testing/events.go index 20dd8358..da04cb47 100644 --- a/x/ibc/testing/events.go +++ b/x/ibc/testing/events.go @@ -17,8 +17,8 @@ func ParseClientIDFromEvents(events sdk.Events) (string, error) { for _, ev := range events { if ev.Type == clienttypes.EventTypeCreateClient { for _, attr := range ev.Attributes { - if string(attr.Key) == clienttypes.AttributeKeyClientID { - return string(attr.Value), nil + if attr.Key == clienttypes.AttributeKeyClientID { + return attr.Value, nil } } } @@ -33,8 +33,8 @@ func ParseConnectionIDFromEvents(events sdk.Events) (string, error) { if ev.Type == connectiontypes.EventTypeConnectionOpenInit || ev.Type == connectiontypes.EventTypeConnectionOpenTry { for _, attr := range ev.Attributes { - if string(attr.Key) == connectiontypes.AttributeKeyConnectionID { - return string(attr.Value), nil + if attr.Key == connectiontypes.AttributeKeyConnectionID { + return attr.Value, nil } } } @@ -48,8 +48,8 @@ func ParseChannelIDFromEvents(events sdk.Events) (string, error) { for _, ev := range events { if ev.Type == channeltypes.EventTypeChannelOpenInit || ev.Type == channeltypes.EventTypeChannelOpenTry { for _, attr := range ev.Attributes { - if string(attr.Key) == channeltypes.AttributeKeyChannelID { - return string(attr.Value), nil + if attr.Key == channeltypes.AttributeKeyChannelID { + return attr.Value, nil } } } diff --git a/x/move/keeper/bank.go b/x/move/keeper/bank.go index f31b992e..ecb720b1 100644 --- a/x/move/keeper/bank.go +++ b/x/move/keeper/bank.go @@ -181,7 +181,10 @@ func (k MoveBankKeeper) BurnCoins( } // send tokens to 0x1 - k.SendCoin(ctx, accAddr, types.StdAddr, coin.Denom, coin.Amount) + err := k.SendCoin(ctx, accAddr, types.StdAddr, coin.Denom, coin.Amount) + if err != nil { + return err + } // execute burn metadata, err := types.MetadataAddressFromDenom(coin.Denom) diff --git a/x/move/keeper/dex.go b/x/move/keeper/dex.go index b8b7acb0..2783ccf7 100644 --- a/x/move/keeper/dex.go +++ b/x/move/keeper/dex.go @@ -307,6 +307,9 @@ func (k DexKeeper) getPoolWeights( timestamp := sdk.NewInt(ctx.BlockTime().Unix()) weightA, weightB, err := types.ReadWeightsFromDexConfig(timestamp, bz) + if err != nil { + return math.LegacyDec{}, math.LegacyDec{}, err + } if ok, err := k.isReverse(ctx, metadataLP); err != nil { return math.LegacyZeroDec(), math.LegacyZeroDec(), err diff --git a/x/move/keeper/genesis.go b/x/move/keeper/genesis.go index 274663ff..ce51541a 100644 --- a/x/move/keeper/genesis.go +++ b/x/move/keeper/genesis.go @@ -45,7 +45,9 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) ([]abc k.authKeeper.GetModuleAccount(ctx, types.MoveStakingModuleName) params := genState.GetParams() - k.SetRawParams(ctx, params.ToRaw()) + if err := k.SetRawParams(ctx, params.ToRaw()); err != nil { + return nil, err + } k.SetExecutionCounter(ctx, genState.ExecutionCounter) if len(genState.GetModules()) == 0 { diff --git a/x/move/keeper/handler.go b/x/move/keeper/handler.go index beec6dcb..467e739f 100644 --- a/x/move/keeper/handler.go +++ b/x/move/keeper/handler.go @@ -69,6 +69,9 @@ func (k Keeper) PublishModuleBundle( } codeBz, err := vmtypes.SerializeBytesVector(moduleCodeArr) + if err != nil { + return err + } // ignore staking deltas and events err = k.ExecuteEntryFunction( diff --git a/x/move/keeper/whitelist.go b/x/move/keeper/whitelist.go index dd7be5dc..00f5f845 100644 --- a/x/move/keeper/whitelist.go +++ b/x/move/keeper/whitelist.go @@ -123,7 +123,9 @@ func (k Keeper) Whitelist(ctx sdk.Context, msg types.MsgWhitelist) error { // register denomLP as staking bond denom bondDenoms = append(bondDenoms, denomLP) - k.StakingKeeper.SetBondDenoms(ctx, bondDenoms) + if err := k.StakingKeeper.SetBondDenoms(ctx, bondDenoms); err != nil { + return err + } // append denomLP reward weight to distribution keeper rewardWeights = append(rewardWeights, distrtypes.RewardWeight{Denom: denomLP, Weight: msg.RewardWeight}) @@ -213,7 +215,10 @@ func (k Keeper) Delist(ctx sdk.Context, msg types.MsgDelist) error { // remove coinLP denom from the staking bond denoms bondDenoms = append(bondDenoms[:bondDenomIndex], bondDenoms[bondDenomIndex+1:]...) - k.StakingKeeper.SetBondDenoms(ctx, bondDenoms) + err = k.StakingKeeper.SetBondDenoms(ctx, bondDenoms) + if err != nil { + return err + } // remove coinLP reward weight from the distribution reward weights rewardWeights = append(rewardWeights[:rewardWeightIndex], rewardWeights[rewardWeightIndex+1:]...) diff --git a/x/move/types/connector.go b/x/move/types/connector.go index 18a5466c..2ef74016 100644 --- a/x/move/types/connector.go +++ b/x/move/types/connector.go @@ -372,7 +372,7 @@ func ReadStoresFromPool(bz []byte) (vmtypes.AccountAddress, vmtypes.AccountAddre } storeB := bz[cursor : cursor+AddressBytesLength] - cursor += AddressBytesLength + cursor += AddressBytesLength //nolint storeBAddr, err := vmtypes.NewAccountAddressFromBytes(storeB) if err != nil { @@ -493,7 +493,7 @@ func ReadCollectionInfo(bz []byte) ( cursor += len uri = string(bz[cursor : cursor+uriLen]) - cursor += uriLen + cursor += uriLen //nolint return } @@ -527,7 +527,7 @@ func ReadNftInfo(bz []byte) (name, uri, desc string) { cursor += len uri = string(bz[cursor : cursor+uriLen]) - cursor += uriLen + cursor += uriLen //nolint return } diff --git a/x/move/types/keys.go b/x/move/types/keys.go index fe92edc3..e705dc94 100644 --- a/x/move/types/keys.go +++ b/x/move/types/keys.go @@ -78,7 +78,7 @@ func GetDexPairKey(metadata vmtypes.AccountAddress) []byte { // GetModulePrefix returns the prefix key of an account module store func GetModulePrefix(addr vmtypes.AccountAddress) []byte { - return append([]byte(addr.Bytes()), ModuleSeparator) + return append(addr.Bytes(), ModuleSeparator) } // GetModuleKey returns the key of the published move module diff --git a/x/mstaking/types/hooks.go b/x/mstaking/types/hooks.go index 483dc395..576c4a48 100644 --- a/x/mstaking/types/hooks.go +++ b/x/mstaking/types/hooks.go @@ -14,69 +14,101 @@ func NewMultiStakingHooks(hooks ...StakingHooks) MultiStakingHooks { } func (h MultiStakingHooks) AfterValidatorCreated(ctx sdk.Context, valAddr sdk.ValAddress) error { + var err error for i := range h { - h[i].AfterValidatorCreated(ctx, valAddr) + if err = h[i].AfterValidatorCreated(ctx, valAddr); err != nil { + return err + } } return nil } func (h MultiStakingHooks) BeforeValidatorModified(ctx sdk.Context, valAddr sdk.ValAddress) error { + var err error for i := range h { - h[i].BeforeValidatorModified(ctx, valAddr) + if err = h[i].BeforeValidatorModified(ctx, valAddr); err != nil { + return err + } } return nil } func (h MultiStakingHooks) AfterValidatorRemoved(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress) error { + var err error for i := range h { - h[i].AfterValidatorRemoved(ctx, consAddr, valAddr) + if err = h[i].AfterValidatorRemoved(ctx, consAddr, valAddr); err != nil { + return err + } } return nil } func (h MultiStakingHooks) AfterValidatorBonded(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress) error { + var err error for i := range h { - h[i].AfterValidatorBonded(ctx, consAddr, valAddr) + if err = h[i].AfterValidatorBonded(ctx, consAddr, valAddr); err != nil { + return err + } } return nil } + func (h MultiStakingHooks) AfterValidatorBeginUnbonding(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress) error { + var err error for i := range h { - h[i].AfterValidatorBeginUnbonding(ctx, consAddr, valAddr) + if err = h[i].AfterValidatorBeginUnbonding(ctx, consAddr, valAddr); err != nil { + return err + } } return nil } func (h MultiStakingHooks) BeforeDelegationCreated(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) error { + var err error for i := range h { - h[i].BeforeDelegationCreated(ctx, delAddr, valAddr) + if err = h[i].BeforeDelegationCreated(ctx, delAddr, valAddr); err != nil { + return err + } } return nil } func (h MultiStakingHooks) BeforeDelegationSharesModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) error { + var err error for i := range h { - h[i].BeforeDelegationSharesModified(ctx, delAddr, valAddr) + if err = h[i].BeforeDelegationSharesModified(ctx, delAddr, valAddr); err != nil { + return err + } } return nil } func (h MultiStakingHooks) BeforeDelegationRemoved(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) error { + var err error for i := range h { - h[i].BeforeDelegationRemoved(ctx, delAddr, valAddr) + if err = h[i].BeforeDelegationRemoved(ctx, delAddr, valAddr); err != nil { + return err + } } return nil } func (h MultiStakingHooks) AfterDelegationModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) error { + var err error for i := range h { - h[i].AfterDelegationModified(ctx, delAddr, valAddr) + if err = h[i].AfterDelegationModified(ctx, delAddr, valAddr); err != nil { + return err + } } return nil } func (h MultiStakingHooks) BeforeValidatorSlashed(ctx sdk.Context, valAddr sdk.ValAddress, fractions sdk.DecCoins) error { + var err error for i := range h { - h[i].BeforeValidatorSlashed(ctx, valAddr, fractions) + if err = h[i].BeforeValidatorSlashed(ctx, valAddr, fractions); err != nil { + return err + } } return nil } func (h MultiStakingHooks) AfterUnbondingInitiated(ctx sdk.Context, id uint64) error { + var err error for i := range h { - if err := h[i].AfterUnbondingInitiated(ctx, id); err != nil { + if err = h[i].AfterUnbondingInitiated(ctx, id); err != nil { return err } } @@ -93,8 +125,11 @@ func NewMultiSlashingHooks(hooks ...SlashingHooks) MultiSlashingHooks { } func (h MultiSlashingHooks) SlashUnbondingDelegations(ctx sdk.Context, valAddr sdk.ValAddress, fraction sdk.Dec) error { + var err error for i := range h { - h[i].SlashUnbondingDelegations(ctx, valAddr, fraction) + if err = h[i].SlashUnbondingDelegations(ctx, valAddr, fraction); err != nil { + return err + } } return nil } diff --git a/x/reward/abci.go b/x/reward/abci.go index 15066100..7105c842 100644 --- a/x/reward/abci.go +++ b/x/reward/abci.go @@ -48,7 +48,9 @@ func BeginBlocker(ctx sdk.Context, k keeper.Keeper) { releaseRate := params.ReleaseRate.Sub(params.ReleaseRate.Mul(params.DilutionRate)) // update store - k.SetReleaseRate(ctx, releaseRate) + if err := k.SetReleaseRate(ctx, releaseRate); err != nil { + panic(err) + } k.SetLastDilutionTimestamp(ctx, ctx.BlockTime()) } diff --git a/x/reward/keeper/genesis.go b/x/reward/keeper/genesis.go index 377abd61..35af745f 100644 --- a/x/reward/keeper/genesis.go +++ b/x/reward/keeper/genesis.go @@ -8,7 +8,9 @@ import ( // InitGenesis new mint genesis func (k Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) { - k.SetParams(ctx, data.Params) + if err := k.SetParams(ctx, data.Params); err != nil { + panic(err) + } k.SetLastReleaseTimestamp(ctx, data.LastReleaseTimestamp) k.SetLastDilutionTimestamp(ctx, data.LastDilutionTimestamp) diff --git a/x/slashing/keeper/genesis.go b/x/slashing/keeper/genesis.go index b8f8cf4f..46592ab6 100644 --- a/x/slashing/keeper/genesis.go +++ b/x/slashing/keeper/genesis.go @@ -16,7 +16,9 @@ func (k Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) { if err != nil { panic(err) } - k.AddPubkey(ctx, consPk) + if err = k.AddPubkey(ctx, consPk); err != nil { + panic(err) + } return false }, )