Skip to content

Commit

Permalink
added backward compatible interface (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtsitrin authored Jan 5, 2023
1 parent bcb8546 commit 1870174
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
15 changes: 14 additions & 1 deletion modules/core/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"

ibcdmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/01-dymint/types"

clientkeeper "github.com/cosmos/ibc-go/v3/modules/core/02-client/keeper"
clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types"
connectionkeeper "github.com/cosmos/ibc-go/v3/modules/core/03-connection/keeper"
Expand Down Expand Up @@ -36,8 +38,19 @@ type Keeper struct {
Router *porttypes.Router
}

// NewKeeper creates a new ibc Keeper
//IBCKeeper initialized in wasm code (in wasmd@v0.28.0/x/wasm/keeper/test_common.go:354)
//We need to maintain backward comptabile interface
func NewKeeper(
cdc codec.BinaryCodec, key sdk.StoreKey, paramSpace paramtypes.Subspace,
stakingKeeper clienttypes.StakingKeeper, upgradeKeeper clienttypes.UpgradeKeeper,
scopedKeeper capabilitykeeper.ScopedKeeper,
) *Keeper {
//Using dymint and nil as default. we can panic instead
return NewKeeperWithSelfClient(cdc, key, paramSpace, stakingKeeper, upgradeKeeper, scopedKeeper, ibcdmtypes.NewSelfClient(), nil)
}

// NewKeeper creates a new ibc Keeper
func NewKeeperWithSelfClient(
cdc codec.BinaryCodec, key sdk.StoreKey, paramSpace paramtypes.Subspace,
stakingKeeper clienttypes.StakingKeeper, upgradeKeeper clienttypes.UpgradeKeeper,
scopedKeeper capabilitykeeper.ScopedKeeper, selfClient exported.SelfClient, clientHooks exported.ClientHooks,
Expand Down
2 changes: 1 addition & 1 deletion modules/core/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (suite *KeeperTestSuite) TestNewKeeper() {
upgradeKeeper clienttypes.UpgradeKeeper
scopedKeeper capabilitykeeper.ScopedKeeper
newIBCKeeper = func() {
ibckeeper.NewKeeper(
ibckeeper.NewKeeperWithSelfClient(
suite.chainA.GetSimApp().AppCodec(),
suite.chainA.GetSimApp().GetKey(ibchost.StoreKey),
suite.chainA.GetSimApp().GetSubspace(ibchost.ModuleName),
Expand Down
2 changes: 1 addition & 1 deletion testing/simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ func NewSimAppWithConsensusType(
panic(fmt.Sprintf("client type %s is not supported", chainConsensusType))
}
// Create IBC Keeper
app.IBCKeeper = ibckeeper.NewKeeper(
app.IBCKeeper = ibckeeper.NewKeeperWithSelfClient(
appCodec, keys[ibchost.StoreKey], app.GetSubspace(ibchost.ModuleName), app.StakingKeeper, app.UpgradeKeeper, scopedIBCKeeper, selfClient, nil,
)

Expand Down

0 comments on commit 1870174

Please sign in to comment.