diff --git a/x/mint/keeper/migrations.go b/x/mint/keeper/migrations.go index 9b5879ee..8ed612a9 100644 --- a/x/mint/keeper/migrations.go +++ b/x/mint/keeper/migrations.go @@ -3,22 +3,19 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/okp4/okp4d/x/mint/exported" v3 "github.com/okp4/okp4d/x/mint/migrations/v3" ) type Migrator struct { - keeper Keeper - legacySubspace exported.Subspace + keeper Keeper } -func NewMigrator(keeper Keeper, legacySubspace exported.Subspace) Migrator { +func NewMigrator(keeper Keeper) Migrator { return Migrator{ - keeper: keeper, - legacySubspace: legacySubspace, + keeper: keeper, } } func (m Migrator) Migrate2to3(ctx sdk.Context) error { - return v3.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc, m.legacySubspace) + return v3.MigrateStore(ctx, ctx.KVStore(m.keeper.storeKey), m.keeper.cdc) } diff --git a/x/mint/migrations/v3/migrations.go b/x/mint/migrations/v3/migrations.go index 338c8f1d..49c15f8f 100644 --- a/x/mint/migrations/v3/migrations.go +++ b/x/mint/migrations/v3/migrations.go @@ -2,18 +2,16 @@ package v3 import ( "github.com/cosmos/cosmos-sdk/codec" - storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/okp4/okp4d/x/mint/exported" + "github.com/okp4/okp4d/x/mint/types" ) // MigrateStore migrates the x/mint module state from the consensus version 2 to // version 3. +// This version include new/deleted parameters in store. func MigrateStore(ctx sdk.Context, - storeKey storetypes.StoreKey, + store sdk.KVStore, cdc codec.BinaryCodec, - legacySubspace exported.Subspace, ) error { logger := ctx.Logger(). With("module", "mint"). @@ -23,7 +21,13 @@ func MigrateStore(ctx sdk.Context, logger.Debug("migrate mint params") - // TODO: + newParams := types.DefaultParams() + + bz, err := cdc.Marshal(&newParams) + if err != nil { + return err + } + store.Set(types.ParamsKey, bz) logger.Debug("module migration done") diff --git a/x/mint/module.go b/x/mint/module.go index 2cd8e541..b9d133d9 100644 --- a/x/mint/module.go +++ b/x/mint/module.go @@ -18,7 +18,6 @@ import ( simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/okp4/okp4d/x/mint/client/cli" - "github.com/okp4/okp4d/x/mint/exported" "github.com/okp4/okp4d/x/mint/keeper" "github.com/okp4/okp4d/x/mint/simulation" "github.com/okp4/okp4d/x/mint/types" @@ -87,17 +86,14 @@ type AppModule struct { keeper keeper.Keeper authKeeper types.AccountKeeper - // legacySubspace is used principally for migration - legacySubspace exported.Subspace } // NewAppModule creates a new AppModule object. -func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak types.AccountKeeper, legacySubspace exported.Subspace) AppModule { +func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak types.AccountKeeper) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{cdc: cdc}, keeper: keeper, authKeeper: ak, - legacySubspace: legacySubspace, } } @@ -115,7 +111,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) types.RegisterQueryServer(cfg.QueryServer(), am.keeper) - migrator := keeper.NewMigrator(am.keeper, am.legacySubspace) + migrator := keeper.NewMigrator(am.keeper) migrations := []struct { fromVersion uint64