From d401dc5e73575a53b44db122bf008156d1a87295 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 24 Jan 2025 20:29:09 +0100 Subject: [PATCH] feat: add a helper to create txenv (#13979) --- crates/evm/src/lib.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/evm/src/lib.rs b/crates/evm/src/lib.rs index f892aad9a4..23bdd3afef 100644 --- a/crates/evm/src/lib.rs +++ b/crates/evm/src/lib.rs @@ -17,10 +17,10 @@ extern crate alloc; -use core::fmt::Debug; - +use alloy_consensus::transaction::Recovered; use alloy_eips::eip2930::AccessList; use alloy_primitives::{Address, Bytes, B256, U256}; +use core::fmt::Debug; use reth_primitives_traits::{BlockHeader, SignedTransaction}; use revm::{Database, DatabaseCommit, GetInspector}; use revm_primitives::{BlockEnv, EVMError, ResultAndState, TxEnv, TxKind}; @@ -188,6 +188,12 @@ pub trait ConfigureEvmEnv: Send + Sync + Unpin + Clone + 'static { /// Returns a [`TxEnv`] from a transaction and [`Address`]. fn tx_env(&self, transaction: &Self::Transaction, signer: Address) -> Self::TxEnv; + /// Returns a [`TxEnv`] from a [`Recovered`] transaction. + fn tx_env_from_recovered(&self, tx: Recovered<&Self::Transaction>) -> Self::TxEnv { + let (tx, address) = tx.into_parts(); + self.tx_env(tx, address) + } + /// Creates a new [`EvmEnv`] for the given header. fn evm_env(&self, header: &Self::Header) -> EvmEnv;