From ed418cabd5184edebf0850aa9038479ca7bb6feb Mon Sep 17 00:00:00 2001 From: motxx Date: Wed, 22 Nov 2017 20:49:04 +0900 Subject: [PATCH] Add GetTransactions to cli Signed-off-by: motxx --- .../impl/interactive_query_cli.cpp | 21 +++++++++++++++++++ .../interactive/interactive_query_cli.hpp | 3 +++ 2 files changed, 24 insertions(+) diff --git a/iroha-cli/interactive/impl/interactive_query_cli.cpp b/iroha-cli/interactive/impl/interactive_query_cli.cpp index 9bed63f6eb..e5d755970d 100644 --- a/iroha-cli/interactive/impl/interactive_query_cli.cpp +++ b/iroha-cli/interactive/impl/interactive_query_cli.cpp @@ -19,6 +19,7 @@ #include +#include "byteutils.hpp" #include "client.hpp" #include "crypto/crypto.hpp" #include "crypto/hash.hpp" @@ -39,6 +40,7 @@ namespace iroha_cli { {GET_ACC, "Get Account Information"}, {GET_ACC_AST, "Get Account's Assets"}, {GET_ACC_TX, "Get Account's Transactions"}, + {GET_TX, "Get Transactions by transactions' hashes"}, {GET_ACC_SIGN, "Get Account's Signatories"}, {GET_ROLES, "Get all current roles in the system"}, {GET_AST_INFO, "Get information about asset"}, @@ -49,11 +51,13 @@ namespace iroha_cli { const auto acc_id = "Requested account Id"; const auto ast_id = "Requested asset Id"; const auto role_id = "Requested role name"; + const auto tx_hashes = "Requested tx hashes"; query_params_descriptions_ = { {GET_ACC, {acc_id}}, {GET_ACC_AST, {acc_id, ast_id}}, {GET_ACC_TX, {acc_id}}, + {GET_TX, {tx_hashes}}, {GET_ACC_SIGN, {acc_id}}, {GET_ROLES, {}}, {GET_AST_INFO, {ast_id}}, @@ -65,6 +69,7 @@ namespace iroha_cli { {GET_ACC, &InteractiveQueryCli::parseGetAccount}, {GET_ACC_AST, &InteractiveQueryCli::parseGetAccountAssets}, {GET_ACC_TX, &InteractiveQueryCli::parseGetAccountTransactions}, + {GET_TX, &InteractiveQueryCli::parseGetTransactions}, {GET_ACC_SIGN, &InteractiveQueryCli::parseGetSignatories}, {GET_ROLE_PERM, &InteractiveQueryCli::parseGetRolePermissions}, {GET_ROLES, &InteractiveQueryCli::parseGetRoles}, @@ -167,6 +172,22 @@ namespace iroha_cli { local_time_, creator_, counter_, account_id); } + std::shared_ptr + InteractiveQueryCli::parseGetTransactions(QueryParams params) { + // TODO 22/11/17 motxx - Parser grammer is obvious for user. + // hash1,hash2,... (without spaces) + std::stringstream ss(params[0]); + GetTransactions::TxHashCollectionType tx_hashes; + for (std::string hexhash; std::getline(ss, hexhash, ',');) { + if (auto opt = + iroha::hexstringToArray(hexhash)) { + tx_hashes.push_back(*opt); + } + } + return generator_.generateGetTransactions( + local_time_, creator_, counter_, tx_hashes); + } + std::shared_ptr InteractiveQueryCli::parseGetSignatories(QueryParams params) { auto account_id = params[0]; diff --git a/iroha-cli/interactive/interactive_query_cli.hpp b/iroha-cli/interactive/interactive_query_cli.hpp index 750b0f0c2f..5096a512f9 100644 --- a/iroha-cli/interactive/interactive_query_cli.hpp +++ b/iroha-cli/interactive/interactive_query_cli.hpp @@ -68,6 +68,7 @@ namespace iroha_cli { const std::string GET_ACC = "get_acc"; const std::string GET_ACC_AST = "get_acc_ast"; const std::string GET_ACC_TX = "get_acc_tx"; + const std::string GET_TX = "get_tx"; const std::string GET_ACC_SIGN = "get_acc_sign"; const std::string GET_ROLES = "get_roles"; const std::string GET_AST_INFO = "get_ast_info"; @@ -96,6 +97,8 @@ namespace iroha_cli { QueryParams params); std::shared_ptr parseGetAccountTransactions( QueryParams params); + std::shared_ptr parseGetTransactions( + QueryParams params); std::shared_ptr parseGetSignatories( QueryParams params); std::shared_ptr parseGetRoles(QueryParams params);