chore(sdk): limit FillTxEnv to super trait of FullSignedTx (#12614)

This commit is contained in:
Emilia Hane
2024-11-18 22:43:26 +01:00
committed by GitHub
parent 7fb862cbde
commit 641d1288e9
7 changed files with 60 additions and 42 deletions

View File

@ -26,6 +26,7 @@ pub use receipt::{FullReceipt, Receipt};
pub mod transaction;
pub use transaction::{
execute::FillTxEnv,
signed::{FullSignedTx, SignedTransaction},
FullTransaction, Transaction, TransactionExt,
};

View File

@ -0,0 +1,10 @@
//! Abstraction of an executable transaction.
use alloy_primitives::Address;
use revm_primitives::TxEnv;
/// Loads transaction into execution environment.
pub trait FillTxEnv {
/// Fills [`TxEnv`] with an [`Address`] and transaction.
fn fill_tx_env(&self, tx_env: &mut TxEnv, sender: Address);
}

View File

@ -1,5 +1,6 @@
//! Transaction abstraction
pub mod execute;
pub mod signed;
use core::{fmt, hash::Hash};

View File

@ -6,14 +6,19 @@ use core::hash::Hash;
use alloy_eips::eip2718::{Decodable2718, Encodable2718};
use alloy_primitives::{keccak256, Address, PrimitiveSignature, TxHash, B256};
use reth_codecs::Compact;
use revm_primitives::TxEnv;
use crate::{FullTransaction, InMemorySize, MaybeArbitrary, MaybeSerde, Transaction};
use crate::{FillTxEnv, FullTransaction, InMemorySize, MaybeArbitrary, MaybeSerde, Transaction};
/// Helper trait that unifies all behaviour required by block to support full node operations.
pub trait FullSignedTx: SignedTransaction<Transaction: FullTransaction> + Compact {}
pub trait FullSignedTx:
SignedTransaction<Transaction: FullTransaction> + FillTxEnv + Compact
{
}
impl<T> FullSignedTx for T where T: SignedTransaction<Transaction: FullTransaction> + Compact {}
impl<T> FullSignedTx for T where
T: SignedTransaction<Transaction: FullTransaction> + FillTxEnv + Compact
{
}
/// A signed transaction.
#[auto_impl::auto_impl(&, Arc)]
@ -71,9 +76,6 @@ pub trait SignedTransaction:
fn recalculate_hash(&self) -> B256 {
keccak256(self.encoded_2718())
}
/// Fills [`TxEnv`] with an [`Address`] and transaction.
fn fill_tx_env(&self, tx_env: &mut TxEnv, sender: Address);
}
/// Helper trait used in testing.