Skip to content

Commit

Permalink
feat: add transfer ibc proto (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
flagrede committed Sep 12, 2022
1 parent 98fba87 commit 61c6cd2
Show file tree
Hide file tree
Showing 16 changed files with 6,425 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/api/proto/ibc/applications/transfer/v1/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
syntax = "proto3";

package ibc.applications.transfer.v1;

option go_package = "github.com/cosmos/ibc-go/v5/modules/apps/transfer/types";

import "ibc/applications/transfer/v1/transfer.proto";
import "gogoproto/gogo.proto";

// GenesisState defines the ibc-transfer genesis state
message GenesisState {
string port_id = 1 [(gogoproto.moretags) = "yaml:\"port_id\""];
repeated DenomTrace denom_traces = 2 [
(gogoproto.castrepeated) = "Traces",
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"denom_traces\""
];
Params params = 3 [(gogoproto.nullable) = false];
}
105 changes: 105 additions & 0 deletions packages/api/proto/ibc/applications/transfer/v1/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
syntax = "proto3";

package ibc.applications.transfer.v1;

import "gogoproto/gogo.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "ibc/applications/transfer/v1/transfer.proto";
import "google/api/annotations.proto";

option go_package = "github.com/cosmos/ibc-go/v5/modules/apps/transfer/types";

// Query provides defines the gRPC querier service.
service Query {
// DenomTrace queries a denomination trace information.
rpc DenomTrace(QueryDenomTraceRequest) returns (QueryDenomTraceResponse) {
option (google.api.http).get = "/ibc/apps/transfer/v1/denom_traces/{hash}";
}

// DenomTraces queries all denomination traces.
rpc DenomTraces(QueryDenomTracesRequest) returns (QueryDenomTracesResponse) {
option (google.api.http).get = "/ibc/apps/transfer/v1/denom_traces";
}

// Params queries all parameters of the ibc-transfer module.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/ibc/apps/transfer/v1/params";
}

// DenomHash queries a denomination hash information.
rpc DenomHash(QueryDenomHashRequest) returns (QueryDenomHashResponse) {
option (google.api.http).get = "/ibc/apps/transfer/v1/denom_hashes/{trace}";
}

// EscrowAddress returns the escrow address for a particular port and channel id.
rpc EscrowAddress(QueryEscrowAddressRequest) returns (QueryEscrowAddressResponse) {
option (google.api.http).get = "/ibc/apps/transfer/v1/channels/{channel_id}/ports/{port_id}/escrow_address";
}
}

// QueryDenomTraceRequest is the request type for the Query/DenomTrace RPC
// method
message QueryDenomTraceRequest {
// hash (in hex format) or denom (full denom with ibc prefix) of the denomination trace information.
string hash = 1;
}

// QueryDenomTraceResponse is the response type for the Query/DenomTrace RPC
// method.
message QueryDenomTraceResponse {
// denom_trace returns the requested denomination trace information.
DenomTrace denom_trace = 1;
}

