From b3318513b7b4291271a2f93c1a4b37ecaa42a281 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Wed, 4 Oct 2023 14:51:18 +0200 Subject: [PATCH] imp!: use expected interface for legacy params subspace (#4811) * imp: use expected interface for legacy params subspace * chore: define GetParamSet on expected interface and rm explicit type conversions --- .../controller/keeper/keeper.go | 5 ++--- .../apps/27-interchain-accounts/host/keeper/keeper.go | 5 ++--- .../27-interchain-accounts/types/expected_keepers.go | 6 ++++++ modules/apps/transfer/keeper/keeper.go | 5 ++--- modules/apps/transfer/types/expected_keepers.go | 6 ++++++ modules/core/02-client/keeper/keeper.go | 5 ++--- modules/core/02-client/types/expected_keepers.go | 7 +++++++ modules/core/03-connection/keeper/keeper.go | 5 ++--- modules/core/03-connection/types/expected_keepers.go | 6 ++++++ modules/core/keeper/keeper.go | 3 +-- modules/core/types/expected_interfaces.go | 11 +++++++++++ 11 files changed, 47 insertions(+), 17 deletions(-) create mode 100644 modules/core/types/expected_interfaces.go diff --git a/modules/apps/27-interchain-accounts/controller/keeper/keeper.go b/modules/apps/27-interchain-accounts/controller/keeper/keeper.go index 9af2a2a32cd..63e606c395e 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/keeper.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/keeper.go @@ -12,7 +12,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types" @@ -28,7 +27,7 @@ import ( type Keeper struct { storeKey storetypes.StoreKey cdc codec.Codec - legacySubspace paramtypes.Subspace + legacySubspace icatypes.ParamSubspace ics4Wrapper porttypes.ICS4Wrapper channelKeeper icatypes.ChannelKeeper portKeeper icatypes.PortKeeper @@ -44,7 +43,7 @@ type Keeper struct { // NewKeeper creates a new interchain accounts controller Keeper instance func NewKeeper( - cdc codec.Codec, key storetypes.StoreKey, legacySubspace paramtypes.Subspace, + cdc codec.Codec, key storetypes.StoreKey, legacySubspace icatypes.ParamSubspace, ics4Wrapper porttypes.ICS4Wrapper, channelKeeper icatypes.ChannelKeeper, portKeeper icatypes.PortKeeper, scopedKeeper exported.ScopedKeeper, msgRouter icatypes.MessageRouter, authority string, ) Keeper { diff --git a/modules/apps/27-interchain-accounts/host/keeper/keeper.go b/modules/apps/27-interchain-accounts/host/keeper/keeper.go index da9ba160325..c426c4cc0cb 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/keeper.go +++ b/modules/apps/27-interchain-accounts/host/keeper/keeper.go @@ -11,7 +11,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" genesistypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/genesis/types" @@ -27,7 +26,7 @@ import ( type Keeper struct { storeKey storetypes.StoreKey cdc codec.Codec - legacySubspace paramtypes.Subspace + legacySubspace icatypes.ParamSubspace ics4Wrapper porttypes.ICS4Wrapper channelKeeper icatypes.ChannelKeeper @@ -45,7 +44,7 @@ type Keeper struct { // NewKeeper creates a new interchain accounts host Keeper instance func NewKeeper( - cdc codec.Codec, key storetypes.StoreKey, legacySubspace paramtypes.Subspace, + cdc codec.Codec, key storetypes.StoreKey, legacySubspace icatypes.ParamSubspace, ics4Wrapper porttypes.ICS4Wrapper, channelKeeper icatypes.ChannelKeeper, portKeeper icatypes.PortKeeper, accountKeeper icatypes.AccountKeeper, scopedKeeper exported.ScopedKeeper, msgRouter icatypes.MessageRouter, authority string, diff --git a/modules/apps/27-interchain-accounts/types/expected_keepers.go b/modules/apps/27-interchain-accounts/types/expected_keepers.go index 3f8d542e891..09cf6c22024 100644 --- a/modules/apps/27-interchain-accounts/types/expected_keepers.go +++ b/modules/apps/27-interchain-accounts/types/expected_keepers.go @@ -4,6 +4,7 @@ import ( "context" sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" @@ -32,3 +33,8 @@ type PortKeeper interface { BindPort(ctx sdk.Context, portID string) *capabilitytypes.Capability IsBound(ctx sdk.Context, portID string) bool } + +// ParamSubspace defines the expected Subspace interface for module parameters. +type ParamSubspace interface { + GetParamSet(ctx sdk.Context, ps paramtypes.ParamSet) +} diff --git a/modules/apps/transfer/keeper/keeper.go b/modules/apps/transfer/keeper/keeper.go index 18ff530ae4b..04704a1f53b 100644 --- a/modules/apps/transfer/keeper/keeper.go +++ b/modules/apps/transfer/keeper/keeper.go @@ -13,7 +13,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" tmbytes "github.com/cometbft/cometbft/libs/bytes" @@ -28,7 +27,7 @@ import ( type Keeper struct { storeKey storetypes.StoreKey cdc codec.BinaryCodec - legacySubspace paramtypes.Subspace + legacySubspace types.ParamSubspace ics4Wrapper porttypes.ICS4Wrapper channelKeeper types.ChannelKeeper @@ -46,7 +45,7 @@ type Keeper struct { func NewKeeper( cdc codec.BinaryCodec, key storetypes.StoreKey, - legacySubspace paramtypes.Subspace, + legacySubspace types.ParamSubspace, ics4Wrapper porttypes.ICS4Wrapper, channelKeeper types.ChannelKeeper, portKeeper types.PortKeeper, diff --git a/modules/apps/transfer/types/expected_keepers.go b/modules/apps/transfer/types/expected_keepers.go index 434c873d8cf..7aee3eace68 100644 --- a/modules/apps/transfer/types/expected_keepers.go +++ b/modules/apps/transfer/types/expected_keepers.go @@ -5,6 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" connectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" @@ -54,3 +55,8 @@ type ConnectionKeeper interface { type PortKeeper interface { BindPort(ctx sdk.Context, portID string) *capabilitytypes.Capability } + +// ParamSubspace defines the expected Subspace interface for module parameters. +type ParamSubspace interface { + GetParamSet(ctx sdk.Context, ps paramtypes.ParamSet) +} diff --git a/modules/core/02-client/keeper/keeper.go b/modules/core/02-client/keeper/keeper.go index b1e63b943fe..a635fbef5a7 100644 --- a/modules/core/02-client/keeper/keeper.go +++ b/modules/core/02-client/keeper/keeper.go @@ -14,7 +14,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/cometbft/cometbft/light" @@ -32,13 +31,13 @@ import ( type Keeper struct { storeKey storetypes.StoreKey cdc codec.BinaryCodec - legacySubspace paramtypes.Subspace + legacySubspace types.ParamSubspace stakingKeeper types.StakingKeeper upgradeKeeper types.UpgradeKeeper } // NewKeeper creates a new NewKeeper instance -func NewKeeper(cdc codec.BinaryCodec, key storetypes.StoreKey, legacySubspace paramtypes.Subspace, sk types.StakingKeeper, uk types.UpgradeKeeper) Keeper { +func NewKeeper(cdc codec.BinaryCodec, key storetypes.StoreKey, legacySubspace types.ParamSubspace, sk types.StakingKeeper, uk types.UpgradeKeeper) Keeper { return Keeper{ storeKey: key, cdc: cdc, diff --git a/modules/core/02-client/types/expected_keepers.go b/modules/core/02-client/types/expected_keepers.go index ea56078ed26..6f4cd34557a 100644 --- a/modules/core/02-client/types/expected_keepers.go +++ b/modules/core/02-client/types/expected_keepers.go @@ -6,6 +6,8 @@ import ( upgradetypes "cosmossdk.io/x/upgrade/types" + sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) @@ -25,3 +27,8 @@ type UpgradeKeeper interface { SetUpgradedConsensusState(ctx context.Context, planHeight int64, bz []byte) error ScheduleUpgrade(ctx context.Context, plan upgradetypes.Plan) error } + +// ParamSubspace defines the expected Subspace interface for module parameters. +type ParamSubspace interface { + GetParamSet(ctx sdk.Context, ps paramtypes.ParamSet) +} diff --git a/modules/core/03-connection/keeper/keeper.go b/modules/core/03-connection/keeper/keeper.go index b4f8cf506c7..cd18555f56e 100644 --- a/modules/core/03-connection/keeper/keeper.go +++ b/modules/core/03-connection/keeper/keeper.go @@ -9,7 +9,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" @@ -24,13 +23,13 @@ type Keeper struct { types.QueryServer storeKey storetypes.StoreKey - legacySubspace paramtypes.Subspace + legacySubspace types.ParamSubspace cdc codec.BinaryCodec clientKeeper types.ClientKeeper } // NewKeeper creates a new IBC connection Keeper instance -func NewKeeper(cdc codec.BinaryCodec, key storetypes.StoreKey, legacySubspace paramtypes.Subspace, ck types.ClientKeeper) Keeper { +func NewKeeper(cdc codec.BinaryCodec, key storetypes.StoreKey, legacySubspace types.ParamSubspace, ck types.ClientKeeper) Keeper { return Keeper{ storeKey: key, cdc: cdc, diff --git a/modules/core/03-connection/types/expected_keepers.go b/modules/core/03-connection/types/expected_keepers.go index b470bf6520f..a37605b64cf 100644 --- a/modules/core/03-connection/types/expected_keepers.go +++ b/modules/core/03-connection/types/expected_keepers.go @@ -4,6 +4,7 @@ import ( storetypes "cosmossdk.io/store/types" sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/cosmos/ibc-go/v8/modules/core/exported" ) @@ -18,3 +19,8 @@ type ClientKeeper interface { IterateClientStates(ctx sdk.Context, prefix []byte, cb func(string, exported.ClientState) bool) ClientStore(ctx sdk.Context, clientID string) storetypes.KVStore } + +// ParamSubspace defines the expected Subspace interface for module parameters. +type ParamSubspace interface { + GetParamSet(ctx sdk.Context, ps paramtypes.ParamSet) +} diff --git a/modules/core/keeper/keeper.go b/modules/core/keeper/keeper.go index 6831be40bda..08ee5dc027e 100644 --- a/modules/core/keeper/keeper.go +++ b/modules/core/keeper/keeper.go @@ -8,7 +8,6 @@ import ( storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/codec" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper" clientkeeper "github.com/cosmos/ibc-go/v8/modules/core/02-client/keeper" @@ -40,7 +39,7 @@ type Keeper struct { // NewKeeper creates a new ibc Keeper func NewKeeper( - cdc codec.BinaryCodec, key storetypes.StoreKey, paramSpace paramtypes.Subspace, + cdc codec.BinaryCodec, key storetypes.StoreKey, paramSpace types.ParamSubspace, stakingKeeper clienttypes.StakingKeeper, upgradeKeeper clienttypes.UpgradeKeeper, scopedKeeper capabilitykeeper.ScopedKeeper, authority string, ) *Keeper { diff --git a/modules/core/types/expected_interfaces.go b/modules/core/types/expected_interfaces.go new file mode 100644 index 00000000000..c6aca313696 --- /dev/null +++ b/modules/core/types/expected_interfaces.go @@ -0,0 +1,11 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" +) + +// ParamSubspace defines the expected Subspace interface for module parameters. +type ParamSubspace interface { + GetParamSet(ctx sdk.Context, ps paramtypes.ParamSet) +}