diff --git a/plugins/chain_plugin/chain_plugin.cpp b/plugins/chain_plugin/chain_plugin.cpp index 91d130d3ec5..b6127a97328 100644 --- a/plugins/chain_plugin/chain_plugin.cpp +++ b/plugins/chain_plugin/chain_plugin.cpp @@ -1806,6 +1806,27 @@ read_only::get_account_results read_only::get_account( const get_account_params& } } } + + //get homepage + const auto& personal_account = db.db().get( N(personal.bos) ); + abi_def abi_personal; + if( abi_serializer::to_abi(personal_account.abi, abi_personal) ) { + abi_serializer abis_personal( abi_personal, abi_serializer_max_time ); + const auto* t_id = d.find(boost::make_tuple( N(personal.bos), params.account_name, N(personaldata) )); + if (t_id != nullptr) { + const auto &idx = d.get_index(); + + name key_name{"homepage"}; + auto it = idx.find(boost::make_tuple( t_id->id, key_name.value )); + if ( it != idx.end() ) { + vector data; + copy_inline_row(*it, data); + variant raw_data= abis_personal.binary_to_variant( "personal", data, abi_serializer_max_time, shorten_abi_errors ); + result.homepage=raw_data["value"].as_string(); + } + } + } + return result; } 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 4a41d99455c..aa493e045fd 100644 --- a/plugins/chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp +++ b/plugins/chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp @@ -138,6 +138,7 @@ class read_only { fc::variant self_delegated_bandwidth; fc::variant refund_request; fc::variant voter_info; + string homepage; }; struct get_account_params { @@ -734,7 +735,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)(homepage) ) 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) ) FC_REFLECT( eosio::chain_apis::read_only::get_abi_results, (account_name)(abi) ) diff --git a/programs/cleos/main.cpp b/programs/cleos/main.cpp index bc9373b84a1..e1047613e24 100644 --- a/programs/cleos/main.cpp +++ b/programs/cleos/main.cpp @@ -851,6 +851,36 @@ struct set_action_permission_subcommand { } }; +struct set_personal_subcommand { + string accountStr; + string keyStr; + string valueStr; + + set_personal_subcommand(CLI::App* actionRoot) { + auto personal = actionRoot->add_subcommand("personal", localized("set personal data for account")); + personal->add_option("account", accountStr, localized("the account to set personal data for"))->required(); + personal->add_option("key", keyStr, localized("the key of personal data"))->required(); + personal->add_option("value", valueStr, localized("the value of personal data"))->required(); + + add_standard_transaction_options(personal, "account@active"); + + personal->set_callback([this] { + name account = name(accountStr); + auto action_var = fc::mutable_variant_object() + ("account", account) + ("key", keyStr) + ("value", valueStr); + + send_actions( + {create_action( + {permission_level{account,config::active_name}}, + N(personal.bos), + N(setpersonal), + action_var) + }); + }); + } +}; bool local_port_used() { using namespace boost::asio; @@ -1845,6 +1875,12 @@ void get_account( const string& accountName, const string& coresym, bool json_fo std::cout << "proxy:" << indent << proxy << std::endl; } } + + if( res.homepage.size() > 0 ){ + std::cout <<"homepage:"; + std::cout << indent << res.homepage << std::endl; + } + std::cout << std::endl; } else { std::cout << fc::json::to_pretty_string(json) << std::endl; @@ -2603,6 +2639,9 @@ int main( int argc, char** argv ) { // set action permission auto setActionPermission = set_action_permission_subcommand(setAction); + //set personal + auto setPersonal = set_personal_subcommand(setSubcommand); + // Transfer subcommand string con = "eosio.token"; string sender;