Merge pull request 'MarketPlace: new srv market added' (#14) from MarketPlace into v2

Reviewed-on: https://git.kahrobatoken.com/Kahroba/proto/pulls/14
This commit is contained in:
mapoofano 2025-02-19 12:46:28 +00:00
commit 08e297b958
6 changed files with 188 additions and 13 deletions

View File

@ -5,7 +5,7 @@ package alert.v1;
import "base/v1/msg.proto"; import "base/v1/msg.proto";
message AlertFilter { message AlertFilter {
base.v1.Filter base_filter = 1; base.v1.BaseQueryParam base_filter = 1;
Importance importance = 2; Importance importance = 2;
LogSource source = 3; LogSource source = 3;
} }

View File

@ -2,6 +2,8 @@ syntax = "proto3";
package auth.v1; package auth.v1;
import "base/v1/msg.proto";
/* /*
Internal Internal
*/ */
@ -81,11 +83,22 @@ message IdReqWithIAM {
int64 id = 1; int64 id = 1;
InternalIAM iam = 2; InternalIAM iam = 2;
} }
// Used for endpoints that need token and Query Param
message IAMWithQP {
InternalIAM iam = 1;
base.v1.BaseQueryParam qp = 2;
}
message ReqWithIAMAndParams { message ReqWithIAMAndParams {
InternalIAM iam = 1; InternalIAM iam = 1;
optional bool accepted = 2; optional bool accepted = 2;
} }
message ReqWithOptioanlIAM {
optional InternalIAM iam = 1;
}
/* /*
User User
*/ */
@ -230,6 +243,9 @@ enum TfaStateEnum {
INTERNAL_TRANSFER = 2; INTERNAL_TRANSFER = 2;
EXTERNAL_TRANSFER = 3; EXTERNAL_TRANSFER = 3;
REDEEM_TOKEN = 4; REDEEM_TOKEN = 4;
MARKET_PALCE_PURCHASE = 5;
MARKET_PALCE_ORDER_CREATE = 6;
MARKET_PALCE_ORDER_CANCEL = 7;
} }
message Recipient { message Recipient {

View File

@ -13,13 +13,21 @@ message IdRes {
message IdReq { message IdReq {
int64 id = 1; int64 id = 1;
} }
message Pagination {
message PaginationReq {
uint32 page = 1; // in query param it will be p uint32 page = 1; // in query param it will be p
uint32 page_size = 2; // in query param it will be pz 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 PaginationResp {
optional Pagination page = 3; uint32 no = 1;
uint32 size = 2;
optional uint32 count = 3;
}
message BaseQueryParam {
repeated string sort = 2; // sort by
optional PaginationReq page = 3;
} }

100
market/v1/msg.proto Normal file
View File

@ -0,0 +1,100 @@
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;
MarketOrderSide side = 8;
MarketOrderStatus status = 9;
int64 from = 10;
wallet.v1.Commission commission = 11;
float completed_amount = 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;
optional MarketOrder source = 19; // purchase is done via this field
// repeated string attachments = 14; // possible files included by seller/buyer
}
message MarketAssetListReq{
base.v1.BaseQueryParam base = 1;
optional auth.v1.InternalIAM iam = 2; // If not set, will returns only public orders which are limited by a white list
}
message MarketAssetList{
repeated wallet.v1.Asset list = 1;
}
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 {
base.v1.PaginationResp page = 2;
repeated MarketOrder list = 1;
}
message NewMarketReq{
auth.v1.InternalIAM iam = 1;
wallet.v1.Asset asset = 2;
double amount = 3;
double unit_price = 4;
MarketOrderSide side = 5;
auth.v1.TFA tfa = 6;
bool accepted_contract = 7;
}
enum MarketOrderSide {
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 {
optional auth.v1.InternalIAM iam = 1;
base.v1.BaseQueryParam base = 2;
optional string search = 3;
repeated MarketOrderSide side = 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;
}

23
market/v1/srv.proto Normal file
View File

@ -0,0 +1,23 @@
syntax = "proto3";
package market.v1;
import "auth/v1/msg.proto";
import "base/v1/msg.proto";
import "market/v1/msg.proto";
service MarketplaceSrv {
rpc GetMarketOrderDet(auth.v1.IdReqWithIAM) returns (MarketOrder); // details of an order by id
rpc GetAllOrderList(OrderListFilter) returns (MarketOrderList); // list of all orders (seller and buyer combined)
rpc GetMarketAssetList(MarketAssetListReq) returns (MarketAssetList); // assets that can be listed in marketplace
rpc NewMarketOrder(NewMarketReq) returns (MarketOrder); // insert new buy order to market
rpc Purchace(PurchaseReq) returns (PurchaseRes); // purchase from an order
rpc CancelOrder(auth.v1.IdReqWithIAM) returns (base.v1.StatusRes); // cancel an order
rpc GetMarketPubHistory(OrderListFilter) returns (MarketOrderList); // This is for public market
rpc GetUserMarketHistory(OrderListFilter) returns (MarketOrderList); // list of order + purchase related to buying an asset
}

View File

@ -183,6 +183,7 @@ message BNPLInfo {
string created_at = 13; string created_at = 13;
string expires_at = 14; string expires_at = 14;
} }
message BNPLList { message BNPLList {
repeated BNPLInfo list = 1; repeated BNPLInfo list = 1;
} }
@ -193,7 +194,7 @@ message BNPLList {
message WalletList { message WalletList {
repeated Wallet list = 1; repeated Wallet list = 1;
// optional base.v1.Pagination pagination = 2; // optional base.v1.Pagination pagination = 2;
double available_balance = 3; double available_balance = 3;
double locked_balance = 4; double locked_balance = 4;
double total_balance = 5; double total_balance = 5;
@ -207,11 +208,23 @@ message Wallet {
int64 federation_id = 5; int64 federation_id = 5;
Federation federation_info = 6; Federation federation_info = 6;
double balance = 7; double balance = 7;
string updated_at = 8; double frozen_balance = 8;
string created_at = 9; string updated_at = 9;
string wallet_code = 10; string created_at = 10;
bool accepted_terms = 11; string wallet_code = 11;
bool is_locked = 12; bool accepted_terms = 12;
bool is_locked = 13;
}
// Frozen Asset is asset locked due to reservation
message FrozenAsset {
uint64 id = 1;
int64 asset_id = 2;
int64 wallet_id = 4;
double amount = 5;
string created_at = 6;
string updated_at = 7;
optional string expires_at = 8;
} }
message UserInitWalletReq { message UserInitWalletReq {
@ -239,6 +252,9 @@ enum TransactionType {
WAGE = 7; WAGE = 7;
EXTERNAL_DEPOSIT = 8; EXTERNAL_DEPOSIT = 8;
INTERNAL_DEPOSIT = 9; INTERNAL_DEPOSIT = 9;
MARKETPLACE_BUY = 10;
MARKETPLACE_SELL = 11;
LOCK = 12;
} }
enum TransactionStatus { enum TransactionStatus {
@ -442,3 +458,15 @@ message Network {
message NetworkList { message NetworkList {
repeated Network list = 1; repeated Network list = 1;
} }
message Commission {
uint64 id = 1;
string name = 2;
double service = 3;
double tax = 4;
double total = 5;
string collector = 6;
optional string description = 7;
string updated_at = 10;
string created_at = 11;
}