Skip to content

Commit

Permalink
Add GetTransactions to cli
Browse files Browse the repository at this point in the history
Signed-off-by: motxx <[email protected]>
  • Loading branch information
motxx committed Dec 18, 2017
1 parent 25c9012 commit ed418ca
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
21 changes: 21 additions & 0 deletions iroha-cli/interactive/impl/interactive_query_cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include <fstream>

#include "byteutils.hpp"
#include "client.hpp"
#include "crypto/crypto.hpp"
#include "crypto/hash.hpp"
Expand All @@ -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"},
Expand All @@ -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}},
Expand All @@ -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},
Expand Down Expand Up @@ -167,6 +172,22 @@ namespace iroha_cli {
local_time_, creator_, counter_, account_id);
}

std::shared_ptr<iroha::model::Query>
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<GetTransactions::TxHashType::size()>(hexhash)) {
tx_hashes.push_back(*opt);
}
}
return generator_.generateGetTransactions(
local_time_, creator_, counter_, tx_hashes);
}

std::shared_ptr<iroha::model::Query>
InteractiveQueryCli::parseGetSignatories(QueryParams params) {
auto account_id = params[0];
Expand Down
3 changes: 3 additions & 0 deletions iroha-cli/interactive/interactive_query_cli.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -96,6 +97,8 @@ namespace iroha_cli {
QueryParams params);
std::shared_ptr<iroha::model::Query> parseGetAccountTransactions(
QueryParams params);
std::shared_ptr<iroha::model::Query> parseGetTransactions(
QueryParams params);
std::shared_ptr<iroha::model::Query> parseGetSignatories(
QueryParams params);
std::shared_ptr<iroha::model::Query> parseGetRoles(QueryParams params);
Expand Down

0 comments on commit ed418ca

Please sign in to comment.