From f18dd3b98e225110f722331f8d847c02d4e4519d Mon Sep 17 00:00:00 2001 From: Wenhua Zhang Date: Tue, 21 Jul 2020 15:16:33 +0800 Subject: [PATCH 1/2] feat(market): add related proto of market --- api/api.proto | 38 +++++++++++++++ core/Tron.proto | 73 +++++++++++++++++++++++++++++ core/contract/market_contract.proto | 20 ++++++++ 3 files changed, 131 insertions(+) create mode 100644 core/contract/market_contract.proto diff --git a/api/api.proto b/api/api.proto index 05f50196a..c79a6f0ce 100644 --- a/api/api.proto +++ b/api/api.proto @@ -13,6 +13,7 @@ import "core/contract/storage_contract.proto"; import "core/contract/exchange_contract.proto"; import "core/contract/smart_contract.proto"; import "core/contract/shield_contract.proto"; +import "core/contract/market_contract.proto"; option java_package = "org.tron.api"; //Specify the name of the package that generated the Java file option java_outer_classname = "GrpcAPI"; //Specify the class name of the generated Java file @@ -731,6 +732,29 @@ service Wallet { rpc GetTransactionInfoByBlockNum (NumberMessage) returns (TransactionInfoList) { } + + // for market + rpc MarketSellAsset (MarketSellAssetContract) returns (TransactionExtention) { + } + + rpc MarketCancelOrder (MarketCancelOrderContract) returns (TransactionExtention) { + } + + rpc GetMarketOrderByAccount (BytesMessage) returns (MarketOrderList) { + } + + rpc GetMarketOrderById (BytesMessage) returns (MarketOrder) { + } + + rpc GetMarketPriceByPair (MarketOrderPair) returns (MarketPriceList) { + } + + rpc GetMarketOrderListByPair (MarketOrderPair) returns (MarketOrderList) { + } + + rpc GetMarketPairList (EmptyMessage) returns (MarketOrderPairList) { + } + // end for market }; service WalletSolidity { @@ -899,6 +923,20 @@ service WalletSolidity { rpc GetTransactionInfoByBlockNum (NumberMessage) returns (TransactionInfoList) { } + rpc GetMarketOrderByAccount (BytesMessage) returns (MarketOrderList) { + } + + rpc GetMarketOrderById (BytesMessage) returns (MarketOrder) { + } + + rpc GetMarketPriceByPair (MarketOrderPair) returns (MarketPriceList) { + } + + rpc GetMarketOrderListByPair (MarketOrderPair) returns (MarketOrderList) { + } + + rpc GetMarketPairList (EmptyMessage) returns (MarketOrderPairList) { + } }; service WalletExtension { diff --git a/core/Tron.proto b/core/Tron.proto index 797273ce6..182461ccc 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -236,6 +236,13 @@ message ResourceReceipt { Transaction.Result.contractResult result = 7; } +message MarketOrderDetail { + bytes makerOrderId = 1; + bytes takerOrderId = 2; + int64 fillSellQuantity = 3; + int64 fillBuyQuantity = 4; +} + message Transaction { message Contract { enum ContractType { @@ -272,6 +279,8 @@ message Transaction { ClearABIContract = 48; UpdateBrokerageContract = 49; ShieldedTransferContract = 51; + MarketSellAssetContract = 60; + MarketCancelOrderContract = 61; } ContractType type = 1; google.protobuf.Any parameter = 2; @@ -368,6 +377,9 @@ message TransactionInfo { int64 exchange_withdraw_another_amount = 20; int64 exchange_id = 21; int64 shielded_transaction_fee = 22; + + bytes orderId = 25; + repeated MarketOrderDetail orderDetails = 26; } message TransactionRet { @@ -629,3 +641,64 @@ message NodeInfo { } } } + +// market +message MarketOrder { + bytes order_id = 1; + bytes owner_address = 2; + int64 create_time = 3; + bytes sell_token_id = 4; + int64 sell_token_quantity = 5; + bytes buy_token_id = 6; + int64 buy_token_quantity = 7; // min to receive + int64 sell_token_quantity_remain = 9; + // When state != ACTIVE and sell_token_quantity_return !=0, + //it means that some sell tokens are returned to the account due to insufficient remaining amount + int64 sell_token_quantity_return = 10; + + enum State { + ACTIVE = 0; + INACTIVE = 1; + CANCELED = 2; + } + State state = 11; + + bytes prev = 12; + bytes next = 13; +} + +message MarketOrderList { + repeated MarketOrder orders = 1; +} + +message MarketOrderPairList { + repeated MarketOrderPair orderPair = 1; +} + +message MarketOrderPair{ + bytes sell_token_id = 1; + bytes buy_token_id = 2; +} + +message MarketAccountOrder { + bytes owner_address = 1; + repeated bytes orders = 2; // order_id list + int64 count = 3; // active count + int64 total_count = 4; +} + +message MarketPrice { + int64 sell_token_quantity = 1; + int64 buy_token_quantity = 2; +} + +message MarketPriceList { + bytes sell_token_id = 1; + bytes buy_token_id = 2; + repeated MarketPrice prices = 3; +} + +message MarketOrderIdList { + bytes head = 1; + bytes tail = 2; +} diff --git a/core/contract/market_contract.proto b/core/contract/market_contract.proto new file mode 100644 index 000000000..0ad035e73 --- /dev/null +++ b/core/contract/market_contract.proto @@ -0,0 +1,20 @@ +syntax = "proto3"; + +package protocol; + +option java_package = "org.tron.protos.contract"; //Specify the name of the package that generated the Java file +option go_package = "github.com/tronprotocol/grpc-gateway/core"; + +message MarketSellAssetContract { + bytes owner_address = 1; + bytes sell_token_id = 2; + int64 sell_token_quantity = 3; + bytes buy_token_id = 4; + int64 buy_token_quantity = 5; // min to receive + bytes pre_price_key = 6; // order price position +} + +message MarketCancelOrderContract { + bytes owner_address = 1; + bytes order_id = 2; +} \ No newline at end of file From 0c1f01c6e52aa5b7dab140def1837f9ec6cc1f7d Mon Sep 17 00:00:00 2001 From: Wenhua Zhang Date: Thu, 23 Jul 2020 16:24:45 +0800 Subject: [PATCH 2/2] feat(market): update market contract enum value --- core/Tron.proto | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/Tron.proto b/core/Tron.proto index 182461ccc..cec919247 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -279,8 +279,8 @@ message Transaction { ClearABIContract = 48; UpdateBrokerageContract = 49; ShieldedTransferContract = 51; - MarketSellAssetContract = 60; - MarketCancelOrderContract = 61; + MarketSellAssetContract = 52; + MarketCancelOrderContract = 53; } ContractType type = 1; google.protobuf.Any parameter = 2;