Skip to content

Commit

Permalink
Merge pull request #2982 from irisnet/feat/v4-upgrade-plan
Browse files Browse the repository at this point in the history
feat: add v4 upgrade plan
  • Loading branch information
mitch1024 authored Dec 17, 2024
2 parents 5ee2f2c + a9af461 commit af27100
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ import (
v200 "github.com/irisnet/irishub/v4/app/upgrades/v200"
v210 "github.com/irisnet/irishub/v4/app/upgrades/v210"
v300 "github.com/irisnet/irishub/v4/app/upgrades/v300"
v400 "github.com/irisnet/irishub/v4/app/upgrades/v400"
)

var (
router = upgrades.NewUpgradeRouter().
Register(v200.Upgrade).
Register(v210.Upgrade).
Register(v300.Upgrade)
Register(v300.Upgrade).
Register(v400.Upgrade)
)

// RegisterUpgradePlans register a handler of upgrade plan
Expand Down
31 changes: 31 additions & 0 deletions app/upgrades/v400/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package v400

import (
"context"

storetypes "cosmossdk.io/store/types"
upgradetypes "cosmossdk.io/x/upgrade/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"

"github.com/irisnet/irishub/v4/app/upgrades"
)

// Upgrade defines a struct containing necessary fields that a SoftwareUpgradeProposal
var Upgrade = upgrades.Upgrade{
UpgradeName: "v4.0.0",
UpgradeHandlerConstructor: upgradeHandlerConstructor,
StoreUpgrades: &storetypes.StoreUpgrades{},
}

func upgradeHandlerConstructor(
m *module.Manager,
c module.Configurator,
box upgrades.Toolbox,
) upgradetypes.UpgradeHandler {
return func(context context.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
ctx := sdk.UnwrapSDKContext(context)
ctx.Logger().Info("execute a upgrade plan...")
return box.ModuleManager.RunMigrations(ctx, c, fromVM)
}
}

0 comments on commit af27100

Please sign in to comment.