hive_virtual_operations.hpp 11.6 KB
Newer Older
Bartek Wrona's avatar
Bartek Wrona committed
1 2 3 4 5 6 7 8 9 10 11
#pragma once
#include <hive/protocol/base.hpp>
#include <hive/protocol/block_header.hpp>
#include <hive/protocol/asset.hpp>

#include <fc/utf8.hpp>

namespace hive { namespace protocol {

  struct author_reward_operation : public virtual_operation {
    author_reward_operation(){}
12 13
    author_reward_operation( const account_name_type& a, const string& p, const asset& s, const asset& st, const asset& v, const asset& c )
      :author(a), permlink(p), hbd_payout(s), hive_payout(st), vesting_payout(v), curators_vesting_payout(c) {}
Bartek Wrona's avatar
Bartek Wrona committed
14 15 16 17 18 19

    account_name_type author;
    string            permlink;
    asset             hbd_payout;
    asset             hive_payout;
    asset             vesting_payout;
20
    asset             curators_vesting_payout;
Bartek Wrona's avatar
Bartek Wrona committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
  };


  struct curation_reward_operation : public virtual_operation
  {
    curation_reward_operation(){}
    curation_reward_operation( const string& c, const asset& r, const string& a, const string& p )
      :curator(c), reward(r), comment_author(a), comment_permlink(p) {}

    account_name_type curator;
    asset             reward;
    account_name_type comment_author;
    string            comment_permlink;
  };


  struct comment_reward_operation : public virtual_operation
  {
    comment_reward_operation() = default;
40 41 42 43
    comment_reward_operation( const account_name_type& a, const string& pl, const asset& p, share_type ar,
                              const asset& tpv, const asset& cpv, const asset& bpv )
      : author(a), permlink(pl), payout(p), author_rewards(ar),
        total_payout_value( tpv ), curator_payout_value( cpv ), beneficiary_payout_value( bpv ) {}
Bartek Wrona's avatar
Bartek Wrona committed
44 45 46 47 48

    account_name_type author;
    string            permlink;
    asset             payout;
    share_type        author_rewards;
49 50 51
    asset             total_payout_value;
    asset             curator_payout_value;
    asset             beneficiary_payout_value;
Bartek Wrona's avatar
Bartek Wrona committed
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
  };


  struct liquidity_reward_operation : public virtual_operation
  {
    liquidity_reward_operation( string o = string(), asset p = asset() )
    :owner(o), payout(p) {}

    account_name_type owner;
    asset             payout;
  };


  struct interest_operation : public virtual_operation
  {
    interest_operation( const string& o = "", const asset& i = asset(0,HBD_SYMBOL) )
      :owner(o),interest(i){}

    account_name_type owner;
    asset             interest;
  };


  struct fill_convert_request_operation : public virtual_operation
  {
    fill_convert_request_operation(){}
    fill_convert_request_operation( const string& o, const uint32_t id, const asset& in, const asset& out )
      :owner(o), requestid(id), amount_in(in), amount_out(out) {}

    account_name_type owner;
    uint32_t          requestid = 0;
    asset             amount_in;
    asset             amount_out;
  };


  struct fill_vesting_withdraw_operation : public virtual_operation
  {
    fill_vesting_withdraw_operation(){}
    fill_vesting_withdraw_operation( const string& f, const string& t, const asset& w, const asset& d )
      :from_account(f), to_account(t), withdrawn(w), deposited(d) {}

    account_name_type from_account;
    account_name_type to_account;
    asset             withdrawn;
    asset             deposited;
  };


  struct shutdown_witness_operation : public virtual_operation
  {
    shutdown_witness_operation(){}
    shutdown_witness_operation( const string& o ):owner(o) {}

    account_name_type owner;
  };


  struct fill_order_operation : public virtual_operation
  {
    fill_order_operation(){}
    fill_order_operation( const string& c_o, uint32_t c_id, const asset& c_p, const string& o_o, uint32_t o_id, const asset& o_p )
    :current_owner(c_o), current_orderid(c_id), current_pays(c_p), open_owner(o_o), open_orderid(o_id), open_pays(o_p) {}

    account_name_type current_owner;
    uint32_t          current_orderid = 0;
    asset             current_pays;
    account_name_type open_owner;
    uint32_t          open_orderid = 0;
    asset             open_pays;
  };


