Add wallet command for custom_operation
Create a new cli_wallet command, run_custom_operation, which makes it convenient to run custom_operation transactions which invoke third party contracts (i.e., dapps)
This commit is contained in:
parent
de87e1b82c
commit
d17eb5ec72
2 changed files with 29 additions and 0 deletions
|
|
@ -2386,6 +2386,9 @@ class wallet_api
|
|||
bool broadcast);
|
||||
vector<account_role_object> get_account_roles_by_owner(string owner_account_id_or_name) const;
|
||||
|
||||
signed_transaction run_custom_operation(string payer_id_or_name, std::vector<string> required_auths,
|
||||
string data, uint16_t id=0, bool broadcast=false);
|
||||
|
||||
void dbg_make_uia(string creator, string symbol);
|
||||
void dbg_make_mia(string creator, string symbol);
|
||||
void dbg_push_blocks( std::string src_filename, uint32_t count );
|
||||
|
|
@ -2709,4 +2712,5 @@ FC_API( graphene::wallet::wallet_api,
|
|||
(get_custom_account_authorities_by_permission_id)
|
||||
(get_custom_account_authorities_by_permission_name)
|
||||
(get_active_custom_account_authorities_by_operation)
|
||||
(run_custom_operation)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -7340,6 +7340,31 @@ vector<account_role_object> wallet_api::get_account_roles_by_owner(string owner_
|
|||
account_object owner_account = my->get_account(owner_account_id_or_name);
|
||||
return my->_remote_db->get_account_roles_by_owner(owner_account.id);
|
||||
}
|
||||
|
||||
signed_transaction wallet_api::run_custom_operation(string payer_id_or_name, std::vector<string> required_auths, string data, uint16_t id, bool broadcast)
|
||||
{
|
||||
account_object payer = my->get_account(payer_id_or_name);
|
||||
custom_operation op;
|
||||
|
||||
// FC offers no way to have quotes in the data string. Add a simple escape option.
|
||||
boost::replace_all(data, "\\\"", "\"");
|
||||
boost::replace_all(data, "\\\\", "\\");
|
||||
|
||||
op.payer = payer.get_id();
|
||||
if (!required_auths.empty())
|
||||
std::transform(required_auths.begin(), required_auths.end(), std::inserter(op.required_auths, op.required_auths.begin()),
|
||||
[&my=my](const string& name_or_id) { return my->get_account(name_or_id).get_id(); });
|
||||
op.id = id;
|
||||
op.data.reserve(data.size());
|
||||
op.data.assign(data.begin(), data.end());
|
||||
|
||||
signed_transaction trx;
|
||||
trx.operations = {std::move(op)};
|
||||
my->set_operation_fees(trx, my->_remote_db->get_global_properties().parameters.current_fees);
|
||||
trx.validate();
|
||||
|
||||
return my->sign_transaction(std::move(trx), broadcast);
|
||||
}
|
||||
// default ctor necessary for FC_REFLECT
|
||||
signed_block_with_info::signed_block_with_info()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue