Skip to main content

TransactResult

Struct TransactResult 

Source
pub struct TransactResult { /* private fields */ }
Expand description

Result of a full transaction: root frame result + commit outcome. Events are accessed via the root frame’s per-frame events.

Implementations§

Source§

impl TransactResult

Source

pub fn new(frame: FrameResult, exec_result: ExecResult) -> Self

Combine a root-frame result with the transaction’s commit outcome.

Source

pub fn fault_panic(&self) -> Option<&PanicRecord>

The panic that faulted the root frame’s body, if it faulted with one. See FrameResult::fault_panic for what None covers — notably, a fault caused by a called contract rather than by this frame’s own body.

Source

pub fn fault_message(&self) -> Option<&str>

Just the message from fault_panic.

Source

pub fn rv32_stack_usage(&self) -> Option<Rv32StackUsage>

The root frame’s FrameResult::rv32_stack_usage: the stack record of the most recent rv32 call made under the root frame.

Source

pub fn rv32_stack_usage_records(&self) -> &[Rv32StackUsage]

The root frame’s FrameResult::rv32_stack_usage_records: the rv32 calls made under it, in the order they finished.

Source

pub fn is_success(&self) -> bool

True if the root frame returned successfully AND the commit was OK.

Source

pub fn assert_success(&self)

Asserts the root frame returned successfully AND the transaction committed OK.

Source

pub fn assert_abort(&self)

Assert the root frame aborted. Frame-only check; the commit outcome is not consulted.

Source

pub fn assert_fault(&self)

Assert the root frame faulted. Frame-only check.

Source

pub fn assert_return_with<R>(&self, check: impl FnOnce(&R))
where R: ReadXDROwned,

Assert the root frame returned successfully and decode its return buffer.

This checks only the frame outcome (contract execution), not the database commit. Use assert_success() when you need to verify both frame return and commit. This separation lets you inspect the return value even when the commit is expected to fail or hasn’t happened yet.

Source

pub fn assert_return_as<R>(&self) -> R
where R: ReadXDROwned,

Assert the root frame returned successfully and decode its return buffer, returning the decoded value. Frame-only check, like assert_return_with.

Source

pub fn assert_abort_as<E>(&self) -> E
where E: Exn + ReadXDROwned,

Assert the root frame aborted with a thrown E and return it; see FrameResult::assert_abort_as. Frame-only check (commit status not checked).

Source

pub fn assert_commit_failed(&self)

Asserts the root frame succeeded but the DB commit step failed.

Source

pub fn assert_commit_failed_nondeterministically(&self)

Assert the root frame succeeded but the commit failed with ExecResultTxNonDeterministicError (a storage conflict).

Source

pub fn exec_result(&self) -> &ExecResult

The transaction’s commit outcome.

Source

pub fn frame(&self) -> &FrameResult

The root frame’s result.

Source

pub fn events(&self) -> &[TxEmittedEvent]

The events the root frame emitted; see FrameResult::events.

Source

pub fn assert_event_count(&self, expected: usize)

Assert exactly expected events were emitted by the root frame.

Source

pub fn assert_no_events(&self)

Assert the root frame emitted no events.

Source

pub fn events_from(&self, address: &ContractAddress) -> Vec<&TxEmittedEvent>

All raw events emitted at the given address by the root frame.

Source

pub fn filter_events<E>( &self, address: &ContractAddress, ) -> Vec<TypedEvent<'_, E>>
where E: Event,

See FrameResult::filter_events for the matching rules.

Source

pub fn assert_raw_event( &self, index: usize, check: impl FnOnce(&EmittedEvent<'_>), )

Inspect a raw emitted event by index; see FrameResult::assert_raw_event.

Source

pub fn assert_event<E>( &self, index: usize, check: impl FnOnce(&TypedEvent<'_, E>), )
where E: Event,

Decode an event as a typed event and pass it to check; see FrameResult::assert_event.

Source

pub fn assert_emitted<E>( &self, address: &ContractAddress, predicate: impl Fn(&TypedEvent<'_, E>) -> bool, )
where E: Event,

See FrameResult::assert_emitted for the matching rules.

Trait Implementations§

Source§

impl Debug for TransactResult

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> StaticIfNoAlloc for T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.