Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Oct 13, 2023
1 parent f9e0c59 commit 63ae124
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions x/bank/keeper/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ func (m Migrator) Migrate2to3(ctx sdk.Context) error {

// Migrate3to4 migrates x/bank storage from version 3 to 4.
func (m Migrator) Migrate3to4(ctx sdk.Context) error {
return v4.MigrateStore(ctx, m.keeper.storeKey, m.legacySubspace, m.keeper.cdc)
}

// Migrate3to4WithSendEnabledParams migrates x/bank storage from version 3 to 4 with
// the send enabled params get from x/params and update the bank params.
func (m Migrator) Migrate3to4WithSendEnabledParams(ctx sdk.Context) error {
sendEnabled := types.GetSendEnabledParams(ctx, m.legacySubspace)
m.keeper.SetAllSendEnabled(ctx, sendEnabled)
return v4.MigrateStore(ctx, m.keeper.storeKey, m.legacySubspace, m.keeper.cdc)
Expand Down
8 changes: 7 additions & 1 deletion x/bank/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
panic(fmt.Sprintf("failed to migrate x/bank from version 2 to 3: %v", err))
}

if err := cfg.RegisterMigration(types.ModuleName, 3, m.Migrate3to4); err != nil {
if err := cfg.RegisterMigration(types.ModuleName, 3, m.Migrate3to4WithSendEnabledParams); err != nil {
panic(fmt.Sprintf("failed to migrate x/bank from version 3 to 4: %v", err))
}
}
Expand Down Expand Up @@ -197,6 +197,12 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp
)
}

// MigrateSubspaceParams get send enabled params from x/params and update the bank params.
func (am AppModule) MigrateSubspaceParams(ctx sdk.Context) {
sendEnabled := types.GetSendEnabledParams(ctx, am.legacySubspace)
am.keeper.SetAllSendEnabled(ctx, sendEnabled)
}

// App Wiring Setup

func init() {
Expand Down

0 comments on commit 63ae124

Please sign in to comment.