Skip to content

Comments

feat(consensus): add EthereumReceipt::map_logs#3710

Merged
mattsse merged 3 commits intoalloy-rs:mainfrom
stevencartavia:into-rpc-receipt
Feb 17, 2026
Merged

feat(consensus): add EthereumReceipt::map_logs#3710
mattsse merged 3 commits intoalloy-rs:mainfrom
stevencartavia:into-rpc-receipt

Conversation

@stevencartavia
Copy link
Contributor

@stevencartavia stevencartavia commented Feb 17, 2026

Add pub fn map_logs on impl<T, L> EthereumReceipt<T, L>, following the same pattern as Receipt::map_logs.

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets add map fns to EthereumReceipt instead

basically like

/// Converts the receipt's log type by applying a function to each log.
///
/// Returns the receipt with the new log type
pub fn map_logs<U>(self, f: impl FnMut(T) -> U) -> Receipt<U> {
let Self { status, cumulative_gas_used, logs } = self;
Receipt { status, cumulative_gas_used, logs: logs.into_iter().map(f).collect() }
}

Comment on lines 155 to 168
/// Converts an [`EthereumReceipt`] with consensus [`alloy_primitives::Log`]s into one with
/// RPC [`Log`]s by enriching each log with block/transaction metadata.
///
/// Uses [`Log::collect_for_receipt`] to populate RPC-specific fields such as block hash, block
/// number, transaction hash, transaction index, and log index.
pub fn into_rpc_receipt<T>(
receipt: EthereumReceipt<T>,
next_log_index: usize,
meta: TransactionMeta,
) -> EthereumReceipt<T, Log> {
let EthereumReceipt { tx_type, success, cumulative_gas_used, logs } = receipt;
let logs = Log::collect_for_receipt(next_log_index, meta, logs);
EthereumReceipt { tx_type, success, cumulative_gas_used, logs }
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait, isnt this just map receipt?

I actually dont like a standalone fn for this if this can also be solved with a simple map

@github-project-automation github-project-automation bot moved this to In Progress in Alloy Feb 17, 2026
@github-project-automation github-project-automation bot moved this from In Progress to Reviewed in Alloy Feb 17, 2026
@stevencartavia stevencartavia changed the title feat(rpc-types-eth): add into_rpc_receipt helper feat(consensus): add EthereumReceipt::map_logs Feb 17, 2026
@mattsse mattsse enabled auto-merge (squash) February 17, 2026 17:38
@mattsse mattsse disabled auto-merge February 17, 2026 18:03
@mattsse mattsse merged commit 1ec547c into alloy-rs:main Feb 17, 2026
28 of 30 checks passed
@github-project-automation github-project-automation bot moved this from Reviewed to Done in Alloy Feb 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants