Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions crates/consensus/src/receipt/envelope.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use core::fmt;

use crate::{Eip658Value, Receipt, ReceiptWithBloom, TxReceipt, TxType};
use alloc::vec::Vec;
use alloy_eips::{
eip2718::{
Decodable2718, Eip2718Error, Eip2718Result, Encodable2718, IsTyped2718, EIP1559_TX_TYPE_ID,
Expand All @@ -10,6 +9,7 @@ use alloy_eips::{
};
use alloy_primitives::{Bloom, Log};
use alloy_rlp::{BufMut, Decodable, Encodable};
use core::fmt;

/// Receipt envelope, as defined in [EIP-2718].
///
Expand Down Expand Up @@ -109,6 +109,11 @@ impl<T> ReceiptEnvelope<T> {
&self.as_receipt().unwrap().logs
}

/// Consumes the type and returns the logs.
pub fn into_logs(self) -> Vec<T> {
self.into_receipt().logs
}

/// Return the receipt's bloom.
pub fn logs_bloom(&self) -> &Bloom {
&self.as_receipt_with_bloom().unwrap().logs_bloom
Expand Down Expand Up @@ -138,6 +143,17 @@ impl<T> ReceiptEnvelope<T> {
}
}

/// Consumes the type and returns the underlying [`Receipt`].
pub fn into_receipt(self) -> Receipt<T> {
match self {
Self::Legacy(t)
| Self::Eip2930(t)
| Self::Eip1559(t)
| Self::Eip4844(t)
| Self::Eip7702(t) => t.receipt,
}
}

/// Return the inner receipt. Currently this is infallible, however, future
/// receipt types may be added.
pub const fn as_receipt(&self) -> Option<&Receipt<T>> {
Expand Down