From bb6430e3a0775738a335d9ff31803cfee4c6134a Mon Sep 17 00:00:00 2001 From: TuanTran Date: Fri, 29 Dec 2023 16:46:33 +0700 Subject: [PATCH] initial commit for upgrade handler v1.2 --- app/app_upgrades.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/app/app_upgrades.go b/app/app_upgrades.go index 22b58877..dd328414 100644 --- a/app/app_upgrades.go +++ b/app/app_upgrades.go @@ -20,6 +20,7 @@ const MarketplaceModuleName = "marketplace" func (app *App) SetUpgradeHandlers() { setHandlerForVersion_1_0(app) setHandlerForVersion_1_1(app) + setHandlerForVersion_1_2(app) } func setHandlerForVersion_1_0(app *App) { @@ -76,3 +77,29 @@ func setHandlerForVersion_1_1(app *App) { app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) } } + +func setHandlerForVersion_1_2(app *App) { + const upgradeVersion string = "v1.2" + + app.UpgradeKeeper.SetUpgradeHandler(upgradeVersion, func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + return app.mm.RunMigrations(ctx, app.configurator, fromVM) + }) + + upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() + if err != nil { + panic(err) + } + + if upgradeInfo.Name == upgradeVersion && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { + storeUpgrades := storetypes.StoreUpgrades{ + Added: []string{}, + Deleted: []string{ + AddressBookModuleName, + MarketplaceModuleName, + NftModuleName, + }, + } + + app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) + } +}