Skip to content

Commit

Permalink
add v5.1.0 upgrade handler (#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
harish551 authored Dec 24, 2024
1 parent e1db0ca commit 2e14b82
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
)

Expand Down
16 changes: 16 additions & 0 deletions app/upgrades/v510/constants.go
Original file line number Diff line number Diff line change
@@ -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{},
},
}
30 changes: 30 additions & 0 deletions app/upgrades/v510/upgrades.go
Original file line number Diff line number Diff line change
@@ -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
}
}

0 comments on commit 2e14b82

Please sign in to comment.