31 namespace graphene {
namespace wallet {
namespace detail {
33 template<
typename WorkerInit>
34 static WorkerInit _create_worker_initializer(
const variant& worker_settings )
50 flat_set< worker_id_type > merged;
52 for(
const worker_id_type& wid : delta.
vote_for )
54 bool inserted = merged.insert( wid ).second;
55 FC_ASSERT( inserted,
"worker ${wid} specified multiple times", (
"wid", wid) );
59 bool inserted = merged.insert( wid ).second;
60 FC_ASSERT( inserted,
"worker ${wid} specified multiple times", (
"wid", wid) );
64 bool inserted = merged.insert( wid ).second;
65 FC_ASSERT( inserted,
"worker ${wid} specified multiple times", (
"wid", wid) );
71 vector< object_id_type > query_ids;
72 for(
const worker_id_type& wid : merged )
78 for(
const variant& obj : objects )
81 worker_id_type wo_id { wo.
id };
112 committee_member_create_op.
url = url;
113 if (
_remote_db->get_committee_member_by_account(owner_account))
114 FC_THROW(
"Account ${owner_account} is already a committee_member", (
"owner_account", owner_account));
117 tx.
operations.push_back( committee_member_create_op );
131 std::vector<witness_id_type> ids_to_get;
132 ids_to_get.push_back(*witness_id);
133 std::vector<fc::optional<witness_object>> witness_objects =
_remote_db->get_witnesses(ids_to_get);
134 if (witness_objects.front())
135 return *witness_objects.front();
136 FC_THROW(
"No witness is registered for id ${id}", (
"id", owner_account));
143 auto owner_account_id = std::string(
get_account_id(owner_account));
148 FC_THROW(
"No witness is registered for account ${account}", (
"account", owner_account));
152 FC_THROW(
"No account or witness named ${account}", (
"account", owner_account));
164 maybe_id<committee_member_id_type>(owner_account);
165 if (committee_member_id)
167 std::vector<committee_member_id_type> ids_to_get;
168 ids_to_get.push_back(*committee_member_id);
169 std::vector<fc::optional<committee_member_object>> committee_member_objects =
170 _remote_db->get_committee_members(ids_to_get);
171 if (committee_member_objects.front())
172 return *committee_member_objects.front();
173 FC_THROW(
"No committee_member is registered for id ${id}", (
"id", owner_account));
181 _remote_db->get_committee_member_by_account(owner_account);
182 if (committee_member)
183 return *committee_member;
185 FC_THROW(
"No committee_member is registered for account ${account}", (
"account", owner_account));
189 FC_THROW(
"No account or committee_member named ${account}", (
"account", owner_account));
197 string url,
bool broadcast )
201 int witness_key_index = find_first_unused_derived_key_index(active_private_key);
209 witness_create_op.
url = url;
212 FC_THROW(
"Account ${owner_account} is already a witness", (
"owner_account", owner_account));
225 string block_signing_key,
bool broadcast )
234 witness_update_op.
new_url = url;
235 if( block_signing_key !=
"" )
247 time_point_sec work_end_date,
share_type daily_pay,
string name,
string url,
248 variant worker_settings,
bool broadcast)
251 std::string wtype = worker_settings[
"type"].
get_string();
254 if( wtype ==
"burn" )
255 init = _create_worker_initializer< burn_worker_initializer >( worker_settings );
256 else if( wtype ==
"refund" )
257 init = _create_worker_initializer< refund_worker_initializer >( worker_settings );
258 else if( wtype ==
"vesting" )
259 init = _create_worker_initializer< vesting_balance_worker_initializer >( worker_settings );
262 FC_ASSERT(
false,
"unknown worker[\"type\"] value" );
283 string committee_member,
bool approve,
bool broadcast )
287 _remote_db->get_committee_member_by_account(committee_member);
288 if (!committee_member_obj)
289 FC_THROW(
"Account ${committee_member} is not registered as a committee_member",
290 (
"committee_member", committee_member));
293 auto insert_result = voting_account_object.
options.
votes.insert(committee_member_obj->
vote_id);
294 if (!insert_result.second)
295 FC_THROW(
"Account ${account} was already voting for committee_member ${committee_member}",
296 (
"account", voting_account)(
"committee_member", committee_member));
300 auto votes_removed = voting_account_object.
options.
votes.erase(committee_member_obj->
vote_id);
301 if( 0 == votes_removed )
302 FC_THROW(
"Account ${account} is already not voting for committee_member ${committee_member}",
303 (
"account", voting_account)(
"committee_member", committee_member));
306 account_update_op.
account = voting_account_object.
id;
318 bool approve,
bool broadcast )
324 FC_THROW(
"Account ${witness} is not registered as a witness", (
"witness",
witness));
328 if (!insert_result.second)
329 FC_THROW(
"Account ${account} was already voting for witness ${witness}",
330 (
"account", voting_account)(
"witness",
witness));
335 if( 0 == votes_removed )
336 FC_THROW(
"Account ${account} is already not voting for witness ${witness}",
337 (
"account", voting_account)(
"witness",
witness));
340 account_update_op.
account = voting_account_object.
id;
357 account_id_type new_voting_account_id =
get_account_id(*voting_account);
359 FC_THROW(
"Voting proxy for ${account} is already set to ${voter}",
360 (
"account", account_to_modify)(
"voter", *voting_account));
366 FC_THROW(
"Account ${account} is already voting for itself", (
"account", account_to_modify));
371 account_update_op.
account = account_object_to_modify.
id;
383 string account_to_modify, uint16_t desired_number_of_witnesses, uint16_t desired_number_of_committee_members,
390 FC_THROW(
"Account ${account} is already voting for ${witnesses} witnesses"
391 " and ${committee_members} committee_members",
392 (
"account", account_to_modify)(
"witnesses", desired_number_of_witnesses)
393 (
"committee_members",desired_number_of_witnesses));
398 account_update_op.
account = account_object_to_modify.
id;
408 (desired_number_of_committee_members)(broadcast) ) }
411 fc::time_point_sec expiration_time,
const variant_object& changed_values,
bool broadcast )
413 FC_ASSERT( !changed_values.contains(
"current_fees") );
442 fc::time_point_sec expiration_time,
const variant_object& changed_fees,
bool broadcast )
447 flat_map< int, fee_parameters > fee_map;
448 fee_map.reserve( current_fees.
parameters.size() );
450 fee_map[ op_fee.which() ] = op_fee;
451 uint32_t scale = current_fees.
scale;
453 for(
const auto& item : changed_fees )
455 const string& key = item.key();
458 int64_t _scale = item.value().as_int64();
460 FC_ASSERT( _scale <= std::numeric_limits<uint32_t>::max() );
461 scale = uint32_t( _scale );
465 auto is_numeric = [&key]() ->
bool
467 size_t n = key.size();
468 for(
size_t i=0; i<n; i++ )
470 if( 0 == isdigit( key[i] ) )
478 which = std::stoi( key );
482 auto it = n2w.find( key );
483 FC_ASSERT( it != n2w.end(),
"unknown operation" );
488 fee_map[ which ] = fp;
493 for(
const std::pair< int, fee_parameters >& item : fee_map )
495 new_fees.
scale = scale;