diff --git a/libraries/eosiolib/capi/eosio/system.h b/libraries/eosiolib/capi/eosio/system.h index c1a6d818f9..b7b7cb63a1 100644 --- a/libraries/eosiolib/capi/eosio/system.h +++ b/libraries/eosiolib/capi/eosio/system.h @@ -85,6 +85,14 @@ uint64_t current_time(); __attribute__((eosio_wasm_import)) bool is_feature_activated( const capi_checksum256* feature_digest ); +/** + * Return name of account that sent current inline action + * + * @return name of account that sent the current inline action (empty name if not called from inline action) + */ +__attribute__((eosio_wasm_import)) +capi_name get_sender(); + #ifdef __cplusplus } #endif diff --git a/libraries/eosiolib/contracts/eosio/system.hpp b/libraries/eosiolib/contracts/eosio/system.hpp index 64c48e8885..5c5c21926b 100644 --- a/libraries/eosiolib/contracts/eosio/system.hpp +++ b/libraries/eosiolib/contracts/eosio/system.hpp @@ -6,6 +6,7 @@ #include "../../core/eosio/time.hpp" #include "../../core/eosio/check.hpp" #include "../../core/eosio/fixed_bytes.hpp" +#include "../../core/eosio/name.hpp" namespace eosio { namespace internal_use_do_not_use { @@ -19,6 +20,9 @@ namespace eosio { __attribute__((eosio_wasm_import)) bool is_feature_activated( const capi_checksum256* feature_digest ); + + __attribute__((eosio_wasm_import)) + uint64_t get_sender(); } } @@ -76,4 +80,14 @@ namespace eosio { reinterpret_cast( feature_digest_data.data() ) ); } + + /** + * Return name of account that sent current inline action + * + * @ingroup system + * @return name of account that sent the current inline action (empty name if not called from inline action) + */ + inline name get_sender() { + return name( internal_use_do_not_use::get_sender() ); + } } diff --git a/libraries/native/intrinsics.cpp b/libraries/native/intrinsics.cpp index 87ce058fd2..e023fbd736 100644 --- a/libraries/native/intrinsics.cpp +++ b/libraries/native/intrinsics.cpp @@ -340,6 +340,9 @@ extern "C" { int get_context_free_data( uint32_t index, char* buff, size_t size ) { return intrinsics::get().call(index, buff, size); } + capi_name get_sender() { + return intrinsics::get().call(); + } // softfloat static constexpr uint32_t inv_float_eps = 0x4B000000; diff --git a/libraries/native/native/eosio/intrinsics_def.hpp b/libraries/native/native/eosio/intrinsics_def.hpp index a5303cfcf3..9166d1f2a4 100644 --- a/libraries/native/native/eosio/intrinsics_def.hpp +++ b/libraries/native/native/eosio/intrinsics_def.hpp @@ -156,7 +156,8 @@ intrinsic_macro(send_inline) \ intrinsic_macro(send_context_free_inline) \ intrinsic_macro(send_deferred) \ intrinsic_macro(cancel_deferred) \ -intrinsic_macro(get_context_free_data) +intrinsic_macro(get_context_free_data) \ +intrinsic_macro(get_sender) #define CREATE_ENUM(name) \ name,