From ea466fe63207a75ab7e1da6e3a838c3e3c4ed26c Mon Sep 17 00:00:00 2001 From: "jaeseung.bae" Date: Wed, 6 Mar 2024 09:50:03 +0900 Subject: [PATCH] chore: add all migrator from original bank modules --- x/bankplus/keeper/migrations.go | 12 ++++++++---- x/bankplus/module/module.go | 9 +++++++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/x/bankplus/keeper/migrations.go b/x/bankplus/keeper/migrations.go index 194cb03453..088f02a02a 100644 --- a/x/bankplus/keeper/migrations.go +++ b/x/bankplus/keeper/migrations.go @@ -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 { @@ -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) } diff --git a/x/bankplus/module/module.go b/x/bankplus/module/module.go index d1618d1ffb..e04cbf393d 100644 --- a/x/bankplus/module/module.go +++ b/x/bankplus/module/module.go @@ -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)) } }