pub trait TxContext: Context {
    // Required methods
    fn tx_index(&self) -> usize;
    fn tx_size(&self) -> u32;
    fn tx_auth_info(&self) -> &AuthInfo;
    fn tx_call_format(&self) -> CallFormat;
    fn is_read_only(&self) -> bool;
    fn is_internal(&self) -> bool;
    fn internal(self) -> Self;
    fn tx_value<V: Any>(&mut self, key: &'static str) -> ContextValue<'_, V>;
    fn emit_message(
        &mut self,
        msg: Message,
        hook: MessageEventHookInvocation
    ) -> Result<(), Error>;
    fn emit_unconditional_event<E: Event>(&mut self, event: E);

    // Provided method
    fn tx_caller_address(&self) -> Address { ... }
}
Expand description

Runtime SDK transaction context.

Required Methods§

source

fn tx_index(&self) -> usize

The index of the transaction in the batch.

source

fn tx_size(&self) -> u32

Transaction size in bytes.

source

fn tx_auth_info(&self) -> &AuthInfo

Transaction authentication information.

source

fn tx_call_format(&self) -> CallFormat

The transaction’s call format.

source

fn is_read_only(&self) -> bool

Whether the call is read-only and must not make any storage modifications.

source

fn is_internal(&self) -> bool

Whether the transaction is internally generated (e.g. by another module in the SDK as a subcall to a different module).

source

fn internal(self) -> Self

Mark this context as part of an internally generated transaction (e.g. a subcall).

source

fn tx_value<V: Any>(&mut self, key: &'static str) -> ContextValue<'_, V>

Fetches an entry pointing to a value associated with the transaction.

source

fn emit_message( &mut self, msg: Message, hook: MessageEventHookInvocation ) -> Result<(), Error>

Emit a consensus message.

source

fn emit_unconditional_event<E: Event>(&mut self, event: E)

Similar as emit_event but the event will persist even in case the transaction that owns this context fails.

Provided Methods§

source

fn tx_caller_address(&self) -> Address

Authenticated address of the caller.

In case there are multiple signers of a transaction, this will return the address corresponding to the first signer.

Implementations on Foreign Types§

source§

impl<'a, 'b, C: TxContext> TxContext for RefMut<'a, &'b mut C>

source§

fn tx_index(&self) -> usize

source§

fn tx_size(&self) -> u32

source§

fn tx_auth_info(&self) -> &AuthInfo

source§

fn tx_call_format(&self) -> CallFormat

source§

fn is_read_only(&self) -> bool

source§

fn is_internal(&self) -> bool

source§

fn internal(self) -> Self

source§

fn tx_caller_address(&self) -> Address

source§

fn tx_value<V: Any>(&mut self, key: &'static str) -> ContextValue<'_, V>

source§

fn emit_message( &mut self, msg: Message, hook: MessageEventHookInvocation ) -> Result<(), Error>

source§

fn emit_unconditional_event<E: Event>(&mut self, event: E)

Implementors§