From 77f226387564d78b2cd6655380f0c3ed8ee34b95 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Fri, 23 Jun 2023 09:40:56 -0500 Subject: [PATCH] feat: add v5.2.0 upgrade handler --- app/app.go | 2 ++ app/upgrades/v520/upgrade.go | 52 ++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 app/upgrades/v520/upgrade.go diff --git a/app/app.go b/app/app.go index f42f88ba47..639503016f 100644 --- a/app/app.go +++ b/app/app.go @@ -18,6 +18,7 @@ import ( "github.com/desmos-labs/desmos/v5/app/upgrades" v500 "github.com/desmos-labs/desmos/v5/app/upgrades/v500" + v520 "github.com/desmos-labs/desmos/v5/app/upgrades/v520" profilesv4 "github.com/desmos-labs/desmos/v5/x/profiles/legacy/v4" @@ -1229,6 +1230,7 @@ func (app *DesmosApp) RegisterNodeService(clientCtx client.Context) { // registerUpgradeHandlers registers all the upgrade handlers that are supported by the app func (app *DesmosApp) registerUpgradeHandlers() { app.registerUpgrade(v500.NewUpgrade(app.mm, app.configurator, app.ParamsKeeper, app.ConsensusParamsKeeper)) + app.registerUpgrade(v520.NewUpgrade(app.mm, app.configurator, app.ParamsKeeper, app.ConsensusParamsKeeper)) } // registerUpgrade registers the given upgrade to be supported by the app diff --git a/app/upgrades/v520/upgrade.go b/app/upgrades/v520/upgrade.go new file mode 100644 index 0000000000..ae5ff8a9b6 --- /dev/null +++ b/app/upgrades/v520/upgrade.go @@ -0,0 +1,52 @@ +package v500 + +import ( + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + consensusparamskeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" + paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + + "github.com/desmos-labs/desmos/v5/app/upgrades" +) + +var ( + _ upgrades.Upgrade = &Upgrade{} +) + +// Upgrade represents the v5.2.0 upgrade +type Upgrade struct { + mm *module.Manager + configurator module.Configurator + + paramsKeeper paramskeeper.Keeper + consensusParamsKeeper consensusparamskeeper.Keeper +} + +// NewUpgrade returns a new Upgrade instance +func NewUpgrade(mm *module.Manager, configurator module.Configurator, pk paramskeeper.Keeper, consensusParamsKeeper consensusparamskeeper.Keeper) *Upgrade { + return &Upgrade{ + mm: mm, + configurator: configurator, + paramsKeeper: pk, + consensusParamsKeeper: consensusParamsKeeper, + } +} + +// Name implements upgrades.Upgrade +func (u *Upgrade) Name() string { + return "v5.2.0" +} + +// Handler implements upgrades.Upgrade +func (u *Upgrade) Handler() upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + return u.mm.RunMigrations(ctx, u.configurator, fromVM) + } +} + +// StoreUpgrades implements upgrades.Upgrade +func (u *Upgrade) StoreUpgrades() *storetypes.StoreUpgrades { + return &storetypes.StoreUpgrades{} +}