feat: simplify envelope conversion (#14146)

This commit is contained in:
Matthias Seitz
2025-02-01 15:29:41 +01:00
committed by GitHub
parent 6e0fbb469b
commit fd4ca7d6d6
4 changed files with 48 additions and 50 deletions

View File

@ -171,6 +171,19 @@ impl From<OpTxEnvelope> for OpTransactionSigned {
}
}
impl From<OpTransactionSigned> for OpTxEnvelope {
fn from(value: OpTransactionSigned) -> Self {
let (tx, signature, hash) = value.into_parts();
match tx {
OpTypedTransaction::Legacy(tx) => Signed::new_unchecked(tx, signature, hash).into(),
OpTypedTransaction::Eip2930(tx) => Signed::new_unchecked(tx, signature, hash).into(),
OpTypedTransaction::Eip1559(tx) => Signed::new_unchecked(tx, signature, hash).into(),
OpTypedTransaction::Deposit(tx) => Sealed::new_unchecked(tx, hash).into(),
OpTypedTransaction::Eip7702(tx) => Signed::new_unchecked(tx, signature, hash).into(),
}
}
}
impl From<OpTransactionSigned> for Signed<OpTypedTransaction> {
fn from(value: OpTransactionSigned) -> Self {
let (tx, sig, hash) = value.into_parts();