Skip to content

Commit

Permalink
Add set account key value to cli
Browse files Browse the repository at this point in the history
Signed-off-by: grimadas <[email protected]>
  • Loading branch information
grimadas authored and kamilsa committed Nov 27, 2017
1 parent 1ab6d21 commit 1b2dad1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
30 changes: 22 additions & 8 deletions iroha-cli/interactive/impl/interactive_transaction_cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@
#include "model/commands/create_role.hpp"
#include "model/commands/grant_permission.hpp"
#include "model/commands/revoke_permission.hpp"
#include "model/commands/set_account_detail.hpp"
#include "model/converters/json_common.hpp"
#include "model/converters/json_transaction_factory.hpp"
#include "model/converters/pb_common.hpp"
#include "model/generators/transaction_generator.hpp"
#include "model/permissions.hpp"
#include "parser/parser.hpp"

using namespace iroha::model;

Expand All @@ -53,7 +52,8 @@ namespace iroha_cli {
{CREATE_ROLE, "Create new role"},
{APPEND_ROLE, "Add new role to account"},
{GRANT_PERM, "Grant permission over your account"},
{REVOKE_PERM, "Revoke permission from account"}
{REVOKE_PERM, "Revoke permission from account"},
{SET_ACC_KV, "Set account key/value detail"}
// commands_description_map_
};

Expand Down Expand Up @@ -106,7 +106,8 @@ namespace iroha_cli {
can_create_account}},
{APPEND_ROLE, {acc_id, role}},
{GRANT_PERM, {acc_id, perm}},
{REVOKE_PERM, {acc_id, perm}}
{REVOKE_PERM, {acc_id, perm}},
{SET_ACC_KV, {acc_id, "key", "value"}}
// command parameters descriptions
};

Expand All @@ -125,7 +126,8 @@ namespace iroha_cli {
{CREATE_ROLE, &InteractiveTransactionCli::parseCreateRole},
{APPEND_ROLE, &InteractiveTransactionCli::parseAppendRole},
{GRANT_PERM, &InteractiveTransactionCli::parseGrantPermission},
{REVOKE_PERM, &InteractiveTransactionCli::parseGrantPermission}
{REVOKE_PERM, &InteractiveTransactionCli::parseGrantPermission},
{SET_ACC_KV, &InteractiveTransactionCli::parseSetAccountDetail}
// Command parsers
};

Expand Down Expand Up @@ -236,9 +238,12 @@ namespace iroha_cli {
auto create_account = parser::parseValue<bool>(params[8]);

if (not read_self.has_value() or not edit_self.has_value()
or not read_all.has_value() or not transfer_receive.has_value()
or not asset_create.has_value() or not create_domain.has_value()
or not roles.has_value() or not create_account.has_value()) {
or not read_all.has_value()
or not transfer_receive.has_value()
or not asset_create.has_value()
or not create_domain.has_value()
or not roles.has_value()
or not create_account.has_value()) {
std::cout << "Wrong format for permission" << std::endl;
return nullptr;
}
Expand Down Expand Up @@ -418,6 +423,15 @@ namespace iroha_cli {
src_account_id, dest_account_id, asset_id, amount);
}

std::shared_ptr<iroha::model::Command>
InteractiveTransactionCli::parseSetAccountDetail(
std::vector<std::string> params) {
auto account_id = params[0];
auto key = params[1];
auto value = params[2];
return std::make_shared<SetAccountDetail>(account_id, key, value);
}

// --------- Result parsers -------------

bool InteractiveTransactionCli::parseResult(std::string line) {
Expand Down
3 changes: 3 additions & 0 deletions iroha-cli/interactive/interactive_transaction_cli.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ namespace iroha_cli {
const std::string CREATE_DOMAIN = "crt_dmn";
const std::string REMOVE_SIGN = "rem_sign";
const std::string SET_QUO = "set_qrm";
const std::string SET_ACC_KV = "set_acc_kv";
const std::string SUB_ASSET_QTY = "sub_ast_qty";
const std::string TRAN_ASSET = "tran_ast";

Expand Down Expand Up @@ -117,6 +118,8 @@ namespace iroha_cli {
std::vector<std::string> line);
std::shared_ptr<iroha::model::Command> parseSetQuorum(
std::vector<std::string> line);
std::shared_ptr<iroha::model::Command> parseSetAccountDetail(
std::vector<std::string> line);
std::shared_ptr<iroha::model::Command> parseSubtractAssetQuantity(
std::vector<std::string> line);
std::shared_ptr<iroha::model::Command> parseTransferAsset(
Expand Down

0 comments on commit 1b2dad1

Please sign in to comment.