Skip to main content

revive_strategy/executor/
context.rs

1use foundry_compilers::{
2    ProjectCompileOutput, resolc::dual_compiled_contracts::DualCompiledContracts,
3};
4use foundry_evm::executors::ExecutorStrategyContext;
5
6use crate::{ReviveRuntimeMode, state::TestEnv};
7
8/// Defines the context for [crate::ReviveExecutorStrategyRunner].
9#[derive(Debug, Default, Clone)]
10pub struct ReviveExecutorStrategyContext {
11    /// Runtime backend mode (PVM or EVM on Polkadot)
12    pub(crate) runtime_mode: ReviveRuntimeMode,
13    /// Dual compiled contracts.
14    pub(crate) dual_compiled_contracts: DualCompiledContracts,
15    /// Compilation output.
16    pub(crate) compilation_output: Option<ProjectCompileOutput>,
17    pub(crate) externalties: TestEnv,
18}
19
20impl ReviveExecutorStrategyContext {
21    pub fn new(runtime_mode: ReviveRuntimeMode) -> Self {
22        Self { runtime_mode, ..Default::default() }
23    }
24}
25
26impl ExecutorStrategyContext for ReviveExecutorStrategyContext {
27    fn new_cloned(&self) -> Box<dyn ExecutorStrategyContext> {
28        Box::new(self.clone())
29    }
30
31    fn as_any_ref(&self) -> &dyn std::any::Any {
32        self
33    }
34
35    fn as_any_mut(&mut self) -> &mut dyn std::any::Any {
36        self
37    }
38}