syntax = "proto3";

package exchain.node.v1;

import "google/api/annotations.proto";
import "google/protobuf/descriptor.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/timestamp.proto";
import "nebula/ext/options.proto";
import "nebula/v1/account.proto";
import "nebula/v1/block.proto";
import "nebula/v1/coin.proto";
import "nebula/v1/order.proto";
import "nebula/v1/pair.proto";
import "nebula/v1/receipt.proto";
import "nebula/v1/transaction.proto";

option csharp_namespace = "ExChain.Node.V1";
option go_package = "github.com/exchain/go-exchain/exchain/protocol/node/v1";
option java_multiple_files = true;
option java_outer_classname = "NodeProto";
option java_package = "org.exchain.node.v1";
option php_namespace = "ExChain\\Node\\v1";

service Exchange {
  rpc SendTransaction(SendTransactionRequest) returns (SendTransactionResponse) {
    option (google.api.http) = {
      post: "/exchain/v1/node/send_transaction"
      body: "*"
    };
  }

  rpc GetOrderList(GetOrderListRequest) returns (GetOrderListResponse) {
    option (google.api.http) = {get: "/exchain/v1/node/get_order_list"};
  }

  rpc GetOrderInfo(GetOrderInfoRequest) returns (GetOrderInfoResponse) {
    option (google.api.http) = {get: "/exchain/v1/node/get_order_info"};
  }

  // kline api.
  // pair api.
  // user info api.
  // order api.
  //
}

enum SortField {
  SORT_WITH_CREATE_TIME = 0;
  SORT_WITH_PRICE = 1;
  SORT_WITH_QUALITY = 2;
}

message OffsetFilter {
  uint64 offset = 1;
  uint64 limit = 2;
}

message TimeRangeFilter {
  uint64 start_time = 1;
  uint64 end_time = 2;
}

message GetOrderListRequest {
  string user = 1;
  string pair = 2;
  oneof filter {
    OffsetFilter offset = 3;
    TimeRangeFilter time_range = 4;
  }
  SortField sort = 5;
  bool sort_asc = 6;
}

message GetOrderListResponse {
  repeated exchain.nebula.v1.Order orders = 1;
}

message GetOrderInfoRequest {
  string id = 1;
}

message GetOrderInfoResponse {
  exchain.nebula.v1.Order order = 1;
}

message SendTransactionRequest {
  exchain.nebula.v1.Transaction transaction = 1;
}

message SendTransactionResponse {
  string hash = 1;
}
