Skip to content

Commit 7eae422

Browse files
committed
Add upgrade logic
1 parent f2f57be commit 7eae422

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

app/app.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ type App struct {
245245
// sm is the simulation manager
246246
sm *module.SimulationManager
247247

248+
configurator module.Configurator
249+
248250
tracingInfo *tracing.TracingInfo
249251
}
250252

@@ -571,7 +573,8 @@ func New(
571573

572574
app.mm.RegisterInvariants(&app.CrisisKeeper)
573575
app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino)
574-
app.mm.RegisterServices(module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter()))
576+
app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())
577+
app.mm.RegisterServices(app.configurator)
575578

576579
// create the simulation manager and define the order of the modules for deterministic simulations
577580
app.sm = module.NewSimulationManager(
@@ -595,6 +598,7 @@ func New(
595598
)
596599
app.sm.RegisterStoreDecoders()
597600

601+
app.RegisterUpgradeHandlers()
598602
// initialize stores
599603
app.MountKVStores(keys)
600604
app.MountTransientStores(tkeys)

app/upgrades.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package app
2+
3+
import (
4+
sdk "github.com/cosmos/cosmos-sdk/types"
5+
"github.com/cosmos/cosmos-sdk/types/module"
6+
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
7+
)
8+
9+
const UPGRADE_1_0_1_BETA = "upgrade-1.0.1beta"
10+
11+
func (app App) RegisterUpgradeHandlers() {
12+
app.UpgradeKeeper.SetUpgradeHandler(UPGRADE_1_0_1_BETA, func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
13+
// Upgrade specific logic goes here
14+
// For now, remove dex, epoch and oracle from the version map since
15+
// they do not yet have upgrade logic
16+
delete(fromVM, "dex")
17+
delete(fromVM, "epoch")
18+
delete(fromVM, "oracle")
19+
return app.mm.RunMigrations(ctx, app.configurator, fromVM)
20+
})
21+
}

0 commit comments

Comments
 (0)