Skip to content

Commit

Permalink
feat(app): register v7.0.0 software upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
amimart committed Feb 29, 2024
1 parent 16e42f8 commit 4358459
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ func New(

// RegisterUpgradeHandlers is used for registering any on-chain upgrades.
// Make sure it's called after `app.ModuleManager` and `app.configurator` are set.
// app.setupUpgradeHandlers()
app.RegisterUpgradeHandlers()

autocliv1.RegisterQueryServer(app.GRPCQueryRouter(), runtimeservices.NewAutoCLIQueryService(app.ModuleManager.Modules))
reflectionSvc, err := runtimeservices.NewReflectionService()
Expand Down
24 changes: 24 additions & 0 deletions app/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package app

import (
"fmt"

v7 "github.com/okp4/okp4d/app/upgrades/v7"
)

// RegisterUpgradeHandlers registers the chain upgrade handlers.
func (app *App) RegisterUpgradeHandlers() {
app.UpgradeKeeper.SetUpgradeHandler(
v7.UpgradeName,
v7.CreateUpgradeHandler(app.ModuleManager, app.configurator),
)

upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
panic(fmt.Sprintf("failed to read upgrade info from disk %s", err))
}

if app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
return
}
}
20 changes: 20 additions & 0 deletions app/upgrades/v7/upgrade.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package v7

import (
"context"

upgradetypes "cosmossdk.io/x/upgrade/types"

"github.com/cosmos/cosmos-sdk/types/module"
)

var UpgradeName = "v7.0.0"

func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
) upgradetypes.UpgradeHandler {
return func(ctx context.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
return mm.RunMigrations(ctx, configurator, vm)
}
}

0 comments on commit 4358459

Please sign in to comment.