syntax = "proto3";
package band.tunnel.v1beta1;

option go_package = "github.com/bandprotocol/chain/v3/x/tunnel/types";

import "google/protobuf/any.proto";
import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "cosmos/base/v1beta1/coin.proto";
import "cosmos/msg/v1/msg.proto";
import "amino/amino.proto";

import "band/tunnel/v1beta1/params.proto";
import "band/tunnel/v1beta1/tunnel.proto";

// Service definition for Msg.
service Msg {
  option (cosmos.msg.v1.service) = true;

  // CreateTunnel is a RPC method to create a new tunnel.
  rpc CreateTunnel(MsgCreateTunnel) returns (MsgCreateTunnelResponse);

  // UpdateRoute is a RPC method to update a route information of the tunnel.
  rpc UpdateRoute(MsgUpdateRoute) returns (MsgUpdateRouteResponse);

  // UpdateSignalsAndInterval is a RPC method to update a signals and interval of the tunnel.
  rpc UpdateSignalsAndInterval(MsgUpdateSignalsAndInterval) returns (MsgUpdateSignalsAndIntervalResponse);

  // WithdrawFeePayerFunds is a RPC method to withdraw fee payer funds to creator.
  rpc WithdrawFeePayerFunds(MsgWithdrawFeePayerFunds) returns (MsgWithdrawFeePayerFundsResponse);

  // ActivateTunnel is a RPC method to activate a tunnel.
  rpc ActivateTunnel(MsgActivateTunnel) returns (MsgActivateTunnelResponse);

  // DeactivateTunnel is a RPC method to deactivate a tunnel.
  rpc DeactivateTunnel(MsgDeactivateTunnel) returns (MsgDeactivateTunnelResponse);

  // TriggerTunnel is a RPC method to manually trigger a tunnel.
  rpc TriggerTunnel(MsgTriggerTunnel) returns (MsgTriggerTunnelResponse);

  // DepositToTunnel is a RPC method to deposit to an existing tunnel.
  rpc DepositToTunnel(MsgDepositToTunnel) returns (MsgDepositToTunnelResponse);

  // WithdrawFromTunnel is a RPC method to withdraw a deposit from an existing tunnel.
  rpc WithdrawFromTunnel(MsgWithdrawFromTunnel) returns (MsgWithdrawFromTunnelResponse);

  // UpdateParams is a RPC method to update parameters
  rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
}

