Skip to content

Commit

Permalink
Merge branch 'master' of github.com:irisnet/irishub into feature/up_s…
Browse files Browse the repository at this point in the history
…imulate
  • Loading branch information
avery committed Dec 17, 2024
2 parents 33a0e99 + af27100 commit 37ff0fe
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 37ff0fe

Please sign in to comment.