From e5847ac0b4f0319811d62140f4e438d33163ad0d Mon Sep 17 00:00:00 2001 From: angelorc Date: Tue, 7 Feb 2023 12:56:58 +0100 Subject: [PATCH] chore: add v014 upgrade handler --- app/app.go | 15 +++++++++++++++ app/upgrades/v014/constants.go | 5 +++++ app/upgrades/v014/upgrades.go | 13 +++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 app/upgrades/v014/constants.go create mode 100644 app/upgrades/v014/upgrades.go diff --git a/app/app.go b/app/app.go index 1ae516f6..b7b8e515 100644 --- a/app/app.go +++ b/app/app.go @@ -3,6 +3,7 @@ package app import ( "fmt" v013 "github.com/bitsongofficial/go-bitsong/app/upgrades/v013" + v014 "github.com/bitsongofficial/go-bitsong/app/upgrades/v014" "strings" v010 "github.com/bitsongofficial/go-bitsong/app/upgrades/v010" @@ -843,6 +844,15 @@ func (app *BitsongApp) setupUpgradeStoreLoaders() { // configure store loader that checks if version == upgradeHeight and applies store upgrades app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) } + + // v14 Upgrade + if upgradeInfo.Name == v014.UpgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { + storeUpgrades := store.StoreUpgrades{} + + // configure store loader that checks if version == upgradeHeight and applies store upgrades + app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) + } + } func (app *BitsongApp) setupUpgradeHandlers() { @@ -860,6 +870,11 @@ func (app *BitsongApp) setupUpgradeHandlers() { v013.UpgradeName, v013.CreateUpgradeHandler(app.mm, app.configurator, &app.wasmKeeper), ) + + app.UpgradeKeeper.SetUpgradeHandler( + v014.UpgradeName, + v014.CreateUpgradeHandler(app.mm, app.configurator), + ) } // RegisterSwaggerAPI registers swagger route with API Server diff --git a/app/upgrades/v014/constants.go b/app/upgrades/v014/constants.go new file mode 100644 index 00000000..ab6d5f45 --- /dev/null +++ b/app/upgrades/v014/constants.go @@ -0,0 +1,5 @@ +package v014 + +const ( + UpgradeName = "v014" +) diff --git a/app/upgrades/v014/upgrades.go b/app/upgrades/v014/upgrades.go new file mode 100644 index 00000000..146fc4b2 --- /dev/null +++ b/app/upgrades/v014/upgrades.go @@ -0,0 +1,13 @@ +package v014 + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" +) + +func CreateUpgradeHandler(mm *module.Manager, configurator module.Configurator) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, _plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { + return mm.RunMigrations(ctx, configurator, vm) + } +}