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 63ae124 commit 142bc2e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
7 changes: 4 additions & 3 deletions x/bank/keeper/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ 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 {
m.MigrateSendEnabledParams(ctx)
return v4.MigrateStore(ctx, m.keeper.storeKey, m.legacySubspace, m.keeper.cdc)
}

// Migrate3to4WithSendEnabledParams migrates x/bank storage from version 3 to 4 with
// MigrateSendEnabledParams 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 {
// This function is only needed for chains having migrated from <= v0.47 to v0.47.0-5
func (m Migrator) MigrateSendEnabledParams(ctx sdk.Context) {
sendEnabled := types.GetSendEnabledParams(ctx, m.legacySubspace)
m.keeper.SetAllSendEnabled(ctx, sendEnabled)
return v4.MigrateStore(ctx, m.keeper.storeKey, m.legacySubspace, m.keeper.cdc)
}
8 changes: 1 addition & 7 deletions 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.Migrate3to4WithSendEnabledParams); err != nil {
if err := cfg.RegisterMigration(types.ModuleName, 3, m.Migrate3to4); err != nil {
panic(fmt.Sprintf("failed to migrate x/bank from version 3 to 4: %v", err))
}
}
Expand Down Expand Up @@ -197,12 +197,6 @@ 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 142bc2e

Please sign in to comment.