From a34507d84c2fbf3e0c3a32330acdb668408053c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Hodul=C3=A1k?= Date: Mon, 16 Jun 2025 19:14:35 +0200 Subject: [PATCH 1/2] refactor: Put variables directly in the format string Resolves clippy warnings --- crates/rpc-types-engine/src/superchain.rs | 4 ++-- crates/rpc-types/src/transaction.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/rpc-types-engine/src/superchain.rs b/crates/rpc-types-engine/src/superchain.rs index 639ccd03f..b970591cc 100644 --- a/crates/rpc-types-engine/src/superchain.rs +++ b/crates/rpc-types-engine/src/superchain.rs @@ -52,7 +52,7 @@ pub enum ProtocolVersion { impl core::fmt::Display for ProtocolVersion { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { match self { - Self::V0(value) => write!(f, "{}", value), + Self::V0(value) => write!(f, "{value}"), } } } @@ -166,7 +166,7 @@ impl ProtocolVersion { /// Returns a human-readable string representation of the ProtocolVersion pub fn display(&self) -> String { match self { - Self::V0(value) => format!("{}", value), + Self::V0(value) => format!("{value}"), } } } diff --git a/crates/rpc-types/src/transaction.rs b/crates/rpc-types/src/transaction.rs index 46dd5c5f5..2d6ed0dcf 100644 --- a/crates/rpc-types/src/transaction.rs +++ b/crates/rpc-types/src/transaction.rs @@ -206,7 +206,7 @@ mod tx_serde { //! [`alloy_consensus::transaction::Recovered::signer`] which resides in //! [`alloy_rpc_types_eth::Transaction::inner`] and [`op_alloy_consensus::TxDeposit::from`]. //! - //! Additionaly, we need similar logic for the `gasPrice` field + //! Additionally, we need similar logic for the `gasPrice` field use super::*; use alloy_consensus::transaction::Recovered; use op_alloy_consensus::OpTransaction; From 761834d62f85649459ac35e8ddca77d9cf066fc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Hodul=C3=A1k?= Date: Mon, 16 Jun 2025 19:15:35 +0200 Subject: [PATCH 2/2] feat(rpc): Convert into RPC transaction from generic `OpTransaction` --- crates/rpc-types/src/transaction.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/rpc-types/src/transaction.rs b/crates/rpc-types/src/transaction.rs index 2d6ed0dcf..2f322fe0f 100644 --- a/crates/rpc-types/src/transaction.rs +++ b/crates/rpc-types/src/transaction.rs @@ -34,9 +34,11 @@ pub struct Transaction { } impl Transaction { - /// Returns a rpc [`Transaction`] with a [`OpTransactionInfo`] and - /// [`Recovered`] as input. - pub fn from_transaction(tx: Recovered, tx_info: OpTransactionInfo) -> Self { + /// Converts a consensus `tx` with an additional context `tx_info` into an RPC [`Transaction`]. + pub fn from_transaction( + tx: Recovered, + tx_info: OpTransactionInfo, + ) -> Transaction { let base_fee = tx_info.inner.base_fee; let effective_gas_price = if tx.is_deposit() { // For deposits, we must always set the `gasPrice` field to 0 in rpc @@ -51,7 +53,7 @@ impl Transaction { .unwrap_or_else(|| tx.max_fee_per_gas()) }; - Self { + Transaction { inner: alloy_rpc_types_eth::Transaction { inner: tx, block_hash: tx_info.inner.block_hash,