  struct fill_transfer_from_savings_operation : public virtual_operation
  {
    fill_transfer_from_savings_operation() {}
    fill_transfer_from_savings_operation( const account_name_type& f, const account_name_type& t, const asset& a, const uint32_t r, const string& m )
      :from(f), to(t), amount(a), request_id(r), memo(m) {}

    account_name_type from;
    account_name_type to;
    asset             amount;
    uint32_t          request_id = 0;
    string            memo;
  };

  struct hardfork_operation : public virtual_operation
  {
    hardfork_operation() {}
    hardfork_operation( uint32_t hf_id ) : hardfork_id( hf_id ) {}

    uint32_t         hardfork_id = 0;
  };

  struct comment_payout_update_operation : public virtual_operation
  {
    comment_payout_update_operation() {}
149
    comment_payout_update_operation( const account_name_type& a, const string& p ) : author( a ), permlink( p ) {}
Bartek Wrona's avatar
Bartek Wrona committed
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165

    account_name_type author;
    string            permlink;
  };

  struct effective_comment_vote_operation : public virtual_operation
  {
    effective_comment_vote_operation() = default;
    effective_comment_vote_operation(const account_name_type& _voter, const account_name_type& _author, const string& _permlink) :
      voter(_voter), author(_author), permlink(_permlink) {}

    account_name_type voter;
    account_name_type author;
    string            permlink;
    uint64_t          weight = 0; ///< defines the score this vote receives, used by vote payout calc. 0 if a negative vote or changed votes.
    int64_t           rshares = 0; ///< The number of rshares this vote is responsible for
166 167
    //potential payout of related comment at the moment of this vote
    asset             pending_payout = asset( 0, HBD_SYMBOL ); //supplemented by account history RocksDB plugin (needed by HiveMind)
Bartek Wrona's avatar
Bartek Wrona committed
168 169
  };

170 171 172 173 174 175 176 177 178 179
  struct ineffective_delete_comment_operation : public virtual_operation
  {
    ineffective_delete_comment_operation() = default;
    ineffective_delete_comment_operation(const account_name_type& _author, const string& _permlink) :
      author(_author), permlink(_permlink) {}

    account_name_type author;
    string            permlink;
  };

Bartek Wrona's avatar
Bartek Wrona committed
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271
  struct return_vesting_delegation_operation : public virtual_operation
  {
    return_vesting_delegation_operation() {}
    return_vesting_delegation_operation( const account_name_type& a, const asset& v ) : account( a ), vesting_shares( v ) {}

    account_name_type account;
    asset             vesting_shares;
  };

  struct comment_benefactor_reward_operation : public virtual_operation
  {
    comment_benefactor_reward_operation() {}
    comment_benefactor_reward_operation( const account_name_type& b, const account_name_type& a, const string& p, const asset& s, const asset& st, const asset& v )
      : benefactor( b ), author( a ), permlink( p ), hbd_payout( s ), hive_payout( st ), vesting_payout( v ) {}

    account_name_type benefactor;
    account_name_type author;
    string            permlink;
    asset             hbd_payout;
    asset             hive_payout;
    asset             vesting_payout;
  };

  struct producer_reward_operation : public virtual_operation
  {
    producer_reward_operation(){}
    producer_reward_operation( const string& p, const asset& v ) : producer( p ), vesting_shares( v ) {}

    account_name_type producer;
    asset             vesting_shares;

  };

  struct clear_null_account_balance_operation : public virtual_operation
  {
    vector< asset >   total_cleared;
  };

  struct consolidate_treasury_balance_operation : public virtual_operation
  {
    vector< asset >   total_moved;
  };

  struct delayed_voting_operation : public virtual_operation
  {
    delayed_voting_operation(){}
    delayed_voting_operation( const account_name_type& _voter, const ushare_type _votes ) : voter( _voter ), votes( _votes ) {}

    account_name_type    voter;
    ushare_type          votes = 0;
  };

  struct sps_fund_operation : public virtual_operation
  {
    sps_fund_operation() {}
    sps_fund_operation( const account_name_type& _fund, const asset& v ) : fund_account( _fund ), additional_funds( v ) {}

    account_name_type fund_account;
    asset additional_funds;
  };

