From 6441183d2564afe8715ffb8f5cd501215c9f856e Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Sat, 5 Oct 2019 23:23:28 +0200 Subject: [PATCH] marketplace documentation and rpc methods renamed --- src/common/command_line.cpp | 2 +- src/currency_core/offers_service_basics.h | 2 +- src/rpc/core_rpc_server.h | 2 +- tests/performance_tests/main.cpp | 5 +- .../performance_tests/print_struct_to_json.h | 26 ++++++++++ ...MAND_MARKETPLACE_CANCEL_OFFER_request.json | 10 ++++ ...AND_MARKETPLACE_CANCEL_OFFER_response.json | 8 +++ ...AND_MARKETPLACE_GET_MY_OFFERS_request.json | 28 ++++++++++ ...ND_MARKETPLACE_GET_MY_OFFERS_response.json | 51 +++++++++++++++++++ ...OMMAND_MARKETPLACE_PUSH_OFFER_request.json | 23 +++++++++ ...MAND_MARKETPLACE_PUSH_OFFER_request_2.json | 23 +++++++++ ...MMAND_MARKETPLACE_PUSH_OFFER_response.json | 17 +++++++ ...MARKETPLACE_PUSH_UPDATE_OFFER_request.json | 25 +++++++++ ...ARKETPLACE_PUSH_UPDATE_OFFER_response.json | 8 +++ 14 files changed, 226 insertions(+), 4 deletions(-) create mode 100644 tests/performance_tests/print_struct_to_json.h create mode 100644 utils/test_api_files/COMMAND_MARKETPLACE_CANCEL_OFFER_request.json create mode 100644 utils/test_api_files/COMMAND_MARKETPLACE_CANCEL_OFFER_response.json create mode 100644 utils/test_api_files/COMMAND_MARKETPLACE_GET_MY_OFFERS_request.json create mode 100644 utils/test_api_files/COMMAND_MARKETPLACE_GET_MY_OFFERS_response.json create mode 100644 utils/test_api_files/COMMAND_MARKETPLACE_PUSH_OFFER_request.json create mode 100644 utils/test_api_files/COMMAND_MARKETPLACE_PUSH_OFFER_request_2.json create mode 100644 utils/test_api_files/COMMAND_MARKETPLACE_PUSH_OFFER_response.json create mode 100644 utils/test_api_files/COMMAND_MARKETPLACE_PUSH_UPDATE_OFFER_request.json create mode 100644 utils/test_api_files/COMMAND_MARKETPLACE_PUSH_UPDATE_OFFER_response.json diff --git a/src/common/command_line.cpp b/src/common/command_line.cpp index 3edb55de..e6fd1c44 100644 --- a/src/common/command_line.cpp +++ b/src/common/command_line.cpp @@ -29,5 +29,5 @@ namespace command_line const arg_descriptor arg_disable_stop_if_time_out_of_sync = { "disable-stop-if-time-out-of-sync", "Do not stop the daemon if serious time synchronization problem is detected", false, true }; const arg_descriptor arg_disable_stop_on_low_free_space = { "disable-stop-on-low-free-space", "Do not stop the daemon if free space at data dir is critically low", false, true }; - const arg_descriptor arg_enable_offers_service = { "enable_offers_service", "Enables marketplace feature", false, false}; + const arg_descriptor arg_enable_offers_service = { "enable-offers-service", "Enables marketplace feature", false, false}; } diff --git a/src/currency_core/offers_service_basics.h b/src/currency_core/offers_service_basics.h index f72c508b..16d2990a 100644 --- a/src/currency_core/offers_service_basics.h +++ b/src/currency_core/offers_service_basics.h @@ -19,7 +19,7 @@ namespace bc_services { //fields filled in UI - uint8_t offer_type; // OFFER_TYPE_PRIMARY_TO_TARGET - 0, OFFER_TYPE_TARGET_TO_PRIMARY - 1 etc. + uint8_t offer_type; // OFFER_TYPE_PRIMARY_TO_TARGET(SELL ORDER) - 0, OFFER_TYPE_TARGET_TO_PRIMARY(BUY ORDER) - 1 etc. uint64_t amount_primary; // amount of the currency uint64_t amount_target; // amount of other currency or goods std::string bonus; // diff --git a/src/rpc/core_rpc_server.h b/src/rpc/core_rpc_server.h index b156ded7..287d16d2 100644 --- a/src/rpc/core_rpc_server.h +++ b/src/rpc/core_rpc_server.h @@ -152,7 +152,7 @@ namespace currency MAP_JON_RPC ("reset_transaction_pool", on_reset_transaction_pool, COMMAND_RPC_RESET_TX_POOL) MAP_JON_RPC ("get_current_core_tx_expiration_median", on_get_current_core_tx_expiration_median, COMMAND_RPC_GET_CURRENT_CORE_TX_EXPIRATION_MEDIAN) // - MAP_JON_RPC_WE("get_offers_ex", on_get_offers_ex, COMMAND_RPC_GET_OFFERS_EX) + MAP_JON_RPC_WE("marketplace_global_get_offers_ex", on_get_offers_ex, COMMAND_RPC_GET_OFFERS_EX) //remote miner rpc MAP_JON_RPC_N(on_login, mining::COMMAND_RPC_LOGIN) diff --git a/tests/performance_tests/main.cpp b/tests/performance_tests/main.cpp index 74a9da5c..dfd93054 100644 --- a/tests/performance_tests/main.cpp +++ b/tests/performance_tests/main.cpp @@ -19,6 +19,7 @@ #include "serialization_performance_test.h" #include "keccak_test.h" #include "blake2_test.h" +#include "print_struct_to_json.h" int main(int argc, char** argv) { @@ -33,7 +34,9 @@ int main(int argc, char** argv) set_process_affinity(1); set_thread_high_priority(); - test_blake2(); + //test_blake2(); + + print_struct_to_json(); //performance_timer timer; //timer.start(); diff --git a/tests/performance_tests/print_struct_to_json.h b/tests/performance_tests/print_struct_to_json.h new file mode 100644 index 00000000..37dbaaec --- /dev/null +++ b/tests/performance_tests/print_struct_to_json.h @@ -0,0 +1,26 @@ +// Copyright (c) 2012-2013 The Boolberry developers +// Copyright (c) 2012-2013 The Zano developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#pragma once + +#include "currency_core/currency_basic.h" +#include "rpc/core_rpc_server_commands_defs.h" +#include "wallet/wallet_public_structs_defs.h" + + + +inline bool print_struct_to_json() +{ + tools::wallet_public::COMMAND_MARKETPLACE_PUSH_OFFER::request of = AUTO_VAL_INIT(of); + tools::wallet_public::COMMAND_MARKETPLACE_PUSH_UPDATE_OFFER::request uo = AUTO_VAL_INIT(uo); + + bc_services::core_offers_filter ft = AUTO_VAL_INIT(ft); + + std::string s = epee::serialization::store_t_to_json(of); + s = epee::serialization::store_t_to_json(ft); + s = epee::serialization::store_t_to_json(uo); + + return true; +} \ No newline at end of file diff --git a/utils/test_api_files/COMMAND_MARKETPLACE_CANCEL_OFFER_request.json b/utils/test_api_files/COMMAND_MARKETPLACE_CANCEL_OFFER_request.json new file mode 100644 index 00000000..08693183 --- /dev/null +++ b/utils/test_api_files/COMMAND_MARKETPLACE_CANCEL_OFFER_request.json @@ -0,0 +1,10 @@ +{ + "jsonrpc": "2.0", + "id": 0, + "method": "marketplace_cancel_offer", + "params": { + "no": 0, + "tx_id": "1ca72152db6b962e473a0f838c281c902b7e1ed79c0a762bdb197ccf7f4ab2d5", + "fee": 10000000000 + } +} \ No newline at end of file diff --git a/utils/test_api_files/COMMAND_MARKETPLACE_CANCEL_OFFER_response.json b/utils/test_api_files/COMMAND_MARKETPLACE_CANCEL_OFFER_response.json new file mode 100644 index 00000000..bbb8b5f3 --- /dev/null +++ b/utils/test_api_files/COMMAND_MARKETPLACE_CANCEL_OFFER_response.json @@ -0,0 +1,8 @@ +{ + "id": 0, + "jsonrpc": "2.0", + "result": { + "tx_blob_size": 368, + "tx_hash": "d52014dae0b65168e0551acef9e95972041f3f38d92455d18c8b886baece3d90" + } +} \ No newline at end of file diff --git a/utils/test_api_files/COMMAND_MARKETPLACE_GET_MY_OFFERS_request.json b/utils/test_api_files/COMMAND_MARKETPLACE_GET_MY_OFFERS_request.json new file mode 100644 index 00000000..f8d60afd --- /dev/null +++ b/utils/test_api_files/COMMAND_MARKETPLACE_GET_MY_OFFERS_request.json @@ -0,0 +1,28 @@ +{ + "jsonrpc": "2.0", + "id": 0, + "method": "marketplace_get_offers_ex", + "params": { + "filter": { + "amount_low_limit": 0, + "amount_up_limit": 0, + "bonus": false, + "category": "", + "fake": false, + "keyword": "", + "limit": 100, + "location_city": "", + "location_country": "", + "offer_type_mask": 0, + "offset": 0, + "order_by": 0, + "primary": "", + "rate_low_limit": "0.000000", + "rate_up_limit": "0.000000", + "reverse": false, + "target": "", + "timestamp_start": 0, + "timestamp_stop": 0 + } + } +} \ No newline at end of file diff --git a/utils/test_api_files/COMMAND_MARKETPLACE_GET_MY_OFFERS_response.json b/utils/test_api_files/COMMAND_MARKETPLACE_GET_MY_OFFERS_response.json new file mode 100644 index 00000000..d4beeccf --- /dev/null +++ b/utils/test_api_files/COMMAND_MARKETPLACE_GET_MY_OFFERS_response.json @@ -0,0 +1,51 @@ +{ + "id": 0, + "jsonrpc": "2.0", + "result": { + "offers": [{ + "ap": "20", + "at": "1", + "b": "", + "cat": "CLS:MAN:TSH", + "cnt": "Skype: some_skype, discord: some_user#01012", + "com": "Some nice comments about tshirt", + "do": "Additional conditions", + "et": 10, + "fee": 10000000000, + "index_in_tx": 0, + "lci": "", + "lco": "World Wide", + "ot": 1, + "p": "USD", + "pt": "Credit cards, BTC, ZANO, ETH", + "security": "0000000000000000000000000000000000000000000000000000000000000000", + "t": "T-shirt with Zano logo, made by Crypjunkie", + "timestamp": 1570219600, + "tx_hash": "6ba12c5d2c66d31f770bfdc88ae9dc90d007b9b33f946fc7c1d9750f8655331c", + "tx_original_hash": "0000000000000000000000000000000000000000000000000000000000000000" + },{ + "ap": "20", + "at": "1", + "b": "", + "cat": "CLS:MAN:TSH", + "cnt": "Skype: some_skype, discord: some_user#01012", + "com": "Some nice comments about tshirt", + "do": "Additional conditions", + "et": 10, + "fee": 10000000000, + "index_in_tx": 0, + "lci": "", + "lco": "World Wide", + "ot": 1, + "p": "USD", + "pt": "Credit cards, BTC, ZANO, ETH", + "security": "0000000000000000000000000000000000000000000000000000000000000000", + "t": "T-shirt with Zano logo, made by Crypjunkie", + "timestamp": 1570219840, + "tx_hash": "2987b671cc337203628a3a1bb7ac811e41f110864d6162d3c2276d2c79f694d6", + "tx_original_hash": "0000000000000000000000000000000000000000000000000000000000000000" + }], + "status": "", + "total_offers": 0 + } +} \ No newline at end of file diff --git a/utils/test_api_files/COMMAND_MARKETPLACE_PUSH_OFFER_request.json b/utils/test_api_files/COMMAND_MARKETPLACE_PUSH_OFFER_request.json new file mode 100644 index 00000000..6b1230be --- /dev/null +++ b/utils/test_api_files/COMMAND_MARKETPLACE_PUSH_OFFER_request.json @@ -0,0 +1,23 @@ +{ + "jsonrpc": "2.0", + "id": 0, + "method": "marketplace_push_offer", + "params": { + "od": { + "ap": "20", + "at": "1", + "cat": "CLS:MAN:TSH", + "cnt": "Skype: some_skype, discord: some_user#01012", + "com": "Some nice comments about tshirt", + "do": "Additional conditions", + "et": 10, + "fee": 10000000000, + "lci": "", + "lco": "World Wide", + "ot": 1, + "p": "USD", + "pt": "Credit cards, BTC, ZANO, ETH", + "t": "T-shirt with Zano logo, made by Crypjunkie[4]" + } + } +} \ No newline at end of file diff --git a/utils/test_api_files/COMMAND_MARKETPLACE_PUSH_OFFER_request_2.json b/utils/test_api_files/COMMAND_MARKETPLACE_PUSH_OFFER_request_2.json new file mode 100644 index 00000000..8a17821d --- /dev/null +++ b/utils/test_api_files/COMMAND_MARKETPLACE_PUSH_OFFER_request_2.json @@ -0,0 +1,23 @@ +{ + "jsonrpc": "2.0", + "id": 0, + "method": "marketplace_push_offer", + "params": { + "od": { + "ap": "10000", + "at": "1", + "cat": "HRD:MIN", + "cnt": "Skype: some_skype, discord: some_user#01012", + "com": "Some nice comments about farm", + "do": "Additional conditions", + "et": 10, + "fee": 10000000000, + "lci": "", + "lco": "World Wide", + "ot": 1, + "p": "USD", + "pt": "Credit cards, BTC, ZANO, ETH", + "t": "Mining farm built by Gigabyted" + } + } +} \ No newline at end of file diff --git a/utils/test_api_files/COMMAND_MARKETPLACE_PUSH_OFFER_response.json b/utils/test_api_files/COMMAND_MARKETPLACE_PUSH_OFFER_response.json new file mode 100644 index 00000000..ee0a2546 --- /dev/null +++ b/utils/test_api_files/COMMAND_MARKETPLACE_PUSH_OFFER_response.json @@ -0,0 +1,17 @@ +{ + "id": 0, + "jsonrpc": "2.0", + "result": { + "tx_blob_size": 549, + "tx_hash": "2987b671cc337203628a3a1bb7ac811e41f110864d6162d3c2276d2c79f694d6" + } +} +-----[2] +{ + "id": 0, + "jsonrpc": "2.0", + "result": { + "tx_blob_size": 552, + "tx_hash": "1ca72152db6b962e473a0f838c281c902b7e1ed79c0a762bdb197ccf7f4ab2d5" + } +} diff --git a/utils/test_api_files/COMMAND_MARKETPLACE_PUSH_UPDATE_OFFER_request.json b/utils/test_api_files/COMMAND_MARKETPLACE_PUSH_UPDATE_OFFER_request.json new file mode 100644 index 00000000..d889eed4 --- /dev/null +++ b/utils/test_api_files/COMMAND_MARKETPLACE_PUSH_UPDATE_OFFER_request.json @@ -0,0 +1,25 @@ +{ + "jsonrpc": "2.0", + "id": 0, + "method": "marketplace_push_update_offer", + "params": { + "no": 0, + "tx_id": "2987b671cc337203628a3a1bb7ac811e41f110864d6162d3c2276d2c79f694d6", + "od": { + "ap": "20", + "at": "1", + "cat": "CLS:MAN:TSH", + "cnt": "Skype: some_skype, discord: some_user#01012", + "com": "Some nice comments about tshirt", + "do": "Additional conditions", + "et": 10, + "fee": 10000000000, + "lci": "", + "lco": "World Wide", + "ot": 1, + "p": "USD", + "pt": "Credit cards, BTC, ZANO, ETH", + "t": "T-shirt with Zano logo, made by Crypjunkie[updated]" + } + } +} \ No newline at end of file diff --git a/utils/test_api_files/COMMAND_MARKETPLACE_PUSH_UPDATE_OFFER_response.json b/utils/test_api_files/COMMAND_MARKETPLACE_PUSH_UPDATE_OFFER_response.json new file mode 100644 index 00000000..a2a9bfb8 --- /dev/null +++ b/utils/test_api_files/COMMAND_MARKETPLACE_PUSH_UPDATE_OFFER_response.json @@ -0,0 +1,8 @@ +{ + "id": 0, + "jsonrpc": "2.0", + "result": { + "tx_blob_size": 725, + "tx_hash": "06da9bac0f15fd7ab41983f9437f95835b1baef6810fe15b2ea831f60b058b4b" + } +} \ No newline at end of file