syntax = "proto3";

package ibc.core.channel.v1;

option go_package = "github.com/cosmos/ibc-go/v10/modules/core/04-channel/types";

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

// Msg defines the ibc/channel Msg service.
service Msg {
  option (cosmos.msg.v1.service) = true;

  // ChannelOpenInit defines a rpc handler method for MsgChannelOpenInit.
  rpc ChannelOpenInit(MsgChannelOpenInit) returns (MsgChannelOpenInitResponse);

  // ChannelOpenTry defines a rpc handler method for MsgChannelOpenTry.
  rpc ChannelOpenTry(MsgChannelOpenTry) returns (MsgChannelOpenTryResponse);

  // ChannelOpenAck defines a rpc handler method for MsgChannelOpenAck.
  rpc ChannelOpenAck(MsgChannelOpenAck) returns (MsgChannelOpenAckResponse);

  // ChannelOpenConfirm defines a rpc handler method for MsgChannelOpenConfirm.
  rpc ChannelOpenConfirm(MsgChannelOpenConfirm) returns (MsgChannelOpenConfirmResponse);

  // ChannelCloseInit defines a rpc handler method for MsgChannelCloseInit.
  rpc ChannelCloseInit(MsgChannelCloseInit) returns (MsgChannelCloseInitResponse);

  // ChannelCloseConfirm defines a rpc handler method for
  // MsgChannelCloseConfirm.
  rpc ChannelCloseConfirm(MsgChannelCloseConfirm) returns (MsgChannelCloseConfirmResponse);

  // RecvPacket defines a rpc handler method for MsgRecvPacket.
  rpc RecvPacket(MsgRecvPacket) returns (MsgRecvPacketResponse);

  // Timeout defines a rpc handler method for MsgTimeout.
  rpc Timeout(MsgTimeout) returns (MsgTimeoutResponse);

  // TimeoutOnClose defines a rpc handler method for MsgTimeoutOnClose.
  rpc TimeoutOnClose(MsgTimeoutOnClose) returns (MsgTimeoutOnCloseResponse);

  // Acknowledgement defines a rpc handler method for MsgAcknowledgement.
  rpc Acknowledgement(MsgAcknowledgement) returns (MsgAcknowledgementResponse);
}

// ResponseResultType defines the possible outcomes of the execution of a message
enum ResponseResultType {
  option (gogoproto.goproto_enum_prefix) = false;

  // Default zero value enumeration
  RESPONSE_RESULT_TYPE_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "UNSPECIFIED"];
  // The message did not call the IBC application callbacks (because, for example, the packet had already been relayed)
  RESPONSE_RESULT_TYPE_NOOP = 1 [(gogoproto.enumvalue_customname) = "NOOP"];
  // The message was executed successfully
  RESPONSE_RESULT_TYPE_SUCCESS = 2 [(gogoproto.enumvalue_customname) = "SUCCESS"];
  // The message was executed unsuccessfully
  RESPONSE_RESULT_TYPE_FAILURE = 3 [(gogoproto.enumvalue_customname) = "FAILURE"];
}

// MsgChannelOpenInit defines an sdk.Msg to initialize a channel handshake. It
// is called by a relayer on Chain A.
message MsgChannelOpenInit {
  option (cosmos.msg.v1.signer) = "signer";

  option (gogoproto.goproto_getters) = false;

  string  port_id = 1;
  Channel channel = 2 [(gogoproto.nullable) = false];
  string  signer  = 3;
}

// MsgChannelOpenInitResponse defines the Msg/ChannelOpenInit response type.
message MsgChannelOpenInitResponse {
  option (gogoproto.goproto_getters) = false;

  string channel_id = 1;
  string version    = 2;
}

// MsgChannelOpenInit defines a msg sent by a Relayer to try to open a channel
// on Chain B. The version field within the Channel field has been deprecated. Its
// value will be ignored by core IBC.
message MsgChannelOpenTry {
  option (cosmos.msg.v1.signer) = "signer";

  option (gogoproto.goproto_getters) = false;

  string port_id = 1;
  // Deprecated: this field is unused. Crossing hello's are no longer supported in core IBC.
  string previous_channel_id = 2 [deprecated = true];
  // NOTE: the version field within the channel has been deprecated. Its value will be ignored by core IBC.
  Channel                   channel              = 3 [(gogoproto.nullable) = false];
  string                    counterparty_version = 4;
  bytes                     proof_init           = 5;
  ibc.core.client.v1.Height proof_height         = 6 [(gogoproto.nullable) = false];
  string                    signer               = 7;
}

// MsgChannelOpenTryResponse defines the Msg/ChannelOpenTry response type.
message MsgChannelOpenTryResponse {
  option (gogoproto.goproto_getters) = false;

  string version    = 1;
  string channel_id = 2;
}

// MsgChannelOpenAck defines a msg sent by a Relayer to Chain A to acknowledge
// the change of channel state to TRYOPEN on Chain B.
message MsgChannelOpenAck {
  option (cosmos.msg.v1.signer) = "signer";

  option (gogoproto.goproto_getters) = false;

  string                    port_id                 = 1;
  string                    channel_id              = 2;
  string                    counterparty_channel_id = 3;
  string                    counterparty_version    = 4;
  bytes                     proof_try               = 5;
  ibc.core.client.v1.Height proof_height            = 6 [(gogoproto.nullable) = false];
  string                    signer                  = 7;
}

