From 10dbfe9d3a6d9366099596a854f770b9a3b36f9d Mon Sep 17 00:00:00 2001 From: RootkitKiller Date: Sat, 22 Feb 2020 08:50:31 +0800 Subject: [PATCH] fix: supprot staking_cashback for full_object api and fix account_obj reflect --- libraries/app/database_api_impl.cpp | 8 ++++++++ .../app/include/graphene/app/full_account.hpp | 4 ++++ .../include/graphene/chain/account_object.hpp | 16 ++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/libraries/app/database_api_impl.cpp b/libraries/app/database_api_impl.cpp index dd405a70..575498d1 100644 --- a/libraries/app/database_api_impl.cpp +++ b/libraries/app/database_api_impl.cpp @@ -742,6 +742,14 @@ std::map database_api_impl::get_full_accounts( const { acnt.cashback_balance = account->cashback_balance(_db); } + if (account->contract_call_cashback_vb) + { + acnt.contract_call_cashback_balance = account->contract_call_cashback_balance(_db); + } + if (account->staking_cashback_vb) + { + acnt.staking_cashback_balance = account->staking_cashback_balance(_db); + } // Add the account's proposals const auto& proposal_idx = _db.get_index_type(); const auto& pidx = dynamic_cast&>(proposal_idx); diff --git a/libraries/app/include/graphene/app/full_account.hpp b/libraries/app/include/graphene/app/full_account.hpp index 121b0f0a..ffdde262 100644 --- a/libraries/app/include/graphene/app/full_account.hpp +++ b/libraries/app/include/graphene/app/full_account.hpp @@ -39,6 +39,8 @@ namespace graphene { namespace app { string lifetime_referrer_name; vector votes; optional cashback_balance; + optional contract_call_cashback_balance; + optional staking_cashback_balance; vector balances; vector locked_balances; vector vesting_balances; @@ -61,6 +63,8 @@ FC_REFLECT( graphene::app::full_account, (lifetime_referrer_name) (votes) (cashback_balance) + (contract_call_cashback_balance) + (staking_cashback_balance) (balances) (locked_balances) (vesting_balances) diff --git a/libraries/chain/include/graphene/chain/account_object.hpp b/libraries/chain/include/graphene/chain/account_object.hpp index 2a97695a..7ed81a0d 100644 --- a/libraries/chain/include/graphene/chain/account_object.hpp +++ b/libraries/chain/include/graphene/chain/account_object.hpp @@ -312,6 +312,20 @@ namespace graphene { namespace chain { return db.get(*cashback_vb); } + template + const vesting_balance_object& contract_call_cashback_balance(const DB& db)const + { + FC_ASSERT(contract_call_cashback_vb); + return db.get(*contract_call_cashback_vb); + } + + template + const vesting_balance_object& staking_cashback_balance(const DB& db)const + { + FC_ASSERT(staking_cashback_vb); + return db.get(*staking_cashback_vb); + } + /// @return true if this is a contract account; false otherwise. bool is_contract_account()const { @@ -521,6 +535,8 @@ FC_REFLECT_DERIVED( graphene::chain::account_object, (name)(vm_type)(vm_version)(code)(code_version)(abi)(owner)(active)(options)(statistics)(whitelisting_accounts)(blacklisting_accounts) (whitelisted_accounts)(blacklisted_accounts) (cashback_vb) + (contract_call_cashback_vb) + (staking_cashback_vb) (owner_special_authority)(active_special_authority) (top_n_control_flags) (allowed_assets)