Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
get_transaction_id_subcommand Struct Reference

Public Member Functions

 get_transaction_id_subcommand (CLI::App *actionRoot)
 

Public Attributes

string trx_to_check
 

Detailed Description

Definition at line 1464 of file main.cpp.

Constructor & Destructor Documentation

◆ get_transaction_id_subcommand()

get_transaction_id_subcommand::get_transaction_id_subcommand ( CLI::App * actionRoot)
inline

Definition at line 1467 of file main.cpp.

1467 {
1468 auto get_transaction_id = actionRoot->add_subcommand("transaction_id", localized("Get transaction id given transaction object"));
1469 get_transaction_id->add_option("transaction", trx_to_check, localized("The JSON string or filename defining the transaction which transaction id we want to retrieve"))->required();
1470
1471 get_transaction_id->callback([&] {
1472 try {
1474 if( trx_var.is_object() ) {
1475 fc::variant_object& vo = trx_var.get_object();
1476 // if actions.data & actions.hex_data provided, use the hex_data since only currently support unexploded data
1477 if( vo.contains("actions") ) {
1478 if( vo["actions"].is_array() ) {
1480 fc::variants& action_variants = mvo["actions"].get_array();
1481 for( auto& action_v : action_variants ) {
1482 if( !action_v.is_object() ) {
1483 std::cerr << "Empty 'action' in transaction" << endl;
1484 return;
1485 }
1486 fc::variant_object& action_vo = action_v.get_object();
1487 if( action_vo.contains( "data" ) && action_vo.contains( "hex_data" ) ) {
1488 fc::mutable_variant_object maction_vo = action_vo;
1489 maction_vo["data"] = maction_vo["hex_data"];
1490 action_vo = maction_vo;
1491 vo = mvo;
1492 } else if( action_vo.contains( "data" ) ) {
1493 if( !action_vo["data"].is_string() ) {
1494 std::cerr << "get transaction_id only supports un-exploded 'data' (hex form)" << std::endl;
1495 return;
1496 }
1497 }
1498 }
1499 } else {
1500 std::cerr << "transaction JSON 'actions' is not an array" << std::endl;
1501 return;
1502 }
1503 } else {
1504 std::cerr << "transaction JSON does not include 'actions'" << std::endl;
1505 return;
1506 }
1507 auto trx = trx_var.as<transaction>();
1508 transaction_id_type id = trx.id();
1509 if( id == transaction().id() ) {
1510 std::cerr << "file/string does not represent a transaction" << std::endl;
1511 } else {
1512 std::cout << string( id ) << std::endl;
1513 }
1514 } else {
1515 std::cerr << "file/string does not represent a transaction" << std::endl;
1516 }
1517 } SYS_RETHROW_EXCEPTIONS(transaction_type_exception, "Fail to parse transaction JSON '${data}'", ("data",trx_to_check))
1518 });
1519 }
#define SYS_RETHROW_EXCEPTIONS(exception_type, FORMAT,...)
App * add_subcommand(std::string subcommand_name="", std::string subcommand_description="")
Add a subcommand. Inherits INHERITABLE and OptionDefaults, and help flag.
Definition CLI11.hpp:5538
Option * add_option(std::string option_name, callback_t option_callback, std::string option_description="", bool defaulted=false, std::function< std::string()> func={})
Definition CLI11.hpp:5099
CRTP * required(bool value=true)
Set the option as required.
Definition CLI11.hpp:3400
An order-preserving dictionary of variants.
An order-preserving dictionary of variants.
bool contains(const char *key) const
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object's.
Definition variant.hpp:191
variant_object & get_object()
Definition variant.cpp:554
T as() const
Definition variant.hpp:327
bool is_object() const
Definition variant.cpp:363
#define localized(str,...)
Definition localize.hpp:10
std::string string
Definition string.hpp:10
std::vector< fc::variant > variants
Definition variant.hpp:173
fc::variant json_from_file_or_string(const string &file_or_str, fc::json::parse_type ptype=fc::json::parse_type::legacy_parser)
Definition main.cpp:509
Here is the call graph for this function:

Member Data Documentation

◆ trx_to_check

string get_transaction_id_subcommand::trx_to_check

Definition at line 1465 of file main.cpp.


The documentation for this struct was generated from the following file: