Scorum
scorum_api_objects.hpp
Go to the documentation of this file.
1 #pragma once
17 
20 
22 
24 
26 
27 namespace scorum {
28 namespace app {
29 
30 using namespace scorum::chain;
31 
33 {
34  advertising_property_api_obj(const chain::advertising_property_object& obj);
35 
37  {
38  }
39 
41 
42  std::vector<percent_type> auction_post_coefficients;
43 
44  std::vector<percent_type> auction_banner_coefficients;
45 };
46 
59 
60 struct dynamic_global_property_api_obj : public api_obj<scorum::chain::dynamic_global_property_object>,
61  public api_obj<scorum::witness::reserve_ratio_object>
62 {
63  template <class T> dynamic_global_property_api_obj& operator=(const T& other)
64  {
65  T& base = static_cast<T&>(*this);
66  base = other;
67  return *this;
68  }
69 
70  asset registration_pool_balance = asset(0, SCORUM_SYMBOL);
71  asset fund_budget_balance = asset(0, SP_SYMBOL);
72  asset reward_pool_balance = asset(0, SCORUM_SYMBOL);
73  asset content_reward_scr_balance = asset(0, SCORUM_SYMBOL);
74  asset content_reward_sp_balance = asset(0, SP_SYMBOL);
75 };
76 
78 {
79  account_api_obj(const chain::account_object& a, const chain::database& db);
80 
82  {
83  }
84 
86 
92  std::string json_metadata;
94 
95  time_point_sec last_owner_update;
96  time_point_sec last_account_update;
97 
98  time_point_sec created;
99  bool created_by_genesis = false;
100  bool owner_challenged = false;
101  bool active_challenged = false;
102  time_point_sec last_owner_proved;
103  time_point_sec last_active_proved;
105  time_point_sec last_account_recovery;
106 
107  bool can_vote = false;
108  uint16_t voting_power = 0;
109  time_point_sec last_vote_time;
110 
111  asset balance = asset(0, SCORUM_SYMBOL);
112 
113  asset scorumpower = asset(0, SP_SYMBOL);
114  asset delegated_scorumpower = asset(0, SP_SYMBOL);
115  asset received_scorumpower = asset(0, SP_SYMBOL);
116 
117  std::vector<share_type> proxied_vsf_votes;
118 
120 
121  share_type average_bandwidth = 0;
122  share_type lifetime_bandwidth = 0;
123  time_point_sec last_bandwidth_update;
124 
125  share_type average_market_bandwidth = 0;
126  share_type lifetime_market_bandwidth = 0;
128 
129  time_point_sec last_post;
130  time_point_sec last_root_post;
131 
132  uint32_t post_count = 0;
133  uint32_t comment_count = 0;
134  uint32_t vote_count = 0;
135 
136  asset curation_rewards_scr = asset(0, SCORUM_SYMBOL);
137  asset curation_rewards_sp = asset(0, SP_SYMBOL);
138  asset posting_rewards_scr = asset(0, SCORUM_SYMBOL);
139  asset posting_rewards_sp = asset(0, SP_SYMBOL);
140 
141  time_point_sec active_sp_holders_cashout_time = fc::time_point_sec::maximum();
142  asset active_sp_holders_pending_scr_reward = asset(0, SCORUM_SYMBOL);
143  asset active_sp_holders_pending_sp_reward = asset(0, SP_SYMBOL);
144 
146 
147 private:
148  inline void set_account(const chain::account_object&);
149  inline void set_account_blogging_statistic(const chain::account_blogging_statistic_object&);
150  inline void initialize(const chain::account_object& a, const chain::database& db);
151 };
152 
154 {
156  : balance(a.balance)
157  , scorumpower(a.scorumpower)
158  {
159  }
160 
162  {
163  }
164 
165  asset balance = asset(0, SCORUM_SYMBOL);
166  asset scorumpower = asset(0, SP_SYMBOL);
167 };
168 
170 {
171  owner_authority_history_api_obj(const chain::owner_authority_history_object& o)
172  : id(o.id)
173  , account(o.account)
174  , previous_owner_authority(authority(o.previous_owner_authority))
175  , last_valid_time(o.last_valid_time)
176  {
177  }
178 
180  {
181  }
182 
184 
187  time_point_sec last_valid_time;
188 };
189 
191 {
192  account_recovery_request_api_obj(const chain::account_recovery_request_object& o)
193  : id(o.id)
194  , account_to_recover(o.account_to_recover)
195  , new_owner_authority(authority(o.new_owner_authority))
196  , expires(o.expires)
197  {
198  }
199 
201  {
202  }
203 
207  time_point_sec expires;
208 };
209 
211 {
213  : id(p.id)
214  , operation(p.operation)
215  , creator(p.creator)
216  , expiration(p.expiration)
217  , quorum_percent(p.quorum_percent)
218  {
219  for (auto& a : p.voted_accounts)
220  {
221  voted_accounts.insert(a);
222  }
223  }
224 
226  {
227  }
228 
229  proposal_object::id_type id;
230 
232 
234 
235  fc::time_point_sec expiration;
236 
237  uint64_t quorum_percent = 0;
238 
239  flat_set<account_name_type> voted_accounts;
240 };
241 
243 {
245  : id(n.id)
246  , uuid(n.uuid)
247  , name(n.name)
248  , owner(n.owner)
249  , created(n.created)
250  , initial_power(n.initial_power)
251  , experience(n.experience)
252  , total_experience(n.initial_power + n.experience)
253 
254 #ifndef IS_LOW_MEM
255  , json_metadata(fc::to_string(n.json_metadata))
256 #endif
257  {
258  }
259 
261  {
262  }
263 
268  time_point_sec created;
269  int32_t initial_power;
272  std::string json_metadata;
273 };
274 
276 {
278  : id(o.id)
279  , uuid(o.uuid)
280  , owner(o.owner)
281  , seed(fc::to_string(o.seed))
282  , verification_key(fc::to_string(o.verification_key))
283  , vrf(fc::to_string(o.vrf))
284  , proof(fc::to_string(o.proof))
285  , result(o.result)
286  {
287  }
288 
290  {
291  }
292 
296 
297  std::string seed;
298  std::string verification_key;
299  std::string vrf;
300  std::string proof;
302 };
303 
305 {
307  : id(w.id)
308  , owner(w.owner)
309  , created(w.created)
310  , url(fc::to_string(w.url))
311  , total_missed(w.total_missed)
312  , last_confirmed_block_num(w.last_confirmed_block_num)
313  , signing_key(w.signing_key)
314  , proposed_chain_props(w.proposed_chain_props)
315  , votes(w.votes)
316  , virtual_last_update(w.virtual_last_update)
317  , virtual_position(w.virtual_position)
318  , virtual_scheduled_time(w.virtual_scheduled_time)
319  , running_version(w.running_version)
321  , hardfork_time_vote(w.hardfork_time_vote)
322  {
323  }
324 
326  {
327  }
328 
331  time_point_sec created;
332  std::string url;
333  uint32_t total_missed = 0;
334  uint64_t last_confirmed_block_num = 0;
338  fc::uint128 virtual_last_update;
339  fc::uint128 virtual_position;
343  time_point_sec hardfork_time_vote;
344 };
345 
348 
350 {
351 public:
353  : id(b.id._id)
354  , uuid(b.uuid)
355  , type(budget_type::post)
356  , owner(b.owner)
357  , json_metadata(fc::to_string(b.json_metadata))
358  , created(b.created)
359  , start(b.start)
360  , deadline(b.deadline)
361  , balance(b.balance)
362  , per_block(b.per_block)
363  , cashout_time(b.cashout_time)
364  , owner_pending_income(b.owner_pending_income)
365  , budget_pending_outgo(b.budget_pending_outgo)
366  {
367  }
368 
370  : id(b.id._id)
371  , uuid(b.uuid)
372  , type(budget_type::banner)
373  , owner(b.owner)
374  , json_metadata(fc::to_string(b.json_metadata))
375  , created(b.created)
376  , start(b.start)
377  , deadline(b.deadline)
378  , balance(b.balance)
379  , per_block(b.per_block)
380  , cashout_time(b.cashout_time)
381  , owner_pending_income(b.owner_pending_income)
382  , budget_pending_outgo(b.budget_pending_outgo)
383  {
384  }
385 
386  // because fc::variant require for temporary object
388  {
389  }
390 
391  int64_t id;
393 
395 
397  std::string json_metadata;
398 
399  fc::time_point_sec created;
400  fc::time_point_sec start;
401  fc::time_point_sec deadline;
402 
403  asset balance = asset(0, SCORUM_SYMBOL);
405 
406  fc::time_point_sec cashout_time;
407  asset owner_pending_income = asset(0, SCORUM_SYMBOL);
408  asset budget_pending_outgo = asset(0, SCORUM_SYMBOL);
409 };
410 
412 
414 {
415  atomicswap_contract_api_obj(const chain::atomicswap_contract_object& c)
416  : id(c.id._id)
417  , contract_initiator(c.type == chain::atomicswap_contract_initiator)
418  , owner(c.owner)
419  , to(c.to)
420  , amount(c.amount)
421  , created(c.created)
422  , deadline(c.deadline)
423  , metadata(fc::to_string(c.metadata))
424  {
425  }
426 
427  // because fc::variant require for temporary object
429  {
430  }
431 
432  int64_t id;
433 
435 
437 
439  asset amount = asset(0, SCORUM_SYMBOL);
440 
441  time_point_sec created;
442  time_point_sec deadline;
443 
444  std::string metadata;
445 };
446 
448 {
449  atomicswap_contract_info_api_obj(const chain::atomicswap_contract_object& c)
451  , secret(fc::to_string(c.secret))
452  , secret_hash(fc::to_string(c.secret_hash))
453  {
454  }
455 
456  // because fc::variant require for temporary object
458  {
459  }
460 
461  std::string secret;
462  std::string secret_hash;
463 
464  bool empty() const
465  {
466  return secret_hash.empty() || !owner.size() || !to.size() || amount.amount == 0;
467  }
468 };
469 
471 {
473  : tr(_tr)
474  {
475  }
476 
479  const std::string& secret = "")
480  : tr(_tr)
481  {
482  obj.contract_initiator = (op.type == protocol::atomicswap_initiate_operation::by_initiator);
483  obj.owner = op.owner;
484  obj.to = op.recipient;
485  obj.amount = op.amount;
486  obj.metadata = op.metadata;
487  obj.secret_hash = op.secret_hash;
488  obj.secret = secret;
489  }
490 
492  {
493  }
494 
497 
498  bool empty() const
499  {
500  return obj.empty();
501  }
502 };
503 
505 {
507  {
508  }
509 
511  : invite_quorum(reg_committee.invite_quorum)
512  , dropout_quorum(reg_committee.dropout_quorum)
513  , change_quorum(reg_committee.change_quorum)
514  {
515  }
516 
517  protocol::percent_type invite_quorum = 0u;
518  protocol::percent_type dropout_quorum = 0u;
519  protocol::percent_type change_quorum = 0u;
520 };
521 
522 } // namespace app
523 } // namespace scorum
524 
525 // clang-format off
526 
528  (moderator)
529  (auction_post_coefficients)
530  (auction_banner_coefficients))
531 
533 FC_REFLECT_DERIVED(scorum::app::block_summary_api_obj, (scorum::chain::block_summary_object), BOOST_PP_SEQ_NIL)
534 FC_REFLECT_DERIVED(scorum::app::change_recovery_account_request_api_obj, (scorum::chain::change_recovery_account_request_object), BOOST_PP_SEQ_NIL)
536 FC_REFLECT_DERIVED(scorum::app::escrow_api_obj, (scorum::chain::escrow_object), BOOST_PP_SEQ_NIL)
537 FC_REFLECT_DERIVED(scorum::app::scorumpower_delegation_api_obj, (scorum::chain::scorumpower_delegation_object), BOOST_PP_SEQ_NIL)
538 FC_REFLECT_DERIVED(scorum::app::scorumpower_delegation_expiration_api_obj, (scorum::chain::scorumpower_delegation_expiration_object), BOOST_PP_SEQ_NIL)
541 FC_REFLECT_DERIVED(scorum::app::witness_vote_api_obj, (scorum::chain::witness_vote_object), BOOST_PP_SEQ_NIL)
542 
545  (registration_pool_balance)
546  (fund_budget_balance)
547  (reward_pool_balance)
548  (content_reward_scr_balance)
549  (content_reward_sp_balance)
550  )
551 FC_REFLECT_DERIVED(scorum::app::development_committee_api_obj, (scorum::chain::dev_committee_object), BOOST_PP_SEQ_NIL)
552 
553 FC_REFLECT(scorum::app::registration_committee_api_obj, (invite_quorum)(dropout_quorum)(change_quorum))
554 
556  (id)(name)(owner)(active)(posting)(memo_key)(json_metadata)(proxy)(last_owner_update)(last_account_update)
557  (created)(created_by_genesis)
558  (owner_challenged)(active_challenged)(last_owner_proved)(last_active_proved)(recovery_account)(last_account_recovery)
559  (can_vote)(voting_power)(last_vote_time)
560  (balance)
561  (scorumpower)(delegated_scorumpower)(received_scorumpower)
562  (proxied_vsf_votes)(witnesses_voted_for)
563  (average_bandwidth)(lifetime_bandwidth)(last_bandwidth_update)
564  (average_market_bandwidth)(lifetime_market_bandwidth)(last_market_bandwidth_update)
565  (last_post)(last_root_post)
566  (post_count)(comment_count)(vote_count)
567  (curation_rewards_scr)
568  (curation_rewards_sp)
569  (posting_rewards_scr)
570  (posting_rewards_sp)
571  (active_sp_holders_cashout_time)
572  (active_sp_holders_pending_scr_reward)
573  (active_sp_holders_pending_sp_reward)
574  (nft_spend_scorumpower)
575  )
576 
578  (balance)(scorumpower))
579 
581  (id)
582  (account)
583  (previous_owner_authority)
584  (last_valid_time)
585  )
586 
588  (id)
589  (account_to_recover)
590  (new_owner_authority)
591  (expires)
592  )
593 
595  (id)
596  (owner)
597  (created)
598  (url)(votes)(virtual_last_update)(virtual_position)(virtual_scheduled_time)(total_missed)
599  (last_confirmed_block_num)(signing_key)
600  (proposed_chain_props)
601  (running_version)
602  (hardfork_version_vote)(hardfork_time_vote)
603  )
604 
606  (id)
607  (creator)
608  (expiration)
609  (operation)
610  (voted_accounts)
611  (quorum_percent)
612  )
613 
615  (id)
616  (uuid)
617  (type)
618  (owner)
619  (json_metadata)
620  (created)
621  (start)
622  (deadline)
623  (balance)
624  (per_block)
625  (cashout_time)
626  (budget_pending_outgo)
627  (owner_pending_income)
628  )
629 
631  (id)
632  (contract_initiator)
633  (owner)
634  (to)
635  (amount)
636  (created)
637  (deadline)
638  (metadata)
639  )
640 
642  (secret)
643  (secret_hash)
644  )
645 
647  (tr)
648  (obj)
649  )
650 
652  (id)
653  (uuid)
654  (name)
655  (owner)
656  (created)
657  (initial_power)
658  (experience)
659  (total_experience)
660  (json_metadata))
661 
663  (id)
664  (uuid)
665  (owner)
666  (seed)
667  (verification_key)
668  (vrf)
669  (proof)
670  (result))
671 
672 // clang-format on
budget_api_obj(const chain::banner_budget_object &b)
budget_api_obj(const chain::post_budget_object &b)
tracks minimal information about past blocks to implement TaPOS
tracks the blockchain state in an extensible manner
Definition: database.hpp:52
fc::shared_flat_set< account_name_type > voted_accounts
#define SP_SYMBOL
Definition: config.hpp:104
#define SCORUM_SYMBOL
Definition: config.hpp:102
FC_REFLECT(appender_args,(appender)(stream)) FC_REFLECT_DERIVED(file_appender_args
Definition: game.cpp:4
api_obj< scorum::chain::scorumpower_delegation_object > scorumpower_delegation_api_obj
api_obj< scorum::chain::dev_committee_object > development_committee_api_obj
api_obj< scorum::chain::withdraw_scorumpower_route_object > withdraw_scorumpower_route_api_obj
api_obj< scorum::chain::escrow_object > escrow_api_obj
api_obj< scorum::witness::reserve_ratio_object > reserve_ratio_api_obj
api_obj< scorum::chain::witness_vote_object > witness_vote_api_obj
api_obj< scorum::chain::decline_voting_rights_request_object > decline_voting_rights_request_api_obj
api_obj< scorum::chain::scorumpower_delegation_expiration_object > scorumpower_delegation_expiration_api_obj
api_obj< scorum::chain::block_summary_object > block_summary_api_obj
api_obj< scorum::witness::account_bandwidth_object > account_bandwidth_api_obj
api_obj< scorum::chain::change_recovery_account_request_object > change_recovery_account_request_api_obj
api_obj< scorum::chain::witness_schedule_object > witness_schedule_api_obj
@ post
Rate limiting posting reward eligibility over time.
fc::safe< share_value_type > share_type
Definition: types.hpp:73
fc::static_variant< vote_operation, comment_operation, transfer_operation, transfer_to_scorumpower_operation, withdraw_scorumpower_operation, account_create_by_committee_operation, account_create_operation, account_create_with_delegation_operation, account_update_operation, witness_update_operation, account_witness_vote_operation, account_witness_proxy_operation, delete_comment_operation, comment_options_operation, set_withdraw_scorumpower_route_to_account_operation, set_withdraw_scorumpower_route_to_dev_pool_operation, prove_authority_operation, request_account_recovery_operation, recover_account_operation, change_recovery_account_operation, escrow_approve_operation, escrow_dispute_operation, escrow_release_operation, escrow_transfer_operation, decline_voting_rights_operation, delegate_scorumpower_operation, create_budget_operation, close_budget_operation, proposal_vote_operation, proposal_create_operation, atomicswap_initiate_operation, atomicswap_redeem_operation, atomicswap_refund_operation, close_budget_by_advertising_moderator_operation, update_budget_operation, create_game_operation, cancel_game_operation, update_game_markets_operation, update_game_start_time_operation, post_game_results_operation, post_bet_operation, cancel_pending_bets_operation, delegate_sp_from_reg_pool_operation, create_nft_operation, update_nft_meta_operation, create_game_round_operation, update_game_round_result_operation, adjust_nft_experience_operation, update_nft_name_operation, author_reward_operation, comment_benefficiary_reward_operation, comment_payout_update_operation, comment_reward_operation, curation_reward_operation, hardfork_operation, producer_reward_operation, active_sp_holders_reward_operation, return_scorumpower_delegation_operation, shutdown_witness_operation, witness_miss_block_operation, expired_contract_refund_operation, acc_finished_vesting_withdraw_operation, devpool_finished_vesting_withdraw_operation, acc_to_acc_vesting_withdraw_operation, devpool_to_acc_vesting_withdraw_operation, acc_to_devpool_vesting_withdraw_operation, devpool_to_devpool_vesting_withdraw_operation, proposal_virtual_operation, budget_outgo_operation, budget_owner_income_operation, active_sp_holders_reward_legacy_operation, budget_closing_operation, bets_matched_operation, game_status_changed_operation, bet_resolved_operation, bet_cancelled_operation, bet_restored_operation, bet_updated_operation > operation
Definition: operations.hpp:112
fc::fixed_string_16 account_name_type
Definition: types.hpp:62
uint16_t percent_type
Definition: types.hpp:69
fc::static_variant< registration_committee_add_member_operation, registration_committee_exclude_member_operation, registration_committee_change_quorum_operation, development_committee_add_member_operation, development_committee_exclude_member_operation, development_committee_change_quorum_operation, development_committee_withdraw_vesting_operation, development_committee_transfer_operation, development_committee_empower_advertising_moderator_operation, development_committee_change_post_budgets_auction_properties_operation, development_committee_change_banner_budgets_auction_properties_operation, development_committee_empower_betting_moderator_operation, development_committee_change_betting_resolve_delay_operation > proposal_operation
Definition: asset.cpp:15
boost::uuids::uuid uuid_type
Definition: types.hpp:53
std::vector< share_type > proxied_vsf_votes
account_balance_info_api_obj(const account_api_obj &a)
account_recovery_request_api_obj(const chain::account_recovery_request_object &o)
std::vector< percent_type > auction_banner_coefficients
std::vector< percent_type > auction_post_coefficients
atomicswap_contract_api_obj(const chain::atomicswap_contract_object &c)
atomicswap_contract_info_api_obj(const chain::atomicswap_contract_object &c)
protocol::annotated_signed_transaction tr
atomicswap_contract_result_api_obj(const protocol::annotated_signed_transaction &_tr)
atomicswap_contract_result_api_obj(const protocol::annotated_signed_transaction &_tr, const protocol::atomicswap_initiate_operation &op, const std::string &secret="")
dynamic_global_property_api_obj & operator=(const T &other)
game_round_api_obj(const chain::game_round_object &o)
nft_api_obj(const chain::nft_object &n)
owner_authority_history_api_obj(const chain::owner_authority_history_object &o)
flat_set< account_name_type > voted_accounts
proposal_api_obj(const proposal_object &p)
protocol::proposal_operation operation
registration_committee_api_obj(const registration_pool_object &reg_committee)
witness_api_obj(const chain::witness_object &w)