Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add v4 upgrade plan #2982

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
}
Loading