diff --git a/modules/apps/27-interchain-accounts/controller/ibc_module.go b/modules/apps/27-interchain-accounts/controller/ibc_module.go index 31e6b59a3be..74d9d0800c1 100644 --- a/modules/apps/27-interchain-accounts/controller/ibc_module.go +++ b/modules/apps/27-interchain-accounts/controller/ibc_module.go @@ -6,7 +6,7 @@ import ( capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/controller/keeper" - "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" + icatypes "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types" porttypes "github.com/cosmos/ibc-go/v2/modules/core/05-port/types" ibcexported "github.com/cosmos/ibc-go/v2/modules/core/exported" @@ -63,7 +63,7 @@ func (im IBCModule) OnChanOpenTry( version, counterpartyVersion string, ) error { - return sdkerrors.Wrap(types.ErrInvalidChannelFlow, "channel handshake must be initiated by controller chain") + return sdkerrors.Wrap(icatypes.ErrInvalidChannelFlow, "channel handshake must be initiated by controller chain") } // OnChanOpenAck implements the IBCModule interface @@ -92,7 +92,7 @@ func (im IBCModule) OnChanOpenConfirm( portID, channelID string, ) error { - return sdkerrors.Wrap(types.ErrInvalidChannelFlow, "channel handshake must be initiated by controller chain") + return sdkerrors.Wrap(icatypes.ErrInvalidChannelFlow, "channel handshake must be initiated by controller chain") } // OnChanCloseInit implements the IBCModule interface @@ -156,5 +156,5 @@ func (im IBCModule) NegotiateAppVersion( counterparty channeltypes.Counterparty, proposedVersion string, ) (string, error) { - return "", sdkerrors.Wrap(types.ErrInvalidChannelFlow, "ICS-27 app version negotiation is unsupported on controller chains") + return "", sdkerrors.Wrap(icatypes.ErrInvalidChannelFlow, "ICS-27 app version negotiation is unsupported on controller chains") } diff --git a/modules/apps/27-interchain-accounts/controller/ibc_module_test.go b/modules/apps/27-interchain-accounts/controller/ibc_module_test.go index 54f07bee76c..cf01f0c5f29 100644 --- a/modules/apps/27-interchain-accounts/controller/ibc_module_test.go +++ b/modules/apps/27-interchain-accounts/controller/ibc_module_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/suite" "github.com/tendermint/tendermint/crypto" - "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" + icatypes "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" clienttypes "github.com/cosmos/ibc-go/v2/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types" host "github.com/cosmos/ibc-go/v2/modules/core/24-host" @@ -19,13 +19,13 @@ import ( var ( // TestAccAddress defines a resuable bech32 address for testing purposes // TODO: update crypto.AddressHash() when sdk uses address.Module() - TestAccAddress = types.GenerateAddress(sdk.AccAddress(crypto.AddressHash([]byte(types.ModuleName))), TestPortID) + TestAccAddress = icatypes.GenerateAddress(sdk.AccAddress(crypto.AddressHash([]byte(icatypes.ModuleName))), TestPortID) // TestOwnerAddress defines a reusable bech32 address for testing purposes TestOwnerAddress = "cosmos17dtl0mjt3t77kpuhg2edqzjpszulwhgzuj9ljs" // TestPortID defines a resuable port identifier for testing purposes - TestPortID, _ = types.GeneratePortID(TestOwnerAddress, ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + TestPortID, _ = icatypes.GeneratePortID(TestOwnerAddress, ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) // TestVersion defines a resuable interchainaccounts version string for testing purposes - TestVersion = types.NewAppVersion(types.VersionPrefix, TestAccAddress.String()) + TestVersion = icatypes.NewAppVersion(icatypes.VersionPrefix, TestAccAddress.String()) ) type InterchainAccountsTestSuite struct { @@ -50,18 +50,18 @@ func (suite *InterchainAccountsTestSuite) SetupTest() { func NewICAPath(chainA, chainB *ibctesting.TestChain) *ibctesting.Path { path := ibctesting.NewPath(chainA, chainB) - path.EndpointA.ChannelConfig.PortID = types.PortID - path.EndpointB.ChannelConfig.PortID = types.PortID + path.EndpointA.ChannelConfig.PortID = icatypes.PortID + path.EndpointB.ChannelConfig.PortID = icatypes.PortID path.EndpointA.ChannelConfig.Order = channeltypes.ORDERED path.EndpointB.ChannelConfig.Order = channeltypes.ORDERED - path.EndpointA.ChannelConfig.Version = types.VersionPrefix + path.EndpointA.ChannelConfig.Version = icatypes.VersionPrefix path.EndpointB.ChannelConfig.Version = TestVersion return path } func InitInterchainAccount(endpoint *ibctesting.Endpoint, owner string) error { - portID, err := types.GeneratePortID(owner, endpoint.ConnectionID, endpoint.Counterparty.ConnectionID) + portID, err := icatypes.GeneratePortID(owner, endpoint.ConnectionID, endpoint.Counterparty.ConnectionID) if err != nil { return err } @@ -144,7 +144,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenInit() { suite.coordinator.SetupConnections(path) // mock init interchain account - portID, err := types.GeneratePortID(TestOwnerAddress, path.EndpointA.ConnectionID, path.EndpointB.ConnectionID) + portID, err := icatypes.GeneratePortID(TestOwnerAddress, path.EndpointA.ConnectionID, path.EndpointB.ConnectionID) suite.Require().NoError(err) portCap := suite.chainA.GetSimApp().IBCKeeper.PortKeeper.BindPort(suite.chainA.GetContext(), portID) @@ -160,7 +160,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenInit() { Ordering: channeltypes.ORDERED, Counterparty: counterparty, ConnectionHops: []string{path.EndpointA.ConnectionID}, - Version: types.VersionPrefix, + Version: icatypes.VersionPrefix, } tc.malleate() // malleate mutates test data @@ -213,7 +213,7 @@ func (suite *InterchainAccountsTestSuite) TestChanOpenTry() { proofInit, proofHeight := path.EndpointB.Chain.QueryProof(channelKey) // use chainA (controller) for ChanOpenTry - msg := channeltypes.NewMsgChannelOpenTry(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, TestVersion, channeltypes.ORDERED, []string{path.EndpointA.ConnectionID}, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, types.VersionPrefix, proofInit, proofHeight, types.ModuleName) + msg := channeltypes.NewMsgChannelOpenTry(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, TestVersion, channeltypes.ORDERED, []string{path.EndpointA.ConnectionID}, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, icatypes.VersionPrefix, proofInit, proofHeight, icatypes.ModuleName) handler := suite.chainA.GetSimApp().MsgServiceRouter().Handler(msg) _, err = handler(suite.chainA.GetContext(), msg) @@ -334,7 +334,7 @@ func (suite *InterchainAccountsTestSuite) TestChanOpenConfirm() { proofAck, proofHeight := path.EndpointB.Chain.QueryProof(channelKey) // use chainA (controller) for ChanOpenConfirm - msg := channeltypes.NewMsgChannelOpenConfirm(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, proofAck, proofHeight, types.ModuleName) + msg := channeltypes.NewMsgChannelOpenConfirm(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, proofAck, proofHeight, icatypes.ModuleName) handler := suite.chainA.GetSimApp().MsgServiceRouter().Handler(msg) _, err = handler(suite.chainA.GetContext(), msg) @@ -505,7 +505,7 @@ func (suite *InterchainAccountsTestSuite) TestNegotiateAppVersion() { cbs, ok := suite.chainA.GetSimApp().GetIBCKeeper().Router.GetRoute(module) suite.Require().True(ok) - counterpartyPortID, err := types.GeneratePortID(TestOwnerAddress, path.EndpointA.ConnectionID, path.EndpointB.ConnectionID) + counterpartyPortID, err := icatypes.GeneratePortID(TestOwnerAddress, path.EndpointA.ConnectionID, path.EndpointB.ConnectionID) suite.Require().NoError(err) counterparty := channeltypes.Counterparty{ @@ -513,14 +513,14 @@ func (suite *InterchainAccountsTestSuite) TestNegotiateAppVersion() { ChannelId: path.EndpointB.ChannelID, } - proposedVersion = types.VersionPrefix + proposedVersion = icatypes.VersionPrefix tc.malleate() version, err := cbs.NegotiateAppVersion(suite.chainA.GetContext(), channeltypes.ORDERED, path.EndpointA.ConnectionID, path.EndpointA.ChannelConfig.PortID, counterparty, proposedVersion) if tc.expPass { suite.Require().NoError(err) - suite.Require().NoError(types.ValidateVersion(version)) + suite.Require().NoError(icatypes.ValidateVersion(version)) suite.Require().Equal(TestVersion, version) } else { suite.Require().Error(err) diff --git a/modules/apps/27-interchain-accounts/controller/keeper/account.go b/modules/apps/27-interchain-accounts/controller/keeper/account.go index ccbe1f38a61..8876b3467b6 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/account.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/account.go @@ -4,7 +4,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" + icatypes "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types" host "github.com/cosmos/ibc-go/v2/modules/core/24-host" ) @@ -16,13 +16,13 @@ import ( // already in use. Gaining access to interchain accounts whose channels have closed // cannot be done with this function. A regular MsgChanOpenInit must be used. func (k Keeper) InitInterchainAccount(ctx sdk.Context, connectionID, counterpartyConnectionID, owner string) error { - portID, err := types.GeneratePortID(owner, connectionID, counterpartyConnectionID) + portID, err := icatypes.GeneratePortID(owner, connectionID, counterpartyConnectionID) if err != nil { return err } if k.portKeeper.IsBound(ctx, portID) { - return sdkerrors.Wrap(types.ErrPortAlreadyBound, portID) + return sdkerrors.Wrap(icatypes.ErrPortAlreadyBound, portID) } cap := k.BindPort(ctx, portID) @@ -30,7 +30,7 @@ func (k Keeper) InitInterchainAccount(ctx sdk.Context, connectionID, counterpart return sdkerrors.Wrap(err, "unable to bind to newly generated portID") } - msg := channeltypes.NewMsgChannelOpenInit(portID, types.VersionPrefix, channeltypes.ORDERED, []string{connectionID}, types.PortID, types.ModuleName) + msg := channeltypes.NewMsgChannelOpenInit(portID, icatypes.VersionPrefix, channeltypes.ORDERED, []string{connectionID}, icatypes.PortID, icatypes.ModuleName) handler := k.msgRouter.Handler(msg) if _, err := handler(ctx, msg); err != nil { return err diff --git a/modules/apps/27-interchain-accounts/controller/keeper/account_test.go b/modules/apps/27-interchain-accounts/controller/keeper/account_test.go index 8627d6f1ce0..3a019deac95 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/account_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/account_test.go @@ -1,7 +1,7 @@ package keeper_test import ( - "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" + icatypes "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" ibctesting "github.com/cosmos/ibc-go/v2/testing" ) @@ -37,7 +37,7 @@ func (suite *KeeperTestSuite) TestInitInterchainAccount() { { "MsgChanOpenInit fails - channel is already active", func() { - portID, err := types.GeneratePortID(owner, path.EndpointA.ConnectionID, path.EndpointB.ConnectionID) + portID, err := icatypes.GeneratePortID(owner, path.EndpointA.ConnectionID, path.EndpointB.ConnectionID) suite.Require().NoError(err) suite.chainA.GetSimApp().ICAControllerKeeper.SetActiveChannelID(suite.chainA.GetContext(), portID, path.EndpointA.ChannelID) diff --git a/modules/apps/27-interchain-accounts/controller/keeper/genesis.go b/modules/apps/27-interchain-accounts/controller/keeper/genesis.go index 101acdea21e..d38a4ed6e77 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/genesis.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/genesis.go @@ -5,12 +5,12 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" + icatypes "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" host "github.com/cosmos/ibc-go/v2/modules/core/24-host" ) // InitGenesis initializes the interchain accounts controller application state from a provided genesis state -func InitGenesis(ctx sdk.Context, keeper Keeper, state types.ControllerGenesisState) { +func InitGenesis(ctx sdk.Context, keeper Keeper, state icatypes.ControllerGenesisState) { for _, portID := range state.Ports { if !keeper.IsBound(ctx, portID) { cap := keeper.BindPort(ctx, portID) @@ -30,8 +30,8 @@ func InitGenesis(ctx sdk.Context, keeper Keeper, state types.ControllerGenesisSt } // ExportGenesis returns the interchain accounts controller exported genesis -func ExportGenesis(ctx sdk.Context, keeper Keeper) types.ControllerGenesisState { - return types.NewControllerGenesisState( +func ExportGenesis(ctx sdk.Context, keeper Keeper) icatypes.ControllerGenesisState { + return icatypes.NewControllerGenesisState( keeper.GetAllActiveChannels(ctx), keeper.GetAllInterchainAccounts(ctx), keeper.GetAllPorts(ctx), diff --git a/modules/apps/27-interchain-accounts/controller/keeper/genesis_test.go b/modules/apps/27-interchain-accounts/controller/keeper/genesis_test.go index 5f0880eb94b..398100458ac 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/genesis_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/genesis_test.go @@ -2,21 +2,21 @@ package keeper_test import ( "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/controller/keeper" - "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" + icatypes "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" ibctesting "github.com/cosmos/ibc-go/v2/testing" ) func (suite *KeeperTestSuite) TestInitGenesis() { suite.SetupTest() - genesisState := types.ControllerGenesisState{ - ActiveChannels: []types.ActiveChannel{ + genesisState := icatypes.ControllerGenesisState{ + ActiveChannels: []icatypes.ActiveChannel{ { PortId: TestPortID, ChannelId: ibctesting.FirstChannelID, }, }, - InterchainAccounts: []types.RegisteredInterchainAccount{ + InterchainAccounts: []icatypes.RegisteredInterchainAccount{ { PortId: TestPortID, AccountAddress: TestAccAddress.String(), diff --git a/modules/apps/27-interchain-accounts/controller/keeper/handshake.go b/modules/apps/27-interchain-accounts/controller/keeper/handshake.go index f88f8f1fadc..e48dee00f08 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/handshake.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/handshake.go @@ -5,7 +5,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" - "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" + icatypes "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" connectiontypes "github.com/cosmos/ibc-go/v2/modules/core/03-connection/types" channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types" porttypes "github.com/cosmos/ibc-go/v2/modules/core/05-port/types" @@ -32,26 +32,26 @@ func (k Keeper) OnChanOpenInit( return sdkerrors.Wrapf(channeltypes.ErrInvalidChannelOrdering, "expected %s channel, got %s", channeltypes.ORDERED, order) } - connSequence, err := types.ParseControllerConnSequence(portID) + connSequence, err := icatypes.ParseControllerConnSequence(portID) if err != nil { - return sdkerrors.Wrapf(err, "expected format %s, got %s", types.ControllerPortFormat, portID) + return sdkerrors.Wrapf(err, "expected format %s, got %s", icatypes.ControllerPortFormat, portID) } - counterpartyConnSequence, err := types.ParseHostConnSequence(portID) + counterpartyConnSequence, err := icatypes.ParseHostConnSequence(portID) if err != nil { - return sdkerrors.Wrapf(err, "expected format %s, got %s", types.ControllerPortFormat, portID) + return sdkerrors.Wrapf(err, "expected format %s, got %s", icatypes.ControllerPortFormat, portID) } if err := k.validateControllerPortParams(ctx, channelID, portID, connSequence, counterpartyConnSequence); err != nil { return sdkerrors.Wrapf(err, "failed to validate controller port %s", portID) } - if counterparty.PortId != types.PortID { - return sdkerrors.Wrapf(porttypes.ErrInvalidPort, "expected %s, got %s", types.PortID, counterparty.PortId) + if counterparty.PortId != icatypes.PortID { + return sdkerrors.Wrapf(porttypes.ErrInvalidPort, "expected %s, got %s", icatypes.PortID, counterparty.PortId) } - if version != types.VersionPrefix { - return sdkerrors.Wrapf(types.ErrInvalidVersion, "expected %s, got %s", types.VersionPrefix, version) + if version != icatypes.VersionPrefix { + return sdkerrors.Wrapf(icatypes.ErrInvalidVersion, "expected %s, got %s", icatypes.VersionPrefix, version) } activeChannelID, found := k.GetActiveChannelID(ctx, portID) @@ -70,19 +70,19 @@ func (k Keeper) OnChanOpenAck( channelID string, counterpartyVersion string, ) error { - if portID == types.PortID { - return sdkerrors.Wrapf(porttypes.ErrInvalidPort, "portID cannot be host chain port ID: %s", types.PortID) + if portID == icatypes.PortID { + return sdkerrors.Wrapf(porttypes.ErrInvalidPort, "portID cannot be host chain port ID: %s", icatypes.PortID) } - if err := types.ValidateVersion(counterpartyVersion); err != nil { + if err := icatypes.ValidateVersion(counterpartyVersion); err != nil { return sdkerrors.Wrap(err, "counterparty version validation failed") } k.SetActiveChannelID(ctx, portID, channelID) - accAddr, err := types.ParseAddressFromVersion(counterpartyVersion) + accAddr, err := icatypes.ParseAddressFromVersion(counterpartyVersion) if err != nil { - return sdkerrors.Wrapf(err, "expected format , got %s", types.Delimiter, counterpartyVersion) + return sdkerrors.Wrapf(err, "expected format , got %s", icatypes.Delimiter, counterpartyVersion) } k.SetInterchainAccountAddress(ctx, portID, accAddr) diff --git a/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go b/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go index f0e634fd362..31aaf9d028e 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go @@ -3,7 +3,7 @@ package keeper_test import ( capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" - "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" + icatypes "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types" host "github.com/cosmos/ibc-go/v2/modules/core/24-host" ibctesting "github.com/cosmos/ibc-go/v2/testing" @@ -77,7 +77,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenInit() { { "invalid connection sequence", func() { - portID, err := types.GeneratePortID(TestOwnerAddress, "connection-1", "connection-0") + portID, err := icatypes.GeneratePortID(TestOwnerAddress, "connection-1", "connection-0") suite.Require().NoError(err) path.EndpointA.ChannelConfig.PortID = portID @@ -88,7 +88,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenInit() { { "invalid counterparty connection sequence", func() { - portID, err := types.GeneratePortID(TestOwnerAddress, "connection-0", "connection-1") + portID, err := icatypes.GeneratePortID(TestOwnerAddress, "connection-0", "connection-1") suite.Require().NoError(err) path.EndpointA.ChannelConfig.PortID = portID @@ -115,7 +115,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenInit() { suite.coordinator.SetupConnections(path) // mock init interchain account - portID, err := types.GeneratePortID(TestOwnerAddress, path.EndpointA.ConnectionID, path.EndpointB.ConnectionID) + portID, err := icatypes.GeneratePortID(TestOwnerAddress, path.EndpointA.ConnectionID, path.EndpointB.ConnectionID) suite.Require().NoError(err) portCap := suite.chainA.GetSimApp().IBCKeeper.PortKeeper.BindPort(suite.chainA.GetContext(), portID) @@ -129,7 +129,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenInit() { Ordering: channeltypes.ORDERED, Counterparty: counterparty, ConnectionHops: []string{path.EndpointA.ConnectionID}, - Version: types.VersionPrefix, + Version: icatypes.VersionPrefix, } chanCap, err = suite.chainA.App.GetScopedIBCKeeper().NewCapability(suite.chainA.GetContext(), host.ChannelCapabilityPath(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID)) @@ -176,7 +176,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenAck() { }, { "invalid portID", func() { - path.EndpointA.ChannelConfig.PortID = types.PortID + path.EndpointA.ChannelConfig.PortID = icatypes.PortID expectedChannelID = "" }, false, }, diff --git a/modules/apps/27-interchain-accounts/controller/keeper/keeper.go b/modules/apps/27-interchain-accounts/controller/keeper/keeper.go index 1fed7445a7a..4f021c1eb16 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/keeper.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/keeper.go @@ -11,7 +11,7 @@ import ( capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" "github.com/tendermint/tendermint/libs/log" - "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" + icatypes "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" host "github.com/cosmos/ibc-go/v2/modules/core/24-host" ) @@ -20,10 +20,10 @@ type Keeper struct { storeKey sdk.StoreKey cdc codec.BinaryCodec - ics4Wrapper types.ICS4Wrapper - channelKeeper types.ChannelKeeper - portKeeper types.PortKeeper - accountKeeper types.AccountKeeper + ics4Wrapper icatypes.ICS4Wrapper + channelKeeper icatypes.ChannelKeeper + portKeeper icatypes.PortKeeper + accountKeeper icatypes.AccountKeeper scopedKeeper capabilitykeeper.ScopedKeeper @@ -33,8 +33,8 @@ type Keeper struct { // NewKeeper creates a new interchain accounts controller Keeper instance func NewKeeper( cdc codec.BinaryCodec, key sdk.StoreKey, - ics4Wrapper types.ICS4Wrapper, channelKeeper types.ChannelKeeper, portKeeper types.PortKeeper, - accountKeeper types.AccountKeeper, scopedKeeper capabilitykeeper.ScopedKeeper, msgRouter *baseapp.MsgServiceRouter, + ics4Wrapper icatypes.ICS4Wrapper, channelKeeper icatypes.ChannelKeeper, portKeeper icatypes.PortKeeper, + accountKeeper icatypes.AccountKeeper, scopedKeeper capabilitykeeper.ScopedKeeper, msgRouter *baseapp.MsgServiceRouter, ) Keeper { return Keeper{ storeKey: key, @@ -50,13 +50,13 @@ func NewKeeper( // Logger returns the application logger, scoped to the associated module func (k Keeper) Logger(ctx sdk.Context) log.Logger { - return ctx.Logger().With("module", fmt.Sprintf("x/%s-%s", host.ModuleName, types.ModuleName)) + return ctx.Logger().With("module", fmt.Sprintf("x/%s-%s", host.ModuleName, icatypes.ModuleName)) } // GetAllPorts returns all ports to which the interchain accounts controller module is bound. Used in ExportGenesis func (k Keeper) GetAllPorts(ctx sdk.Context) []string { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, []byte(types.PortKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte(icatypes.PortKeyPrefix)) defer iterator.Close() var ports []string @@ -72,7 +72,7 @@ func (k Keeper) GetAllPorts(ctx sdk.Context) []string { // BindPort stores the provided portID and binds to it, returning the associated capability func (k Keeper) BindPort(ctx sdk.Context, portID string) *capabilitytypes.Capability { store := ctx.KVStore(k.storeKey) - store.Set(types.KeyPort(portID), []byte{0x01}) + store.Set(icatypes.KeyPort(portID), []byte{0x01}) return k.portKeeper.BindPort(ctx, portID) } @@ -96,7 +96,7 @@ func (k Keeper) ClaimCapability(ctx sdk.Context, cap *capabilitytypes.Capability // GetActiveChannelID retrieves the active channelID from the store keyed by the provided portID func (k Keeper) GetActiveChannelID(ctx sdk.Context, portID string) (string, bool) { store := ctx.KVStore(k.storeKey) - key := types.KeyActiveChannel(portID) + key := icatypes.KeyActiveChannel(portID) if !store.Has(key) { return "", false @@ -106,16 +106,16 @@ func (k Keeper) GetActiveChannelID(ctx sdk.Context, portID string) (string, bool } // GetAllActiveChannels returns a list of all active interchain accounts controller channels and their associated port identifiers -func (k Keeper) GetAllActiveChannels(ctx sdk.Context) []types.ActiveChannel { +func (k Keeper) GetAllActiveChannels(ctx sdk.Context) []icatypes.ActiveChannel { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, []byte(types.ActiveChannelKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte(icatypes.ActiveChannelKeyPrefix)) defer iterator.Close() - var activeChannels []types.ActiveChannel + var activeChannels []icatypes.ActiveChannel for ; iterator.Valid(); iterator.Next() { keySplit := strings.Split(string(iterator.Key()), "/") - ch := types.ActiveChannel{ + ch := icatypes.ActiveChannel{ PortId: keySplit[1], ChannelId: string(iterator.Value()), } @@ -129,13 +129,13 @@ func (k Keeper) GetAllActiveChannels(ctx sdk.Context) []types.ActiveChannel { // SetActiveChannelID stores the active channelID, keyed by the provided portID func (k Keeper) SetActiveChannelID(ctx sdk.Context, portID, channelID string) { store := ctx.KVStore(k.storeKey) - store.Set(types.KeyActiveChannel(portID), []byte(channelID)) + store.Set(icatypes.KeyActiveChannel(portID), []byte(channelID)) } // DeleteActiveChannelID removes the active channel keyed by the provided portID stored in state func (k Keeper) DeleteActiveChannelID(ctx sdk.Context, portID string) { store := ctx.KVStore(k.storeKey) - store.Delete(types.KeyActiveChannel(portID)) + store.Delete(icatypes.KeyActiveChannel(portID)) } // IsActiveChannel returns true if there exists an active channel for the provided portID, otherwise false @@ -147,7 +147,7 @@ func (k Keeper) IsActiveChannel(ctx sdk.Context, portID string) bool { // GetInterchainAccountAddress retrieves the InterchainAccount address from the store keyed by the provided portID func (k Keeper) GetInterchainAccountAddress(ctx sdk.Context, portID string) (string, bool) { store := ctx.KVStore(k.storeKey) - key := types.KeyOwnerAccount(portID) + key := icatypes.KeyOwnerAccount(portID) if !store.Has(key) { return "", false @@ -157,15 +157,15 @@ func (k Keeper) GetInterchainAccountAddress(ctx sdk.Context, portID string) (str } // GetAllInterchainAccounts returns a list of all registered interchain account addresses and their associated controller port identifiers -func (k Keeper) GetAllInterchainAccounts(ctx sdk.Context) []types.RegisteredInterchainAccount { +func (k Keeper) GetAllInterchainAccounts(ctx sdk.Context) []icatypes.RegisteredInterchainAccount { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, []byte(types.OwnerKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte(icatypes.OwnerKeyPrefix)) - var interchainAccounts []types.RegisteredInterchainAccount + var interchainAccounts []icatypes.RegisteredInterchainAccount for ; iterator.Valid(); iterator.Next() { keySplit := strings.Split(string(iterator.Key()), "/") - acc := types.RegisteredInterchainAccount{ + acc := icatypes.RegisteredInterchainAccount{ PortId: keySplit[1], AccountAddress: string(iterator.Value()), } @@ -179,5 +179,5 @@ func (k Keeper) GetAllInterchainAccounts(ctx sdk.Context) []types.RegisteredInte // SetInterchainAccountAddress stores the InterchainAccount address, keyed by the associated portID func (k Keeper) SetInterchainAccountAddress(ctx sdk.Context, portID string, address string) { store := ctx.KVStore(k.storeKey) - store.Set(types.KeyOwnerAccount(portID), []byte(address)) + store.Set(icatypes.KeyOwnerAccount(portID), []byte(address)) } diff --git a/modules/apps/27-interchain-accounts/controller/keeper/keeper_test.go b/modules/apps/27-interchain-accounts/controller/keeper/keeper_test.go index 0e61d738826..f522a954fa1 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/keeper_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/keeper_test.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/suite" "github.com/tendermint/tendermint/crypto" - "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" + icatypes "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types" ibctesting "github.com/cosmos/ibc-go/v2/testing" ) @@ -16,13 +16,13 @@ import ( var ( // TestAccAddress defines a resuable bech32 address for testing purposes // TODO: update crypto.AddressHash() when sdk uses address.Module() - TestAccAddress = types.GenerateAddress(sdk.AccAddress(crypto.AddressHash([]byte(types.ModuleName))), TestPortID) + TestAccAddress = icatypes.GenerateAddress(sdk.AccAddress(crypto.AddressHash([]byte(icatypes.ModuleName))), TestPortID) // TestOwnerAddress defines a reusable bech32 address for testing purposes TestOwnerAddress = "cosmos17dtl0mjt3t77kpuhg2edqzjpszulwhgzuj9ljs" // TestPortID defines a resuable port identifier for testing purposes - TestPortID, _ = types.GeneratePortID(TestOwnerAddress, ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + TestPortID, _ = icatypes.GeneratePortID(TestOwnerAddress, ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) // TestVersion defines a resuable interchainaccounts version string for testing purposes - TestVersion = types.NewAppVersion(types.VersionPrefix, TestAccAddress.String()) + TestVersion = icatypes.NewAppVersion(icatypes.VersionPrefix, TestAccAddress.String()) ) type KeeperTestSuite struct { @@ -45,11 +45,11 @@ func (suite *KeeperTestSuite) SetupTest() { func NewICAPath(chainA, chainB *ibctesting.TestChain) *ibctesting.Path { path := ibctesting.NewPath(chainA, chainB) - path.EndpointA.ChannelConfig.PortID = types.PortID - path.EndpointB.ChannelConfig.PortID = types.PortID + path.EndpointA.ChannelConfig.PortID = icatypes.PortID + path.EndpointB.ChannelConfig.PortID = icatypes.PortID path.EndpointA.ChannelConfig.Order = channeltypes.ORDERED path.EndpointB.ChannelConfig.Order = channeltypes.ORDERED - path.EndpointA.ChannelConfig.Version = types.VersionPrefix + path.EndpointA.ChannelConfig.Version = icatypes.VersionPrefix path.EndpointB.ChannelConfig.Version = TestVersion return path @@ -78,7 +78,7 @@ func SetupICAPath(path *ibctesting.Path, owner string) error { // InitInterchainAccount is a helper function for starting the channel handshake func InitInterchainAccount(endpoint *ibctesting.Endpoint, owner string) error { - portID, err := types.GeneratePortID(owner, endpoint.ConnectionID, endpoint.Counterparty.ConnectionID) + portID, err := icatypes.GeneratePortID(owner, endpoint.ConnectionID, endpoint.Counterparty.ConnectionID) if err != nil { return err } @@ -143,7 +143,7 @@ func (suite *KeeperTestSuite) TestGetInterchainAccountAddress() { suite.Require().NoError(err) counterpartyPortID := path.EndpointA.ChannelConfig.PortID - expectedAddr := authtypes.NewBaseAccountWithAddress(types.GenerateAddress(suite.chainA.GetSimApp().AccountKeeper.GetModuleAddress(types.ModuleName), counterpartyPortID)).GetAddress() + expectedAddr := authtypes.NewBaseAccountWithAddress(icatypes.GenerateAddress(suite.chainA.GetSimApp().AccountKeeper.GetModuleAddress(icatypes.ModuleName), counterpartyPortID)).GetAddress() retrievedAddr, found := suite.chainA.GetSimApp().ICAControllerKeeper.GetInterchainAccountAddress(suite.chainA.GetContext(), counterpartyPortID) suite.Require().True(found) @@ -170,7 +170,7 @@ func (suite *KeeperTestSuite) TestGetAllActiveChannels() { suite.chainA.GetSimApp().ICAControllerKeeper.SetActiveChannelID(suite.chainA.GetContext(), expectedPortID, expectedChannelID) - expectedChannels := []types.ActiveChannel{ + expectedChannels := []icatypes.ActiveChannel{ { PortId: TestPortID, ChannelId: path.EndpointA.ChannelID, @@ -202,7 +202,7 @@ func (suite *KeeperTestSuite) TestGetAllInterchainAccounts() { suite.chainA.GetSimApp().ICAControllerKeeper.SetInterchainAccountAddress(suite.chainA.GetContext(), expectedPortID, expectedAccAddr) - expectedAccounts := []types.RegisteredInterchainAccount{ + expectedAccounts := []icatypes.RegisteredInterchainAccount{ { PortId: TestPortID, AccountAddress: TestAccAddress.String(), diff --git a/modules/apps/27-interchain-accounts/controller/keeper/relay.go b/modules/apps/27-interchain-accounts/controller/keeper/relay.go index 02a79a00e97..a7bbda175af 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/relay.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/relay.go @@ -5,18 +5,18 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" - "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" + icatypes "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" clienttypes "github.com/cosmos/ibc-go/v2/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types" ) // TrySendTx takes in a transaction from an authentication module and attempts to send the packet // if the base application has the capability to send on the provided portID -func (k Keeper) TrySendTx(ctx sdk.Context, chanCap *capabilitytypes.Capability, portID string, icaPacketData types.InterchainAccountPacketData) (uint64, error) { +func (k Keeper) TrySendTx(ctx sdk.Context, chanCap *capabilitytypes.Capability, portID string, icaPacketData icatypes.InterchainAccountPacketData) (uint64, error) { // Check for the active channel activeChannelID, found := k.GetActiveChannelID(ctx, portID) if !found { - return 0, sdkerrors.Wrapf(types.ErrActiveChannelNotFound, "failed to retrieve active channel for port %s", portID) + return 0, sdkerrors.Wrapf(icatypes.ErrActiveChannelNotFound, "failed to retrieve active channel for port %s", portID) } sourceChannelEnd, found := k.channelKeeper.GetChannel(ctx, portID, activeChannelID) @@ -37,7 +37,7 @@ func (k Keeper) createOutgoingPacket( destinationPort, destinationChannel string, chanCap *capabilitytypes.Capability, - icaPacketData types.InterchainAccountPacketData, + icaPacketData icatypes.InterchainAccountPacketData, ) (uint64, error) { if err := icaPacketData.ValidateBasic(); err != nil { return 0, sdkerrors.Wrap(err, "invalid interchain account packet data") diff --git a/modules/apps/27-interchain-accounts/controller/keeper/relay_test.go b/modules/apps/27-interchain-accounts/controller/keeper/relay_test.go index 561cc370ddf..d00ed6a936a 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/relay_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/relay_test.go @@ -5,7 +5,7 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" - "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" + icatypes "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" clienttypes "github.com/cosmos/ibc-go/v2/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types" host "github.com/cosmos/ibc-go/v2/modules/core/24-host" @@ -15,7 +15,7 @@ import ( func (suite *KeeperTestSuite) TestTrySendTx() { var ( path *ibctesting.Path - packetData types.InterchainAccountPacketData + packetData icatypes.InterchainAccountPacketData chanCap *capabilitytypes.Capability ) @@ -36,11 +36,11 @@ func (suite *KeeperTestSuite) TestTrySendTx() { Amount: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))), } - data, err := types.SerializeCosmosTx(suite.chainB.GetSimApp().AppCodec(), []sdk.Msg{msg}) + data, err := icatypes.SerializeCosmosTx(suite.chainB.GetSimApp().AppCodec(), []sdk.Msg{msg}) suite.Require().NoError(err) - packetData = types.InterchainAccountPacketData{ - Type: types.EXECUTE_TX, + packetData = icatypes.InterchainAccountPacketData{ + Type: icatypes.EXECUTE_TX, Data: data, } }, @@ -65,11 +65,11 @@ func (suite *KeeperTestSuite) TestTrySendTx() { }, } - data, err := types.SerializeCosmosTx(suite.chainB.GetSimApp().AppCodec(), msgsBankSend) + data, err := icatypes.SerializeCosmosTx(suite.chainB.GetSimApp().AppCodec(), msgsBankSend) suite.Require().NoError(err) - packetData = types.InterchainAccountPacketData{ - Type: types.EXECUTE_TX, + packetData = icatypes.InterchainAccountPacketData{ + Type: icatypes.EXECUTE_TX, Data: data, } }, @@ -78,8 +78,8 @@ func (suite *KeeperTestSuite) TestTrySendTx() { { "data is nil", func() { - packetData = types.InterchainAccountPacketData{ - Type: types.EXECUTE_TX, + packetData = icatypes.InterchainAccountPacketData{ + Type: icatypes.EXECUTE_TX, Data: nil, } }, diff --git a/modules/apps/27-interchain-accounts/host/ibc_module.go b/modules/apps/27-interchain-accounts/host/ibc_module.go index a304c121ef0..3e28117ba22 100644 --- a/modules/apps/27-interchain-accounts/host/ibc_module.go +++ b/modules/apps/27-interchain-accounts/host/ibc_module.go @@ -6,7 +6,7 @@ import ( capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/host/keeper" - "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" + icatypes "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types" ibcexported "github.com/cosmos/ibc-go/v2/modules/core/exported" ) @@ -34,7 +34,7 @@ func (im IBCModule) OnChanOpenInit( counterparty channeltypes.Counterparty, version string, ) error { - return sdkerrors.Wrap(types.ErrInvalidChannelFlow, "channel handshake must be initiated by controller chain") + return sdkerrors.Wrap(icatypes.ErrInvalidChannelFlow, "channel handshake must be initiated by controller chain") } // OnChanOpenTry implements the IBCModule interface @@ -59,7 +59,7 @@ func (im IBCModule) OnChanOpenAck( channelID string, counterpartyVersion string, ) error { - return sdkerrors.Wrap(types.ErrInvalidChannelFlow, "channel handshake must be initiated by controller chain") + return sdkerrors.Wrap(icatypes.ErrInvalidChannelFlow, "channel handshake must be initiated by controller chain") } // OnChanOpenAck implements the IBCModule interface @@ -113,7 +113,7 @@ func (im IBCModule) OnAcknowledgementPacket( acknowledgement []byte, relayer sdk.AccAddress, ) error { - return sdkerrors.Wrap(types.ErrInvalidChannelFlow, "cannot receive acknowledgement on a host channel end, a host chain does not send a packet over the channel") + return sdkerrors.Wrap(icatypes.ErrInvalidChannelFlow, "cannot receive acknowledgement on a host channel end, a host chain does not send a packet over the channel") } // OnTimeoutPacket implements the IBCModule interface @@ -122,7 +122,7 @@ func (im IBCModule) OnTimeoutPacket( packet channeltypes.Packet, relayer sdk.AccAddress, ) error { - return sdkerrors.Wrap(types.ErrInvalidChannelFlow, "cannot cause a packet timeout on a host channel end, a host chain does not send a packet over the channel") + return sdkerrors.Wrap(icatypes.ErrInvalidChannelFlow, "cannot cause a packet timeout on a host channel end, a host chain does not send a packet over the channel") } // NegotiateAppVersion implements the IBCModule interface diff --git a/modules/apps/27-interchain-accounts/host/ibc_module_test.go b/modules/apps/27-interchain-accounts/host/ibc_module_test.go index b3362d9faaa..aa99ac811f5 100644 --- a/modules/apps/27-interchain-accounts/host/ibc_module_test.go +++ b/modules/apps/27-interchain-accounts/host/ibc_module_test.go @@ -10,7 +10,7 @@ import ( "github.com/stretchr/testify/suite" "github.com/tendermint/tendermint/crypto" - "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" + icatypes "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" clienttypes "github.com/cosmos/ibc-go/v2/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types" host "github.com/cosmos/ibc-go/v2/modules/core/24-host" @@ -21,13 +21,13 @@ import ( var ( // TestAccAddress defines a resuable bech32 address for testing purposes // TODO: update crypto.AddressHash() when sdk uses address.Module() - TestAccAddress = types.GenerateAddress(sdk.AccAddress(crypto.AddressHash([]byte(types.ModuleName))), TestPortID) + TestAccAddress = icatypes.GenerateAddress(sdk.AccAddress(crypto.AddressHash([]byte(icatypes.ModuleName))), TestPortID) // TestOwnerAddress defines a reusable bech32 address for testing purposes TestOwnerAddress = "cosmos17dtl0mjt3t77kpuhg2edqzjpszulwhgzuj9ljs" // TestPortID defines a resuable port identifier for testing purposes - TestPortID, _ = types.GeneratePortID(TestOwnerAddress, ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + TestPortID, _ = icatypes.GeneratePortID(TestOwnerAddress, ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) // TestVersion defines a resuable interchainaccounts version string for testing purposes - TestVersion = types.NewAppVersion(types.VersionPrefix, TestAccAddress.String()) + TestVersion = icatypes.NewAppVersion(icatypes.VersionPrefix, TestAccAddress.String()) ) type InterchainAccountsTestSuite struct { @@ -52,18 +52,18 @@ func (suite *InterchainAccountsTestSuite) SetupTest() { func NewICAPath(chainA, chainB *ibctesting.TestChain) *ibctesting.Path { path := ibctesting.NewPath(chainA, chainB) - path.EndpointA.ChannelConfig.PortID = types.PortID - path.EndpointB.ChannelConfig.PortID = types.PortID + path.EndpointA.ChannelConfig.PortID = icatypes.PortID + path.EndpointB.ChannelConfig.PortID = icatypes.PortID path.EndpointA.ChannelConfig.Order = channeltypes.ORDERED path.EndpointB.ChannelConfig.Order = channeltypes.ORDERED - path.EndpointA.ChannelConfig.Version = types.VersionPrefix + path.EndpointA.ChannelConfig.Version = icatypes.VersionPrefix path.EndpointB.ChannelConfig.Version = TestVersion return path } func InitInterchainAccount(endpoint *ibctesting.Endpoint, owner string) error { - portID, err := types.GeneratePortID(owner, endpoint.ConnectionID, endpoint.Counterparty.ConnectionID) + portID, err := icatypes.GeneratePortID(owner, endpoint.ConnectionID, endpoint.Counterparty.ConnectionID) if err != nil { return err } @@ -114,7 +114,7 @@ func (suite *InterchainAccountsTestSuite) TestChanOpenInit() { suite.coordinator.SetupConnections(path) // use chainB (host) for ChanOpenInit - msg := channeltypes.NewMsgChannelOpenInit(path.EndpointB.ChannelConfig.PortID, types.VersionPrefix, channeltypes.ORDERED, []string{path.EndpointB.ConnectionID}, path.EndpointA.ChannelConfig.PortID, types.ModuleName) + msg := channeltypes.NewMsgChannelOpenInit(path.EndpointB.ChannelConfig.PortID, icatypes.VersionPrefix, channeltypes.ORDERED, []string{path.EndpointB.ConnectionID}, path.EndpointA.ChannelConfig.PortID, icatypes.ModuleName) handler := suite.chainB.GetSimApp().MsgServiceRouter().Handler(msg) _, err := handler(suite.chainB.GetContext(), msg) @@ -150,7 +150,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenTry() { }, { "ICA callback fails - invalid version", func() { - channel.Version = types.VersionPrefix + channel.Version = icatypes.VersionPrefix }, false, }, } @@ -235,7 +235,7 @@ func (suite *InterchainAccountsTestSuite) TestChanOpenAck() { proofTry, proofHeight := path.EndpointA.Chain.QueryProof(channelKey) // use chainB (host) for ChanOpenAck - msg := channeltypes.NewMsgChannelOpenAck(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, path.EndpointA.ChannelID, TestVersion, proofTry, proofHeight, types.ModuleName) + msg := channeltypes.NewMsgChannelOpenAck(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, path.EndpointA.ChannelID, TestVersion, proofTry, proofHeight, icatypes.ModuleName) handler := suite.chainB.GetSimApp().MsgServiceRouter().Handler(msg) _, err = handler(suite.chainB.GetContext(), msg) @@ -427,11 +427,11 @@ func (suite *InterchainAccountsTestSuite) TestOnRecvPacket() { ToAddress: suite.chainB.SenderAccount.GetAddress().String(), Amount: amount, } - data, err := types.SerializeCosmosTx(suite.chainA.Codec, []sdk.Msg{msg}) + data, err := icatypes.SerializeCosmosTx(suite.chainA.Codec, []sdk.Msg{msg}) suite.Require().NoError(err) - icaPacketData := types.InterchainAccountPacketData{ - Type: types.EXECUTE_TX, + icaPacketData := icatypes.InterchainAccountPacketData{ + Type: icatypes.EXECUTE_TX, Data: data, } packetData = icaPacketData.GetBytes() @@ -593,13 +593,13 @@ func (suite *InterchainAccountsTestSuite) TestNegotiateAppVersion() { path := NewICAPath(suite.chainA, suite.chainB) suite.coordinator.SetupConnections(path) - module, _, err := suite.chainA.GetSimApp().GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), types.PortID) + module, _, err := suite.chainA.GetSimApp().GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), icatypes.PortID) suite.Require().NoError(err) cbs, ok := suite.chainA.GetSimApp().GetIBCKeeper().Router.GetRoute(module) suite.Require().True(ok) - counterpartyPortID, err := types.GeneratePortID(TestOwnerAddress, path.EndpointA.ConnectionID, path.EndpointB.ConnectionID) + counterpartyPortID, err := icatypes.GeneratePortID(TestOwnerAddress, path.EndpointA.ConnectionID, path.EndpointB.ConnectionID) suite.Require().NoError(err) counterparty := &channeltypes.Counterparty{ @@ -607,14 +607,14 @@ func (suite *InterchainAccountsTestSuite) TestNegotiateAppVersion() { ChannelId: path.EndpointB.ChannelID, } - proposedVersion = types.VersionPrefix + proposedVersion = icatypes.VersionPrefix tc.malleate() - version, err := cbs.NegotiateAppVersion(suite.chainA.GetContext(), channeltypes.ORDERED, path.EndpointA.ConnectionID, types.PortID, *counterparty, proposedVersion) + version, err := cbs.NegotiateAppVersion(suite.chainA.GetContext(), channeltypes.ORDERED, path.EndpointA.ConnectionID, icatypes.PortID, *counterparty, proposedVersion) if tc.expPass { suite.Require().NoError(err) - suite.Require().NoError(types.ValidateVersion(version)) + suite.Require().NoError(icatypes.ValidateVersion(version)) suite.Require().Equal(TestVersion, version) } else { suite.Require().Error(err) diff --git a/modules/apps/27-interchain-accounts/host/keeper/account.go b/modules/apps/27-interchain-accounts/host/keeper/account.go index d9e213f4ace..4ed947eb285 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/account.go +++ b/modules/apps/27-interchain-accounts/host/keeper/account.go @@ -4,7 +4,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" + icatypes "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" ) // RegisterInterchainAccount attempts to create a new account using the provided address and stores it in state keyed by the provided port identifier @@ -14,7 +14,7 @@ func (k Keeper) RegisterInterchainAccount(ctx sdk.Context, accAddr sdk.AccAddres return } - interchainAccount := types.NewInterchainAccount( + interchainAccount := icatypes.NewInterchainAccount( authtypes.NewBaseAccountWithAddress(accAddr), controllerPortID, ) diff --git a/modules/apps/27-interchain-accounts/host/keeper/account_test.go b/modules/apps/27-interchain-accounts/host/keeper/account_test.go index 65ce1646905..90be30ff2c8 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/account_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/account_test.go @@ -3,7 +3,7 @@ package keeper_test import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" + icatypes "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" ibctesting "github.com/cosmos/ibc-go/v2/testing" ) @@ -17,7 +17,7 @@ func (suite *KeeperTestSuite) TestRegisterInterchainAccount() { err := SetupICAPath(path, TestOwnerAddress) suite.Require().NoError(err) - portID, err := types.GeneratePortID(TestOwnerAddress, ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + portID, err := icatypes.GeneratePortID(TestOwnerAddress, ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) suite.Require().NoError(err) // Get the address of the interchain account stored in state during handshake step diff --git a/modules/apps/27-interchain-accounts/host/keeper/genesis.go b/modules/apps/27-interchain-accounts/host/keeper/genesis.go index 4a8584102f5..3fd5c02f8da 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/genesis.go +++ b/modules/apps/27-interchain-accounts/host/keeper/genesis.go @@ -5,12 +5,12 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" + icatypes "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" host "github.com/cosmos/ibc-go/v2/modules/core/24-host" ) // InitGenesis initializes the interchain accounts host application state from a provided genesis state -func InitGenesis(ctx sdk.Context, keeper Keeper, state types.HostGenesisState) { +func InitGenesis(ctx sdk.Context, keeper Keeper, state icatypes.HostGenesisState) { if !keeper.IsBound(ctx, state.Port) { cap := keeper.BindPort(ctx, state.Port) if err := keeper.ClaimCapability(ctx, cap, host.PortPath(state.Port)); err != nil { @@ -28,10 +28,10 @@ func InitGenesis(ctx sdk.Context, keeper Keeper, state types.HostGenesisState) { } // ExportGenesis returns the interchain accounts host exported genesis -func ExportGenesis(ctx sdk.Context, keeper Keeper) types.HostGenesisState { - return types.NewHostGenesisState( +func ExportGenesis(ctx sdk.Context, keeper Keeper) icatypes.HostGenesisState { + return icatypes.NewHostGenesisState( keeper.GetAllActiveChannels(ctx), keeper.GetAllInterchainAccounts(ctx), - types.PortID, + icatypes.PortID, ) } diff --git a/modules/apps/27-interchain-accounts/host/keeper/genesis_test.go b/modules/apps/27-interchain-accounts/host/keeper/genesis_test.go index 41cdcf5b671..272109b5412 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/genesis_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/genesis_test.go @@ -2,27 +2,27 @@ package keeper_test import ( "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/host/keeper" - "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" + icatypes "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" ibctesting "github.com/cosmos/ibc-go/v2/testing" ) func (suite *KeeperTestSuite) TestInitGenesis() { suite.SetupTest() - genesisState := types.HostGenesisState{ - ActiveChannels: []types.ActiveChannel{ + genesisState := icatypes.HostGenesisState{ + ActiveChannels: []icatypes.ActiveChannel{ { PortId: TestPortID, ChannelId: ibctesting.FirstChannelID, }, }, - InterchainAccounts: []types.RegisteredInterchainAccount{ + InterchainAccounts: []icatypes.RegisteredInterchainAccount{ { PortId: TestPortID, AccountAddress: TestAccAddress.String(), }, }, - Port: types.PortID, + Port: icatypes.PortID, } keeper.InitGenesis(suite.chainA.GetContext(), suite.chainA.GetSimApp().ICAHostKeeper, genesisState) @@ -53,5 +53,5 @@ func (suite *KeeperTestSuite) TestExportGenesis() { suite.Require().Equal(TestAccAddress.String(), genesisState.InterchainAccounts[0].AccountAddress) suite.Require().Equal(path.EndpointA.ChannelConfig.PortID, genesisState.InterchainAccounts[0].PortId) - suite.Require().Equal(types.PortID, genesisState.GetPort()) + suite.Require().Equal(icatypes.PortID, genesisState.GetPort()) } diff --git a/modules/apps/27-interchain-accounts/host/keeper/handshake.go b/modules/apps/27-interchain-accounts/host/keeper/handshake.go index 864498137f9..c4c40e68d8e 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/handshake.go +++ b/modules/apps/27-interchain-accounts/host/keeper/handshake.go @@ -5,7 +5,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" - "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" + icatypes "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" connectiontypes "github.com/cosmos/ibc-go/v2/modules/core/03-connection/types" channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types" porttypes "github.com/cosmos/ibc-go/v2/modules/core/05-port/types" @@ -29,30 +29,30 @@ func (k Keeper) OnChanOpenTry( return sdkerrors.Wrapf(channeltypes.ErrInvalidChannelOrdering, "expected %s channel, got %s", channeltypes.ORDERED, order) } - if portID != types.PortID { - return sdkerrors.Wrapf(porttypes.ErrInvalidPort, "expected %s, got %s", types.PortID, portID) + if portID != icatypes.PortID { + return sdkerrors.Wrapf(porttypes.ErrInvalidPort, "expected %s, got %s", icatypes.PortID, portID) } - connSequence, err := types.ParseHostConnSequence(counterparty.PortId) + connSequence, err := icatypes.ParseHostConnSequence(counterparty.PortId) if err != nil { - return sdkerrors.Wrapf(err, "expected format %s, got %s", types.ControllerPortFormat, counterparty.PortId) + return sdkerrors.Wrapf(err, "expected format %s, got %s", icatypes.ControllerPortFormat, counterparty.PortId) } - counterpartyConnSequence, err := types.ParseControllerConnSequence(counterparty.PortId) + counterpartyConnSequence, err := icatypes.ParseControllerConnSequence(counterparty.PortId) if err != nil { - return sdkerrors.Wrapf(err, "expected format %s, got %s", types.ControllerPortFormat, counterparty.PortId) + return sdkerrors.Wrapf(err, "expected format %s, got %s", icatypes.ControllerPortFormat, counterparty.PortId) } if err := k.validateControllerPortParams(ctx, channelID, portID, connSequence, counterpartyConnSequence); err != nil { return sdkerrors.Wrapf(err, "failed to validate controller port %s", counterparty.PortId) } - if err := types.ValidateVersion(version); err != nil { + if err := icatypes.ValidateVersion(version); err != nil { return sdkerrors.Wrap(err, "version validation failed") } - if counterpartyVersion != types.VersionPrefix { - return sdkerrors.Wrapf(types.ErrInvalidVersion, "expected %s, got %s", types.VersionPrefix, version) + if counterpartyVersion != icatypes.VersionPrefix { + return sdkerrors.Wrapf(icatypes.ErrInvalidVersion, "expected %s, got %s", icatypes.VersionPrefix, version) } // On the host chain the capability may only be claimed during the OnChanOpenTry @@ -62,14 +62,14 @@ func (k Keeper) OnChanOpenTry( } // Check to ensure that the version string contains the expected address generated from the Counterparty portID - accAddr := types.GenerateAddress(k.accountKeeper.GetModuleAddress(types.ModuleName), counterparty.PortId) - parsedAddr, err := types.ParseAddressFromVersion(version) + accAddr := icatypes.GenerateAddress(k.accountKeeper.GetModuleAddress(icatypes.ModuleName), counterparty.PortId) + parsedAddr, err := icatypes.ParseAddressFromVersion(version) if err != nil { - return sdkerrors.Wrapf(err, "expected format , got %s", types.Delimiter, version) + return sdkerrors.Wrapf(err, "expected format , got %s", icatypes.Delimiter, version) } if parsedAddr != accAddr.String() { - return sdkerrors.Wrapf(types.ErrInvalidVersion, "version contains invalid account address: expected %s, got %s", parsedAddr, accAddr) + return sdkerrors.Wrapf(icatypes.ErrInvalidVersion, "version contains invalid account address: expected %s, got %s", parsedAddr, accAddr) } // Register interchain account if it does not already exist diff --git a/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go b/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go index fde51a961ff..c07b46834e6 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go @@ -3,7 +3,7 @@ package keeper_test import ( capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" - "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" + icatypes "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types" host "github.com/cosmos/ibc-go/v2/modules/core/24-host" ibctesting "github.com/cosmos/ibc-go/v2/testing" @@ -69,7 +69,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { { "invalid connection sequence", func() { - portID, err := types.GeneratePortID(TestOwnerAddress, "connection-0", "connection-1") + portID, err := icatypes.GeneratePortID(TestOwnerAddress, "connection-0", "connection-1") suite.Require().NoError(err) channel.Counterparty.PortId = portID @@ -80,7 +80,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { { "invalid counterparty connection sequence", func() { - portID, err := types.GeneratePortID(TestOwnerAddress, "connection-1", "connection-0") + portID, err := icatypes.GeneratePortID(TestOwnerAddress, "connection-1", "connection-0") suite.Require().NoError(err) channel.Counterparty.PortId = portID @@ -116,7 +116,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { { "invalid account address", func() { - portID, err := types.GeneratePortID("invalid-owner-addr", "connection-0", "connection-0") + portID, err := icatypes.GeneratePortID("invalid-owner-addr", "connection-0", "connection-0") suite.Require().NoError(err) channel.Counterparty.PortId = portID @@ -133,7 +133,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { suite.SetupTest() // reset path = NewICAPath(suite.chainA, suite.chainB) - counterpartyVersion = types.VersionPrefix + counterpartyVersion = icatypes.VersionPrefix suite.coordinator.SetupConnections(path) err := InitInterchainAccount(path.EndpointA, TestOwnerAddress) diff --git a/modules/apps/27-interchain-accounts/host/keeper/keeper.go b/modules/apps/27-interchain-accounts/host/keeper/keeper.go index 44735ae81ea..23fcd168c5a 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/keeper.go +++ b/modules/apps/27-interchain-accounts/host/keeper/keeper.go @@ -12,7 +12,7 @@ import ( capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" "github.com/tendermint/tendermint/libs/log" - "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" + icatypes "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types" host "github.com/cosmos/ibc-go/v2/modules/core/24-host" ) @@ -22,9 +22,9 @@ type Keeper struct { storeKey sdk.StoreKey cdc codec.BinaryCodec - channelKeeper types.ChannelKeeper - portKeeper types.PortKeeper - accountKeeper types.AccountKeeper + channelKeeper icatypes.ChannelKeeper + portKeeper icatypes.PortKeeper + accountKeeper icatypes.AccountKeeper scopedKeeper capabilitykeeper.ScopedKeeper @@ -33,12 +33,12 @@ type Keeper struct { // NewKeeper creates a new interchain accounts host Keeper instance func NewKeeper( - cdc codec.BinaryCodec, key sdk.StoreKey, channelKeeper types.ChannelKeeper, portKeeper types.PortKeeper, - accountKeeper types.AccountKeeper, scopedKeeper capabilitykeeper.ScopedKeeper, msgRouter *baseapp.MsgServiceRouter, + cdc codec.BinaryCodec, key sdk.StoreKey, channelKeeper icatypes.ChannelKeeper, portKeeper icatypes.PortKeeper, + accountKeeper icatypes.AccountKeeper, scopedKeeper capabilitykeeper.ScopedKeeper, msgRouter *baseapp.MsgServiceRouter, ) Keeper { // ensure ibc interchain accounts module account is set - if addr := accountKeeper.GetModuleAddress(types.ModuleName); addr == nil { + if addr := accountKeeper.GetModuleAddress(icatypes.ModuleName); addr == nil { panic("the Interchain Accounts module account has not been set") } @@ -55,13 +55,13 @@ func NewKeeper( // Logger returns the application logger, scoped to the associated module func (k Keeper) Logger(ctx sdk.Context) log.Logger { - return ctx.Logger().With("module", fmt.Sprintf("x/%s-%s", host.ModuleName, types.ModuleName)) + return ctx.Logger().With("module", fmt.Sprintf("x/%s-%s", host.ModuleName, icatypes.ModuleName)) } // BindPort stores the provided portID and binds to it, returning the associated capability func (k Keeper) BindPort(ctx sdk.Context, portID string) *capabilitytypes.Capability { store := ctx.KVStore(k.storeKey) - store.Set(types.KeyPort(portID), []byte{0x01}) + store.Set(icatypes.KeyPort(portID), []byte{0x01}) return k.portKeeper.BindPort(ctx, portID) } @@ -85,7 +85,7 @@ func (k Keeper) ClaimCapability(ctx sdk.Context, cap *capabilitytypes.Capability // GetActiveChannelID retrieves the active channelID from the store keyed by the provided portID func (k Keeper) GetActiveChannelID(ctx sdk.Context, portID string) (string, bool) { store := ctx.KVStore(k.storeKey) - key := types.KeyActiveChannel(portID) + key := icatypes.KeyActiveChannel(portID) if !store.Has(key) { return "", false @@ -95,16 +95,16 @@ func (k Keeper) GetActiveChannelID(ctx sdk.Context, portID string) (string, bool } // GetAllActiveChannels returns a list of all active interchain accounts host channels and their associated port identifiers -func (k Keeper) GetAllActiveChannels(ctx sdk.Context) []types.ActiveChannel { +func (k Keeper) GetAllActiveChannels(ctx sdk.Context) []icatypes.ActiveChannel { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, []byte(types.ActiveChannelKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte(icatypes.ActiveChannelKeyPrefix)) defer iterator.Close() - var activeChannels []types.ActiveChannel + var activeChannels []icatypes.ActiveChannel for ; iterator.Valid(); iterator.Next() { keySplit := strings.Split(string(iterator.Key()), "/") - ch := types.ActiveChannel{ + ch := icatypes.ActiveChannel{ PortId: keySplit[1], ChannelId: string(iterator.Value()), } @@ -118,13 +118,13 @@ func (k Keeper) GetAllActiveChannels(ctx sdk.Context) []types.ActiveChannel { // SetActiveChannelID stores the active channelID, keyed by the provided portID func (k Keeper) SetActiveChannelID(ctx sdk.Context, portID, channelID string) { store := ctx.KVStore(k.storeKey) - store.Set(types.KeyActiveChannel(portID), []byte(channelID)) + store.Set(icatypes.KeyActiveChannel(portID), []byte(channelID)) } // DeleteActiveChannelID removes the active channel keyed by the provided portID stored in state func (k Keeper) DeleteActiveChannelID(ctx sdk.Context, portID string) { store := ctx.KVStore(k.storeKey) - store.Delete(types.KeyActiveChannel(portID)) + store.Delete(icatypes.KeyActiveChannel(portID)) } // IsActiveChannel returns true if there exists an active channel for the provided portID, otherwise false @@ -136,7 +136,7 @@ func (k Keeper) IsActiveChannel(ctx sdk.Context, portID string) bool { // GetInterchainAccountAddress retrieves the InterchainAccount address from the store keyed by the provided portID func (k Keeper) GetInterchainAccountAddress(ctx sdk.Context, portID string) (string, bool) { store := ctx.KVStore(k.storeKey) - key := types.KeyOwnerAccount(portID) + key := icatypes.KeyOwnerAccount(portID) if !store.Has(key) { return "", false @@ -146,15 +146,15 @@ func (k Keeper) GetInterchainAccountAddress(ctx sdk.Context, portID string) (str } // GetAllInterchainAccounts returns a list of all registered interchain account addresses and their associated controller port identifiers -func (k Keeper) GetAllInterchainAccounts(ctx sdk.Context) []types.RegisteredInterchainAccount { +func (k Keeper) GetAllInterchainAccounts(ctx sdk.Context) []icatypes.RegisteredInterchainAccount { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, []byte(types.OwnerKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte(icatypes.OwnerKeyPrefix)) - var interchainAccounts []types.RegisteredInterchainAccount + var interchainAccounts []icatypes.RegisteredInterchainAccount for ; iterator.Valid(); iterator.Next() { keySplit := strings.Split(string(iterator.Key()), "/") - acc := types.RegisteredInterchainAccount{ + acc := icatypes.RegisteredInterchainAccount{ PortId: keySplit[1], AccountAddress: string(iterator.Value()), } @@ -168,7 +168,7 @@ func (k Keeper) GetAllInterchainAccounts(ctx sdk.Context) []types.RegisteredInte // SetInterchainAccountAddress stores the InterchainAccount address, keyed by the associated portID func (k Keeper) SetInterchainAccountAddress(ctx sdk.Context, portID string, address string) { store := ctx.KVStore(k.storeKey) - store.Set(types.KeyOwnerAccount(portID), []byte(address)) + store.Set(icatypes.KeyOwnerAccount(portID), []byte(address)) } // NegotiateAppVersion handles application version negotation for the IBC interchain accounts module @@ -180,12 +180,12 @@ func (k Keeper) NegotiateAppVersion( counterparty channeltypes.Counterparty, proposedVersion string, ) (string, error) { - if proposedVersion != types.VersionPrefix { - return "", sdkerrors.Wrapf(types.ErrInvalidVersion, "failed to negotiate app version: expected %s, got %s", types.VersionPrefix, proposedVersion) + if proposedVersion != icatypes.VersionPrefix { + return "", sdkerrors.Wrapf(icatypes.ErrInvalidVersion, "failed to negotiate app version: expected %s, got %s", icatypes.VersionPrefix, proposedVersion) } - moduleAccAddr := k.accountKeeper.GetModuleAddress(types.ModuleName) - accAddr := types.GenerateAddress(moduleAccAddr, counterparty.PortId) + moduleAccAddr := k.accountKeeper.GetModuleAddress(icatypes.ModuleName) + accAddr := icatypes.GenerateAddress(moduleAccAddr, counterparty.PortId) - return types.NewAppVersion(types.VersionPrefix, accAddr.String()), nil + return icatypes.NewAppVersion(icatypes.VersionPrefix, accAddr.String()), nil } diff --git a/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go b/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go index ad79e439b34..5f12ab2dfd1 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/suite" "github.com/tendermint/tendermint/crypto" - "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" + icatypes "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types" ibctesting "github.com/cosmos/ibc-go/v2/testing" ) @@ -16,13 +16,13 @@ import ( var ( // TestAccAddress defines a resuable bech32 address for testing purposes // TODO: update crypto.AddressHash() when sdk uses address.Module() - TestAccAddress = types.GenerateAddress(sdk.AccAddress(crypto.AddressHash([]byte(types.ModuleName))), TestPortID) + TestAccAddress = icatypes.GenerateAddress(sdk.AccAddress(crypto.AddressHash([]byte(icatypes.ModuleName))), TestPortID) // TestOwnerAddress defines a reusable bech32 address for testing purposes TestOwnerAddress = "cosmos17dtl0mjt3t77kpuhg2edqzjpszulwhgzuj9ljs" // TestPortID defines a resuable port identifier for testing purposes - TestPortID, _ = types.GeneratePortID(TestOwnerAddress, ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + TestPortID, _ = icatypes.GeneratePortID(TestOwnerAddress, ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) // TestVersion defines a resuable interchainaccounts version string for testing purposes - TestVersion = types.NewAppVersion(types.VersionPrefix, TestAccAddress.String()) + TestVersion = icatypes.NewAppVersion(icatypes.VersionPrefix, TestAccAddress.String()) ) type KeeperTestSuite struct { @@ -45,11 +45,11 @@ func (suite *KeeperTestSuite) SetupTest() { func NewICAPath(chainA, chainB *ibctesting.TestChain) *ibctesting.Path { path := ibctesting.NewPath(chainA, chainB) - path.EndpointA.ChannelConfig.PortID = types.PortID - path.EndpointB.ChannelConfig.PortID = types.PortID + path.EndpointA.ChannelConfig.PortID = icatypes.PortID + path.EndpointB.ChannelConfig.PortID = icatypes.PortID path.EndpointA.ChannelConfig.Order = channeltypes.ORDERED path.EndpointB.ChannelConfig.Order = channeltypes.ORDERED - path.EndpointA.ChannelConfig.Version = types.VersionPrefix + path.EndpointA.ChannelConfig.Version = icatypes.VersionPrefix path.EndpointB.ChannelConfig.Version = TestVersion return path @@ -78,7 +78,7 @@ func SetupICAPath(path *ibctesting.Path, owner string) error { // InitInterchainAccount is a helper function for starting the channel handshake func InitInterchainAccount(endpoint *ibctesting.Endpoint, owner string) error { - portID, err := types.GeneratePortID(owner, endpoint.ConnectionID, endpoint.Counterparty.ConnectionID) + portID, err := icatypes.GeneratePortID(owner, endpoint.ConnectionID, endpoint.Counterparty.ConnectionID) if err != nil { return err } @@ -127,7 +127,7 @@ func (suite *KeeperTestSuite) TestGetInterchainAccountAddress() { suite.Require().NoError(err) counterpartyPortID := path.EndpointA.ChannelConfig.PortID - expectedAddr := authtypes.NewBaseAccountWithAddress(types.GenerateAddress(suite.chainA.GetSimApp().AccountKeeper.GetModuleAddress(types.ModuleName), counterpartyPortID)).GetAddress() + expectedAddr := authtypes.NewBaseAccountWithAddress(icatypes.GenerateAddress(suite.chainA.GetSimApp().AccountKeeper.GetModuleAddress(icatypes.ModuleName), counterpartyPortID)).GetAddress() retrievedAddr, found := suite.chainB.GetSimApp().ICAHostKeeper.GetInterchainAccountAddress(suite.chainB.GetContext(), counterpartyPortID) suite.Require().True(found) @@ -154,7 +154,7 @@ func (suite *KeeperTestSuite) TestGetAllActiveChannels() { suite.chainB.GetSimApp().ICAHostKeeper.SetActiveChannelID(suite.chainB.GetContext(), expectedPortID, expectedChannelID) - expectedChannels := []types.ActiveChannel{ + expectedChannels := []icatypes.ActiveChannel{ { PortId: path.EndpointB.ChannelConfig.PortID, ChannelId: path.EndpointB.ChannelID, @@ -186,7 +186,7 @@ func (suite *KeeperTestSuite) TestGetAllInterchainAccounts() { suite.chainB.GetSimApp().ICAHostKeeper.SetInterchainAccountAddress(suite.chainB.GetContext(), expectedPortID, expectedAccAddr) - expectedAccounts := []types.RegisteredInterchainAccount{ + expectedAccounts := []icatypes.RegisteredInterchainAccount{ { PortId: TestPortID, AccountAddress: TestAccAddress.String(), diff --git a/modules/apps/27-interchain-accounts/host/keeper/relay.go b/modules/apps/27-interchain-accounts/host/keeper/relay.go index 85e8e1e8dec..dc53cdc54f0 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/relay.go +++ b/modules/apps/27-interchain-accounts/host/keeper/relay.go @@ -4,7 +4,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" + icatypes "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types" ) @@ -13,7 +13,7 @@ import ( func (k Keeper) AuthenticateTx(ctx sdk.Context, msgs []sdk.Msg, portID string) error { interchainAccountAddr, found := k.GetInterchainAccountAddress(ctx, portID) if !found { - return sdkerrors.Wrapf(types.ErrInterchainAccountNotFound, "failed to retrieve interchain account on port %s", portID) + return sdkerrors.Wrapf(icatypes.ErrInterchainAccountNotFound, "failed to retrieve interchain account on port %s", portID) } for _, msg := range msgs { @@ -54,7 +54,7 @@ func (k Keeper) executeTx(ctx sdk.Context, sourcePort, destPort, destChannel str func (k Keeper) executeMsg(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { handler := k.msgRouter.Handler(msg) if handler == nil { - return nil, types.ErrInvalidRoute + return nil, icatypes.ErrInvalidRoute } return handler(ctx, msg) @@ -62,16 +62,16 @@ func (k Keeper) executeMsg(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { // OnRecvPacket handles a given interchain accounts packet on a destination host chain func (k Keeper) OnRecvPacket(ctx sdk.Context, packet channeltypes.Packet) error { - var data types.InterchainAccountPacketData + var data icatypes.InterchainAccountPacketData - if err := types.ModuleCdc.UnmarshalJSON(packet.GetData(), &data); err != nil { + if err := icatypes.ModuleCdc.UnmarshalJSON(packet.GetData(), &data); err != nil { // UnmarshalJSON errors are indeterminate and therefore are not wrapped and included in failed acks - return sdkerrors.Wrapf(types.ErrUnknownDataType, "cannot unmarshal ICS-27 interchain account packet data") + return sdkerrors.Wrapf(icatypes.ErrUnknownDataType, "cannot unmarshal ICS-27 interchain account packet data") } switch data.Type { - case types.EXECUTE_TX: - msgs, err := types.DeserializeCosmosTx(k.cdc, data.Data) + case icatypes.EXECUTE_TX: + msgs, err := icatypes.DeserializeCosmosTx(k.cdc, data.Data) if err != nil { return err } @@ -82,6 +82,6 @@ func (k Keeper) OnRecvPacket(ctx sdk.Context, packet channeltypes.Packet) error return nil default: - return types.ErrUnknownDataType + return icatypes.ErrUnknownDataType } } diff --git a/modules/apps/27-interchain-accounts/host/keeper/relay_test.go b/modules/apps/27-interchain-accounts/host/keeper/relay_test.go index 9109f7559e5..cdfba6956b1 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/relay_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/relay_test.go @@ -10,7 +10,7 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" + icatypes "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" transfertypes "github.com/cosmos/ibc-go/v2/modules/apps/transfer/types" clienttypes "github.com/cosmos/ibc-go/v2/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types" @@ -40,11 +40,11 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { Amount: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))), } - data, err := types.SerializeCosmosTx(suite.chainA.GetSimApp().AppCodec(), []sdk.Msg{msg}) + data, err := icatypes.SerializeCosmosTx(suite.chainA.GetSimApp().AppCodec(), []sdk.Msg{msg}) suite.Require().NoError(err) - icaPacketData := types.InterchainAccountPacketData{ - Type: types.EXECUTE_TX, + icaPacketData := icatypes.InterchainAccountPacketData{ + Type: icatypes.EXECUTE_TX, Data: data, } @@ -65,11 +65,11 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { Amount: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(5000)), } - data, err := types.SerializeCosmosTx(suite.chainA.GetSimApp().AppCodec(), []sdk.Msg{msg}) + data, err := icatypes.SerializeCosmosTx(suite.chainA.GetSimApp().AppCodec(), []sdk.Msg{msg}) suite.Require().NoError(err) - icaPacketData := types.InterchainAccountPacketData{ - Type: types.EXECUTE_TX, + icaPacketData := icatypes.InterchainAccountPacketData{ + Type: icatypes.EXECUTE_TX, Data: data, } @@ -96,11 +96,11 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { Amount: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(5000)), } - data, err := types.SerializeCosmosTx(suite.chainA.GetSimApp().AppCodec(), []sdk.Msg{msgDelegate, msgUndelegate}) + data, err := icatypes.SerializeCosmosTx(suite.chainA.GetSimApp().AppCodec(), []sdk.Msg{msgDelegate, msgUndelegate}) suite.Require().NoError(err) - icaPacketData := types.InterchainAccountPacketData{ - Type: types.EXECUTE_TX, + icaPacketData := icatypes.InterchainAccountPacketData{ + Type: icatypes.EXECUTE_TX, Data: data, } @@ -128,11 +128,11 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { Proposer: interchainAccountAddr, } - data, err := types.SerializeCosmosTx(suite.chainA.GetSimApp().AppCodec(), []sdk.Msg{msg}) + data, err := icatypes.SerializeCosmosTx(suite.chainA.GetSimApp().AppCodec(), []sdk.Msg{msg}) suite.Require().NoError(err) - icaPacketData := types.InterchainAccountPacketData{ - Type: types.EXECUTE_TX, + icaPacketData := icatypes.InterchainAccountPacketData{ + Type: icatypes.EXECUTE_TX, Data: data, } @@ -164,11 +164,11 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { Option: govtypes.OptionYes, } - data, err := types.SerializeCosmosTx(suite.chainA.GetSimApp().AppCodec(), []sdk.Msg{msg}) + data, err := icatypes.SerializeCosmosTx(suite.chainA.GetSimApp().AppCodec(), []sdk.Msg{msg}) suite.Require().NoError(err) - icaPacketData := types.InterchainAccountPacketData{ - Type: types.EXECUTE_TX, + icaPacketData := icatypes.InterchainAccountPacketData{ + Type: icatypes.EXECUTE_TX, Data: data, } @@ -187,11 +187,11 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { Depositor: interchainAccountAddr, } - data, err := types.SerializeCosmosTx(suite.chainA.GetSimApp().AppCodec(), []sdk.Msg{msg}) + data, err := icatypes.SerializeCosmosTx(suite.chainA.GetSimApp().AppCodec(), []sdk.Msg{msg}) suite.Require().NoError(err) - icaPacketData := types.InterchainAccountPacketData{ - Type: types.EXECUTE_TX, + icaPacketData := icatypes.InterchainAccountPacketData{ + Type: icatypes.EXECUTE_TX, Data: data, } @@ -210,11 +210,11 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { WithdrawAddress: suite.chainB.SenderAccount.GetAddress().String(), } - data, err := types.SerializeCosmosTx(suite.chainA.GetSimApp().AppCodec(), []sdk.Msg{msg}) + data, err := icatypes.SerializeCosmosTx(suite.chainA.GetSimApp().AppCodec(), []sdk.Msg{msg}) suite.Require().NoError(err) - icaPacketData := types.InterchainAccountPacketData{ - Type: types.EXECUTE_TX, + icaPacketData := icatypes.InterchainAccountPacketData{ + Type: icatypes.EXECUTE_TX, Data: data, } @@ -244,11 +244,11 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { TimeoutTimestamp: uint64(0), } - data, err := types.SerializeCosmosTx(suite.chainA.GetSimApp().AppCodec(), []sdk.Msg{msg}) + data, err := icatypes.SerializeCosmosTx(suite.chainA.GetSimApp().AppCodec(), []sdk.Msg{msg}) suite.Require().NoError(err) - icaPacketData := types.InterchainAccountPacketData{ - Type: types.EXECUTE_TX, + icaPacketData := icatypes.InterchainAccountPacketData{ + Type: icatypes.EXECUTE_TX, Data: data, } @@ -268,8 +268,8 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { func() { data := []byte("invalid packet data") - icaPacketData := types.InterchainAccountPacketData{ - Type: types.EXECUTE_TX, + icaPacketData := icatypes.InterchainAccountPacketData{ + Type: icatypes.EXECUTE_TX, Data: data, } @@ -280,11 +280,11 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { { "invalid packet type - UNSPECIFIED", func() { - data, err := types.SerializeCosmosTx(suite.chainA.GetSimApp().AppCodec(), []sdk.Msg{&banktypes.MsgSend{}}) + data, err := icatypes.SerializeCosmosTx(suite.chainA.GetSimApp().AppCodec(), []sdk.Msg{&banktypes.MsgSend{}}) suite.Require().NoError(err) - icaPacketData := types.InterchainAccountPacketData{ - Type: types.UNSPECIFIED, + icaPacketData := icatypes.InterchainAccountPacketData{ + Type: icatypes.UNSPECIFIED, Data: data, } @@ -297,11 +297,11 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { func() { path.EndpointA.ChannelConfig.PortID = "invalid-port-id" - data, err := types.SerializeCosmosTx(suite.chainA.GetSimApp().AppCodec(), []sdk.Msg{&banktypes.MsgSend{}}) + data, err := icatypes.SerializeCosmosTx(suite.chainA.GetSimApp().AppCodec(), []sdk.Msg{&banktypes.MsgSend{}}) suite.Require().NoError(err) - icaPacketData := types.InterchainAccountPacketData{ - Type: types.EXECUTE_TX, + icaPacketData := icatypes.InterchainAccountPacketData{ + Type: icatypes.EXECUTE_TX, Data: data, } @@ -318,11 +318,11 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { Amount: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))), } - data, err := types.SerializeCosmosTx(suite.chainA.GetSimApp().AppCodec(), []sdk.Msg{msg}) + data, err := icatypes.SerializeCosmosTx(suite.chainA.GetSimApp().AppCodec(), []sdk.Msg{msg}) suite.Require().NoError(err) - icaPacketData := types.InterchainAccountPacketData{ - Type: types.EXECUTE_TX, + icaPacketData := icatypes.InterchainAccountPacketData{ + Type: icatypes.EXECUTE_TX, Data: data, } @@ -344,7 +344,7 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { err := SetupICAPath(path, TestOwnerAddress) suite.Require().NoError(err) - portID, err := types.GeneratePortID(TestOwnerAddress, ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + portID, err := icatypes.GeneratePortID(TestOwnerAddress, ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) suite.Require().NoError(err) // Get the address of the interchain account stored in state during handshake step