diff --git a/app/app.go b/app/app.go index bba7bdb..0c63d77 100644 --- a/app/app.go +++ b/app/app.go @@ -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 ( @@ -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( @@ -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, + ), + ) + +} diff --git a/upgrades/drs-2/upgrade.go b/upgrades/drs-2/upgrade.go new file mode 100644 index 0000000..20c3a94 --- /dev/null +++ b/upgrades/drs-2/upgrade.go @@ -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) + } +}