From 576cef4b13c236d78bf3a7049518922b081df8fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Hodul=C3=A1k?= Date: Tue, 17 Jun 2025 15:33:10 +0200 Subject: [PATCH] feat(rpc): Implement `FromConsensusTx` for generic `OpTransaction` (#16832) --- crates/rpc/rpc-types-compat/src/transaction.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/crates/rpc/rpc-types-compat/src/transaction.rs b/crates/rpc/rpc-types-compat/src/transaction.rs index 3802e102f9..625cf585b2 100644 --- a/crates/rpc/rpc-types-compat/src/transaction.rs +++ b/crates/rpc/rpc-types-compat/src/transaction.rs @@ -2,8 +2,7 @@ use crate::fees::{CallFees, CallFeesError}; use alloy_consensus::{ - error::ValueError, transaction::Recovered, EthereumTxEnvelope, SignableTransaction, - Transaction as ConsensusTransaction, TxEip4844, + error::ValueError, transaction::Recovered, EthereumTxEnvelope, SignableTransaction, TxEip4844, }; use alloy_network::Network; use alloy_primitives::{Address, Bytes, Signature, TxKind, U256}; @@ -124,7 +123,7 @@ pub trait FromConsensusTx { fn from_consensus_tx(tx: T, signer: Address, tx_info: Self::TxInfo) -> Self; } -impl FromConsensusTx for Transaction { +impl FromConsensusTx for Transaction { type TxInfo = TransactionInfo; fn from_consensus_tx(tx: T, signer: Address, tx_info: Self::TxInfo) -> Self { @@ -149,7 +148,7 @@ impl FromConsensusTx for Transaction { impl IntoRpcTx for ConsensusTx where - ConsensusTx: ConsensusTransaction, + ConsensusTx: alloy_consensus::Transaction, RpcTx: FromConsensusTx, { type TxInfo = RpcTx::TxInfo; @@ -226,11 +225,13 @@ pub fn try_into_op_tx_info>( Ok(OpTransactionInfo::new(tx_info, deposit_meta)) } -impl FromConsensusTx for op_alloy_rpc_types::Transaction { +impl FromConsensusTx + for op_alloy_rpc_types::Transaction +{ type TxInfo = OpTransactionInfo; - fn from_consensus_tx(tx: OpTxEnvelope, signer: Address, tx_info: Self::TxInfo) -> Self { - Self::from_transaction(tx.with_signer(signer), tx_info) + fn from_consensus_tx(tx: T, signer: Address, tx_info: Self::TxInfo) -> Self { + Self::from_transaction(Recovered::new_unchecked(tx, signer), tx_info) } }