diff --git a/contracts/eoslib/account.h b/contracts/eoslib/account.h index 8a83f0627c90cab6f1273f0b9a825c1dfe12f103..52fc4a1eca03ffd1e3270f08c754dd2ca59d6528 100644 --- a/contracts/eoslib/account.h +++ b/contracts/eoslib/account.h @@ -14,10 +14,11 @@ extern "C" { /** - * @brief Return the balance for the provided account + * @brief Retrieve the balance for the provided account * * @param balance - a pointer to a range of memory to store balance data * @param len - length of the range of memory to store balance data + * @ret true if account information is retrieved * * @pre data is a valid pointer to a range of memory at least datalen bytes long * @pre data is a pointer to a balance object @@ -31,6 +32,6 @@ extern "C" { * @endcode */ - void account_balance_get( void* balance, uint32_t len ); + bool account_balance_get( void* balance, uint32_t len ); ///@ } accountcapi } diff --git a/contracts/eoslib/account.hpp b/contracts/eoslib/account.hpp index 0f543d185ec122bdd2200eeb4b5eb50161e6600c..cd6d5d0b294605b8b787e3e6dfcf9adbf838b25f 100644 --- a/contracts/eoslib/account.hpp +++ b/contracts/eoslib/account.hpp @@ -5,7 +5,7 @@ * */ #pragma once -#include +#include #include @@ -75,7 +75,7 @@ struct PACKED (account_balance) { bool get(account_balance& b) { - return account_balance(&b, sizeof(account_balance)); + return account_balance_get(&b, sizeof(account_balance)); } } } diff --git a/libraries/chain/wasm_interface.cpp b/libraries/chain/wasm_interface.cpp index 6afd93ae530c643c8c460a94c7f40115ff1889ab..9271f485d27ea33676680b0cfc922e45069a4129 100644 --- a/libraries/chain/wasm_interface.cpp +++ b/libraries/chain/wasm_interface.cpp @@ -735,6 +735,8 @@ DEFINE_INTRINSIC_FUNCTION2(env,account_balance_get,account_balance_get,i32,i32,c account_balance& total_balance = memoryRef( mem, charptr ); + wasm.current_apply_context->require_scope(total_balance.account); + auto& db = wasm.current_apply_context->db; auto* balance = db.find< balance_object,by_owner_name >( total_balance.account ); auto* staked_balance = db.find( total_balance.account );