Skip to main content

CheatcodesExecutor

Trait CheatcodesExecutor 

Source
pub trait CheatcodesExecutor<FEN: FoundryEvmNetwork> {
    // Required methods
    fn exec_message(
        &mut self,
        cheats: &mut Cheatcodes<FEN>,
        backend: &mut dyn CheatcodesBackend<FEN>,
        evm: &mut FoundryEvmFor<'_, FEN>,
        message: &mut MessageFor<FEN>,
    ) -> Result<MessageResultFor<FEN>, ExecutionError>;
    fn nested_transaction(
        &mut self,
        cheats: &mut Cheatcodes<FEN>,
        backend: &mut dyn CheatcodesBackend<FEN>,
        evm: &mut FoundryEvmFor<'_, FEN>,
        depth: u16,
        tx: &Recovered<TxFor<FEN>>,
        env: Option<EvmEnvFor<FEN>>,
    ) -> Result<TxResultFor<FEN>>;
    fn transact(
        &mut self,
        cheats: &mut Cheatcodes<FEN>,
        backend: &mut dyn CheatcodesBackend<FEN>,
        evm: &mut FoundryEvmFor<'_, FEN>,
        depth: u16,
        fork_id: Option<U256>,
        transaction: B256,
    ) -> Result<TxResultFor<FEN>>;
    fn transact_from_tx(
        &mut self,
        cheats: &mut Cheatcodes<FEN>,
        backend: &mut dyn CheatcodesBackend<FEN>,
        evm: &mut FoundryEvmFor<'_, FEN>,
        depth: u16,
        tx: &Recovered<TxFor<FEN>>,
        env: Option<EvmEnvFor<FEN>>,
    ) -> Result<TxResultFor<FEN>>;
    fn console_log(&mut self, msg: &str);

    // Provided method
    fn tracing_inspector(&mut self) -> Option<&mut TracingInspector> { ... }
}
Expand description

Runs nested executions on behalf of cheatcodes.

The executor owns the inspectors besides Cheatcodes, so nested executions are observed by the whole inspector stack: tracing, logs, coverage and cheatcodes themselves.

Required Methods§

Source

fn exec_message( &mut self, cheats: &mut Cheatcodes<FEN>, backend: &mut dyn CheatcodesBackend<FEN>, evm: &mut FoundryEvmFor<'_, FEN>, message: &mut MessageFor<FEN>, ) -> Result<MessageResultFor<FEN>, ExecutionError>

Executes message as a nested frame of the transaction evm is running, with cheats active, such as for deployCode or storage-hook callbacks.

Source

fn nested_transaction( &mut self, cheats: &mut Cheatcodes<FEN>, backend: &mut dyn CheatcodesBackend<FEN>, evm: &mut FoundryEvmFor<'_, FEN>, depth: u16, tx: &Recovered<TxFor<FEN>>, env: Option<EvmEnvFor<FEN>>, ) -> Result<TxResultFor<FEN>>

Executes tx as a nested transaction of the transaction evm is running, with env or the running environment, and merges its changes so that they survive reverts of the enclosing calls, such as for executeTransaction. A failed transaction only keeps its nonce increment.

depth is the depth of the cheatcode call; the nested transaction’s root frame duplicates it, so its children run one level deeper.

Source

fn transact( &mut self, cheats: &mut Cheatcodes<FEN>, backend: &mut dyn CheatcodesBackend<FEN>, evm: &mut FoundryEvmFor<'_, FEN>, depth: u16, fork_id: Option<U256>, transaction: B256, ) -> Result<TxResultFor<FEN>>

Replays a mined transaction of fork fork_id, or of the active fork, for vm.transact.

The replayed transaction runs with cheats active over a throwaway copy of backend, so its cheatcodes cannot modify backend. Its root frame is a call below the cheatcode call at depth.

Source

fn transact_from_tx( &mut self, cheats: &mut Cheatcodes<FEN>, backend: &mut dyn CheatcodesBackend<FEN>, evm: &mut FoundryEvmFor<'_, FEN>, depth: u16, tx: &Recovered<TxFor<FEN>>, env: Option<EvmEnvFor<FEN>>, ) -> Result<TxResultFor<FEN>>

Executes a signed transaction as a nested transaction, such as for broadcastRawTransaction.

The transaction runs with cheats active over a throwaway copy of backend, in env or the running environment for None. Its root frame is a call below the cheatcode call at depth.

Source

fn console_log(&mut self, msg: &str)

Simulates console.log invocation.

Provided Methods§

Source

fn tracing_inspector(&mut self) -> Option<&mut TracingInspector>

Returns a mutable reference to the tracing inspector if it is available.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§