diff --git a/plugins/chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp b/plugins/chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp index 377adb00ae..cdf1ae97a7 100644 --- a/plugins/chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp +++ b/plugins/chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp @@ -479,7 +479,7 @@ class read_only { get_scheduled_transactions_result get_scheduled_transactions( const get_scheduled_transactions_params& params, const fc::time_point& deadline ) const; struct compute_transaction_results { chain::transaction_id_type transaction_id; - fc::variant processed; + fc::variant processed; // "processed" is expected JSON for trxs in cleos }; struct compute_transaction_params { @@ -738,7 +738,7 @@ class read_write { using push_transaction_params = fc::variant_object; struct push_transaction_results { chain::transaction_id_type transaction_id; - fc::variant processed; + fc::variant processed; // "processed" is expected JSON for trxs in cleos }; void push_transaction(const push_transaction_params& params, chain::plugin_interface::next_function next); diff --git a/programs/cleos/main.cpp b/programs/cleos/main.cpp index 53b127eabb..39ae27fca7 100644 --- a/programs/cleos/main.cpp +++ b/programs/cleos/main.cpp @@ -181,6 +181,7 @@ bool print_request = false; bool print_response = false; bool no_auto_keosd = false; bool verbose = false; +int return_code = 0; uint8_t tx_max_cpu_usage = 0; uint32_t tx_max_net_usage = 0; @@ -622,6 +623,32 @@ void print_action_tree( const fc::variant& action ) { } } +int get_return_code( const fc::variant& result ) { + // if a trx with a processed, then check to see if it failed execution for return value + int r = 0; + if (result.is_object() && result.get_object().contains("processed")) { + const auto& processed = result["processed"]; + if( processed.is_object() && processed.get_object().contains( "except" ) ) { + const auto& except = processed["except"]; + if( except.is_object() ) { + try { + auto soft_except = except.as(); + auto code = soft_except.code(); + if( code > std::numeric_limits::max() ) { + r = 1; + } else { + r = static_cast( code ); + } + if( r == 0 ) r = 1; + } catch( ... ) { + r = 1; + } + } + } + } + return r; +} + void print_result( const fc::variant& result ) { try { if (result.is_object() && result.get_object().contains("processed")) { const auto& processed = result["processed"]; @@ -685,6 +712,7 @@ void send_actions(std::vector&& actions, const std::vector