// MsgChannelOpenAckResponse defines the Msg/ChannelOpenAck response type.
message MsgChannelOpenAckResponse {}

// MsgChannelOpenConfirm defines a msg sent by a Relayer to Chain B to
// acknowledge the change of channel state to OPEN on Chain A.
message MsgChannelOpenConfirm {
  option (cosmos.msg.v1.signer) = "signer";

  option (gogoproto.goproto_getters) = false;

  string                    port_id      = 1;
  string                    channel_id   = 2;
  bytes                     proof_ack    = 3;
  ibc.core.client.v1.Height proof_height = 4 [(gogoproto.nullable) = false];
  string                    signer       = 5;
}

// MsgChannelOpenConfirmResponse defines the Msg/ChannelOpenConfirm response
// type.
message MsgChannelOpenConfirmResponse {}

// MsgChannelCloseInit defines a msg sent by a Relayer to Chain A
// to close a channel with Chain B.
message MsgChannelCloseInit {
  option (cosmos.msg.v1.signer) = "signer";

  option (gogoproto.goproto_getters) = false;

  string port_id    = 1;
  string channel_id = 2;
  string signer     = 3;
}

// MsgChannelCloseInitResponse defines the Msg/ChannelCloseInit response type.
message MsgChannelCloseInitResponse {}

// MsgChannelCloseConfirm defines a msg sent by a Relayer to Chain B
// to acknowledge the change of channel state to CLOSED on Chain A.
message MsgChannelCloseConfirm {
  option (cosmos.msg.v1.signer) = "signer";

  option (gogoproto.goproto_getters) = false;

  string                    port_id      = 1;
  string                    channel_id   = 2;
  bytes                     proof_init   = 3;
  ibc.core.client.v1.Height proof_height = 4 [(gogoproto.nullable) = false];
  string                    signer       = 5;
}

// MsgChannelCloseConfirmResponse defines the Msg/ChannelCloseConfirm response
// type.
message MsgChannelCloseConfirmResponse {}

// MsgRecvPacket receives incoming IBC packet
message MsgRecvPacket {
  option (cosmos.msg.v1.signer) = "signer";

  option (gogoproto.goproto_getters) = false;

  Packet                    packet           = 1 [(gogoproto.nullable) = false];
  bytes                     proof_commitment = 2;
  ibc.core.client.v1.Height proof_height     = 3 [(gogoproto.nullable) = false];
  string                    signer           = 4;
}

// MsgRecvPacketResponse defines the Msg/RecvPacket response type.
message MsgRecvPacketResponse {
  option (gogoproto.goproto_getters) = false;

  ResponseResultType result = 1;
}

// MsgTimeout receives timed-out packet
message MsgTimeout {
  option (cosmos.msg.v1.signer) = "signer";

  option (gogoproto.goproto_getters) = false;

  Packet                    packet             = 1 [(gogoproto.nullable) = false];
  bytes                     proof_unreceived   = 2;
  ibc.core.client.v1.Height proof_height       = 3 [(gogoproto.nullable) = false];
  uint64                    next_sequence_recv = 4;
  string                    signer             = 5;
}

// MsgTimeoutResponse defines the Msg/Timeout response type.
message MsgTimeoutResponse {
  option (gogoproto.goproto_getters) = false;

  ResponseResultType result = 1;
}

// MsgTimeoutOnClose timed-out packet upon counterparty channel closure.
message MsgTimeoutOnClose {
  option (cosmos.msg.v1.signer) = "signer";

  option (gogoproto.goproto_getters) = false;

  Packet                    packet             = 1 [(gogoproto.nullable) = false];
  bytes                     proof_unreceived   = 2;
  bytes                     proof_close        = 3;
  ibc.core.client.v1.Height proof_height       = 4 [(gogoproto.nullable) = false];
  uint64                    next_sequence_recv = 5;
  string                    signer             = 6;
}

// MsgTimeoutOnCloseResponse defines the Msg/TimeoutOnClose response type.
message MsgTimeoutOnCloseResponse {
  option (gogoproto.goproto_getters) = false;

  ResponseResultType result = 1;
}

// MsgAcknowledgement receives incoming IBC acknowledgement
message MsgAcknowledgement {
  option (cosmos.msg.v1.signer) = "signer";

  option (gogoproto.goproto_getters) = false;

  Packet                    packet          = 1 [(gogoproto.nullable) = false];
  bytes                     acknowledgement = 2;
  bytes                     proof_acked     = 3;
  ibc.core.client.v1.Height proof_height    = 4 [(gogoproto.nullable) = false];
  string                    signer          = 5;
}

// MsgAcknowledgementResponse defines the Msg/Acknowledgement response type.
message MsgAcknowledgementResponse {
  option (gogoproto.goproto_getters) = false;

  ResponseResultType result = 1;
}
