diff --git a/crates/consensus-any/src/receipt/envelope.rs b/crates/consensus-any/src/receipt/envelope.rs index e34d549ffb7..740e4798779 100644 --- a/crates/consensus-any/src/receipt/envelope.rs +++ b/crates/consensus-any/src/receipt/envelope.rs @@ -1,7 +1,8 @@ -use alloy_consensus::{Eip658Value, Receipt, ReceiptWithBloom, RlpEncodableReceipt, TxReceipt}; +use alloy_consensus::{Eip658Value, Receipt, ReceiptWithBloom, TxReceipt}; use alloy_eips::eip2718::{Decodable2718, Eip2718Result, Encodable2718}; use alloy_primitives::{bytes::BufMut, Bloom, Log}; use alloy_rlp::{Decodable, Encodable}; +use core::fmt; /// Receipt envelope, as defined in [EIP-2718]. /// @@ -16,23 +17,23 @@ use alloy_rlp::{Decodable, Encodable}; #[derive(Clone, Debug, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[doc(alias = "AnyTransactionReceiptEnvelope", alias = "AnyTxReceiptEnvelope")] -pub struct AnyReceiptEnvelope> { +pub struct AnyReceiptEnvelope { /// The receipt envelope. #[cfg_attr(feature = "serde", serde(flatten))] - pub inner: ReceiptWithBloom, + pub inner: ReceiptWithBloom>, /// The transaction type. #[cfg_attr(feature = "serde", serde(with = "alloy_serde::quantity"))] pub r#type: u8, } -impl AnyReceiptEnvelope { +impl AnyReceiptEnvelope { /// Returns whether this is a legacy receipt (type 0) pub const fn is_legacy(&self) -> bool { self.r#type == 0 } } -impl AnyReceiptEnvelope { +impl AnyReceiptEnvelope { /// Calculate the length of the rlp payload of the network encoded receipt. pub fn rlp_payload_length(&self) -> usize { let length = self.inner.length(); @@ -44,7 +45,7 @@ impl AnyReceiptEnvelope { } } -impl AnyReceiptEnvelope { +impl AnyReceiptEnvelope { /// Return true if the transaction was successful. /// /// ## Note @@ -53,7 +54,7 @@ impl AnyReceiptEnvelope { /// for transactions before [EIP-658]. /// /// [EIP-658]: https://eips.ethereum.org/EIPS/eip-658 - pub fn is_success(&self) -> bool { + pub const fn is_success(&self) -> bool { self.status() } @@ -65,8 +66,8 @@ impl AnyReceiptEnvelope { /// for transactions before [EIP-658]. /// /// [EIP-658]: https://eips.ethereum.org/EIPS/eip-658 - pub fn status(&self) -> bool { - self.inner.receipt.status() + pub const fn status(&self) -> bool { + self.inner.receipt.status.coerce_status() } /// Return the receipt's bloom. @@ -75,40 +76,40 @@ impl AnyReceiptEnvelope { } /// Returns the cumulative gas used at this receipt. - pub fn cumulative_gas_used(&self) -> u128 { - self.inner.receipt.cumulative_gas_used() + pub const fn cumulative_gas_used(&self) -> u128 { + self.inner.receipt.cumulative_gas_used } /// Return the receipt logs. - pub fn logs(&self) -> &[R::Log] { - self.inner.receipt.logs() + pub fn logs(&self) -> &[T] { + &self.inner.receipt.logs } } -impl TxReceipt for AnyReceiptEnvelope +impl TxReceipt for AnyReceiptEnvelope where - R: TxReceipt, + T: Clone + fmt::Debug + PartialEq + Eq + Send + Sync, { - type Log = R::Log; + type Log = T; fn status_or_post_state(&self) -> Eip658Value { - self.inner.receipt.status_or_post_state() + self.inner.receipt.status } fn status(&self) -> bool { - self.inner.receipt.status() + self.status() } fn bloom(&self) -> Bloom { - self.inner.logs_bloom + self.bloom() } fn cumulative_gas_used(&self) -> u128 { - self.inner.receipt.cumulative_gas_used() + self.cumulative_gas_used() } - fn logs(&self) -> &[Self::Log] { - self.inner.receipt.logs() + fn logs(&self) -> &[T] { + self.logs() } } diff --git a/crates/rpc-types-any/Cargo.toml b/crates/rpc-types-any/Cargo.toml index 16a2d8dc234..560ef541358 100644 --- a/crates/rpc-types-any/Cargo.toml +++ b/crates/rpc-types-any/Cargo.toml @@ -19,7 +19,6 @@ rustdoc-args = ["--cfg", "docsrs"] workspace = true [dependencies] -alloy-consensus = { workspace = true, features = ["serde"] } alloy-consensus-any = { workspace = true, features = ["serde"] } alloy-rpc-types-eth.workspace = true alloy-serde.workspace = true diff --git a/crates/rpc-types-any/src/transaction/receipt.rs b/crates/rpc-types-any/src/transaction/receipt.rs index 21ff8d7fc64..b4730893de7 100644 --- a/crates/rpc-types-any/src/transaction/receipt.rs +++ b/crates/rpc-types-any/src/transaction/receipt.rs @@ -1,12 +1,10 @@ -use alloy_consensus::Receipt; use alloy_consensus_any::AnyReceiptEnvelope; use alloy_rpc_types_eth::{Log, TransactionReceipt}; use alloy_serde::WithOtherFields; /// Alias for a catch-all receipt type. #[doc(alias = "AnyTxReceipt")] -pub type AnyTransactionReceipt = - WithOtherFields>>>; +pub type AnyTransactionReceipt = WithOtherFields>>; #[cfg(test)] mod test { diff --git a/crates/rpc-types-eth/src/log.rs b/crates/rpc-types-eth/src/log.rs index 5d73929fac4..c9e8f2def6c 100644 --- a/crates/rpc-types-eth/src/log.rs +++ b/crates/rpc-types-eth/src/log.rs @@ -1,5 +1,3 @@ -use core::borrow::Borrow; - use alloy_primitives::{Address, BlockHash, LogData, TxHash, B256}; /// Ethereum Log emitted by a transaction @@ -153,12 +151,6 @@ impl AsMut for Log { } } -impl Borrow> for Log { - fn borrow(&self) -> &alloy_primitives::Log { - &self.inner - } -} - #[cfg(test)] mod tests { use alloy_primitives::{Address, Bytes};