// MsgCreateTunnel is the transaction message to create a new tunnel.
message MsgCreateTunnel {
  option (cosmos.msg.v1.signer) = "creator";
  option (amino.name)           = "tunnel/MsgCreateTunnel";

  // signal_deviations is the list of signal deviations.
  repeated SignalDeviation signal_deviations = 1 [(gogoproto.nullable) = false];
  // interval is the interval for delivering the signal prices in seconds.
  uint64 interval = 2;
  // route is the route for delivering the signal prices
  google.protobuf.Any route = 3 [(cosmos_proto.accepts_interface) = "RouteI"];
  // initial_deposit is the deposit value that must be paid at tunnel creation.
  repeated cosmos.base.v1beta1.Coin initial_deposit = 4 [
    (gogoproto.nullable)     = false,
    (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
    (amino.dont_omitempty)   = true
  ];
  // creator is the address of the creator.
  string creator = 5 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// MsgCreateTunnelResponse is the response type for the Msg/CreateTunnel RPC method.
message MsgCreateTunnelResponse {
  uint64 tunnel_id = 1 [(gogoproto.customname) = "TunnelID"];
}

// MsgUpdateRoute is the transaction message to update a route information of the tunnel.
message MsgUpdateRoute {
  option (cosmos.msg.v1.signer) = "creator";
  option (amino.name)           = "tunnel/MsgUpdateRoute";

  // tunnel_id is the ID of the tunnel to edit.
  uint64 tunnel_id = 1 [(gogoproto.customname) = "TunnelID"];
  // route is the route for delivering the signal prices
  google.protobuf.Any route = 2 [(cosmos_proto.accepts_interface) = "RouteI"];
  // creator is the address of the creator.
  string creator = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// MsgUpdateRouteResponse is the response type for the Msg/UpdateRoute RPC method.
message MsgUpdateRouteResponse {}

// MsgUpdateSignalsAndInterval is the transaction message to update signals and interval of the tunnel.
message MsgUpdateSignalsAndInterval {
  option (cosmos.msg.v1.signer) = "creator";
  option (amino.name)           = "tunnel/MsgUpdateSignalsAndInterval";

  // tunnel_id is the ID of the tunnel to edit.
  uint64 tunnel_id = 1 [(gogoproto.customname) = "TunnelID"];
  // signal_deviations is the list of signal deviations.
  repeated SignalDeviation signal_deviations = 2 [(gogoproto.nullable) = false];
  // interval is the interval for delivering the signal prices.
  uint64 interval = 3;
  // creator is the address of the creator.
  string creator = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// MsgUpdateSignalsAndIntervalResponse is the response type for the Msg/UpdateSignalsAndInterval RPC method.
message MsgUpdateSignalsAndIntervalResponse {}

// MsgWithdrawFeePayerFunds is the transaction message to withdraw fee payer funds to creator.
message MsgWithdrawFeePayerFunds {
  option (cosmos.msg.v1.signer) = "creator";
  option (amino.name)           = "tunnel/MsgWithdrawFeePayerFunds";

  // tunnel_id is the ID of the tunnel to withdraw fee payer coins.
  uint64 tunnel_id = 1 [(gogoproto.customname) = "TunnelID"];
  // amount is the coins to withdraw.
  repeated cosmos.base.v1beta1.Coin amount = 2 [
    (gogoproto.nullable)     = false,
    (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
    (amino.dont_omitempty)   = true
  ];
  // creator is the address of the creator.
  string creator = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// MsgWithdrawFeePayerFundsResponse is the response type for the Msg/WithdrawFeePayerFunds RPC method.
message MsgWithdrawFeePayerFundsResponse {}

// MsgActivateTunnel is the transaction message to activate a tunnel.
message MsgActivateTunnel {
  option (cosmos.msg.v1.signer) = "creator";
  option (amino.name)           = "tunnel/MsgActivateTunnel";

  // tunnel_id is the ID of the tunnel to activate.
  uint64 tunnel_id = 1 [(gogoproto.customname) = "TunnelID"];
  // creator is the address of the creator.
  string creator = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// MsgActivateTunnelResponse is the response type for the Msg/Activate RPC method.
message MsgActivateTunnelResponse {}

// MsgDeactivateTunnel is the transaction message to deactivate a tunnel.
message MsgDeactivateTunnel {
  option (cosmos.msg.v1.signer) = "creator";
  option (amino.name)           = "tunnel/MsgDeactivateTunnel";

  // tunnel_id is the ID of the tunnel to deactivate.
  uint64 tunnel_id = 1 [(gogoproto.customname) = "TunnelID"];
  // creator is the address of the creator.
  string creator = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// MsgDeactivateTunnelResponse is the response type for the Msg/Deactivate RPC method.
message MsgDeactivateTunnelResponse {}

// MsgTriggerTunnel is the transaction message to manually trigger a tunnel.
message MsgTriggerTunnel {
  option (cosmos.msg.v1.signer) = "creator";
  option (amino.name)           = "tunnel/MsgTriggerTunnel";

  // tunnel_id is the ID of the tunnel to manually trigger.
  uint64 tunnel_id = 1 [(gogoproto.customname) = "TunnelID"];
  // creator is the address of the creator.
  string creator = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// MsgTriggerTunnelResponse is the response type for the Msg/TriggerTunnel RPC method.
message MsgTriggerTunnelResponse {}

// MsgDepositToTunnel defines a message to deposit to an existing tunnel.
message MsgDepositToTunnel {
  option (cosmos.msg.v1.signer) = "depositor";
  option (amino.name)           = "tunnel/MsgDepositToTunnel";

  // tunnel_id defines the unique id of the tunnel.
  uint64 tunnel_id = 1 [(gogoproto.customname) = "TunnelID"];

  // amount to be deposited by depositor.
  repeated cosmos.base.v1beta1.Coin amount = 2 [
    (gogoproto.nullable)     = false,
    (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
    (amino.dont_omitempty)   = true
  ];

  // depositor defines the deposit addresses from the tunnel.
  string depositor = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// MsgDepositToTunnelResponse defines the Msg/DepositToTunnel response type.
message MsgDepositToTunnelResponse {}

// MsgWithdrawFromTunnel is the transaction message to withdraw a deposit from an existing tunnel.
message MsgWithdrawFromTunnel {
  option (cosmos.msg.v1.signer) = "withdrawer";
  option (amino.name)           = "tunnel/MsgWithdrawFromTunnel";

  // tunnel_id defines the unique id of the tunnel.
  uint64 tunnel_id = 1 [(gogoproto.customname) = "TunnelID"];

  // amount to be withdrawn by withdrawer.
  repeated cosmos.base.v1beta1.Coin amount = 2 [
    (gogoproto.nullable)     = false,
    (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
    (amino.dont_omitempty)   = true
  ];

  // withdrawer defines the withdraw addresses from the tunnel.
  string withdrawer = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// MsgWithdrawFromTunnelResponse defines the Msg/WithdrawFromTunnel response type.
message MsgWithdrawFromTunnelResponse {}

// MsgUpdateParams is the transaction message to update parameters.
message MsgUpdateParams {
  option (cosmos.msg.v1.signer) = "authority";
  option (amino.name)           = "tunnel/MsgUpdateParams";

  // authority is the address of the governance account.
  string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];

  // params is the x/tunnel parameters to update.
  Params params = 2 [(gogoproto.nullable) = false];
}

// MsgUpdateParamsResponse is the response type for the Msg/UpdateParams RPC method.
message MsgUpdateParamsResponse {}
