Skip to main content

FoundryContextExt

Trait FoundryContextExt 

pub trait FoundryContextExt: ContextTr{
    // Required methods
    fn block_mut(&mut self) -> &mut Self::Block;
    fn tx_mut(&mut self) -> &mut Self::Tx;
    fn cfg_mut(&mut self) -> &mut Self::Cfg;
    fn db_journal_inner_mut(
        &mut self,
    ) -> (&mut Self::Db, &mut JournalInner<JournalEntry>);

    // Provided methods
    fn set_block(&mut self, block: Self::Block) { ... }
    fn set_tx(&mut self, tx: Self::Tx) { ... }
    fn set_cfg(&mut self, cfg: Self::Cfg) { ... }
    fn set_journal_inner(&mut self, journal_inner: JournalInner<JournalEntry>) { ... }
    fn set_evm(
        &mut self,
        evm_env: EvmEnv<<Self::Cfg as FoundryCfg>::Spec, Self::Block>,
    )
       where Self::Cfg: From<CfgEnv<<Self::Cfg as FoundryCfg>::Spec>> { ... }
    fn tx_clone(&self) -> Self::Tx { ... }
    fn evm_clone(&self) -> EvmEnv<<Self::Cfg as FoundryCfg>::Spec, Self::Block>
       where Self::Cfg: Into<CfgEnv<<Self::Cfg as FoundryCfg>::Spec>> { ... }
}
Expand description

Extension trait providing mutable field access to block, tx, and cfg environments.

ContextTr only exposes immutable references for block, tx, and cfg. Cheatcodes like vm.warp(), vm.roll(), vm.chainId() need to mutate these fields.

Required Methods§

fn block_mut(&mut self) -> &mut Self::Block

Mutable reference to the block environment.

fn tx_mut(&mut self) -> &mut Self::Tx

Mutable reference to the transaction environment.

fn cfg_mut(&mut self) -> &mut Self::Cfg

Mutable reference to the configuration environment.

fn db_journal_inner_mut( &mut self, ) -> (&mut Self::Db, &mut JournalInner<JournalEntry>)

Mutable reference to the db and the journal inner.

Provided Methods§

fn set_block(&mut self, block: Self::Block)

Sets block environment.

fn set_tx(&mut self, tx: Self::Tx)

Sets transaction environment.

fn set_cfg(&mut self, cfg: Self::Cfg)

Sets configuration environment.

fn set_journal_inner(&mut self, journal_inner: JournalInner<JournalEntry>)

Sets journal inner.

fn set_evm( &mut self, evm_env: EvmEnv<<Self::Cfg as FoundryCfg>::Spec, Self::Block>, )
where Self::Cfg: From<CfgEnv<<Self::Cfg as FoundryCfg>::Spec>>,

Sets EVM environment.

fn tx_clone(&self) -> Self::Tx

Cloned transaction environment.

fn evm_clone(&self) -> EvmEnv<<Self::Cfg as FoundryCfg>::Spec, Self::Block>
where Self::Cfg: Into<CfgEnv<<Self::Cfg as FoundryCfg>::Spec>>,

Cloned EVM environment (Cfg + Block).

Implementors§

§

impl<BLOCK, TX, CFG, DB> FoundryContextExt for Context<BLOCK, TX, CFG, DB>
where BLOCK: FoundryBlock + Clone, TX: FoundryTransaction + Clone, CFG: FoundryCfg, DB: Database,