From cb9b5ac9f2b63d506ea341c28296ece2b8ae3d96 Mon Sep 17 00:00:00 2001 From: nfel Date: Sat, 8 Feb 2025 18:10:47 +0330 Subject: [PATCH] MarketPlace: new srv market added Signed-off-by: nfel --- alert/v1/msg.proto | 2 +- auth/v1/msg.proto | 12 ++++++ base/v1/msg.proto | 6 +-- market/v1/msg.proto | 101 ++++++++++++++++++++++++++++++++++++++++++++ market/v1/srv.proto | 24 +++++++++++ 5 files changed, 141 insertions(+), 4 deletions(-) create mode 100644 market/v1/msg.proto create mode 100644 market/v1/srv.proto diff --git a/alert/v1/msg.proto b/alert/v1/msg.proto index 0ee7e9d..bc3fa00 100644 --- a/alert/v1/msg.proto +++ b/alert/v1/msg.proto @@ -5,7 +5,7 @@ package alert.v1; import "base/v1/msg.proto"; message AlertFilter { - base.v1.Filter base_filter = 1; + base.v1.BaseQueryParam base_filter = 1; Importance importance = 2; LogSource source = 3; } diff --git a/auth/v1/msg.proto b/auth/v1/msg.proto index b92f955..7c9a1bf 100644 --- a/auth/v1/msg.proto +++ b/auth/v1/msg.proto @@ -2,6 +2,8 @@ syntax = "proto3"; package auth.v1; +import "base/v1/msg.proto"; + /* Internal */ @@ -81,6 +83,13 @@ message IdReqWithIAM { int64 id = 1; InternalIAM iam = 2; } + +// Used for endpoints that need token and Query Param +message IAMWithQP { + InternalIAM iam = 1; + base.v1.BaseQueryParam qp = 2; +} + message ReqWithIAMAndParams { InternalIAM iam = 1; optional bool accepted = 2; @@ -230,6 +239,9 @@ enum TfaStateEnum { INTERNAL_TRANSFER = 2; EXTERNAL_TRANSFER = 3; REDEEM_TOKEN = 4; + MARKET_PALCE_PURCHASE = 5; + MARKET_PALCE_ORDER_CREATE = 6; + MARKET_PALCE_ORDER_CANCEL = 7; } message Recipient { diff --git a/base/v1/msg.proto b/base/v1/msg.proto index 0215f45..918db7f 100644 --- a/base/v1/msg.proto +++ b/base/v1/msg.proto @@ -18,8 +18,8 @@ message Pagination { uint32 page_size = 2; // in query param it will be pz optional uint32 total_count = 3; // reponse } -message Filter { - string query = 1; // q - string sort = 2; // s + +message BaseQueryParam { + repeated string sort = 2; // sort by optional Pagination page = 3; } diff --git a/market/v1/msg.proto b/market/v1/msg.proto new file mode 100644 index 0000000..e413160 --- /dev/null +++ b/market/v1/msg.proto @@ -0,0 +1,101 @@ +syntax = "proto3"; + +package market.v1; + +import "auth/v1/msg.proto"; +import "base/v1/msg.proto"; +import "wallet/v1/msg.proto"; + +message MPHistoryFilter {} +message MPListFilter {} +message MarketOrder { + uint64 id = 1; + uint64 trx_id = 2; + wallet.v1.Asset asset = 3; + wallet.v1.Asset counter_asset = 4; + double amount = 5; + double unit_price = 6; + double total_price = 7; + MarketOrderType type = 8; + MarketOrderStatus status = 9; + string from = 10; + float commission = 11; + float completion_rate = 12; + string created_at = 13; + string updated_at = 14; + bool is_public = 15; + wallet.v1.TransactionList trx = 16; + repeated string tags = 17; + repeated string comment = 18; + // repeated string attachments = 14; // possible files included by seller/buyer +} + +message PurchaseReq { + uint64 order_id = 1; + double amount = 2; + bool accepted_contract = 3; + auth.v1.TFA tfa = 4; +} +message PurchaseRes { + uint64 order_id = 1; + uint64 trx_id = 2; + double calculated_amount = 3; + MarketOrderStatus status = 4; +} + +message MarketOrderList { + repeated MarketOrder list = 1; +} + +message Buyer {} +message Seller {} +message CancleOrderReq{ + uint64 order_id = 1; +} +message NewMarketRes{ + uint64 order_id = 1; + wallet.v1.Asset asset = 2; + double amount = 3; + double unit_price = 4; +} +message NewMarketReq{ + auth.v1.InternalIAM iam = 1; + wallet.v1.Asset asset = 2; + double amount = 3; + double unit_price = 4; + auth.v1.TFA tfa = 5; + bool accepted_contract = 6; +} + +enum MarketOrderType { + MO_UNKOWN = 0; + MO_BUY = 1; + MO_SELL = 2; +} +enum MarketOrderStatus { + MO_UNKOWN_MP_STATUS = 0; // Unknown + MO_OPEN = 1; // Order is open and waiting to be completed + MO_CANCEL = 2; // Cancelled by user + MO_COMPLETED = 3; // Order is completed + MO_FAILED = 4; // Order is failed - bad trx , etc. + MO_REFUNDED = 5; // Order is refunded by platform to user due to regulation + // MO_EXPIRED = 4; // Order is expired +} +message OrderListFilter { + base.v1.BaseQueryParam base = 2; + optional string search = 3; + repeated MarketOrderType type = 4; + repeated MarketOrderStatus status = 5; + repeated string from = 6; + repeated string to = 7; + optional double starting_price = 8; + optional double ending_price = 9; + repeated wallet.v1.Asset asset = 10; + uint64 order_id = 11; + uint64 trx_id = 12; +} + +message OrderListFilterWithIAM { + OrderListFilter filter = 1; + auth.v1.InternalIAM iam = 2; +} diff --git a/market/v1/srv.proto b/market/v1/srv.proto new file mode 100644 index 0000000..1f39741 --- /dev/null +++ b/market/v1/srv.proto @@ -0,0 +1,24 @@ +syntax = "proto3"; + +package market.v1; + +import "base/v1/msg.proto"; +import "market/v1/msg.proto"; + +service MarketplaceSrv { + rpc GetSellerList(OrderListFilter) returns (MarketOrderList); + rpc GetBuyerList(OrderListFilter) returns (MarketOrderList); + rpc GetAllOrderList(OrderListFilter) returns (MarketOrderList); + + rpc GetMarketHistory(OrderListFilter) returns (MarketOrderList); // This is for public market + + rpc Purchace(PurchaseReq) returns (PurchaseRes); + + rpc NewSellOrder(NewMarketReq) returns (NewMarketRes); + rpc NewBuyOrder(NewMarketReq) returns (NewMarketRes); + + rpc CancleOrder(CancleOrderReq) returns (base.v1.StatusRes); + + rpc GetBuyHistory(OrderListFilterWithIAM) returns (MarketOrderList); + rpc GetSellHistory(OrderListFilterWithIAM) returns (MarketOrderList); +}