Skip to content

Commit

Permalink
initial commit for upgrade handler v1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
tuantran1702 committed Dec 29, 2023
1 parent ffd62f1 commit bb6430e
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions app/app_upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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))
}
}

0 comments on commit bb6430e

Please sign in to comment.