From 2e14b821e1d42dbdcd2397a894d16dc7cb849950 Mon Sep 17 00:00:00 2001 From: Marri Harish Date: Tue, 24 Dec 2024 20:01:01 +0530 Subject: [PATCH] add v5.1.0 upgrade handler (#198) --- app/app.go | 3 ++- app/upgrades/v510/constants.go | 16 ++++++++++++++++ app/upgrades/v510/upgrades.go | 30 ++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 app/upgrades/v510/constants.go create mode 100644 app/upgrades/v510/upgrades.go diff --git a/app/app.go b/app/app.go index 4af05de..e6b1d26 100644 --- a/app/app.go +++ b/app/app.go @@ -59,6 +59,7 @@ import ( v3 "github.com/OmniFlix/omniflixhub/v5/app/upgrades/v3" v4 "github.com/OmniFlix/omniflixhub/v5/app/upgrades/v4" v5 "github.com/OmniFlix/omniflixhub/v5/app/upgrades/v5" + v510 "github.com/OmniFlix/omniflixhub/v5/app/upgrades/v510" ) const Name = "omniflixhub" @@ -85,7 +86,7 @@ func getGovProposalHandlers() []govclient.ProposalHandler { var ( // DefaultNodeHome default home directories for the application daemon DefaultNodeHome string - Upgrades = []upgrades.Upgrade{v012.Upgrade, v2.Upgrade, v2_1.Upgrade, v3.Upgrade, v4.Upgrade, v5.Upgrade} + Upgrades = []upgrades.Upgrade{v012.Upgrade, v2.Upgrade, v2_1.Upgrade, v3.Upgrade, v4.Upgrade, v5.Upgrade, v510.Upgrade} Forks []upgrades.Fork ) diff --git a/app/upgrades/v510/constants.go b/app/upgrades/v510/constants.go new file mode 100644 index 0000000..e6c9d30 --- /dev/null +++ b/app/upgrades/v510/constants.go @@ -0,0 +1,16 @@ +package v510 + +import ( + store "cosmossdk.io/store/types" + "github.com/OmniFlix/omniflixhub/v5/app/upgrades" +) + +const UpgradeName = "v5.1.0" + +var Upgrade = upgrades.Upgrade{ + UpgradeName: UpgradeName, + CreateUpgradeHandler: CreateV510UpgradeHandler, + StoreUpgrades: store.StoreUpgrades{ + Added: []string{}, + }, +} diff --git a/app/upgrades/v510/upgrades.go b/app/upgrades/v510/upgrades.go new file mode 100644 index 0000000..ef21141 --- /dev/null +++ b/app/upgrades/v510/upgrades.go @@ -0,0 +1,30 @@ +package v510 + +import ( + "context" + + upgradetypes "cosmossdk.io/x/upgrade/types" + "github.com/OmniFlix/omniflixhub/v5/app/keepers" + "github.com/OmniFlix/omniflixhub/v5/app/upgrades" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" +) + +func CreateV510UpgradeHandler( + mm *module.Manager, + cfg module.Configurator, + _ upgrades.BaseAppParamManager, + keepers *keepers.AppKeepers, +) upgradetypes.UpgradeHandler { + return func(context context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + ctx := sdk.UnwrapSDKContext(context) + // Run migrations before applying any other state changes. + // NOTE: DO NOT PUT ANY STATE CHANGES BEFORE RunMigrations(). + versionMap, err := mm.RunMigrations(ctx, cfg, fromVM) + if err != nil { + return nil, err + } + ctx.Logger().Info("Upgrade complete") + return versionMap, nil + } +}