Skip to content

Commit

Permalink
chore: add all migrator from original bank modules
Browse files Browse the repository at this point in the history
  • Loading branch information
jaeseung-bae committed Mar 6, 2024
1 parent b857f02 commit ea466fe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
12 changes: 8 additions & 4 deletions x/bankplus/keeper/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package keeper
import (
sdk "github.com/cosmos/cosmos-sdk/types"
bankv2 "github.com/cosmos/cosmos-sdk/x/bank/migrations/v2"
bankv3 "github.com/cosmos/cosmos-sdk/x/bank/migrations/v3"
)

type Migrator struct {
Expand All @@ -13,11 +14,14 @@ func NewMigrator(keeper BaseKeeper) *Migrator {
return &Migrator{keeper: keeper}
}

func (m Migrator) WrappedMigrateBankplusWithBankMigrate1to2(ctx sdk.Context) error {
err := DeprecateBankPlus(ctx, m.keeper.storeService)
if err != nil {
func (m Migrator) WrappedMigrateBankplusWithBankMigrate1to2n3(ctx sdk.Context) error {
if err := DeprecateBankPlus(ctx, m.keeper.storeService); err != nil {
return err
}

return bankv2.MigrateStore(ctx, m.keeper.storeService, m.keeper.cdc)
if err := bankv2.MigrateStore(ctx, m.keeper.storeService, m.keeper.cdc); err != nil {
return err
}

return bankv3.MigrateStore(ctx, m.keeper.storeService, m.keeper.cdc)
}
9 changes: 7 additions & 2 deletions x/bankplus/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,13 @@ func (a AppModule) RegisterServices(cfg module.Configurator) {
banktypes.RegisterMsgServer(cfg.MsgServer(), bankkeeper.NewMsgServerImpl(a.bankKeeper))
banktypes.RegisterQueryServer(cfg.QueryServer(), a.bankKeeper)
bkplusMigrator := keeper.NewMigrator(a.bankplusKeeper)
if err := cfg.RegisterMigration(banktypes.ModuleName, 1, bkplusMigrator.WrappedMigrateBankplusWithBankMigrate1to2); err != nil {
panic(fmt.Sprintf("failed to migrate x/bank from version 1 to 2: %v", err))
if err := cfg.RegisterMigration(banktypes.ModuleName, 2, bkplusMigrator.WrappedMigrateBankplusWithBankMigrate1to2n3); err != nil {
panic(fmt.Sprintf("failed to migrate x/bank from version 1 to 2,3(including original bank1 to 2,3: %v", err))
}

m := bankkeeper.NewMigrator(a.bankKeeper.(bankkeeper.BaseKeeper), a.legacySubspace)
if err := cfg.RegisterMigration(banktypes.ModuleName, 3, m.Migrate3to4); err != nil {
panic(fmt.Sprintf("failed to migrate x/bank from version 3 to 4: %v", err))
}
}

Expand Down

0 comments on commit ea466fe

Please sign in to comment.