cli_wallet: Implement approve_proposal to more easily approve proposals
This commit is contained in:
parent
1d2dc6abda
commit
d1484fb41e
2 changed files with 78 additions and 2 deletions
|
|
@ -203,6 +203,16 @@ struct exported_keys
|
|||
vector<exported_account_keys> account_keys;
|
||||
};
|
||||
|
||||
struct approval_delta
|
||||
{
|
||||
vector<string> active_approvals_to_add;
|
||||
vector<string> active_approvals_to_remove;
|
||||
vector<string> owner_approvals_to_add;
|
||||
vector<string> owner_approvals_to_remove;
|
||||
vector<string> key_approvals_to_add;
|
||||
vector<string> key_approvals_to_remove;
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
class wallet_api_impl;
|
||||
}
|
||||
|
|
@ -1211,11 +1221,25 @@ class wallet_api
|
|||
const variant_object& changed_values,
|
||||
bool broadcast = false);
|
||||
|
||||
/** Approve or disapprove a proposal.
|
||||
*
|
||||
* @param fee_paying_account The account paying the fee for the op.
|
||||
* @param proposal_id The proposal to modify.
|
||||
* @param delta Members contain approvals to create or remove. In JSON you can leave empty members undefined.
|
||||
* @param broadcast true if you wish to broadcast the transaction
|
||||
* @return the signed version of the transaction
|
||||
*/
|
||||
signed_transaction approve_proposal(
|
||||
const string& fee_paying_account,
|
||||
const string& proposal_id,
|
||||
const approval_delta& delta,
|
||||
bool broadcast /* = false */
|
||||
);
|
||||
|
||||
void dbg_make_uia(string creator, string symbol);
|
||||
void dbg_make_mia(string creator, string symbol);
|
||||
void flood_network(string prefix, uint32_t number_of_transactions);
|
||||
|
||||
|
||||
/**
|
||||
* Used to transfer from one set of blinded balances to another
|
||||
*/
|
||||
|
|
@ -1269,6 +1293,15 @@ FC_REFLECT( graphene::wallet::exported_keys, (password_checksum)(account_keys) )
|
|||
FC_REFLECT( graphene::wallet::blind_receipt,
|
||||
(date)(from_key)(from_label)(to_key)(to_label)(amount)(memo)(control_authority)(data)(used)(conf) )
|
||||
|
||||
FC_REFLECT( graphene::wallet::approval_delta,
|
||||
(active_approvals_to_add)
|
||||
(active_approvals_to_remove)
|
||||
(owner_approvals_to_add)
|
||||
(owner_approvals_to_remove)
|
||||
(key_approvals_to_add)
|
||||
(key_approvals_to_remove)
|
||||
)
|
||||
|
||||
FC_API( graphene::wallet::wallet_api,
|
||||
(help)
|
||||
(gethelp)
|
||||
|
|
@ -1344,6 +1377,7 @@ FC_API( graphene::wallet::wallet_api,
|
|||
(get_prototype_operation)
|
||||
(propose_parameter_change)
|
||||
(propose_fee_change)
|
||||
(approve_proposal)
|
||||
(dbg_make_uia)
|
||||
(dbg_make_mia)
|
||||
(flood_network)
|
||||
|
|
@ -1360,4 +1394,3 @@ FC_API( graphene::wallet::wallet_api,
|
|||
(blind_history)
|
||||
(receive_blind_transfer)
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -1879,6 +1879,39 @@ public:
|
|||
FC_ASSERT( false, "not implemented" );
|
||||
}
|
||||
|
||||
signed_transaction approve_proposal(
|
||||
const string& fee_paying_account,
|
||||
const string& proposal_id,
|
||||
const approval_delta& delta,
|
||||
bool broadcast = false)
|
||||
{
|
||||
proposal_update_operation update_op;
|
||||
|
||||
update_op.fee_paying_account = get_account(fee_paying_account).id;
|
||||
update_op.proposal = fc::variant(proposal_id).as<proposal_id_type>();
|
||||
// make sure the proposal exists
|
||||
get_object( update_op.proposal );
|
||||
|
||||
for( const std::string& name : delta.active_approvals_to_add )
|
||||
update_op.active_approvals_to_add.insert( get_account( name ).id );
|
||||
for( const std::string& name : delta.active_approvals_to_remove )
|
||||
update_op.active_approvals_to_remove.insert( get_account( name ).id );
|
||||
for( const std::string& name : delta.owner_approvals_to_add )
|
||||
update_op.owner_approvals_to_add.insert( get_account( name ).id );
|
||||
for( const std::string& name : delta.owner_approvals_to_remove )
|
||||
update_op.owner_approvals_to_remove.insert( get_account( name ).id );
|
||||
for( const std::string& k : delta.key_approvals_to_add )
|
||||
update_op.key_approvals_to_add.insert( public_key_type( k ) );
|
||||
for( const std::string& k : delta.key_approvals_to_remove )
|
||||
update_op.key_approvals_to_remove.insert( public_key_type( k ) );
|
||||
|
||||
signed_transaction tx;
|
||||
tx.operations.push_back(update_op);
|
||||
set_operation_fees(tx, get_global_properties().parameters.current_fees);
|
||||
tx.validate();
|
||||
return sign_transaction(tx, broadcast);
|
||||
}
|
||||
|
||||
void dbg_make_uia(string creator, string symbol)
|
||||
{
|
||||
asset_options opts;
|
||||
|
|
@ -2615,6 +2648,16 @@ signed_transaction wallet_api::propose_fee_change(
|
|||
return my->propose_fee_change( proposing_account, changed_values, broadcast );
|
||||
}
|
||||
|
||||
signed_transaction wallet_api::approve_proposal(
|
||||
const string& fee_paying_account,
|
||||
const string& proposal_id,
|
||||
const approval_delta& delta,
|
||||
bool broadcast /* = false */
|
||||
)
|
||||
{
|
||||
return my->approve_proposal( fee_paying_account, proposal_id, delta, broadcast );
|
||||
}
|
||||
|
||||
global_property_object wallet_api::get_global_properties() const
|
||||
{
|
||||
return my->get_global_properties();
|
||||
|
|
|
|||
Loading…
Reference in a new issue