Skip to content

Commit

Permalink
imp!: use expected interface for legacy params subspace (backport #4811
Browse files Browse the repository at this point in the history
…) (#4835)

* 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

(cherry picked from commit b331851)

* add changelog entry

---------

Co-authored-by: Damian Nolan <[email protected]>
Co-authored-by: Carlos Rodriguez <[email protected]>
  • Loading branch information
3 people authored Oct 5, 2023
1 parent 9c72121 commit c592a8d
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions modules/apps/27-interchain-accounts/host/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions modules/apps/27-interchain-accounts/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
5 changes: 2 additions & 3 deletions modules/apps/transfer/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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
Expand All @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions modules/apps/transfer/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
5 changes: 2 additions & 3 deletions modules/core/02-client/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions modules/core/02-client/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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)
}
5 changes: 2 additions & 3 deletions modules/core/03-connection/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions modules/core/03-connection/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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)
}
3 changes: 1 addition & 2 deletions modules/core/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down
11 changes: 11 additions & 0 deletions modules/core/types/expected_interfaces.go
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit c592a8d

Please sign in to comment.