Skip to content

Commit

Permalink
[WIP] create account serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilsa authored and lebdron committed Jul 18, 2017
1 parent 2d5e4cb commit 3e57623
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
19 changes: 19 additions & 0 deletions irohad/ametsuchi/impl/block_serializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <model/commands/add_peer.hpp>
#include <model/commands/add_signatory.hpp>
#include <model/commands/assign_master_key.hpp>
#include <model/commands/create_account.hpp>

namespace iroha {
namespace ametsuchi {
Expand Down Expand Up @@ -173,6 +174,24 @@ namespace iroha {
writer.String("pubkey");
writer.String(assign_master_key.pubkey.to_string().c_str());

writer.EndObject();
}
if (instanceof <model::CreateAccount>(&command)) {
auto create_account = static_cast<model::CreateAccount&>(command);
writer.StartObject();

writer.String("command_type");
writer.String("CreateAccount");

writer.String("domain_id");
writer.String(create_account.domain_id.c_str());

writer.String("account_name");
writer.String(create_account.account_name.c_str());

writer.String("pubkey");
writer.String(create_account.pubkey.to_string().c_str());

writer.EndObject();
}
}
Expand Down
8 changes: 8 additions & 0 deletions test/module/irohad/ametsuchi/block_serializer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <model/commands/add_asset_quantity.hpp>
#include <model/commands/add_signatory.hpp>
#include <model/commands/assign_master_key.hpp>
#include <model/commands/create_account.hpp>

iroha::model::Signature create_signature();
iroha::model::Transaction create_transaction();
Expand Down Expand Up @@ -75,6 +76,13 @@ iroha::model::Transaction create_transaction() {
assign_master_key.account_id = "123";
tx.commands.push_back(std::make_shared<iroha::model::AssignMasterKey>(assign_master_key));

//CreateAccount
iroha::model::CreateAccount create_account;
std::fill(create_account.pubkey.begin(), create_account.pubkey.end(), 0x123);
create_account.account_name = "123";
create_account.domain_id = "123";
tx.commands.push_back(std::make_shared<iroha::model::CreateAccount>(create_account));

return tx;
}

Expand Down

0 comments on commit 3e57623

Please sign in to comment.