Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ica: fix imports from merging main #436

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f6303dd
migrate ibc-account module to ibc-go
colin-axner Jul 15, 2021
c27653a
Add @seantking to CODEOWNERS for interchain accounts module
colin-axner Jul 15, 2021
0148576
rename ibc-account -> interchain-accounts (#280)
colin-axner Jul 21, 2021
b870be4
Integrate ICA into testing package, add simple keeper tests (#282)
colin-axner Jul 22, 2021
c3be169
Add interchain account OnChanOpenInit and InitInterchainAccount tests…
colin-axner Jul 23, 2021
a9cdf5a
feat: ica proto (#305)
seantking Jul 29, 2021
2a160ed
ICA OnChanOpenTry update + tests (#299)
colin-axner Aug 5, 2021
38ebbff
test: adding test for OnChanOpenConfirm (#312)
seantking Aug 5, 2021
881276f
fix: updating port-id & fixing OnChanOpenInit bug (#321)
seantking Aug 9, 2021
9d3f02c
Add counterparty port ID to controller portID (#319)
colin-axner Aug 9, 2021
b4d82a2
test: check active channel is correct (#324)
seantking Aug 13, 2021
8acf6e6
Removed memkey from ICA keeper (#342)
lukerhoads Aug 24, 2021
1bf7930
moving stateless GenerateAddress func to types (#352)
damiannolan Aug 27, 2021
599ad7f
update ica branch codeowners (#353)
colin-axner Aug 27, 2021
0174855
move Get/SetInterchainAccount to keeper.go, add tests (#355)
damiannolan Aug 30, 2021
01bb9bf
chore: interchain accounts cleanup, cli alias (#362)
damiannolan Aug 31, 2021
2a3e526
updating interchain accounts pkg naming (#364)
damiannolan Sep 1, 2021
74fb34e
adding ica grpc query tests (#368)
damiannolan Sep 2, 2021
d37f2ec
updating grpc query tests, removing queryClient on KeeperTestSuite (#…
damiannolan Sep 6, 2021
e8d0dde
ICA: Adding tests for relay.go (#337)
seantking Sep 13, 2021
e0cef86
Update ICA on main + add app version negotiation stub (#403)
seantking Sep 14, 2021
b5ad323
Merge branch 'main' into interchain-accounts
seantking Sep 15, 2021
7c7bf8e
Merge pull request #407 from cosmos/sean/chore-merge-conflicts-ica
seantking Sep 15, 2021
3517def
fix err message (#419)
colin-axner Sep 20, 2021
e7cf4d3
feat: ica app version negotiation (#410)
damiannolan Sep 20, 2021
e64fb25
test: adding tests for OnRecvPacket (#412)
seantking Sep 23, 2021
bf9f20a
Merge branch 'main' into interchain-accounts
colin-axner Sep 23, 2021
c701619
fix imports
colin-axner Sep 23, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
213 changes: 213 additions & 0 deletions docs/ibc/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@

## Table of Contents

- [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)
- [GenesisState](#ibc.applications.interchain_accounts.v1.GenesisState)

- [ibc/applications/interchain_accounts/v1/query.proto](#ibc/applications/interchain_accounts/v1/query.proto)
- [QueryInterchainAccountAddressRequest](#ibc.applications.interchain_accounts.v1.QueryInterchainAccountAddressRequest)
- [QueryInterchainAccountAddressResponse](#ibc.applications.interchain_accounts.v1.QueryInterchainAccountAddressResponse)

- [Query](#ibc.applications.interchain_accounts.v1.Query)

- [ibc/applications/interchain_accounts/v1/types.proto](#ibc/applications/interchain_accounts/v1/types.proto)
- [IBCAccountPacketData](#ibc.applications.interchain_accounts.v1.IBCAccountPacketData)
- [IBCTxBody](#ibc.applications.interchain_accounts.v1.IBCTxBody)
- [IBCTxRaw](#ibc.applications.interchain_accounts.v1.IBCTxRaw)

- [Type](#ibc.applications.interchain_accounts.v1.Type)

- [ibc/applications/transfer/v1/transfer.proto](#ibc/applications/transfer/v1/transfer.proto)
- [DenomTrace](#ibc.applications.transfer.v1.DenomTrace)
- [Params](#ibc.applications.transfer.v1.Params)
Expand Down Expand Up @@ -254,6 +273,200 @@



<a name="ibc/applications/interchain_accounts/v1/account.proto"></a>
<p align="right"><a href="#top">Top</a></p>

## ibc/applications/interchain_accounts/v1/account.proto



<a name="ibc.applications.interchain_accounts.v1.InterchainAccount"></a>

### InterchainAccount
An InterchainAccount is defined as a BaseAccount & the address of the account owner on the controller chain


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `base_account` | [cosmos.auth.v1beta1.BaseAccount](#cosmos.auth.v1beta1.BaseAccount) | | |
| `account_owner` | [string](#string) | | |





<!-- end messages -->

<!-- end enums -->

<!-- end HasExtensions -->

<!-- end services -->



<a name="ibc/applications/interchain_accounts/v1/genesis.proto"></a>
<p align="right"><a href="#top">Top</a></p>

## ibc/applications/interchain_accounts/v1/genesis.proto



<a name="ibc.applications.interchain_accounts.v1.GenesisState"></a>

### GenesisState
GenesisState defines the interchain_account genesis state


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `port_id` | [string](#string) | | |





<!-- end messages -->

<!-- end enums -->

<!-- end HasExtensions -->

<!-- end services -->



<a name="ibc/applications/interchain_accounts/v1/query.proto"></a>
<p align="right"><a href="#top">Top</a></p>

## ibc/applications/interchain_accounts/v1/query.proto



<a name="ibc.applications.interchain_accounts.v1.QueryInterchainAccountAddressRequest"></a>

### QueryInterchainAccountAddressRequest
Query request for an interchain account address


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `counterparty_port_id` | [string](#string) | | Counterparty PortID is the portID on the controller chain |






<a name="ibc.applications.interchain_accounts.v1.QueryInterchainAccountAddressResponse"></a>

### QueryInterchainAccountAddressResponse
Query response for an interchain account address


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `interchain_account_address` | [string](#string) | | The corresponding interchain account address on the host chain |





<!-- end messages -->

<!-- end enums -->

<!-- end HasExtensions -->


<a name="ibc.applications.interchain_accounts.v1.Query"></a>

### Query
Query defines the gRPC querier service.

| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint |
| ----------- | ------------ | ------------- | ------------| ------- | -------- |
| `InterchainAccountAddress` | [QueryInterchainAccountAddressRequest](#ibc.applications.interchain_accounts.v1.QueryInterchainAccountAddressRequest) | [QueryInterchainAccountAddressResponse](#ibc.applications.interchain_accounts.v1.QueryInterchainAccountAddressResponse) | Query to get the address of an interchain account | |

<!-- end services -->



<a name="ibc/applications/interchain_accounts/v1/types.proto"></a>
<p align="right"><a href="#top">Top</a></p>

## ibc/applications/interchain_accounts/v1/types.proto



<a name="ibc.applications.interchain_accounts.v1.IBCAccountPacketData"></a>

### IBCAccountPacketData
Packet data is comprised of raw transaction & type of transaction


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `type` | [Type](#ibc.applications.interchain_accounts.v1.Type) | | |
| `data` | [bytes](#bytes) | | |






<a name="ibc.applications.interchain_accounts.v1.IBCTxBody"></a>

### IBCTxBody
Body of a tx for an ics27 IBC packet


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `messages` | [google.protobuf.Any](#google.protobuf.Any) | repeated | |






<a name="ibc.applications.interchain_accounts.v1.IBCTxRaw"></a>

### IBCTxRaw
Raw tx body


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `body_bytes` | [bytes](#bytes) | | |





<!-- end messages -->


<a name="ibc.applications.interchain_accounts.v1.Type"></a>

### Type
The different types of interchain account transactions
EXECUTE_TX is used when sending a TX from the controller side to the host side. The host side will execute the tx on
behalf of the interchain account.

| Name | Number | Description |
| ---- | ------ | ----------- |
| TYPE_EXECUTE_TX_UNSPECIFIED | 0 | Execute message type |


<!-- end enums -->

<!-- end HasExtensions -->

<!-- end services -->



<a name="ibc/applications/transfer/v1/transfer.proto"></a>
<p align="right"><a href="#top">Top</a></p>

Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ require (
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/pkg/errors v0.9.1
github.com/rakyll/statik v0.1.7
github.com/regen-network/cosmos-proto v0.3.1
github.com/spf13/cast v1.4.1
github.com/spf13/cobra v1.2.1
github.com/spf13/viper v1.9.0
Expand All @@ -23,4 +24,5 @@ require (
google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71
google.golang.org/grpc v1.40.0
google.golang.org/protobuf v1.27.1
gopkg.in/yaml.v2 v2.4.0
)
52 changes: 52 additions & 0 deletions modules/apps/27-interchain-accounts/client/cli/query.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package cli

import (
"context"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/spf13/cobra"

"github.com/cosmos/ibc-go/modules/apps/27-interchain-accounts/types"
)

func GetQueryCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "interchain-accounts",
Aliases: []string{"ica"},
Short: "Querying commands for the interchain accounts module",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}

cmd.AddCommand(GetInterchainAccountCmd())

return cmd
}

func GetInterchainAccountCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "address [counterparty-port-id]",
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

counterpartyPortID := args[0]

queryClient := types.NewQueryClient(clientCtx)
res, err := queryClient.InterchainAccountAddress(context.Background(), &types.QueryInterchainAccountAddressRequest{CounterpartyPortId: counterpartyPortID})
if err != nil {
return err
}

return clientCtx.PrintProto(res)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}
30 changes: 30 additions & 0 deletions modules/apps/27-interchain-accounts/genesis.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package interchain_accounts

import (
"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/ibc-go/modules/apps/27-interchain-accounts/keeper"
"github.com/cosmos/ibc-go/modules/apps/27-interchain-accounts/types"

host "github.com/cosmos/ibc-go/modules/core/24-host"
)

// InitGenesis initializes the interchain accounts application state from a provided genesis state
func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, state types.GenesisState) {
if !keeper.IsBound(ctx, state.PortId) {
cap := keeper.BindPort(ctx, state.PortId)
if err := keeper.ClaimCapability(ctx, cap, host.PortPath(state.PortId)); err != nil {
panic(fmt.Sprintf("could not claim port capability: %v", err))
}
}
}

// ExportGenesis exports transfer module's portID into its geneis state
func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) *types.GenesisState {
portID := keeper.GetPort(ctx)

return &types.GenesisState{
PortId: portID,
}
}
71 changes: 71 additions & 0 deletions modules/apps/27-interchain-accounts/keeper/account.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package keeper

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"

"github.com/cosmos/ibc-go/modules/apps/27-interchain-accounts/types"
channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types"
host "github.com/cosmos/ibc-go/modules/core/24-host"
)

// InitInterchainAccount is the entry point to registering an interchain account.
// It generates a new port identifier using the owner address, connection identifier,
// and counterparty connection identifier. It will bind to the port identifier and
// call 04-channel 'ChanOpenInit'. An error is returned if the port identifier is
// 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)
if err != nil {
return err
}

if k.IsBound(ctx, portID) {
return sdkerrors.Wrap(types.ErrPortAlreadyBound, portID)
}

cap := k.BindPort(ctx, portID)
if err := k.ClaimCapability(ctx, cap, host.PortPath(portID)); err != nil {
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)
handler := k.msgRouter.Handler(msg)
if _, err := handler(ctx, msg); err != nil {
return err
}

return nil
}

// RegisterInterchainAccount attempts to create a new account using the provided address and stores it in state keyed by the provided port identifier
// If an account for the provided address already exists this function returns early (no-op)
func (k Keeper) RegisterInterchainAccount(ctx sdk.Context, accAddr sdk.AccAddress, portID string) {
if acc := k.accountKeeper.GetAccount(ctx, accAddr); acc != nil {
return
}

interchainAccount := types.NewInterchainAccount(
authtypes.NewBaseAccountWithAddress(accAddr),
portID,
)

k.accountKeeper.NewAccount(ctx, interchainAccount)
k.accountKeeper.SetAccount(ctx, interchainAccount)
k.SetInterchainAccountAddress(ctx, portID, interchainAccount.Address)
}

func (k Keeper) GetInterchainAccount(ctx sdk.Context, addr sdk.AccAddress) (types.InterchainAccount, error) {
acc := k.accountKeeper.GetAccount(ctx, addr)
if acc == nil {
return types.InterchainAccount{}, sdkerrors.Wrap(types.ErrInterchainAccountNotFound, "there is no account")
}

interchainAccount, ok := acc.(*types.InterchainAccount)
if !ok {
return types.InterchainAccount{}, sdkerrors.Wrap(types.ErrInterchainAccountNotFound, "account is not an interchain account")
}
return *interchainAccount, nil
}
Loading