refactor: move x/auth, x/authz, x/slashing and x/mint Init/Export genesis to keeper (#11871)

This commit is contained in:
likhita-809
2022-05-04 12:50:33 -04:00
committed by GitHub
parent 710b57c0fb
commit 6e18f582bf
10 changed files with 73 additions and 71 deletions
@@ -1,8 +1,7 @@
package auth
package keeper
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/keeper"
"github.com/cosmos/cosmos-sdk/x/auth/types"
)
@@ -10,7 +9,7 @@ import (
//
// CONTRACT: old coins from the FeeCollectionKeeper need to be transferred through
// a genesis port script to the new fee collector account
func InitGenesis(ctx sdk.Context, ak keeper.AccountKeeper, data types.GenesisState) {
func (ak AccountKeeper) InitGenesis(ctx sdk.Context, data types.GenesisState) {
ak.SetParams(ctx, data.Params)
accounts, err := types.UnpackAccounts(data.Accounts)
@@ -28,7 +27,7 @@ func InitGenesis(ctx sdk.Context, ak keeper.AccountKeeper, data types.GenesisSta
}
// ExportGenesis returns a GenesisState for a given context and keeper
func ExportGenesis(ctx sdk.Context, ak keeper.AccountKeeper) *types.GenesisState {
func (ak AccountKeeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
params := ak.GetParams(ctx)
var genAccounts types.GenesisAccounts
+2 -2
View File
@@ -136,14 +136,14 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate {
var genesisState types.GenesisState
cdc.MustUnmarshalJSON(data, &genesisState)
InitGenesis(ctx, am.accountKeeper, genesisState)
am.accountKeeper.InitGenesis(ctx, genesisState)
return []abci.ValidatorUpdate{}
}
// ExportGenesis returns the exported genesis state as raw bytes for the auth
// module.
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
gs := ExportGenesis(ctx, am.accountKeeper)
gs := am.accountKeeper.ExportGenesis(ctx)
return cdc.MustMarshalJSON(gs)
}