diff --git a/crates/primitives/src/transaction/pooled.rs b/crates/primitives/src/transaction/pooled.rs index 6f2a727008..145660f44c 100644 --- a/crates/primitives/src/transaction/pooled.rs +++ b/crates/primitives/src/transaction/pooled.rs @@ -667,48 +667,43 @@ impl<'a> arbitrary::Arbitrary<'a> for PooledTransactionsElement { /// A signed pooled transaction with recovered signer. #[derive(Debug, Clone, PartialEq, Eq, AsRef, Deref)] -pub struct PooledTransactionsElementEcRecovered { +pub struct PooledTransactionsElementEcRecovered { /// Signer of the transaction signer: Address, /// Signed transaction #[deref] #[as_ref] - transaction: PooledTransactionsElement, + transaction: T, } -// === impl PooledTransactionsElementEcRecovered === +impl PooledTransactionsElementEcRecovered { + /// Create an instance from the given transaction and the [`Address`] of the signer. + pub const fn from_signed_transaction(transaction: T, signer: Address) -> Self { + Self { transaction, signer } + } -impl PooledTransactionsElementEcRecovered { /// Signer of transaction recovered from signature pub const fn signer(&self) -> Address { self.signer } - /// Transform back to [`PooledTransactionsElement`] - pub fn into_transaction(self) -> PooledTransactionsElement { + /// Consume the type and return the transaction + pub fn into_transaction(self) -> T { self.transaction } + /// Dissolve Self to its component + pub fn into_components(self) -> (T, Address) { + (self.transaction, self.signer) + } +} +impl PooledTransactionsElementEcRecovered { /// Transform back to [`TransactionSignedEcRecovered`] pub fn into_ecrecovered_transaction(self) -> TransactionSignedEcRecovered { let (tx, signer) = self.into_components(); tx.into_ecrecovered_transaction(signer) } - /// Dissolve Self to its component - pub fn into_components(self) -> (PooledTransactionsElement, Address) { - (self.transaction, self.signer) - } - - /// Create [`TransactionSignedEcRecovered`] from [`PooledTransactionsElement`] and [`Address`] - /// of the signer. - pub const fn from_signed_transaction( - transaction: PooledTransactionsElement, - signer: Address, - ) -> Self { - Self { transaction, signer } - } - /// Converts from an EIP-4844 [`TransactionSignedEcRecovered`] to a /// [`PooledTransactionsElementEcRecovered`] with the given sidecar. /// @@ -739,7 +734,7 @@ impl TryFrom for PooledTransactionsElementEcRecove } } -impl Encodable2718 for PooledTransactionsElementEcRecovered { +impl Encodable2718 for PooledTransactionsElementEcRecovered { fn type_flag(&self) -> Option { self.transaction.type_flag() }