跳到主要内容

Action

Module: Contracts API

Defines type-safe C++ wrappers for querying action and sending action. More...

Classes

Name
structeosio::permission_level
structeosio::action

Functions

Name
template <typename T >
T
unpack_action_data()
voidrequire_recipient(name notify_account)
Add the specified account to set of accounts to be notified.
template <typename... accounts>
void
require_recipient(name notify_account, accounts... remaining_accounts)
voidrequire_auth(name n)
time_pointpublication_time()
uint32_tread_action_data(void * msg, uint32_t len)
voidrequire_auth(const permission_level & level)
boolhas_auth(name n)
boolis_account(name n)

Detailed Description

Defines type-safe C++ wrappers for querying action and sending action.

Note: There are some methods from the Action that can be used directly from C++

Functions Documentation

function unpack_action_data

template <typename T >
T unpack_action_data()

Return: Unpacked action data casted as T.

Example:

struct dummy_action {
char a; //1
unsigned long long b; //8
int c; //4

EOSLIB_SERIALIZE( dummy_action, (a)(b)(c) )
};
dummy_action msg = unpack_action_data<dummy_action>();

function require_recipient

inline void require_recipient(
name notify_account
)

Add the specified account to set of accounts to be notified.

Parameters:

  • notify_account - name of the account to be verified

Add the specified account to set of accounts to be notified

function require_recipient

template <typename... accounts>
void require_recipient(
name notify_account,
accounts... remaining_accounts
)

Parameters:

  • notify_account account to be notified
  • remaining_accounts accounts to be notified

Note: action.code is also considered as part of the set of notified accounts

All of the listed accounts will be added to the set of accounts to be notified

This helper method enables you to add multiple accounts to accounts to be notified list with a single call rather than having to call the similar C API multiple times.

Example:

require_recipient("Account1"_n, "Account2"_n, "Account3"_n); // throws exception if any of them not in set.

function require_auth

inline void require_auth(
name n
)

Parameters:

  • name - name of the account to be verified

Verifies that Name exists in the set of provided auths on a action. Fails if not found.

function publication_time

inline time_point publication_time()

Return: the time in microseconds from 1970 of the publication_time

Returns the time in microseconds from 1970 of the publication_time

function read_action_data

inline uint32_t read_action_data(
void * msg,
uint32_t len
)

Parameters:

  • msg - a pointer where up to length bytes of the current action data will be copied
  • len - len of the current action data to be copied, 0 to report required size

Return: the number of bytes copied to msg, or number of bytes that can be copied if len==0 passed

Precondition: msg is a valid pointer to a range of memory at least len bytes long

Postcondition: msg is filled with packed action data

Copy up to length bytes of current action data to the specified location

function require_auth

inline void require_auth(
const permission_level & level
)

Parameters:

  • level - Authorization to be required

Require the specified authorization for this action. If this action doesn't contain the specified auth, it will fail.

function has_auth

inline bool has_auth(
name n
)

Parameters:

  • n - name of the account to be verified

Verifies that n has auth.

function is_account

inline bool is_account(
name n
)

Parameters:

  • n - name of the account to check

Verifies that n is an existing account.


Updated on 2022-12-05 at 15:38:07 +0000