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

Feat/ica proto #305

Merged
merged 4 commits into from
Jul 29, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
214 changes: 214 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)
- [QueryInterchainAccountRequest](#ibc.applications.interchain_accounts.v1.QueryInterchainAccountRequest)
- [QueryInterchainAccountResponse](#ibc.applications.interchain_accounts.v1.QueryInterchainAccountResponse)

- [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)
- [FungibleTokenPacketData](#ibc.applications.transfer.v1.FungibleTokenPacketData)
Expand Down Expand Up @@ -246,6 +265,201 @@



<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.QueryInterchainAccountRequest"></a>

### QueryInterchainAccountRequest
Query request for an interchain account address


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `address` | [string](#string) | | Address is the address to query. |
| `connection_id` | [string](#string) | | |






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

### QueryInterchainAccountResponse
Query response for an interchain account address


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `account_address` | [string](#string) | | Account defines the account of the corresponding address. |





<!-- 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 |
| ----------- | ------------ | ------------- | ------------| ------- | -------- |
| `InterchainAccount` | [QueryInterchainAccountRequest](#ibc.applications.interchain_accounts.v1.QueryInterchainAccountRequest) | [QueryInterchainAccountResponse](#ibc.applications.interchain_accounts.v1.QueryInterchainAccountResponse) | 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
6 changes: 3 additions & 3 deletions modules/apps/27-interchain-accounts/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ func GetQueryCmd() *cobra.Command {
RunE: client.ValidateCmd,
}

cmd.AddCommand(GetIBCAccountCmd())
cmd.AddCommand(GetInterchainAccountCmd())

return cmd
}

func GetIBCAccountCmd() *cobra.Command {
func GetInterchainAccountCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "address [address] [connection-id]",
RunE: func(cmd *cobra.Command, args []string) error {
Expand All @@ -37,7 +37,7 @@ func GetIBCAccountCmd() *cobra.Command {
connectionId := args[1]

queryClient := types.NewQueryClient(clientCtx)
res, err := queryClient.IBCAccount(context.Background(), &types.QueryIBCAccountRequest{Address: address, ConnectionId: connectionId})
res, err := queryClient.InterchainAccount(context.Background(), &types.QueryInterchainAccountRequest{Address: address, ConnectionId: connectionId})
if err != nil {
return err
}
Expand Down
16 changes: 8 additions & 8 deletions modules/apps/27-interchain-accounts/keeper/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ func (k Keeper) InitInterchainAccount(ctx sdk.Context, connectionId, owner strin
}

// Register interchain account if it has not already been created
func (k Keeper) RegisterInterchainAccount(ctx sdk.Context, portId string) (types.IBCAccountI, error) {
func (k Keeper) RegisterInterchainAccount(ctx sdk.Context, portId string) (types.InterchainAccountI, error) {
address := k.GenerateAddress(portId)
account := k.accountKeeper.GetAccount(ctx, address)

if account != nil {
return nil, sdkerrors.Wrap(types.ErrAccountAlreadyExist, account.String())
}

interchainAccount := types.NewIBCAccount(
interchainAccount := types.NewInterchainAccount(
authtypes.NewBaseAccountWithAddress(address),
portId,
)
Expand All @@ -71,7 +71,7 @@ func (k Keeper) GetInterchainAccountAddress(ctx sdk.Context, portId string) (str
store := ctx.KVStore(k.storeKey)
key := types.KeyOwnerAccount(portId)
if !store.Has(key) {
return "", sdkerrors.Wrap(types.ErrIBCAccountNotFound, portId)
return "", sdkerrors.Wrap(types.ErrInterchainAccountNotFound, portId)
}

interchainAccountAddr := string(store.Get(key))
Expand All @@ -83,15 +83,15 @@ func (k Keeper) GenerateAddress(identifier string) []byte {
return tmhash.SumTruncated(append([]byte(identifier)))
}

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

ibcAcc, ok := acc.(*types.IBCAccount)
interchainAccount, ok := acc.(*types.InterchainAccount)
if !ok {
return types.IBCAccount{}, sdkerrors.Wrap(types.ErrIBCAccountNotFound, "account is not an IBC account")
return types.InterchainAccount{}, sdkerrors.Wrap(types.ErrInterchainAccountNotFound, "account is not an interchain account")
}
return *ibcAcc, nil
return *interchainAccount, nil
}
6 changes: 3 additions & 3 deletions modules/apps/27-interchain-accounts/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (

var _ types.QueryServer = Keeper{}

// IBCAccount implements the Query/IBCAccount gRPC method
func (k Keeper) IBCAccount(ctx context.Context, req *types.QueryIBCAccountRequest) (*types.QueryIBCAccountResponse, error) {
// InterchainAccount implements the Query/InterchainAccount gRPC method
func (k Keeper) InterchainAccount(ctx context.Context, req *types.QueryInterchainAccountRequest) (*types.QueryInterchainAccountResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
}
Expand All @@ -31,5 +31,5 @@ func (k Keeper) IBCAccount(ctx context.Context, req *types.QueryIBCAccountReques
return nil, err
}

return &types.QueryIBCAccountResponse{AccountAddress: address}, nil
return &types.QueryInterchainAccountResponse{AccountAddress: address}, nil
}
4 changes: 2 additions & 2 deletions modules/apps/27-interchain-accounts/keeper/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (k Keeper) createOutgoingPacket(
}

packetData := types.IBCAccountPacketData{
Type: types.Type_RUNTX,
Type: types.EXECUTE_TX,
Data: txBytes,
}

Expand Down Expand Up @@ -206,7 +206,7 @@ func (k Keeper) OnRecvPacket(ctx sdk.Context, packet channeltypes.Packet) error
}

switch data.Type {
case types.Type_RUNTX:
case types.EXECUTE_TX:
msgs, err := k.DeserializeTx(ctx, data.Data)
if err != nil {
return err
Expand Down
Loading