syntax = "proto3";

package ibc.core.channel.v1;

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

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

// Msg defines the ibc/channel Msg service.
service Msg {
  // 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_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_NOOP = 1 [(gogoproto.enumvalue_customname) = "NOOP"];
  // The message was executed successfully
  RESPONSE_RESULT_SUCCESS = 2 [(gogoproto.enumvalue_customname) = "SUCCESS"];
}

// MsgChannelOpenInit defines an sdk.Msg to initialize a channel handshake. It
// is called by a relayer on Chain A.
message MsgChannelOpenInit {
  option (gogoproto.equal)           = false;
  option (gogoproto.goproto_getters) = false;

  string  port_id = 1 [(gogoproto.moretags) = "yaml:\"port_id\""];
  Channel channel = 2 [(gogoproto.nullable) = false];
  string  signer  = 3;
}

// MsgChannelOpenInitResponse defines the Msg/ChannelOpenInit response type.
message MsgChannelOpenInitResponse {
  string channel_id = 1 [(gogoproto.moretags) = "yaml:\"channel_id\""];
}

// 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 (gogoproto.equal)           = false;
  option (gogoproto.goproto_getters) = false;

  string port_id = 1 [(gogoproto.moretags) = "yaml:\"port_id\""];
  // in the case of crossing hello's, when both chains call OpenInit, we need
  // the channel identifier of the previous channel in state INIT
  string previous_channel_id = 2 [(gogoproto.moretags) = "yaml:\"previous_channel_id\""];
  // 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 [(gogoproto.moretags) = "yaml:\"counterparty_version\""];
  bytes                     proof_init           = 5 [(gogoproto.moretags) = "yaml:\"proof_init\""];
  ibc.core.client.v1.Height proof_height         = 6
      [(gogoproto.moretags) = "yaml:\"proof_height\"", (gogoproto.nullable) = false];
  string signer = 7;
}

// MsgChannelOpenTryResponse defines the Msg/ChannelOpenTry response type.
message MsgChannelOpenTryResponse {}

// 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 (gogoproto.equal)           = false;
  option (gogoproto.goproto_getters) = false;

  string                    port_id                 = 1 [(gogoproto.moretags) = "yaml:\"port_id\""];
  string                    channel_id              = 2 [(gogoproto.moretags) = "yaml:\"channel_id\""];
  string                    counterparty_channel_id = 3 [(gogoproto.moretags) = "yaml:\"counterparty_channel_id\""];
  string                    counterparty_version    = 4 [(gogoproto.moretags) = "yaml:\"counterparty_version\""];
  bytes                     proof_try               = 5 [(gogoproto.moretags) = "yaml:\"proof_try\""];
  ibc.core.client.v1.Height proof_height            = 6
      [(gogoproto.moretags) = "yaml:\"proof_height\"", (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 (gogoproto.equal)           = false;
  option (gogoproto.goproto_getters) = false;

  string                    port_id      = 1 [(gogoproto.moretags) = "yaml:\"port_id\""];
  string                    channel_id   = 2 [(gogoproto.moretags) = "yaml:\"channel_id\""];
  bytes                     proof_ack    = 3 [(gogoproto.moretags) = "yaml:\"proof_ack\""];
  ibc.core.client.v1.Height proof_height = 4
      [(gogoproto.moretags) = "yaml:\"proof_height\"", (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 (gogoproto.equal)           = false;
  option (gogoproto.goproto_getters) = false;

  string port_id    = 1 [(gogoproto.moretags) = "yaml:\"port_id\""];
  string channel_id = 2 [(gogoproto.moretags) = "yaml:\"channel_id\""];
  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 (gogoproto.equal)           = false;
  option (gogoproto.goproto_getters) = false;

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

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

// MsgRecvPacket receives incoming IBC packet
message MsgRecvPacket {
  option (gogoproto.equal)           = false;
  option (gogoproto.goproto_getters) = false;

  Packet                    packet           = 1 [(gogoproto.nullable) = false];
  bytes                     proof_commitment = 2 [(gogoproto.moretags) = "yaml:\"proof_commitment\""];
  ibc.core.client.v1.Height proof_height     = 3
      [(gogoproto.moretags) = "yaml:\"proof_height\"", (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 (gogoproto.equal)           = false;
  option (gogoproto.goproto_getters) = false;

  Packet                    packet           = 1 [(gogoproto.nullable) = false];
  bytes                     proof_unreceived = 2 [(gogoproto.moretags) = "yaml:\"proof_unreceived\""];
  ibc.core.client.v1.Height proof_height     = 3
      [(gogoproto.moretags) = "yaml:\"proof_height\"", (gogoproto.nullable) = false];
  uint64 next_sequence_recv = 4 [(gogoproto.moretags) = "yaml:\"next_sequence_recv\""];
  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 (gogoproto.equal)           = false;
  option (gogoproto.goproto_getters) = false;

  Packet                    packet           = 1 [(gogoproto.nullable) = false];
  bytes                     proof_unreceived = 2 [(gogoproto.moretags) = "yaml:\"proof_unreceived\""];
  bytes                     proof_close      = 3 [(gogoproto.moretags) = "yaml:\"proof_close\""];
  ibc.core.client.v1.Height proof_height     = 4
      [(gogoproto.moretags) = "yaml:\"proof_height\"", (gogoproto.nullable) = false];
  uint64 next_sequence_recv = 5 [(gogoproto.moretags) = "yaml:\"next_sequence_recv\""];
  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 (gogoproto.equal)           = false;
  option (gogoproto.goproto_getters) = false;

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

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

  ResponseResultType result = 1;
}