  // TODO : Fix legacy error itr != to_full_tag.end(): Invalid operation name: hardfork_hive {"n":"hardfork_hive"}
  struct hardfork_hive_operation : public virtual_operation
  {
    hardfork_hive_operation() {}
    hardfork_hive_operation( const account_name_type& acc, const account_name_type& _treasury,
      const asset& s, const asset& st, const asset& v, const asset& cs )
      : account( acc ), treasury( _treasury ), hbd_transferred( s ), hive_transferred( st ), vests_converted( v ), total_hive_from_vests(cs)
    {}

    account_name_type account;
    account_name_type treasury;
    asset             hbd_transferred;
    asset             hive_transferred;
    asset             vests_converted; // Amount of converted vests
    asset             total_hive_from_vests; // Resulting HIVE from conversion
  };

  struct hardfork_hive_restore_operation : public virtual_operation
  {
    hardfork_hive_restore_operation() {}
    hardfork_hive_restore_operation( const account_name_type& acc, const account_name_type& _treasury, const asset& s, const asset& st )
      : account( acc ), treasury( _treasury ), hbd_transferred( s ), hive_transferred( st ) {}

    account_name_type account;
    account_name_type treasury;
    asset             hbd_transferred;
    asset             hive_transferred;
  };

} } //hive::protocol

272
FC_REFLECT( hive::protocol::author_reward_operation, (author)(permlink)(hbd_payout)(hive_payout)(vesting_payout)(curators_vesting_payout) )
Bartek Wrona's avatar
Bartek Wrona committed
273
FC_REFLECT( hive::protocol::curation_reward_operation, (curator)(reward)(comment_author)(comment_permlink) )
274
FC_REFLECT( hive::protocol::comment_reward_operation, (author)(permlink)(payout)(author_rewards)(total_payout_value)(curator_payout_value)(beneficiary_payout_value) )
Bartek Wrona's avatar
Bartek Wrona committed
275 276 277 278 279 280 281 282
FC_REFLECT( hive::protocol::fill_convert_request_operation, (owner)(requestid)(amount_in)(amount_out) )
FC_REFLECT( hive::protocol::liquidity_reward_operation, (owner)(payout) )
FC_REFLECT( hive::protocol::interest_operation, (owner)(interest) )
FC_REFLECT( hive::protocol::fill_vesting_withdraw_operation, (from_account)(to_account)(withdrawn)(deposited) )
FC_REFLECT( hive::protocol::shutdown_witness_operation, (owner) )
FC_REFLECT( hive::protocol::fill_order_operation, (current_owner)(current_orderid)(current_pays)(open_owner)(open_orderid)(open_pays) )
FC_REFLECT( hive::protocol::fill_transfer_from_savings_operation, (from)(to)(amount)(request_id)(memo) )
FC_REFLECT( hive::protocol::hardfork_operation, (hardfork_id) )
283
FC_REFLECT( hive::protocol::comment_payout_update_operation, (author)(permlink) )
284
FC_REFLECT( hive::protocol::effective_comment_vote_operation, (voter)(author)(permlink)(weight)(rshares)(pending_payout))
285
FC_REFLECT( hive::protocol::ineffective_delete_comment_operation, (author)(permlink))
Bartek Wrona's avatar
Bartek Wrona committed
286 287 288 289 290 291 292 293 294
FC_REFLECT( hive::protocol::return_vesting_delegation_operation, (account)(vesting_shares) )
FC_REFLECT( hive::protocol::comment_benefactor_reward_operation, (benefactor)(author)(permlink)(hbd_payout)(hive_payout)(vesting_payout) )
FC_REFLECT( hive::protocol::producer_reward_operation, (producer)(vesting_shares) )
FC_REFLECT( hive::protocol::clear_null_account_balance_operation, (total_cleared) )
FC_REFLECT( hive::protocol::consolidate_treasury_balance_operation, ( total_moved ) )
FC_REFLECT( hive::protocol::delayed_voting_operation, (voter)(votes) )
FC_REFLECT( hive::protocol::sps_fund_operation, (fund_account)(additional_funds) )
FC_REFLECT( hive::protocol::hardfork_hive_operation, (account)(treasury)(hbd_transferred)(hive_transferred)(vests_converted)(total_hive_from_vests) )
FC_REFLECT( hive::protocol::hardfork_hive_restore_operation, (account)(treasury)(hbd_transferred)(hive_transferred) )