diff --git a/CHANGELOG.md b/CHANGELOG.md index ae3378bfe46..dafccccb5ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -71,6 +71,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Improvements +* (apps/27-interchain-accounts) [\#2133](https://github.com/cosmos/ibc-go/pull/2133) Generates genesis protos in a separate directory to avoid circular import errors. The protobuf package name has changed for the genesis types. * (linting) [\#1418](https://github.com/cosmos/ibc-go/pull/1418) Fix linting errors, resulting compatiblity with go1.18 linting style, golangci-lint 1.46.2 and the revivie linter. This caused breaking changes in core/04-channel, core/ante, and the testing library. * (modules/light-clients/07-tendermint) [\#1713](https://github.com/cosmos/ibc-go/pull/1713) Allow client upgrade proposals to update `TrustingPeriod`. See ADR-026 for context. * (modules/core/02-client) [\#1188](https://github.com/cosmos/ibc-go/pull/1188/files) Routing `MsgSubmitMisbehaviour` to `UpdateClient` keeper function. Deprecating `SubmitMisbehaviour` endpoint. diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index 21d874ccdf2..ee2d23577e6 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -98,6 +98,13 @@ - [ibc/applications/interchain_accounts/host/v1/host.proto](#ibc/applications/interchain_accounts/host/v1/host.proto) - [Params](#ibc.applications.interchain_accounts.host.v1.Params) +- [ibc/applications/interchain_accounts/genesis/v1/genesis.proto](#ibc/applications/interchain_accounts/genesis/v1/genesis.proto) + - [ActiveChannel](#ibc.applications.interchain_accounts.genesis.v1.ActiveChannel) + - [ControllerGenesisState](#ibc.applications.interchain_accounts.genesis.v1.ControllerGenesisState) + - [GenesisState](#ibc.applications.interchain_accounts.genesis.v1.GenesisState) + - [HostGenesisState](#ibc.applications.interchain_accounts.genesis.v1.HostGenesisState) + - [RegisteredInterchainAccount](#ibc.applications.interchain_accounts.genesis.v1.RegisteredInterchainAccount) + - [ibc/applications/interchain_accounts/host/v1/query.proto](#ibc/applications/interchain_accounts/host/v1/query.proto) - [QueryParamsRequest](#ibc.applications.interchain_accounts.host.v1.QueryParamsRequest) - [QueryParamsResponse](#ibc.applications.interchain_accounts.host.v1.QueryParamsResponse) @@ -107,13 +114,6 @@ - [ibc/applications/interchain_accounts/v1/account.proto](#ibc/applications/interchain_accounts/v1/account.proto) - [InterchainAccount](#ibc.applications.interchain_accounts.v1.InterchainAccount) -- [ibc/applications/interchain_accounts/v1/genesis.proto](#ibc/applications/interchain_accounts/v1/genesis.proto) - - [ActiveChannel](#ibc.applications.interchain_accounts.v1.ActiveChannel) - - [ControllerGenesisState](#ibc.applications.interchain_accounts.v1.ControllerGenesisState) - - [GenesisState](#ibc.applications.interchain_accounts.v1.GenesisState) - - [HostGenesisState](#ibc.applications.interchain_accounts.v1.HostGenesisState) - - [RegisteredInterchainAccount](#ibc.applications.interchain_accounts.v1.RegisteredInterchainAccount) - - [ibc/applications/interchain_accounts/v1/metadata.proto](#ibc/applications/interchain_accounts/v1/metadata.proto) - [Metadata](#ibc.applications.interchain_accounts.v1.Metadata) @@ -1608,74 +1608,93 @@ The following parameters may be used to disable the host submodule. - +

Top

-## ibc/applications/interchain_accounts/host/v1/query.proto +## ibc/applications/interchain_accounts/genesis/v1/genesis.proto - + -### QueryParamsRequest -QueryParamsRequest is the request type for the Query/Params RPC method. +### ActiveChannel +ActiveChannel contains a connection ID, port ID and associated active channel ID +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `connection_id` | [string](#string) | | | +| `port_id` | [string](#string) | | | +| `channel_id` | [string](#string) | | | - -### QueryParamsResponse -QueryParamsResponse is the response type for the Query/Params RPC method. + + + +### ControllerGenesisState +ControllerGenesisState defines the interchain accounts controller genesis state | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `params` | [Params](#ibc.applications.interchain_accounts.host.v1.Params) | | params defines the parameters of the module. | +| `active_channels` | [ActiveChannel](#ibc.applications.interchain_accounts.genesis.v1.ActiveChannel) | repeated | | +| `interchain_accounts` | [RegisteredInterchainAccount](#ibc.applications.interchain_accounts.genesis.v1.RegisteredInterchainAccount) | repeated | | +| `ports` | [string](#string) | repeated | | +| `params` | [ibc.applications.interchain_accounts.controller.v1.Params](#ibc.applications.interchain_accounts.controller.v1.Params) | | | - - + - +### GenesisState +GenesisState defines the interchain accounts genesis state - +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `controller_genesis_state` | [ControllerGenesisState](#ibc.applications.interchain_accounts.genesis.v1.ControllerGenesisState) | | | +| `host_genesis_state` | [HostGenesisState](#ibc.applications.interchain_accounts.genesis.v1.HostGenesisState) | | | -### Query -Query provides defines the gRPC querier service. -| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | -| ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `Params` | [QueryParamsRequest](#ibc.applications.interchain_accounts.host.v1.QueryParamsRequest) | [QueryParamsResponse](#ibc.applications.interchain_accounts.host.v1.QueryParamsResponse) | Params queries all parameters of the ICA host submodule. | GET|/ibc/apps/interchain_accounts/host/v1/params| - - -

Top

+ -## ibc/applications/interchain_accounts/v1/account.proto +### HostGenesisState +HostGenesisState defines the interchain accounts host genesis state + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `active_channels` | [ActiveChannel](#ibc.applications.interchain_accounts.genesis.v1.ActiveChannel) | repeated | | +| `interchain_accounts` | [RegisteredInterchainAccount](#ibc.applications.interchain_accounts.genesis.v1.RegisteredInterchainAccount) | repeated | | +| `port` | [string](#string) | | | +| `params` | [ibc.applications.interchain_accounts.host.v1.Params](#ibc.applications.interchain_accounts.host.v1.Params) | | | - -### InterchainAccount -An InterchainAccount is defined as a BaseAccount & the address of the account owner on the controller chain + + + + +### RegisteredInterchainAccount +RegisteredInterchainAccount contains a connection ID, port ID and associated interchain account address | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `base_account` | [cosmos.auth.v1beta1.BaseAccount](#cosmos.auth.v1beta1.BaseAccount) | | | -| `account_owner` | [string](#string) | | | +| `connection_id` | [string](#string) | | | +| `port_id` | [string](#string) | | | +| `account_address` | [string](#string) | | | @@ -1691,93 +1710,74 @@ An InterchainAccount is defined as a BaseAccount & the address of the account ow - +

Top

-## ibc/applications/interchain_accounts/v1/genesis.proto - - +## ibc/applications/interchain_accounts/host/v1/query.proto - -### ActiveChannel -ActiveChannel contains a connection ID, port ID and associated active channel ID + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `connection_id` | [string](#string) | | | -| `port_id` | [string](#string) | | | -| `channel_id` | [string](#string) | | | +### QueryParamsRequest +QueryParamsRequest is the request type for the Query/Params RPC method. - + -### ControllerGenesisState -ControllerGenesisState defines the interchain accounts controller genesis state +### QueryParamsResponse +QueryParamsResponse is the response type for the Query/Params RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `active_channels` | [ActiveChannel](#ibc.applications.interchain_accounts.v1.ActiveChannel) | repeated | | -| `interchain_accounts` | [RegisteredInterchainAccount](#ibc.applications.interchain_accounts.v1.RegisteredInterchainAccount) | repeated | | -| `ports` | [string](#string) | repeated | | -| `params` | [ibc.applications.interchain_accounts.controller.v1.Params](#ibc.applications.interchain_accounts.controller.v1.Params) | | | - - - +| `params` | [Params](#ibc.applications.interchain_accounts.host.v1.Params) | | params defines the parameters of the module. | - -### GenesisState -GenesisState defines the interchain accounts genesis state - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `controller_genesis_state` | [ControllerGenesisState](#ibc.applications.interchain_accounts.v1.ControllerGenesisState) | | | -| `host_genesis_state` | [HostGenesisState](#ibc.applications.interchain_accounts.v1.HostGenesisState) | | | + + + + - +### Query +Query provides defines the gRPC querier service. -### HostGenesisState -HostGenesisState defines the interchain accounts host genesis state +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `Params` | [QueryParamsRequest](#ibc.applications.interchain_accounts.host.v1.QueryParamsRequest) | [QueryParamsResponse](#ibc.applications.interchain_accounts.host.v1.QueryParamsResponse) | Params queries all parameters of the ICA host submodule. | GET|/ibc/apps/interchain_accounts/host/v1/params| + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `active_channels` | [ActiveChannel](#ibc.applications.interchain_accounts.v1.ActiveChannel) | repeated | | -| `interchain_accounts` | [RegisteredInterchainAccount](#ibc.applications.interchain_accounts.v1.RegisteredInterchainAccount) | repeated | | -| `port` | [string](#string) | | | -| `params` | [ibc.applications.interchain_accounts.host.v1.Params](#ibc.applications.interchain_accounts.host.v1.Params) | | | + +

Top

+## ibc/applications/interchain_accounts/v1/account.proto - + -### RegisteredInterchainAccount -RegisteredInterchainAccount contains a connection ID, port ID and associated interchain account address +### InterchainAccount +An InterchainAccount is defined as a BaseAccount & the address of the account owner on the controller chain | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `connection_id` | [string](#string) | | | -| `port_id` | [string](#string) | | | -| `account_address` | [string](#string) | | | +| `base_account` | [cosmos.auth.v1beta1.BaseAccount](#cosmos.auth.v1beta1.BaseAccount) | | | +| `account_owner` | [string](#string) | | | diff --git a/modules/apps/27-interchain-accounts/controller/keeper/genesis.go b/modules/apps/27-interchain-accounts/controller/keeper/genesis.go index 25acfc74a8a..ebf63a7ca3f 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" - icatypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/types" + genesistypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/genesis/types" host "github.com/cosmos/ibc-go/v5/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 icatypes.ControllerGenesisState) { +func InitGenesis(ctx sdk.Context, keeper Keeper, state genesistypes.ControllerGenesisState) { for _, portID := range state.Ports { if !keeper.IsBound(ctx, portID) { cap := keeper.BindPort(ctx, portID) @@ -32,8 +32,8 @@ func InitGenesis(ctx sdk.Context, keeper Keeper, state icatypes.ControllerGenesi } // ExportGenesis returns the interchain accounts controller exported genesis -func ExportGenesis(ctx sdk.Context, keeper Keeper) icatypes.ControllerGenesisState { - return icatypes.NewControllerGenesisState( +func ExportGenesis(ctx sdk.Context, keeper Keeper) genesistypes.ControllerGenesisState { + return genesistypes.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 ac4698cbc7f..a787c52c03b 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/genesis_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/genesis_test.go @@ -3,22 +3,22 @@ package keeper_test import ( "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/controller/keeper" "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/controller/types" - icatypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/types" + genesistypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/genesis/types" ibctesting "github.com/cosmos/ibc-go/v5/testing" ) func (suite *KeeperTestSuite) TestInitGenesis() { suite.SetupTest() - genesisState := icatypes.ControllerGenesisState{ - ActiveChannels: []icatypes.ActiveChannel{ + genesisState := genesistypes.ControllerGenesisState{ + ActiveChannels: []genesistypes.ActiveChannel{ { ConnectionId: ibctesting.FirstConnectionID, PortId: TestPortID, ChannelId: ibctesting.FirstChannelID, }, }, - InterchainAccounts: []icatypes.RegisteredInterchainAccount{ + InterchainAccounts: []genesistypes.RegisteredInterchainAccount{ { ConnectionId: ibctesting.FirstConnectionID, PortId: TestPortID, diff --git a/modules/apps/27-interchain-accounts/controller/keeper/keeper.go b/modules/apps/27-interchain-accounts/controller/keeper/keeper.go index 2b281e93a45..9ccd4abc6a4 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/keeper.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/keeper.go @@ -12,6 +12,7 @@ import ( "github.com/tendermint/tendermint/libs/log" "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/controller/types" + genesistypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/genesis/types" icatypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/types" channeltypes "github.com/cosmos/ibc-go/v5/modules/core/04-channel/types" host "github.com/cosmos/ibc-go/v5/modules/core/24-host" @@ -134,16 +135,16 @@ func (k Keeper) GetOpenActiveChannel(ctx sdk.Context, connectionID, portID strin } // GetAllActiveChannels returns a list of all active interchain accounts controller channels and their associated connection and port identifiers -func (k Keeper) GetAllActiveChannels(ctx sdk.Context) []icatypes.ActiveChannel { +func (k Keeper) GetAllActiveChannels(ctx sdk.Context) []genesistypes.ActiveChannel { store := ctx.KVStore(k.storeKey) iterator := sdk.KVStorePrefixIterator(store, []byte(icatypes.ActiveChannelKeyPrefix)) defer iterator.Close() - var activeChannels []icatypes.ActiveChannel + var activeChannels []genesistypes.ActiveChannel for ; iterator.Valid(); iterator.Next() { keySplit := strings.Split(string(iterator.Key()), "/") - ch := icatypes.ActiveChannel{ + ch := genesistypes.ActiveChannel{ ConnectionId: keySplit[2], PortId: keySplit[1], ChannelId: string(iterator.Value()), @@ -180,15 +181,15 @@ func (k Keeper) GetInterchainAccountAddress(ctx sdk.Context, connectionID, portI } // GetAllInterchainAccounts returns a list of all registered interchain account addresses and their associated connection and controller port identifiers -func (k Keeper) GetAllInterchainAccounts(ctx sdk.Context) []icatypes.RegisteredInterchainAccount { +func (k Keeper) GetAllInterchainAccounts(ctx sdk.Context) []genesistypes.RegisteredInterchainAccount { store := ctx.KVStore(k.storeKey) iterator := sdk.KVStorePrefixIterator(store, []byte(icatypes.OwnerKeyPrefix)) - var interchainAccounts []icatypes.RegisteredInterchainAccount + var interchainAccounts []genesistypes.RegisteredInterchainAccount for ; iterator.Valid(); iterator.Next() { keySplit := strings.Split(string(iterator.Key()), "/") - acc := icatypes.RegisteredInterchainAccount{ + acc := genesistypes.RegisteredInterchainAccount{ ConnectionId: keySplit[2], PortId: keySplit[1], AccountAddress: string(iterator.Value()), 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 21d58f0762c..18d9860e66a 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/keeper_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/keeper_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/suite" "github.com/tendermint/tendermint/crypto" + genesistypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/genesis/types" icatypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/types" channeltypes "github.com/cosmos/ibc-go/v5/modules/core/04-channel/types" ibctesting "github.com/cosmos/ibc-go/v5/testing" @@ -179,7 +180,7 @@ func (suite *KeeperTestSuite) TestGetAllActiveChannels() { suite.chainA.GetSimApp().ICAControllerKeeper.SetActiveChannelID(suite.chainA.GetContext(), ibctesting.FirstConnectionID, expectedPortID, expectedChannelID) - expectedChannels := []icatypes.ActiveChannel{ + expectedChannels := []genesistypes.ActiveChannel{ { ConnectionId: ibctesting.FirstConnectionID, PortId: TestPortID, @@ -213,7 +214,7 @@ func (suite *KeeperTestSuite) TestGetAllInterchainAccounts() { suite.chainA.GetSimApp().ICAControllerKeeper.SetInterchainAccountAddress(suite.chainA.GetContext(), ibctesting.FirstConnectionID, expectedPortID, expectedAccAddr) - expectedAccounts := []icatypes.RegisteredInterchainAccount{ + expectedAccounts := []genesistypes.RegisteredInterchainAccount{ { ConnectionId: ibctesting.FirstConnectionID, PortId: TestPortID, diff --git a/modules/apps/27-interchain-accounts/types/genesis.go b/modules/apps/27-interchain-accounts/genesis/types/genesis.go similarity index 93% rename from modules/apps/27-interchain-accounts/types/genesis.go rename to modules/apps/27-interchain-accounts/genesis/types/genesis.go index 38929c664b0..7d6be8f6502 100644 --- a/modules/apps/27-interchain-accounts/types/genesis.go +++ b/modules/apps/27-interchain-accounts/genesis/types/genesis.go @@ -3,6 +3,7 @@ package types import ( controllertypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/controller/types" hosttypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/host/types" + icatypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/types" host "github.com/cosmos/ibc-go/v5/modules/core/24-host" ) @@ -69,7 +70,7 @@ func (gs ControllerGenesisState) Validate() error { return err } - if err := ValidateAccountAddress(acc.AccountAddress); err != nil { + if err := icatypes.ValidateAccountAddress(acc.AccountAddress); err != nil { return err } } @@ -90,7 +91,7 @@ func (gs ControllerGenesisState) Validate() error { // DefaultHostGenesis creates and returns the default interchain accounts HostGenesisState func DefaultHostGenesis() HostGenesisState { return HostGenesisState{ - Port: PortID, + Port: icatypes.PortID, Params: hosttypes.DefaultParams(), } } @@ -122,7 +123,7 @@ func (gs HostGenesisState) Validate() error { return err } - if err := ValidateAccountAddress(acc.AccountAddress); err != nil { + if err := icatypes.ValidateAccountAddress(acc.AccountAddress); err != nil { return err } } diff --git a/modules/apps/27-interchain-accounts/types/genesis.pb.go b/modules/apps/27-interchain-accounts/genesis/types/genesis.pb.go similarity index 89% rename from modules/apps/27-interchain-accounts/types/genesis.pb.go rename to modules/apps/27-interchain-accounts/genesis/types/genesis.pb.go index 7bac7e84f53..fb0a9bd7b5e 100644 --- a/modules/apps/27-interchain-accounts/types/genesis.pb.go +++ b/modules/apps/27-interchain-accounts/genesis/types/genesis.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: ibc/applications/interchain_accounts/v1/genesis.proto +// source: ibc/applications/interchain_accounts/genesis/v1/genesis.proto package types @@ -35,7 +35,7 @@ func (m *GenesisState) Reset() { *m = GenesisState{} } func (m *GenesisState) String() string { return proto.CompactTextString(m) } func (*GenesisState) ProtoMessage() {} func (*GenesisState) Descriptor() ([]byte, []int) { - return fileDescriptor_629b3ced0911516b, []int{0} + return fileDescriptor_d4aa48c8e29a1947, []int{0} } func (m *GenesisState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -90,7 +90,7 @@ func (m *ControllerGenesisState) Reset() { *m = ControllerGenesisState{} func (m *ControllerGenesisState) String() string { return proto.CompactTextString(m) } func (*ControllerGenesisState) ProtoMessage() {} func (*ControllerGenesisState) Descriptor() ([]byte, []int) { - return fileDescriptor_629b3ced0911516b, []int{1} + return fileDescriptor_d4aa48c8e29a1947, []int{1} } func (m *ControllerGenesisState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -159,7 +159,7 @@ func (m *HostGenesisState) Reset() { *m = HostGenesisState{} } func (m *HostGenesisState) String() string { return proto.CompactTextString(m) } func (*HostGenesisState) ProtoMessage() {} func (*HostGenesisState) Descriptor() ([]byte, []int) { - return fileDescriptor_629b3ced0911516b, []int{2} + return fileDescriptor_d4aa48c8e29a1947, []int{2} } func (m *HostGenesisState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -227,7 +227,7 @@ func (m *ActiveChannel) Reset() { *m = ActiveChannel{} } func (m *ActiveChannel) String() string { return proto.CompactTextString(m) } func (*ActiveChannel) ProtoMessage() {} func (*ActiveChannel) Descriptor() ([]byte, []int) { - return fileDescriptor_629b3ced0911516b, []int{3} + return fileDescriptor_d4aa48c8e29a1947, []int{3} } func (m *ActiveChannel) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -288,7 +288,7 @@ func (m *RegisteredInterchainAccount) Reset() { *m = RegisteredInterchai func (m *RegisteredInterchainAccount) String() string { return proto.CompactTextString(m) } func (*RegisteredInterchainAccount) ProtoMessage() {} func (*RegisteredInterchainAccount) Descriptor() ([]byte, []int) { - return fileDescriptor_629b3ced0911516b, []int{4} + return fileDescriptor_d4aa48c8e29a1947, []int{4} } func (m *RegisteredInterchainAccount) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -339,60 +339,60 @@ func (m *RegisteredInterchainAccount) GetAccountAddress() string { } func init() { - proto.RegisterType((*GenesisState)(nil), "ibc.applications.interchain_accounts.v1.GenesisState") - proto.RegisterType((*ControllerGenesisState)(nil), "ibc.applications.interchain_accounts.v1.ControllerGenesisState") - proto.RegisterType((*HostGenesisState)(nil), "ibc.applications.interchain_accounts.v1.HostGenesisState") - proto.RegisterType((*ActiveChannel)(nil), "ibc.applications.interchain_accounts.v1.ActiveChannel") - proto.RegisterType((*RegisteredInterchainAccount)(nil), "ibc.applications.interchain_accounts.v1.RegisteredInterchainAccount") + proto.RegisterType((*GenesisState)(nil), "ibc.applications.interchain_accounts.genesis.v1.GenesisState") + proto.RegisterType((*ControllerGenesisState)(nil), "ibc.applications.interchain_accounts.genesis.v1.ControllerGenesisState") + proto.RegisterType((*HostGenesisState)(nil), "ibc.applications.interchain_accounts.genesis.v1.HostGenesisState") + proto.RegisterType((*ActiveChannel)(nil), "ibc.applications.interchain_accounts.genesis.v1.ActiveChannel") + proto.RegisterType((*RegisteredInterchainAccount)(nil), "ibc.applications.interchain_accounts.genesis.v1.RegisteredInterchainAccount") } func init() { - proto.RegisterFile("ibc/applications/interchain_accounts/v1/genesis.proto", fileDescriptor_629b3ced0911516b) -} - -var fileDescriptor_629b3ced0911516b = []byte{ - // 645 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x95, 0x3f, 0x6f, 0x13, 0x3f, - 0x18, 0xc7, 0xe3, 0xa4, 0xbf, 0xfe, 0x14, 0xf7, 0x0f, 0xc5, 0x94, 0xea, 0x08, 0xd2, 0x25, 0x78, - 0x69, 0x24, 0xd4, 0x3b, 0xb5, 0xb4, 0x54, 0x54, 0x42, 0xa8, 0x17, 0x10, 0x64, 0x43, 0x66, 0x41, - 0x2c, 0x27, 0xc7, 0x67, 0x25, 0x96, 0x92, 0x73, 0x74, 0x76, 0x23, 0x75, 0x62, 0x67, 0x62, 0x43, - 0xac, 0x48, 0xbc, 0x00, 0xde, 0x01, 0x63, 0x27, 0xd4, 0x91, 0x29, 0x42, 0xed, 0x3b, 0xc8, 0x2b, - 0x40, 0xf6, 0x9d, 0x92, 0xf4, 0x48, 0xab, 0x9b, 0x98, 0x98, 0x62, 0xdf, 0xe3, 0xef, 0xf7, 0xf9, - 0x3c, 0x7e, 0x1c, 0x1b, 0x1e, 0x88, 0x0e, 0xf3, 0xe9, 0x70, 0xd8, 0x17, 0x8c, 0x6a, 0x21, 0x63, - 0xe5, 0x8b, 0x58, 0xf3, 0x84, 0xf5, 0xa8, 0x88, 0x43, 0xca, 0x98, 0x3c, 0x89, 0xb5, 0xf2, 0x47, - 0xbb, 0x7e, 0x97, 0xc7, 0x5c, 0x09, 0xe5, 0x0d, 0x13, 0xa9, 0x25, 0xda, 0x16, 0x1d, 0xe6, 0xcd, - 0xcb, 0xbc, 0x05, 0x32, 0x6f, 0xb4, 0x5b, 0xdb, 0xec, 0xca, 0xae, 0xb4, 0x1a, 0xdf, 0x8c, 0x52, - 0x79, 0xad, 0x55, 0x28, 0x2b, 0x93, 0xb1, 0x4e, 0x64, 0xbf, 0xcf, 0x13, 0x03, 0x30, 0x9b, 0x65, - 0x26, 0x87, 0x85, 0x4c, 0x7a, 0x52, 0x69, 0x23, 0x37, 0xbf, 0xa9, 0x10, 0x7f, 0x2f, 0xc3, 0xd5, - 0x97, 0x69, 0x39, 0x6f, 0x34, 0xd5, 0x1c, 0x7d, 0x01, 0xd0, 0x99, 0xd9, 0x87, 0x59, 0xa9, 0xa1, - 0x32, 0x41, 0x07, 0x34, 0x40, 0x73, 0x65, 0xef, 0x99, 0x57, 0xb0, 0x62, 0xaf, 0x35, 0x35, 0x9a, - 0xcf, 0x11, 0x6c, 0x9f, 0x8d, 0xeb, 0xa5, 0xc9, 0xb8, 0x5e, 0x3f, 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x2b, 0xfd, 0xd1, 0x81, 0x3f, 0x90, 0xd1, 0x49, 0x9f, - 0x2b, 0xf3, 0xf8, 0x28, 0x7f, 0xef, 0x70, 0x67, 0xd6, 0xfc, 0x9d, 0xe9, 0xbb, 0xa3, 0x4f, 0x87, - 0x5c, 0x75, 0x96, 0xed, 0x8b, 0xf3, 0xe8, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x5c, 0x2b, 0x9a, - 0xce, 0x67, 0x07, 0x00, 0x00, + proto.RegisterFile("ibc/applications/interchain_accounts/genesis/v1/genesis.proto", fileDescriptor_d4aa48c8e29a1947) +} + +var fileDescriptor_d4aa48c8e29a1947 = []byte{ + // 648 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x95, 0x4d, 0x6b, 0x13, 0x41, + 0x18, 0xc7, 0x33, 0x49, 0xad, 0x64, 0xfa, 0x62, 0x1d, 0x6b, 0x59, 0x23, 0x6c, 0xe2, 0x5c, 0x0c, + 0x48, 0x77, 0x69, 0xad, 0x14, 0x0a, 0x15, 0xb2, 0x39, 0xd4, 0x80, 0x82, 0x8c, 0x17, 0xf1, 0x12, + 0x26, 0xb3, 0xc3, 0x66, 0x20, 0xd9, 0x09, 0x3b, 0xd3, 0x40, 0x3f, 0x81, 0x57, 0xf1, 0x1b, 0x78, + 0x13, 0x6f, 0x5e, 0xfc, 0x0c, 0x3d, 0x49, 0x8f, 0x9e, 0x82, 0xb4, 0xdf, 0x20, 0x9f, 0x40, 0x66, + 0x76, 0x9b, 0xb7, 0xa6, 0x92, 0x5c, 0x3c, 0x79, 0xca, 0xcc, 0xce, 0xf3, 0xff, 0x3f, 0xbf, 0x67, + 0x9e, 0xc9, 0x0c, 0x3c, 0x16, 0x2d, 0xe6, 0xd3, 0x5e, 0xaf, 0x23, 0x18, 0xd5, 0x42, 0xc6, 0xca, + 0x17, 0xb1, 0xe6, 0x09, 0x6b, 0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0xae, 0x81, 0x35, 0xc2, 0xbc, 0x15, 0xa2, 0xe1, 0xa0, 0xbc, 0x99, 0x0a, + 0xb3, 0x05, 0x4c, 0x56, 0xcd, 0xa8, 0x11, 0xa2, 0x03, 0x08, 0xb3, 0x36, 0x99, 0x78, 0x5b, 0x6b, + 0xf0, 0x70, 0x38, 0x28, 0xdf, 0xcf, 0x12, 0x8d, 0xd6, 0x30, 0x29, 0x66, 0x93, 0x46, 0x88, 0x7f, + 0x02, 0xf8, 0xf8, 0x2f, 0x7b, 0xfe, 0x4f, 0x2b, 0xa8, 0x9b, 0x43, 0x6d, 0xd3, 0x36, 0x69, 0x18, + 0x26, 0x5c, 0xa9, 0xac, 0x8c, 0xd2, 0xe4, 0x81, 0x9c, 0x0a, 0xb0, 0x07, 0xd2, 0x7e, 0xa9, 0xa5, + 0x1f, 0x82, 0xe8, 0xfc, 0xd2, 0x05, 0x17, 0x97, 0x2e, 0xf8, 0x7d, 0xe9, 0x82, 0x4f, 0x57, 0x6e, + 0xee, 0xe2, 0xca, 0xcd, 0xfd, 0xba, 0x72, 0x73, 0x1f, 0xde, 0x44, 0x42, 0xb7, 0x4f, 0x5b, 0x1e, + 0x93, 0x5d, 0x9f, 0x49, 0xd5, 0x95, 0xca, 0x3c, 0x96, 0xbb, 0x91, 0xf4, 0xfb, 0x2f, 0xfc, 0xae, + 0x0c, 0x4f, 0x3b, 0x5c, 0x99, 0xe7, 0x4a, 0xf9, 0xfb, 0x87, 0xbb, 0xe3, 0xe6, 0xef, 0xde, 0x78, + 0x74, 0xf5, 0x59, 0x8f, 0xab, 0xd6, 0xaa, 0x7d, 0xab, 0x9e, 0xff, 0x09, 0x00, 0x00, 0xff, 0xff, + 0x1d, 0xb1, 0x33, 0x63, 0xb1, 0x07, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/modules/apps/27-interchain-accounts/types/genesis_test.go b/modules/apps/27-interchain-accounts/genesis/types/genesis_test.go similarity index 53% rename from modules/apps/27-interchain-accounts/types/genesis_test.go rename to modules/apps/27-interchain-accounts/genesis/types/genesis_test.go index 9adc1469564..9f3a9c7be45 100644 --- a/modules/apps/27-interchain-accounts/types/genesis_test.go +++ b/modules/apps/27-interchain-accounts/genesis/types/genesis_test.go @@ -1,14 +1,29 @@ package types_test import ( + "github.com/stretchr/testify/suite" + controllertypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/controller/types" + genesistypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/genesis/types" hosttypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/host/types" - "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/types" + icatypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/types" ibctesting "github.com/cosmos/ibc-go/v5/testing" ) -func (suite *TypesTestSuite) TestValidateGenesisState() { - var genesisState types.GenesisState +var ( + // TestOwnerAddress defines a reusable bech32 address for testing purposes + TestOwnerAddress = "cosmos17dtl0mjt3t77kpuhg2edqzjpszulwhgzuj9ljs" + + // TestPortID defines a reusable port identifier for testing purposes + TestPortID, _ = icatypes.NewControllerPortID(TestOwnerAddress) +) + +type GenesisTypesTestSuite struct { + suite.Suite +} + +func (suite *GenesisTypesTestSuite) TestValidateGenesisState() { + var genesisState genesistypes.GenesisState testCases := []struct { name string @@ -23,21 +38,21 @@ func (suite *TypesTestSuite) TestValidateGenesisState() { { "failed to validate - empty value", func() { - genesisState = types.GenesisState{} + genesisState = genesistypes.GenesisState{} }, false, }, { "failed to validate - invalid controller genesis", func() { - genesisState = *types.NewGenesisState(types.ControllerGenesisState{Ports: []string{"invalid|port"}}, types.DefaultHostGenesis()) + genesisState = *genesistypes.NewGenesisState(genesistypes.ControllerGenesisState{Ports: []string{"invalid|port"}}, genesistypes.DefaultHostGenesis()) }, false, }, { "failed to validate - invalid host genesis", func() { - genesisState = *types.NewGenesisState(types.DefaultControllerGenesis(), types.HostGenesisState{}) + genesisState = *genesistypes.NewGenesisState(genesistypes.DefaultControllerGenesis(), genesistypes.HostGenesisState{}) }, false, }, @@ -45,7 +60,7 @@ func (suite *TypesTestSuite) TestValidateGenesisState() { for _, tc := range testCases { suite.Run(tc.name, func() { - genesisState = *types.DefaultGenesis() + genesisState = *genesistypes.DefaultGenesis() tc.malleate() // malleate mutates test data @@ -60,8 +75,8 @@ func (suite *TypesTestSuite) TestValidateGenesisState() { } } -func (suite *TypesTestSuite) TestValidateControllerGenesisState() { - var genesisState types.ControllerGenesisState +func (suite *GenesisTypesTestSuite) TestValidateControllerGenesisState() { + var genesisState genesistypes.ControllerGenesisState testCases := []struct { name string @@ -76,91 +91,91 @@ func (suite *TypesTestSuite) TestValidateControllerGenesisState() { { "failed to validate active channel - invalid port identifier", func() { - activeChannels := []types.ActiveChannel{ + activeChannels := []genesistypes.ActiveChannel{ { PortId: "invalid|port", ChannelId: ibctesting.FirstChannelID, }, } - genesisState = types.NewControllerGenesisState(activeChannels, []types.RegisteredInterchainAccount{}, []string{}, controllertypes.DefaultParams()) + genesisState = genesistypes.NewControllerGenesisState(activeChannels, []genesistypes.RegisteredInterchainAccount{}, []string{}, controllertypes.DefaultParams()) }, false, }, { "failed to validate active channel - invalid channel identifier", func() { - activeChannels := []types.ActiveChannel{ + activeChannels := []genesistypes.ActiveChannel{ { PortId: TestPortID, ChannelId: "invalid|channel", }, } - genesisState = types.NewControllerGenesisState(activeChannels, []types.RegisteredInterchainAccount{}, []string{}, controllertypes.DefaultParams()) + genesisState = genesistypes.NewControllerGenesisState(activeChannels, []genesistypes.RegisteredInterchainAccount{}, []string{}, controllertypes.DefaultParams()) }, false, }, { "failed to validate registered account - invalid port identifier", func() { - activeChannels := []types.ActiveChannel{ + activeChannels := []genesistypes.ActiveChannel{ { PortId: TestPortID, ChannelId: ibctesting.FirstChannelID, }, } - registeredAccounts := []types.RegisteredInterchainAccount{ + registeredAccounts := []genesistypes.RegisteredInterchainAccount{ { PortId: "invalid|port", AccountAddress: TestOwnerAddress, }, } - genesisState = types.NewControllerGenesisState(activeChannels, registeredAccounts, []string{}, controllertypes.DefaultParams()) + genesisState = genesistypes.NewControllerGenesisState(activeChannels, registeredAccounts, []string{}, controllertypes.DefaultParams()) }, false, }, { "failed to validate registered account - invalid owner address", func() { - activeChannels := []types.ActiveChannel{ + activeChannels := []genesistypes.ActiveChannel{ { PortId: TestPortID, ChannelId: ibctesting.FirstChannelID, }, } - registeredAccounts := []types.RegisteredInterchainAccount{ + registeredAccounts := []genesistypes.RegisteredInterchainAccount{ { PortId: TestPortID, AccountAddress: "", }, } - genesisState = types.NewControllerGenesisState(activeChannels, registeredAccounts, []string{}, controllertypes.DefaultParams()) + genesisState = genesistypes.NewControllerGenesisState(activeChannels, registeredAccounts, []string{}, controllertypes.DefaultParams()) }, false, }, { "failed to validate controller ports - invalid port identifier", func() { - activeChannels := []types.ActiveChannel{ + activeChannels := []genesistypes.ActiveChannel{ { PortId: TestPortID, ChannelId: ibctesting.FirstChannelID, }, } - registeredAccounts := []types.RegisteredInterchainAccount{ + registeredAccounts := []genesistypes.RegisteredInterchainAccount{ { PortId: TestPortID, AccountAddress: TestOwnerAddress, }, } - genesisState = types.NewControllerGenesisState(activeChannels, registeredAccounts, []string{"invalid|port"}, controllertypes.DefaultParams()) + genesisState = genesistypes.NewControllerGenesisState(activeChannels, registeredAccounts, []string{"invalid|port"}, controllertypes.DefaultParams()) }, false, }, @@ -168,7 +183,7 @@ func (suite *TypesTestSuite) TestValidateControllerGenesisState() { for _, tc := range testCases { suite.Run(tc.name, func() { - genesisState = types.DefaultControllerGenesis() + genesisState = genesistypes.DefaultControllerGenesis() tc.malleate() // malleate mutates test data @@ -183,8 +198,8 @@ func (suite *TypesTestSuite) TestValidateControllerGenesisState() { } } -func (suite *TypesTestSuite) TestValidateHostGenesisState() { - var genesisState types.HostGenesisState +func (suite *GenesisTypesTestSuite) TestValidateHostGenesisState() { + var genesisState genesistypes.HostGenesisState testCases := []struct { name string @@ -199,91 +214,91 @@ func (suite *TypesTestSuite) TestValidateHostGenesisState() { { "failed to validate active channel - invalid port identifier", func() { - activeChannels := []types.ActiveChannel{ + activeChannels := []genesistypes.ActiveChannel{ { PortId: "invalid|port", ChannelId: ibctesting.FirstChannelID, }, } - genesisState = types.NewHostGenesisState(activeChannels, []types.RegisteredInterchainAccount{}, types.PortID, hosttypes.DefaultParams()) + genesisState = genesistypes.NewHostGenesisState(activeChannels, []genesistypes.RegisteredInterchainAccount{}, icatypes.PortID, hosttypes.DefaultParams()) }, false, }, { "failed to validate active channel - invalid channel identifier", func() { - activeChannels := []types.ActiveChannel{ + activeChannels := []genesistypes.ActiveChannel{ { PortId: TestPortID, ChannelId: "invalid|channel", }, } - genesisState = types.NewHostGenesisState(activeChannels, []types.RegisteredInterchainAccount{}, types.PortID, hosttypes.DefaultParams()) + genesisState = genesistypes.NewHostGenesisState(activeChannels, []genesistypes.RegisteredInterchainAccount{}, icatypes.PortID, hosttypes.DefaultParams()) }, false, }, { "failed to validate registered account - invalid port identifier", func() { - activeChannels := []types.ActiveChannel{ + activeChannels := []genesistypes.ActiveChannel{ { PortId: TestPortID, ChannelId: ibctesting.FirstChannelID, }, } - registeredAccounts := []types.RegisteredInterchainAccount{ + registeredAccounts := []genesistypes.RegisteredInterchainAccount{ { PortId: "invalid|port", AccountAddress: TestOwnerAddress, }, } - genesisState = types.NewHostGenesisState(activeChannels, registeredAccounts, types.PortID, hosttypes.DefaultParams()) + genesisState = genesistypes.NewHostGenesisState(activeChannels, registeredAccounts, icatypes.PortID, hosttypes.DefaultParams()) }, false, }, { "failed to validate registered account - invalid owner address", func() { - activeChannels := []types.ActiveChannel{ + activeChannels := []genesistypes.ActiveChannel{ { PortId: TestPortID, ChannelId: ibctesting.FirstChannelID, }, } - registeredAccounts := []types.RegisteredInterchainAccount{ + registeredAccounts := []genesistypes.RegisteredInterchainAccount{ { PortId: TestPortID, AccountAddress: "", }, } - genesisState = types.NewHostGenesisState(activeChannels, registeredAccounts, types.PortID, hosttypes.DefaultParams()) + genesisState = genesistypes.NewHostGenesisState(activeChannels, registeredAccounts, icatypes.PortID, hosttypes.DefaultParams()) }, false, }, { "failed to validate controller ports - invalid port identifier", func() { - activeChannels := []types.ActiveChannel{ + activeChannels := []genesistypes.ActiveChannel{ { PortId: TestPortID, ChannelId: ibctesting.FirstChannelID, }, } - registeredAccounts := []types.RegisteredInterchainAccount{ + registeredAccounts := []genesistypes.RegisteredInterchainAccount{ { PortId: TestPortID, AccountAddress: TestOwnerAddress, }, } - genesisState = types.NewHostGenesisState(activeChannels, registeredAccounts, "invalid|port", hosttypes.DefaultParams()) + genesisState = genesistypes.NewHostGenesisState(activeChannels, registeredAccounts, "invalid|port", hosttypes.DefaultParams()) }, false, }, @@ -291,7 +306,7 @@ func (suite *TypesTestSuite) TestValidateHostGenesisState() { for _, tc := range testCases { suite.Run(tc.name, func() { - genesisState = types.DefaultHostGenesis() + genesisState = genesistypes.DefaultHostGenesis() tc.malleate() // malleate mutates test data diff --git a/modules/apps/27-interchain-accounts/host/keeper/genesis.go b/modules/apps/27-interchain-accounts/host/keeper/genesis.go index c4c66e88414..03a714804bf 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/genesis.go +++ b/modules/apps/27-interchain-accounts/host/keeper/genesis.go @@ -5,12 +5,13 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + genesistypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/genesis/types" icatypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/types" host "github.com/cosmos/ibc-go/v5/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 icatypes.HostGenesisState) { +func InitGenesis(ctx sdk.Context, keeper Keeper, state genesistypes.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 { @@ -30,8 +31,8 @@ func InitGenesis(ctx sdk.Context, keeper Keeper, state icatypes.HostGenesisState } // ExportGenesis returns the interchain accounts host exported genesis -func ExportGenesis(ctx sdk.Context, keeper Keeper) icatypes.HostGenesisState { - return icatypes.NewHostGenesisState( +func ExportGenesis(ctx sdk.Context, keeper Keeper) genesistypes.HostGenesisState { + return genesistypes.NewHostGenesisState( keeper.GetAllActiveChannels(ctx), keeper.GetAllInterchainAccounts(ctx), 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 9a39befbaee..d9c3cfa8091 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/genesis_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/genesis_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + genesistypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/genesis/types" "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/host/keeper" "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/host/types" icatypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/types" @@ -10,15 +11,15 @@ import ( func (suite *KeeperTestSuite) TestInitGenesis() { suite.SetupTest() - genesisState := icatypes.HostGenesisState{ - ActiveChannels: []icatypes.ActiveChannel{ + genesisState := genesistypes.HostGenesisState{ + ActiveChannels: []genesistypes.ActiveChannel{ { ConnectionId: ibctesting.FirstConnectionID, PortId: TestPortID, ChannelId: ibctesting.FirstChannelID, }, }, - InterchainAccounts: []icatypes.RegisteredInterchainAccount{ + InterchainAccounts: []genesistypes.RegisteredInterchainAccount{ { ConnectionId: ibctesting.FirstConnectionID, PortId: TestPortID, diff --git a/modules/apps/27-interchain-accounts/host/keeper/keeper.go b/modules/apps/27-interchain-accounts/host/keeper/keeper.go index acad2ea4622..693df6fcd67 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/keeper.go +++ b/modules/apps/27-interchain-accounts/host/keeper/keeper.go @@ -11,6 +11,7 @@ import ( paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/tendermint/tendermint/libs/log" + genesistypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/genesis/types" "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/host/types" icatypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/types" channeltypes "github.com/cosmos/ibc-go/v5/modules/core/04-channel/types" @@ -118,16 +119,16 @@ func (k Keeper) GetOpenActiveChannel(ctx sdk.Context, connectionID, portID strin } // GetAllActiveChannels returns a list of all active interchain accounts host channels and their associated connection and port identifiers -func (k Keeper) GetAllActiveChannels(ctx sdk.Context) []icatypes.ActiveChannel { +func (k Keeper) GetAllActiveChannels(ctx sdk.Context) []genesistypes.ActiveChannel { store := ctx.KVStore(k.storeKey) iterator := sdk.KVStorePrefixIterator(store, []byte(icatypes.ActiveChannelKeyPrefix)) defer iterator.Close() - var activeChannels []icatypes.ActiveChannel + var activeChannels []genesistypes.ActiveChannel for ; iterator.Valid(); iterator.Next() { keySplit := strings.Split(string(iterator.Key()), "/") - ch := icatypes.ActiveChannel{ + ch := genesistypes.ActiveChannel{ ConnectionId: keySplit[2], PortId: keySplit[1], ChannelId: string(iterator.Value()), @@ -164,15 +165,15 @@ func (k Keeper) GetInterchainAccountAddress(ctx sdk.Context, connectionID, portI } // GetAllInterchainAccounts returns a list of all registered interchain account addresses and their associated connection and controller port identifiers -func (k Keeper) GetAllInterchainAccounts(ctx sdk.Context) []icatypes.RegisteredInterchainAccount { +func (k Keeper) GetAllInterchainAccounts(ctx sdk.Context) []genesistypes.RegisteredInterchainAccount { store := ctx.KVStore(k.storeKey) iterator := sdk.KVStorePrefixIterator(store, []byte(icatypes.OwnerKeyPrefix)) - var interchainAccounts []icatypes.RegisteredInterchainAccount + var interchainAccounts []genesistypes.RegisteredInterchainAccount for ; iterator.Valid(); iterator.Next() { keySplit := strings.Split(string(iterator.Key()), "/") - acc := icatypes.RegisteredInterchainAccount{ + acc := genesistypes.RegisteredInterchainAccount{ ConnectionId: keySplit[2], PortId: keySplit[1], AccountAddress: string(iterator.Value()), 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 eb475cea6c8..25a01f66ea9 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/suite" "github.com/tendermint/tendermint/crypto" + genesistypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/genesis/types" icatypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/types" channeltypes "github.com/cosmos/ibc-go/v5/modules/core/04-channel/types" ibctesting "github.com/cosmos/ibc-go/v5/testing" @@ -163,7 +164,7 @@ func (suite *KeeperTestSuite) TestGetAllActiveChannels() { suite.chainB.GetSimApp().ICAHostKeeper.SetActiveChannelID(suite.chainB.GetContext(), ibctesting.FirstConnectionID, expectedPortID, expectedChannelID) - expectedChannels := []icatypes.ActiveChannel{ + expectedChannels := []genesistypes.ActiveChannel{ { ConnectionId: ibctesting.FirstConnectionID, PortId: path.EndpointA.ChannelConfig.PortID, @@ -197,7 +198,7 @@ func (suite *KeeperTestSuite) TestGetAllInterchainAccounts() { suite.chainB.GetSimApp().ICAHostKeeper.SetInterchainAccountAddress(suite.chainB.GetContext(), ibctesting.FirstConnectionID, expectedPortID, expectedAccAddr) - expectedAccounts := []icatypes.RegisteredInterchainAccount{ + expectedAccounts := []genesistypes.RegisteredInterchainAccount{ { ConnectionId: ibctesting.FirstConnectionID, PortId: TestPortID, diff --git a/modules/apps/27-interchain-accounts/module.go b/modules/apps/27-interchain-accounts/module.go index 18c52693313..778053333ab 100644 --- a/modules/apps/27-interchain-accounts/module.go +++ b/modules/apps/27-interchain-accounts/module.go @@ -17,6 +17,7 @@ import ( "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/client/cli" controllerkeeper "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/controller/keeper" controllertypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/controller/types" + genesistypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/genesis/types" "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/host" hostkeeper "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/host/keeper" hosttypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/host/types" @@ -45,18 +46,19 @@ func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} // RegisterInterfaces registers module concrete types into protobuf Any func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) { + controllertypes.RegisterInterfaces(registry) types.RegisterInterfaces(registry) } // DefaultGenesis returns default genesis state as raw bytes for the IBC // interchain accounts module func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { - return cdc.MustMarshalJSON(types.DefaultGenesis()) + return cdc.MustMarshalJSON(genesistypes.DefaultGenesis()) } // ValidateGenesis performs genesis state validation for the IBC interchain acounts module func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { - var gs types.GenesisState + var gs genesistypes.GenesisState if err := cdc.UnmarshalJSON(bz, &gs); err != nil { return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) } @@ -152,7 +154,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { // InitGenesis performs genesis initialization for the interchain accounts module. // It returns no validator updates. func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { - var genesisState types.GenesisState + var genesisState genesistypes.GenesisState cdc.MustUnmarshalJSON(data, &genesisState) if am.controllerKeeper != nil { @@ -169,8 +171,8 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json. // ExportGenesis returns the exported genesis state as raw bytes for the interchain accounts module func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { var ( - controllerGenesisState = types.DefaultControllerGenesis() - hostGenesisState = types.DefaultHostGenesis() + controllerGenesisState = genesistypes.DefaultControllerGenesis() + hostGenesisState = genesistypes.DefaultHostGenesis() ) if am.controllerKeeper != nil { @@ -181,7 +183,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw hostGenesisState = hostkeeper.ExportGenesis(ctx, *am.hostKeeper) } - gs := types.NewGenesisState(controllerGenesisState, hostGenesisState) + gs := genesistypes.NewGenesisState(controllerGenesisState, hostGenesisState) return cdc.MustMarshalJSON(gs) } diff --git a/modules/apps/27-interchain-accounts/types/codec.go b/modules/apps/27-interchain-accounts/types/codec.go index f2400d3d1b7..4c9fdea401d 100644 --- a/modules/apps/27-interchain-accounts/types/codec.go +++ b/modules/apps/27-interchain-accounts/types/codec.go @@ -6,8 +6,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - - controllertypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/controller/types" ) // ModuleCdc references the global interchain accounts module codec. Note, the codec @@ -20,8 +18,6 @@ var ModuleCdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry()) // RegisterInterfaces registers the interchain accounts controller types and the concrete InterchainAccount implementation // against the associated x/auth AccountI and GenesisAccount interfaces. func RegisterInterfaces(registry codectypes.InterfaceRegistry) { - controllertypes.RegisterInterfaces(registry) - registry.RegisterImplementations((*authtypes.AccountI)(nil), &InterchainAccount{}) registry.RegisterImplementations((*authtypes.GenesisAccount)(nil), &InterchainAccount{}) } diff --git a/proto/ibc/applications/interchain_accounts/v1/genesis.proto b/proto/ibc/applications/interchain_accounts/genesis/v1/genesis.proto similarity index 96% rename from proto/ibc/applications/interchain_accounts/v1/genesis.proto rename to proto/ibc/applications/interchain_accounts/genesis/v1/genesis.proto index 0687003195f..58870b8cd7c 100644 --- a/proto/ibc/applications/interchain_accounts/v1/genesis.proto +++ b/proto/ibc/applications/interchain_accounts/genesis/v1/genesis.proto @@ -1,8 +1,8 @@ syntax = "proto3"; -package ibc.applications.interchain_accounts.v1; +package ibc.applications.interchain_accounts.genesis.v1; -option go_package = "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/types"; +option go_package = "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/genesis/types"; import "gogoproto/gogo.proto"; import "ibc/applications/interchain_accounts/controller/v1/controller.proto";