Skip to content

Commit

Permalink
feat: v0.3.0 upgrade handler (#319)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamewozniak authored Nov 15, 2023
1 parent dba3a2c commit 1ba3d24
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
gmptypes "github.com/ojo-network/ojo/x/gmp/types"

oraclekeeper "github.com/ojo-network/ojo/x/oracle/keeper"
oracletypes "github.com/ojo-network/ojo/x/oracle/types"
Expand All @@ -33,6 +34,7 @@ func (app App) RegisterUpgradeHandlers() {
app.registerUpgrade0_2_0(upgradeInfo)
app.registerUpgrade0_2_1(upgradeInfo)
app.registerUpgrade0_2_2(upgradeInfo)
app.registerUpgrade0_3_0(upgradeInfo)
}

// performs upgrade from v0.1.3 to v0.1.4
Expand Down Expand Up @@ -132,6 +134,22 @@ func (app *App) registerUpgrade0_2_2(_ upgradetypes.Plan) {
)
}

func (app *App) registerUpgrade0_3_0(upgradeInfo upgradetypes.Plan) {
const planName = "v0.3.0"
app.UpgradeKeeper.SetUpgradeHandler(planName,
func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
ctx.Logger().Info("Upgrade handler execution", "name", planName)
return app.mm.RunMigrations(ctx, app.configurator, fromVM)
},
)

app.storeUpgrade(planName, upgradeInfo, storetypes.StoreUpgrades{
Added: []string{
gmptypes.ModuleName,
},
})
}

// helper function to check if the store loader should be upgraded
func (app *App) storeUpgrade(planName string, ui upgradetypes.Plan, stores storetypes.StoreUpgrades) {
if ui.Name == planName && !app.UpgradeKeeper.IsSkipHeight(ui.Height) {
Expand Down

0 comments on commit 1ba3d24

Please sign in to comment.