// QueryConnectionsRequest is the request type for the Query/DenomTraces RPC
// method
message QueryDenomTracesRequest {
// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}

// QueryConnectionsResponse is the response type for the Query/DenomTraces RPC
// method.
message QueryDenomTracesResponse {
// denom_traces returns all denominations trace information.
repeated DenomTrace denom_traces = 1 [(gogoproto.castrepeated) = "Traces", (gogoproto.nullable) = false];
// pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

// QueryParamsRequest is the request type for the Query/Params RPC method.
message QueryParamsRequest {}

// QueryParamsResponse is the response type for the Query/Params RPC method.
message QueryParamsResponse {
// params defines the parameters of the module.
Params params = 1;
}

// QueryDenomHashRequest is the request type for the Query/DenomHash RPC
// method
message QueryDenomHashRequest {
// The denomination trace ([port_id]/[channel_id])+/[denom]
string trace = 1;
}

// QueryDenomHashResponse is the response type for the Query/DenomHash RPC
// method.
message QueryDenomHashResponse {
// hash (in hex format) of the denomination trace information.
string hash = 1;
}

// QueryEscrowAddressRequest is the request type for the EscrowAddress RPC method.
message QueryEscrowAddressRequest {
// unique port identifier
string port_id = 1;
// unique channel identifier
string channel_id = 2;
}

// QueryEscrowAddressResponse is the response type of the EscrowAddress RPC method.
message QueryEscrowAddressResponse {
// the escrow account address
string escrow_address = 1;
}
30 changes: 30 additions & 0 deletions packages/api/proto/ibc/applications/transfer/v1/transfer.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
syntax = "proto3";

package ibc.applications.transfer.v1;

option go_package = "github.com/cosmos/ibc-go/v5/modules/apps/transfer/types";

import "gogoproto/gogo.proto";

// DenomTrace contains the base denomination for ICS20 fungible tokens and the
// source tracing information path.
message DenomTrace {
// path defines the chain of port/channel identifiers used for tracing the
// source of the fungible token.
string path = 1;
// base denomination of the relayed fungible token.
string base_denom = 2;
}

// Params defines the set of IBC transfer parameters.
// NOTE: To prevent a single token from being transferred, set the
// TransfersEnabled parameter to true and then set the bank module's SendEnabled
// parameter for the denomination to false.
message Params {
// send_enabled enables or disables all cross-chain token transfers from this
// chain.
bool send_enabled = 1 [(gogoproto.moretags) = "yaml:\"send_enabled\""];
// receive_enabled enables or disables all cross-chain token transfers to this
// chain.
bool receive_enabled = 2 [(gogoproto.moretags) = "yaml:\"receive_enabled\""];
}
44 changes: 44 additions & 0 deletions packages/api/proto/ibc/applications/transfer/v1/tx.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
syntax = "proto3";

package ibc.applications.transfer.v1;

option go_package = "github.com/cosmos/ibc-go/v5/modules/apps/transfer/types";

import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";
import "ibc/core/client/v1/client.proto";

// Msg defines the ibc/transfer Msg service.
service Msg {
// Transfer defines a rpc handler method for MsgTransfer.
rpc Transfer(MsgTransfer) returns (MsgTransferResponse);
}

// MsgTransfer defines a msg to transfer fungible tokens (i.e Coins) between
// ICS20 enabled chains. See ICS Spec here:
// https://github.com/cosmos/ibc/tree/master/spec/app/ics-020-fungible-token-transfer#data-structures
message MsgTransfer {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

// the port on which the packet will be sent
string source_port = 1 [(gogoproto.moretags) = "yaml:\"source_port\""];
// the channel by which the packet will be sent
string source_channel = 2 [(gogoproto.moretags) = "yaml:\"source_channel\""];
// the tokens to be transferred
cosmos.base.v1beta1.Coin token = 3 [(gogoproto.nullable) = false];
// the sender address
string sender = 4;
// the recipient address on the destination chain
string receiver = 5;
// Timeout height relative to the current block height.
// The timeout is disabled when set to 0.
ibc.core.client.v1.Height timeout_height = 6
[(gogoproto.moretags) = "yaml:\"timeout_height\"", (gogoproto.nullable) = false];
// Timeout timestamp in absolute nanoseconds since unix epoch.
// The timeout is disabled when set to 0.
uint64 timeout_timestamp = 7 [(gogoproto.moretags) = "yaml:\"timeout_timestamp\""];
}

// MsgTransferResponse defines the Msg/Transfer response type.
message MsgTransferResponse {}
103 changes: 103 additions & 0 deletions packages/api/proto/ibc/core/client/v1/client.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
syntax = "proto3";

package ibc.core.client.v1;

option go_package = "github.com/cosmos/ibc-go/v5/modules/core/02-client/types";

import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";
import "cosmos/upgrade/v1beta1/upgrade.proto";
import "cosmos_proto/cosmos.proto";

// IdentifiedClientState defines a client state with an additional client
// identifier field.
message IdentifiedClientState {
// client identifier
string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""];
// client state
google.protobuf.Any client_state = 2 [(gogoproto.moretags) = "yaml:\"client_state\""];
}

// ConsensusStateWithHeight defines a consensus state with an additional height
// field.
message ConsensusStateWithHeight {
// consensus state height
Height height = 1 [(gogoproto.nullable) = false];
// consensus state
google.protobuf.Any consensus_state = 2 [(gogoproto.moretags) = "yaml:\"consensus_state\""];
}

// ClientConsensusStates defines all the stored consensus states for a given
// client.
message ClientConsensusStates {
// client identifier
string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""];
// consensus states and their heights associated with the client
repeated ConsensusStateWithHeight consensus_states = 2
[(gogoproto.moretags) = "yaml:\"consensus_states\"", (gogoproto.nullable) = false];
}

