From 69d8fa2bafa2c5ca5b8f1fd91ef379cec0b07d03 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Fri, 8 Jul 2022 02:38:18 -0400 Subject: [PATCH] chore: params cleanup (#12480) Adds missing error checks to the modules that migrated away from `x/params` --- x/distribution/module.go | 11 +++++------ x/gov/module.go | 18 +++++++++--------- x/mint/keeper/genesis.go | 6 +++++- x/slashing/keeper/genesis.go | 4 +++- x/staking/module.go | 14 ++++++-------- 5 files changed, 28 insertions(+), 25 deletions(-) diff --git a/x/distribution/module.go b/x/distribution/module.go index 91a058f1aa..c303b2712e 100644 --- a/x/distribution/module.go +++ b/x/distribution/module.go @@ -4,14 +4,14 @@ import ( "context" "encoding/json" "fmt" - govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" "math/rand" + modulev1 "cosmossdk.io/api/cosmos/distribution/module/v1" + "cosmossdk.io/core/appmodule" gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" - "cosmossdk.io/core/appmodule" sdkclient "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -22,14 +22,13 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" - staking "github.com/cosmos/cosmos-sdk/x/staking/types" - - modulev1 "cosmossdk.io/api/cosmos/distribution/module/v1" "github.com/cosmos/cosmos-sdk/x/distribution/client/cli" "github.com/cosmos/cosmos-sdk/x/distribution/keeper" "github.com/cosmos/cosmos-sdk/x/distribution/simulation" "github.com/cosmos/cosmos-sdk/x/distribution/types" + govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" + staking "github.com/cosmos/cosmos-sdk/x/staking/types" ) var ( diff --git a/x/gov/module.go b/x/gov/module.go index edef902471..2147096a39 100644 --- a/x/gov/module.go +++ b/x/gov/module.go @@ -4,27 +4,26 @@ package gov import ( "context" - modulev1 "cosmossdk.io/api/cosmos/gov/module/v1" - "cosmossdk.io/core/appmodule" "encoding/json" "fmt" - "github.com/cosmos/cosmos-sdk/baseapp" - "github.com/cosmos/cosmos-sdk/depinject" - "github.com/cosmos/cosmos-sdk/runtime" - store "github.com/cosmos/cosmos-sdk/store/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - "golang.org/x/exp/maps" - "golang.org/x/exp/slices" "math/rand" "sort" + modulev1 "cosmossdk.io/api/cosmos/gov/module/v1" + "cosmossdk.io/core/appmodule" gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" + "golang.org/x/exp/maps" + "golang.org/x/exp/slices" + "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/depinject" + "github.com/cosmos/cosmos-sdk/runtime" + store "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" @@ -35,6 +34,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/gov/types" v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) var ( diff --git a/x/mint/keeper/genesis.go b/x/mint/keeper/genesis.go index c6a120bee7..ce0d9361b7 100644 --- a/x/mint/keeper/genesis.go +++ b/x/mint/keeper/genesis.go @@ -8,7 +8,11 @@ import ( // InitGenesis new mint genesis func (keeper Keeper) InitGenesis(ctx sdk.Context, ak types.AccountKeeper, data *types.GenesisState) { keeper.SetMinter(ctx, data.Minter) - keeper.SetParams(ctx, data.Params) + + if err := keeper.SetParams(ctx, data.Params); err != nil { + panic(err) + } + ak.GetModuleAccount(ctx, types.ModuleName) } diff --git a/x/slashing/keeper/genesis.go b/x/slashing/keeper/genesis.go index 469947ed38..e53ef3730c 100644 --- a/x/slashing/keeper/genesis.go +++ b/x/slashing/keeper/genesis.go @@ -38,7 +38,9 @@ func (keeper Keeper) InitGenesis(ctx sdk.Context, stakingKeeper types.StakingKee } } - keeper.SetParams(ctx, data.Params) + if err := keeper.SetParams(ctx, data.Params); err != nil { + panic(err) + } } // ExportGenesis writes the current store values diff --git a/x/staking/module.go b/x/staking/module.go index 4bbbf2d05c..944d7d4842 100644 --- a/x/staking/module.go +++ b/x/staking/module.go @@ -7,25 +7,23 @@ import ( "math/rand" "sort" - gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" - "golang.org/x/exp/maps" - modulev1 "cosmossdk.io/api/cosmos/staking/module/v1" "cosmossdk.io/core/appmodule" - "github.com/cosmos/cosmos-sdk/depinject" - "github.com/cosmos/cosmos-sdk/runtime" - store "github.com/cosmos/cosmos-sdk/store/types" - paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" - + gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" + "golang.org/x/exp/maps" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/depinject" + "github.com/cosmos/cosmos-sdk/runtime" + store "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/cosmos/cosmos-sdk/x/staking/client/cli" "github.com/cosmos/cosmos-sdk/x/staking/keeper" "github.com/cosmos/cosmos-sdk/x/staking/simulation"