Skip to content

Commit

Permalink
add upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
adamewozniak committed Oct 1, 2024
1 parent 5fab69f commit ea8fa68
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
gmptypes "github.com/ojo-network/ojo/x/gmp/types"

gasestimatetypes "github.com/ojo-network/ojo/x/gasestimate/types"
oraclekeeper "github.com/ojo-network/ojo/x/oracle/keeper"
oracletypes "github.com/ojo-network/ojo/x/oracle/types"
)
Expand All @@ -47,6 +48,7 @@ func (app App) RegisterUpgradeHandlers() {
app.registerUpgrade0_3_2(upgradeInfo)
app.registerUpgrade0_4_0(upgradeInfo)
app.registerUpgrade0_4_1(upgradeInfo)
app.registerUpgrade0_5_0(upgradeInfo)
}

// performs upgrade from v0.1.3 to v0.1.4
Expand All @@ -66,7 +68,7 @@ func (app *App) registerUpgrade0_1_4(_ upgradetypes.Plan) {
)
}

//nolint: all
// nolint: all

Check failure on line 71 in app/upgrades.go

View workflow job for this annotation

GitHub Actions / lint

directive `// nolint: all` should be written without leading space as `//nolint: all` (nolintlint)
func (app *App) registerUpgrade0_2_0(upgradeInfo upgradetypes.Plan) {
const planName = "v0.2.0"

Expand Down Expand Up @@ -333,6 +335,25 @@ func (app *App) registerUpgrade0_4_1(upgradeInfo upgradetypes.Plan) {
})
}

// performs upgrade from v0.4.x to v0.5.0
func (app *App) registerUpgrade0_5_0(upgradeInfo upgradetypes.Plan) {
const planName = "v0.5.0"
app.UpgradeKeeper.SetUpgradeHandler(planName,
func(ctx context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
sdkCtx := sdk.UnwrapSDKContext(ctx)
sdkCtx.Logger().Info("Upgrade handler execution", "name", planName)
return app.mm.RunMigrations(ctx, app.configurator, fromVM)
},
)

// REF: https://github.com/cosmos/cosmos-sdk/blob/a32186608aab0bd436049377ddb34f90006fcbf7/simapp/upgrades.go
app.storeUpgrade(planName, upgradeInfo, storetypes.StoreUpgrades{
Added: []string{
gasestimatetypes.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 ea8fa68

Please sign in to comment.