From 4c1208e9d92f8fa5a4e7fec4e036e63fed1e8850 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 23 Dec 2024 23:45:18 +0100 Subject: [PATCH] feat: add missing from impls (#13527) --- crates/primitives/src/transaction/mod.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/crates/primitives/src/transaction/mod.rs b/crates/primitives/src/transaction/mod.rs index 58c0c27ed8..c729dda214 100644 --- a/crates/primitives/src/transaction/mod.rs +++ b/crates/primitives/src/transaction/mod.rs @@ -4,7 +4,7 @@ use alloc::vec::Vec; pub use alloy_consensus::transaction::PooledTransaction; use alloy_consensus::{ transaction::RlpEcdsaTx, SignableTransaction, Signed, Transaction as _, TxEip1559, TxEip2930, - TxEip4844, TxEip4844Variant, TxEip4844WithSidecar, TxEip7702, TxLegacy, Typed2718, + TxEip4844, TxEip4844Variant, TxEip4844WithSidecar, TxEip7702, TxEnvelope, TxLegacy, Typed2718, TypedTransaction, }; use alloy_eips::{ @@ -1465,6 +1465,26 @@ impl From> for TransactionSigned { } } +impl From> for TransactionSigned { + fn from(value: Signed) -> Self { + let (tx, sig, hash) = value.into_parts(); + Self::new(tx.into(), sig, hash) + } +} + +impl From for TransactionSigned { + fn from(value: TxEnvelope) -> Self { + match value { + TxEnvelope::Legacy(tx) => tx.into(), + TxEnvelope::Eip2930(tx) => tx.into(), + TxEnvelope::Eip1559(tx) => tx.into(), + TxEnvelope::Eip4844(tx) => tx.into(), + TxEnvelope::Eip7702(tx) => tx.into(), + _ => unreachable!(), + } + } +} + impl From for Signed { fn from(value: TransactionSigned) -> Self { let (tx, sig, hash) = value.into_parts();