Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Add REX balance info to cleos get account command #7315

Merged
merged 1 commit into from
May 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions plugins/chain_plugin/chain_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2233,6 +2233,17 @@ read_only::get_account_results read_only::get_account( const get_account_params&
result.voter_info = abis.binary_to_variant( "voter_info", data, abi_serializer_max_time, shorten_abi_errors );
}
}

t_id = d.find<chain::table_id_object, chain::by_code_scope_table>(boost::make_tuple( config::system_account_name, config::system_account_name, N(rexbal) ));
if (t_id != nullptr) {
const auto &idx = d.get_index<key_value_index, by_scope_primary>();
auto it = idx.find(boost::make_tuple( t_id->id, params.account_name ));
if( it != idx.end() ) {
vector<char> data;
copy_inline_row(*it, data);
result.rex_info = abis.binary_to_variant( "rex_balance", data, abi_serializer_max_time, shorten_abi_errors );
}
}
}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ class read_only {
fc::variant self_delegated_bandwidth;
fc::variant refund_request;
fc::variant voter_info;
fc::variant rex_info;
};

struct get_account_params {
Expand Down Expand Up @@ -760,7 +761,7 @@ FC_REFLECT( eosio::chain_apis::read_only::get_scheduled_transactions_result, (tr
FC_REFLECT( eosio::chain_apis::read_only::get_account_results,
(account_name)(head_block_num)(head_block_time)(privileged)(last_code_update)(created)
(core_liquid_balance)(ram_quota)(net_weight)(cpu_weight)(net_limit)(cpu_limit)(ram_usage)(permissions)
(total_resources)(self_delegated_bandwidth)(refund_request)(voter_info) )
(total_resources)(self_delegated_bandwidth)(refund_request)(voter_info)(rex_info) )
// @swap code_hash
FC_REFLECT( eosio::chain_apis::read_only::get_code_results, (account_name)(code_hash)(wast)(wasm)(abi) )
FC_REFLECT( eosio::chain_apis::read_only::get_code_hash_results, (account_name)(code_hash) )
Expand Down
12 changes: 12 additions & 0 deletions programs/cleos/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2288,6 +2288,18 @@ void get_account( const string& accountName, const string& coresym, bool json_fo
std::cout << std::endl;
}

if( res.rex_info.is_object() ) {
auto& obj = res.rex_info.get_object();
asset vote_stake = asset::from_string( obj["vote_stake"].as_string() );
asset rex_balance = asset::from_string( obj["rex_balance"].as_string() );
std::cout << rex_balance.get_symbol().name() << " balances: " << std::endl;
std::cout << indent << std::left << std::setw(11)
<< "balance:" << std::right << std::setw(18) << rex_balance << std::endl;
std::cout << indent << std::left << std::setw(11)
<< "staked:" << std::right << std::setw(18) << vote_stake << std::endl;
std::cout << std::endl;
}

if ( res.voter_info.is_object() ) {
auto& obj = res.voter_info.get_object();
string proxy = obj["proxy"].as_string();
Expand Down