From ceae46d20f2742d22d1a7f133bd3e68f10b8109e Mon Sep 17 00:00:00 2001 From: colmazia Date: Wed, 4 Oct 2023 16:25:31 +0700 Subject: [PATCH] add param subspace --- app/upgrades/v2_6/upgrades.go | 50 +++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/app/upgrades/v2_6/upgrades.go b/app/upgrades/v2_6/upgrades.go index ab4c90aaa..61cd319c8 100644 --- a/app/upgrades/v2_6/upgrades.go +++ b/app/upgrades/v2_6/upgrades.go @@ -1,10 +1,22 @@ package v2_6 import ( + oracletypes "github.com/bandprotocol/chain/v2/x/oracle/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" + slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" icahosttypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/types" + ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" "github.com/bandprotocol/chain/v2/app/keepers" "github.com/bandprotocol/chain/v2/app/upgrades" @@ -18,6 +30,44 @@ func CreateUpgradeHandler( keepers *keepers.AppKeepers, ) upgradetypes.UpgradeHandler { return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + // Set param key table for params module migration + for _, subspace := range keepers.ParamsKeeper.GetSubspaces() { + subspace := subspace + + var keyTable paramstypes.KeyTable + switch subspace.Name() { + case authtypes.ModuleName: + keyTable = authtypes.ParamKeyTable() //nolint:staticcheck + case banktypes.ModuleName: + keyTable = banktypes.ParamKeyTable() //nolint:staticcheck + case stakingtypes.ModuleName: + keyTable = stakingtypes.ParamKeyTable() //nolint:staticcheck + case minttypes.ModuleName: + keyTable = minttypes.ParamKeyTable() //nolint:staticcheck + case distrtypes.ModuleName: + keyTable = distrtypes.ParamKeyTable() //nolint:staticcheck + case slashingtypes.ModuleName: + keyTable = slashingtypes.ParamKeyTable() //nolint:staticcheck + case govtypes.ModuleName: + keyTable = govv1.ParamKeyTable() //nolint:staticcheck + case crisistypes.ModuleName: + keyTable = crisistypes.ParamKeyTable() //nolint:staticcheck + // ibc types + case ibctransfertypes.ModuleName: + keyTable = ibctransfertypes.ParamKeyTable() //nolint:staticcheck + case icahosttypes.SubModuleName: + keyTable = icahosttypes.ParamKeyTable() //nolint:staticcheck + case oracletypes.ModuleName: + keyTable = oracletypes.ParamKeyTable() //nolint:staticcheck + default: + continue + } + + if !subspace.HasKeyTable() { + subspace.WithKeyTable(keyTable) + } + } + hostParams := icahosttypes.Params{ HostEnabled: true, // specifying the whole list instead of adding and removing. Less fragile.