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

import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";
import "akash/market/v1beta2/bid.proto";

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

// LeaseID stores bid details of lease
message LeaseID {
  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\""];
  string provider = 5 [(gogoproto.jsontag) = "provider", (gogoproto.moretags) = "yaml:\"provider\""];
}

// Lease stores LeaseID, state of lease and price
message Lease {
  option (gogoproto.equal)            = false;
  option (gogoproto.goproto_stringer) = false;

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

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

    // Prefix should start with 0 in enum. So declaring dummy state
    invalid = 0 [(gogoproto.enumvalue_customname) = "LeaseStateInvalid"];
    // LeaseActive denotes state for lease active
    active = 1 [(gogoproto.enumvalue_customname) = "LeaseActive"];
    // LeaseInsufficientFunds denotes state for lease insufficient_funds
    insufficient_funds = 2 [(gogoproto.enumvalue_customname) = "LeaseInsufficientFunds"];
    // LeaseClosed denotes state for lease closed
    closed = 3 [(gogoproto.enumvalue_customname) = "LeaseClosed"];
  }

  State                    state = 2 [(gogoproto.jsontag) = "state", (gogoproto.moretags) = "yaml:\"state\""];
  cosmos.base.v1beta1.DecCoin price = 3
      [(gogoproto.nullable) = false, (gogoproto.jsontag) = "price", (gogoproto.moretags) = "yaml:\"price\""];
  int64 created_at = 4;
  int64 closed_on = 5;
}

// LeaseFilters defines flags for lease list filter
message LeaseFilters {
  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 provider = 5 [(gogoproto.jsontag) = "provider", (gogoproto.moretags) = "yaml:\"provider\""];
  string state    = 6 [(gogoproto.jsontag) = "state", (gogoproto.moretags) = "yaml:\"state\""];
}

// MsgCreateLease is sent to create a lease
message MsgCreateLease {
  option (gogoproto.equal) = false;

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

// MsgCreateLeaseResponse is the response from creating a lease
message MsgCreateLeaseResponse {}

// MsgWithdrawLease defines an SDK message for closing bid
message MsgWithdrawLease {
  option (gogoproto.equal) = false;

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

// MsgWithdrawLeaseResponse defines the Msg/WithdrawLease response type.
message MsgWithdrawLeaseResponse {}


// MsgCloseLease defines an SDK message for closing order
message MsgCloseLease {
  option (gogoproto.equal) = false;

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

// MsgCloseLeaseResponse defines the Msg/CloseLease response type.
message MsgCloseLeaseResponse {}
