Skip to content

Commit

Permalink
add upgrade handler
Browse files Browse the repository at this point in the history
  • Loading branch information
srene committed Dec 11, 2024
1 parent 491a5ed commit d1a8b05
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
16 changes: 16 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ import (
rollappparamstypes "github.com/dymensionxyz/dymension-rdk/x/rollappparams/types"

dymintversion "github.com/dymensionxyz/dymint/version"

// Upgrade handlers
drs2_upgrade "github.com/dymensionxyz/rollapp-wasm/app/upgrades/drs-2"
)

const (
Expand Down Expand Up @@ -847,6 +850,7 @@ func NewRollapp(
app.SetBeginBlocker(app.BeginBlocker)
app.SetEndBlocker(app.EndBlocker)
app.setAnteHandler(encodingConfig.TxConfig, wasmConfig)
app.setupUpgradeHandlers()

if manager := app.SnapshotManager(); manager != nil {
err := manager.RegisterExtensions(
Expand Down Expand Up @@ -1206,3 +1210,15 @@ func getAcceptedStargateQueries() wasmkeeper.AcceptedStargateQueries {
"/rollapp.cwerrors.v1.Query/Errors": &cwerrorsTypes.QueryErrorsRequest{},
}
}

func (app *App) setupUpgradeHandlers() {

app.UpgradeKeeper.SetUpgradeHandler(
"upgrade-drs-2",
drs2_upgrade.CreateUpgradeHandler(
app.RollappParamsKeeper,
app.mm, app.configurator,
),
)

}
27 changes: 27 additions & 0 deletions upgrades/drs-2/upgrade.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package v2_2_0

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
rollappparamskeeper "github.com/dymensionxyz/dymension-rdk/x/rollappparams/keeper"
rollappparamstypes "github.com/dymensionxyz/dymension-rdk/x/rollappparams/types"
)

func CreateUpgradeHandler(
rpKeeper rollappparamskeeper.Keeper,
mm *module.Manager,
configurator module.Configurator,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
da := rpKeeper.DA(ctx)
version := uint32(2)
params := rollappparamstypes.DefaultParams()
params.Da = da
params.DrsVersion = version

rpKeeper.SetParams(ctx, params)

return mm.RunMigrations(ctx, configurator, fromVM)
}
}

0 comments on commit d1a8b05

Please sign in to comment.