From ba3ce62d4fbb3d0d546229003afe8cb6b71c8614 Mon Sep 17 00:00:00 2001 From: Brian Johnson Date: Tue, 21 Nov 2017 11:04:23 -0600 Subject: [PATCH] Fixed account api based on testing. --- contracts/eoslib/account.h | 5 +++-- contracts/eoslib/account.hpp | 4 ++-- libraries/chain/wasm_interface.cpp | 2 ++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/contracts/eoslib/account.h b/contracts/eoslib/account.h index 8a83f0627..52fc4a1ec 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 0f543d185..cd6d5d0b2 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 6afd93ae5..9271f485d 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 ); -- GitLab