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

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

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

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

// Query service defines the gRPC querier service.
service Query {
  // Tunnels is a RPC method that returns all tunnels.
  rpc Tunnels(QueryTunnelsRequest) returns (QueryTunnelsResponse) {
    option (google.api.http).get = "/tunnel/v1beta1/tunnels";
  }

  // Tunnel is a RPC method that returns a tunnel by its ID.
  rpc Tunnel(QueryTunnelRequest) returns (QueryTunnelResponse) {
    option (google.api.http).get = "/tunnel/v1beta1/tunnels/{tunnel_id}";
  }

  // Deposits queries all deposits of a single tunnel.
  rpc Deposits(QueryDepositsRequest) returns (QueryDepositsResponse) {
    option (google.api.http).get = "/tunnel/v1beta1/tunnels/{tunnel_id}/deposits";
  }

  // Deposit queries single deposit information based tunnelID, depositAddr.
  rpc Deposit(QueryDepositRequest) returns (QueryDepositResponse) {
    option (google.api.http).get = "/tunnel/v1beta1/tunnels/{tunnel_id}/deposits/{depositor}";
  }

  // Packets is a RPC method that returns all packets of a tunnel.
  rpc Packets(QueryPacketsRequest) returns (QueryPacketsResponse) {
    option (google.api.http).get = "/tunnel/v1beta1/tunnels/{tunnel_id}/packets";
  }

  // Packet is a RPC method that returns a packet by its tunnel ID and sequence.
  rpc Packet(QueryPacketRequest) returns (QueryPacketResponse) {
    option (google.api.http).get = "/tunnel/v1beta1/tunnels/{tunnel_id}/packets/{sequence}";
  }

  // TotalFees is a RPC method that returns the total fees collected by the tunnel
  rpc TotalFees(QueryTotalFeesRequest) returns (QueryTotalFeesResponse) {
    option (google.api.http).get = "/tunnel/v1beta1/total_fees";
  }

  // Params is a RPC method that returns all parameters of the module.
  rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
    option (google.api.http).get = "/tunnel/v1beta1/params";
  }
}

// TunnelStatusFilter defines a filter for tunnel status.
enum TunnelStatusFilter {
  option (gogoproto.goproto_enum_prefix) = false;

  // TUNNEL_STATUS_FILTER_UNSPECIFIED defines an unspecified status.
  TUNNEL_STATUS_FILTER_UNSPECIFIED = 0;
  // TUNNEL_STATUS_FILTER_ACTIVE defines an active tunnel.
  TUNNEL_STATUS_FILTER_ACTIVE = 1;
  // TUNNEL_STATUS_FILTER_INACTIVE defines an inactive tunnel.
  TUNNEL_STATUS_FILTER_INACTIVE = 2;
}

// QueryTunnelsRequest is the request type for the Query/Tunnels RPC method.
message QueryTunnelsRequest {
  // status_filter is a flag to filter tunnels by status.
  TunnelStatusFilter status_filter = 1;
  // pagination defines an optional pagination for the request.
  cosmos.base.query.v1beta1.PageRequest pagination = 2;
}

// QueryTunnelsResponse is the response type for the Query/Tunnels RPC method.
message QueryTunnelsResponse {
  // Tunnels is a list of tunnels.
  repeated Tunnel tunnels = 1;
  // pagination defines an optional pagination for the response.
  cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

// QueryTunnelRequest is the request type for the Query/Tunnel RPC method.
message QueryTunnelRequest {
  // tunnel_id is the ID of the tunnel to query.
  uint64 tunnel_id = 1;
}

// QueryTunnelResponse is the response type for the Query/Tunnel RPC method.
message QueryTunnelResponse {
  // tunnel is the tunnel with the given ID.
  Tunnel tunnel = 1 [(gogoproto.nullable) = false];
}

// QueryDepositsRequest is the request type for the Query/Deposits RPC method.
message QueryDepositsRequest {
  // tunnel_id is the ID of the tunnel to query deposits.
  uint64 tunnel_id = 1;
  // pagination defines an optional pagination for the request.
  cosmos.base.query.v1beta1.PageRequest pagination = 2;
}

// QueryDepositsResponse is the response type for the Query/Deposits RPC method.
message QueryDepositsResponse {
  // deposits is a list of deposits.
  repeated Deposit deposits = 1;
  // pagination defines an optional pagination for the response.
  cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

// QueryDepositRequest is the request type for the Query/Deposit RPC method.
message QueryDepositRequest {
  // tunnel_id is the ID of the tunnel to query.
  uint64 tunnel_id = 1;
  // depositor is the address of the depositor to query.
  string depositor = 2;
}

// QueryDepositResponse is the response type for the Query/Deposit RPC method.
message QueryDepositResponse {
  // deposit is the deposit with the given tunnel ID and depositor address.
  Deposit deposit = 1 [(gogoproto.nullable) = false];
}

// QueryPacketsRequest is the request type for the Query/Packets RPC method.
message QueryPacketsRequest {
  // tunnel_id is the ID of the tunnel to query packets.
  uint64 tunnel_id = 1;
  // pagination defines an optional pagination for the request.
  cosmos.base.query.v1beta1.PageRequest pagination = 2;
}

// QueryPacketsResponse is the response type for the Query/Packets RPC method.
message QueryPacketsResponse {
  // packets is a list of packets.
  repeated Packet packets = 1;
  // pagination defines an optional pagination for the response.
  cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

// QueryPacketRequest is the request type for the Query/Packet RPC method.
message QueryPacketRequest {
  // tunnel_id is the ID of the tunnel to query packets.
  uint64 tunnel_id = 1;
  // sequence is the sequence of the packet to query.
  uint64 sequence = 2;
}

// QueryPacketResponse is the response type for the Query/Packet RPC method.
message QueryPacketResponse {
  // packet is the packet with the given tunnel ID and sequence.
  Packet packet = 1;
}

// QueryTotalFeesRequest is the request type for the Query/TotalFees RPC method.
message QueryTotalFeesRequest {}

// QueryTotalFeesResponse is the response type for the Query/TotalFees RPC method.
message QueryTotalFeesResponse {
  // total_fees is the total fees collected by the tunnel.
  TotalFees total_fees = 1 [(gogoproto.nullable) = false];
}

// 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 is the parameters of the module.
  Params params = 1 [(gogoproto.nullable) = false];
}
