diff --git a/CHANGELOG.md b/CHANGELOG.md index c0186d41e75..38da90e403a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,6 +67,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (apps/29-fee) [\#4290](https://github.com/cosmos/ibc-go/pull/4290) Use `types.MetadataFromVersion` helper function for callback handlers. * (core/04-channel) [\#4155](https://github.com/cosmos/ibc-go/pull/4155) Adding `IsOpen` and `IsClosed` methods to `Channel` type. * (core/03-connection) [\#4110](https://github.com/cosmos/ibc-go/pull/4110) Remove `Version` interface and casting functions from 03-connection. +* (core) [\#4835](https://github.com/cosmos/ibc-go/pull/4835) Use expected interface for legacy params subspace parameter of keeper constructor functions. ### Features 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) +}