// ClientUpdateProposal is a governance proposal. If it passes, the substitute
// client's latest consensus state is copied over to the subject client. The proposal
// handler may fail if the subject and the substitute do not match in client and
// chain parameters (with exception to latest height, frozen height, and chain-id).
message ClientUpdateProposal {
option (gogoproto.goproto_getters) = false;
option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content";
// the title of the update proposal
string title = 1;
// the description of the proposal
string description = 2;
// the client identifier for the client to be updated if the proposal passes
string subject_client_id = 3 [(gogoproto.moretags) = "yaml:\"subject_client_id\""];
// the substitute client identifier for the client standing in for the subject
// client
string substitute_client_id = 4 [(gogoproto.moretags) = "yaml:\"substitute_client_id\""];
}

// UpgradeProposal is a gov Content type for initiating an IBC breaking
// upgrade.
message UpgradeProposal {
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;
option (gogoproto.equal) = true;
option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content";

string title = 1;
string description = 2;
cosmos.upgrade.v1beta1.Plan plan = 3 [(gogoproto.nullable) = false];

// An UpgradedClientState must be provided to perform an IBC breaking upgrade.
// This will make the chain commit to the correct upgraded (self) client state
// before the upgrade occurs, so that connecting chains can verify that the
// new upgraded client is valid by verifying a proof on the previous version
// of the chain. This will allow IBC connections to persist smoothly across
// planned chain upgrades
google.protobuf.Any upgraded_client_state = 4 [(gogoproto.moretags) = "yaml:\"upgraded_client_state\""];
}

// Height is a monotonically increasing data type
// that can be compared against another Height for the purposes of updating and
// freezing clients
//
// Normally the RevisionHeight is incremented at each height while keeping
// RevisionNumber the same. However some consensus algorithms may choose to
// reset the height in certain conditions e.g. hard forks, state-machine
// breaking changes In these cases, the RevisionNumber is incremented so that
// height continues to be monitonically increasing even as the RevisionHeight
// gets reset
message Height {
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;

// the revision that the client is currently on
uint64 revision_number = 1 [(gogoproto.moretags) = "yaml:\"revision_number\""];
// the height within the given revision
uint64 revision_height = 2 [(gogoproto.moretags) = "yaml:\"revision_height\""];
}

// Params defines the set of IBC light client parameters.
message Params {
// allowed_clients defines the list of allowed client state types.
repeated string allowed_clients = 1 [(gogoproto.moretags) = "yaml:\"allowed_clients\""];
}
48 changes: 48 additions & 0 deletions packages/api/proto/ibc/core/client/v1/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
syntax = "proto3";

package ibc.core.client.v1;

option go_package = "github.com/cosmos/ibc-go/v5/modules/core/02-client/types";

import "ibc/core/client/v1/client.proto";
import "gogoproto/gogo.proto";

// GenesisState defines the ibc client submodule's genesis state.
message GenesisState {
// client states with their corresponding identifiers
repeated IdentifiedClientState clients = 1
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "IdentifiedClientStates"];
// consensus states from each client
repeated ClientConsensusStates clients_consensus = 2 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "ClientsConsensusStates",
(gogoproto.moretags) = "yaml:\"clients_consensus\""
];
// metadata from each client
repeated IdentifiedGenesisMetadata clients_metadata = 3
[(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"clients_metadata\""];
Params params = 4 [(gogoproto.nullable) = false];
// create localhost on initialization
bool create_localhost = 5 [(gogoproto.moretags) = "yaml:\"create_localhost\""];
// the sequence for the next generated client identifier
uint64 next_client_sequence = 6 [(gogoproto.moretags) = "yaml:\"next_client_sequence\""];
}

// GenesisMetadata defines the genesis type for metadata that clients may return
// with ExportMetadata
message GenesisMetadata {
option (gogoproto.goproto_getters) = false;

// store key of metadata without clientID-prefix
bytes key = 1;
// metadata value
bytes value = 2;
}

// IdentifiedGenesisMetadata has the client metadata with the corresponding
// client id.
message IdentifiedGenesisMetadata {
string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""];
repeated GenesisMetadata client_metadata = 2
[(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"client_metadata\""];
}
Loading

0 comments on commit 61c6cd2

Please sign in to comment.