diff --git a/golang/cosmos/x/vbank/keeper/keeper.go b/golang/cosmos/x/vbank/keeper/keeper.go index d6f948356e5..4e2932d8bfd 100644 --- a/golang/cosmos/x/vbank/keeper/keeper.go +++ b/golang/cosmos/x/vbank/keeper/keeper.go @@ -93,7 +93,7 @@ func (k Keeper) IsAllowedMonitoringAccount(ctx sdk.Context, addr sdk.AccAddress) } func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { - k.paramSpace.GetParamSet(ctx, ¶ms) + k.paramSpace.GetParamSetIfExists(ctx, ¶ms) return params } diff --git a/golang/cosmos/x/vbank/keeper/migrations.go b/golang/cosmos/x/vbank/keeper/migrations.go new file mode 100644 index 00000000000..360d691bd61 --- /dev/null +++ b/golang/cosmos/x/vbank/keeper/migrations.go @@ -0,0 +1,30 @@ +package keeper + +import ( + "github.com/Agoric/agoric-sdk/golang/cosmos/x/vbank/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// Migrator handles in-place store migrations. +type Migrator struct { + keeper Keeper +} + +// NewMigrator creates a new Migrator based on the keeper. +func NewMigrator(keeper Keeper) Migrator { + return Migrator{keeper: keeper} +} + +// Migrate1to2 migrates from version 1 to 2. +func (m Migrator) Migrate1to2(ctx sdk.Context) error { + params := m.keeper.GetParams(ctx) + if params.AllowedMonitoringAccounts != nil { + return nil + } + + defaultParams := types.DefaultParams() + params.AllowedMonitoringAccounts = defaultParams.AllowedMonitoringAccounts + m.keeper.SetParams(ctx, params) + + return nil +} diff --git a/golang/cosmos/x/vbank/module.go b/golang/cosmos/x/vbank/module.go index 4f982f030ed..0d755d6a60b 100644 --- a/golang/cosmos/x/vbank/module.go +++ b/golang/cosmos/x/vbank/module.go @@ -91,7 +91,7 @@ func (AppModule) Name() string { return ModuleName } -func (AppModule) ConsensusVersion() uint64 { return 1 } +func (AppModule) ConsensusVersion() uint64 { return 2 } // BeginBlock implements the AppModule interface func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) { @@ -204,6 +204,12 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { tx := &types.UnimplementedMsgServer{} types.RegisterMsgServer(cfg.MsgServer(), tx) types.RegisterQueryServer(cfg.QueryServer(), am.keeper) + + m := keeper.NewMigrator(am.keeper) + err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2) + if err != nil { + panic(err) + } } // InitGenesis performs genesis initialization for the ibc-transfer module. It returns