Skip to content

Commit

Permalink
add upgrade handle
Browse files Browse the repository at this point in the history
  • Loading branch information
kienvc authored May 31, 2024
1 parent f904836 commit 0826dbf
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
v702 "github.com/aura-nw/aura/app/upgrades/v0.7.2"

v081 "github.com/aura-nw/aura/app/upgrades/v0.8.1"
ibcupgrade "github.com/aura-nw/aura/app/upgrades/ibcupgrade"

"github.com/aura-nw/aura/app/internal"

Expand Down Expand Up @@ -1300,6 +1301,11 @@ func (app *App) setupUpgradeHandlers() {
v081.CreateUpgradeHandler(app.mm, app.configurator),
)

app.UpgradeKeeper.SetUpgradeHandler(
ibcupgrade.UpgradeName,
ibcupgrade.CreateUpgradeHandler(app.mm, app.configurator),
)

// When a planned update height is reached, the old binary will panic
// writing on disk the height and name of the update that triggered it
// This will read that value, and execute the preparations for the upgrade.
Expand Down Expand Up @@ -1381,7 +1387,8 @@ func (app *App) setupUpgradeHandlers() {

case v081.UpgradeName:
// no store upgrades in v0.8.1

case ibcupgrade.UpgradeName:
// no store upgrades in ibcupgrade
}

if storeUpgrades != nil {
Expand Down
20 changes: 20 additions & 0 deletions app/upgrades/ibcupgrade/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package ibcupgrade

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

// UpgradeName is the name of upgrade. This upgrade added new module
const UpgradeName = "ibcupgrade"

func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {

return mm.RunMigrations(ctx, configurator, vm)
}
}

0 comments on commit 0826dbf

Please sign in to comment.