From 95e4ed3e025e574035820bc94f2f969cec0a2271 Mon Sep 17 00:00:00 2001 From: Michael Tsitrin Date: Thu, 5 Jan 2023 15:08:41 +0200 Subject: [PATCH] added backward compatible interface --- modules/core/keeper/keeper.go | 15 ++++++++++++++- modules/core/keeper/keeper_test.go | 2 +- testing/simapp/app.go | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/modules/core/keeper/keeper.go b/modules/core/keeper/keeper.go index 0a0ea80998a..c4fe8959f67 100644 --- a/modules/core/keeper/keeper.go +++ b/modules/core/keeper/keeper.go @@ -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" @@ -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, diff --git a/modules/core/keeper/keeper_test.go b/modules/core/keeper/keeper_test.go index 912f972d6a4..4afa0dcad4b 100644 --- a/modules/core/keeper/keeper_test.go +++ b/modules/core/keeper/keeper_test.go @@ -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), diff --git a/testing/simapp/app.go b/testing/simapp/app.go index 0562740ecb5..748aa66280b 100644 --- a/testing/simapp/app.go +++ b/testing/simapp/app.go @@ -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, )