foundry_evm_core/env/chain.rs
1//! Chain context construction and lifecycle operations.
2
3use std::fmt::Debug;
4
5#[cfg(feature = "monad")]
6use super::FoundryJournal;
7
8/// Foundry extension for chain context type
9///
10/// Every family that doesn't need chain metadata uses `()`.
11pub trait FoundryChain<Tx>: Clone + Debug + Default + Send + Sync {
12 /// Builds chain context for a standalone synthetic transaction.
13 fn for_transaction(_tx: &Tx) -> Self {
14 Self::default()
15 }
16
17 /// Builds chain context for a transaction at an exact block position.
18 fn for_block(
19 _grandparent: &[Tx],
20 _parent: &[Tx],
21 _current: &[Tx],
22 _current_tx_index: usize,
23 ) -> Self {
24 Self::default()
25 }
26
27 /// Refreshes journal state derived from the active chain position.
28 #[cfg(feature = "monad")]
29 fn refresh_journal<J: FoundryJournal>(&self, _journal: &mut J) {}
30
31 /// Clears cached protocol fees after a synthetic transaction restores chain context.
32 fn clear_transaction_fee_cache(&mut self) {}
33}
34
35impl<Tx> FoundryChain<Tx> for () {}