syntax = "proto3";
package akash.market.v1beta2;

import "gogoproto/gogo.proto";
import "akash/deployment/v1beta2/groupspec.proto";

option go_package = "github.com/akash-network/akash-api/go/node/market/v1beta2";

// OrderID stores owner and all other seq numbers
message OrderID {
  option (gogoproto.equal)            = false;
  option (gogoproto.goproto_stringer) = false;

  string owner = 1 [(gogoproto.jsontag) = "owner", (gogoproto.moretags) = "yaml:\"owner\""];
  uint64 dseq  = 2
      [(gogoproto.customname) = "DSeq", (gogoproto.jsontag) = "dseq", (gogoproto.moretags) = "yaml:\"dseq\""];
  uint32 gseq = 3
      [(gogoproto.customname) = "GSeq", (gogoproto.jsontag) = "gseq", (gogoproto.moretags) = "yaml:\"gseq\""];
  uint32 oseq = 4
      [(gogoproto.customname) = "OSeq", (gogoproto.jsontag) = "oseq", (gogoproto.moretags) = "yaml:\"oseq\""];
}

// Order stores orderID, state of order and other details
message Order {
  option (gogoproto.equal)            = false;
  option (gogoproto.goproto_stringer) = false;

  OrderID order_id = 1 [
    (gogoproto.customname) = "OrderID",
    (gogoproto.nullable)   = false,
    (gogoproto.jsontag)    = "id",
    (gogoproto.moretags)   = "yaml:\"id\""
  ];

  // State is an enum which refers to state of order
  enum State {
    option (gogoproto.goproto_enum_prefix) = false;

    // Prefix should start with 0 in enum. So declaring dummy state
    invalid = 0 [(gogoproto.enumvalue_customname) = "OrderStateInvalid"];
    // OrderOpen denotes state for order open
    open = 1 [(gogoproto.enumvalue_customname) = "OrderOpen"];
    // OrderMatched denotes state for order matched
    active = 2 [(gogoproto.enumvalue_customname) = "OrderActive"];
    // OrderClosed denotes state for order lost
    closed = 3 [(gogoproto.enumvalue_customname) = "OrderClosed"];
  }

  State state    = 2 [
    (gogoproto.jsontag) = "state",
    (gogoproto.moretags) = "yaml:\"state\""
  ];
  akash.deployment.v1beta2.GroupSpec spec = 3 [
    (gogoproto.nullable) = false,
    (gogoproto.jsontag) = "spec",
    (gogoproto.moretags) = "yaml:\"spec\""
  ];

  int64 created_at = 4;
}

// OrderFilters defines flags for order list filter
message OrderFilters {
  option (gogoproto.equal) = false;

  string owner = 1 [(gogoproto.jsontag) = "owner", (gogoproto.moretags) = "yaml:\"owner\""];
  uint64 dseq  = 2
      [(gogoproto.customname) = "DSeq", (gogoproto.jsontag) = "dseq", (gogoproto.moretags) = "yaml:\"dseq\""];
  uint32 gseq = 3
      [(gogoproto.customname) = "GSeq", (gogoproto.jsontag) = "gseq", (gogoproto.moretags) = "yaml:\"gseq\""];
  uint32 oseq = 4
      [(gogoproto.customname) = "OSeq", (gogoproto.jsontag) = "oseq", (gogoproto.moretags) = "yaml:\"oseq\""];
  string state = 5 [(gogoproto.jsontag) = "state", (gogoproto.moretags) = "yaml:\"state\""];
}
