Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
add get_sender intrinsic
Browse files Browse the repository at this point in the history
  • Loading branch information
arhag committed Sep 18, 2019
1 parent 0e9b9b0 commit b528a65
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
8 changes: 8 additions & 0 deletions libraries/eosiolib/capi/eosio/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions libraries/eosiolib/contracts/eosio/system.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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();
}
}

Expand Down Expand Up @@ -76,4 +80,14 @@ namespace eosio {
reinterpret_cast<const internal_use_do_not_use::capi_checksum256*>( 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() );
}
}
3 changes: 3 additions & 0 deletions libraries/native/intrinsics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,9 @@ extern "C" {
int get_context_free_data( uint32_t index, char* buff, size_t size ) {
return intrinsics::get().call<intrinsics::get_context_free_data>(index, buff, size);
}
capi_name get_sender() {
return intrinsics::get().call<intrinsics::get_sender>();
}

// softfloat
static constexpr uint32_t inv_float_eps = 0x4B000000;
Expand Down
3 changes: 2 additions & 1 deletion libraries/native/native/eosio/intrinsics_def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit b528a65

Please sign in to comment.