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: unspecified type enum for interchain account packet data #487

Merged
merged 3 commits into from
Oct 13, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 4 additions & 4 deletions docs/ibc/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -435,13 +435,13 @@ InterchainAccountPacketData is comprised of a raw transaction, type of transacti
<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.
Type defines a classification of message issued from a controller chain to its associated interchain accounts
host

| Name | Number | Description |
| ---- | ------ | ----------- |
| TYPE_EXECUTE_TX_UNSPECIFIED | 0 | Execute message type |
| TYPE_UNSPECIFIED | 0 | Default zero value enumeration |
| TYPE_EXECUTE_TX | 1 | Execute a transaction on an interchain accounts host chain |


<!-- end enums -->
Expand Down
4 changes: 4 additions & 0 deletions modules/apps/27-interchain-accounts/types/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ const MaxMemoCharLength = 256
// ValidateBasic performs basic validation of the interchain account packet data.
// The memo may be empty.
func (iapd InterchainAccountPacketData) ValidateBasic() error {
if iapd.Type == UNSPECIFIED {
return sdkerrors.Wrap(ErrInvalidOutgoingData, "packet data type cannot be unspecified")
}

if iapd.Data == nil {
return sdkerrors.Wrap(ErrInvalidOutgoingData, "packet data cannot be empty")
}
Expand Down
9 changes: 9 additions & 0 deletions modules/apps/27-interchain-accounts/types/packet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ func (suite *TypesTestSuite) TestValidateBasic() {
},
true,
},
{
"type unspecified",
types.InterchainAccountPacketData{
Type: types.UNSPECIFIED,
Data: []byte("data"),
Memo: "memo",
},
false,
},
{
"empty data",
types.InterchainAccountPacketData{
Expand Down
70 changes: 37 additions & 33 deletions modules/apps/27-interchain-accounts/types/types.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 9 additions & 8 deletions proto/ibc/applications/interchain_accounts/v1/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,25 @@ import "google/protobuf/any.proto";
import "gogoproto/gogo.proto";
option go_package = "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types";

// 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.
// Type defines a classification of message issued from a controller chain to its associated interchain accounts
// host
enum Type {
option (gogoproto.goproto_enum_prefix) = false;
// Execute message type
TYPE_EXECUTE_TX_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "EXECUTE_TX"];

// Default zero value enumeration
TYPE_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "UNSPECIFIED"];
// Execute a transaction on an interchain accounts host chain
TYPE_EXECUTE_TX = 1 [(gogoproto.enumvalue_customname) = "EXECUTE_TX"];
}

// InterchainAccountPacketData is comprised of a raw transaction, type of transaction and optional memo field.
message InterchainAccountPacketData {
Type type = 1;
bytes data = 2;
Type type = 1;
bytes data = 2;
string memo = 3;
}

// CosmosTx contains a list of sdk.Msg's. It should be used when sending transactions to an SDK host chain.
message CosmosTx {
repeated google.protobuf.Any messages = 1;
}