Skip to content

Commit 8b78c68

Browse files
mattsseclaude
andauthored
refactor(anvil): simplify receipt conversion using map_logs (#12413)
Replaced verbose manual receipt conversion logic with map_logs helper method for cleaner and more maintainable code. The previous implementation manually iterated through logs, created new Vec, and reconstructed the ReceiptWithBloom. The new implementation uses the map_logs helper which does the same thing more concisely. Co-authored-by: Claude <[email protected]>
1 parent 51f168f commit 8b78c68

File tree

1 file changed

+10
-24
lines changed
  • crates/anvil/core/src/eth/transaction

1 file changed

+10
-24
lines changed

crates/anvil/core/src/eth/transaction/mod.rs

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,30 +1187,16 @@ impl TypedReceipt {
11871187
fn convert_receipt_to_rpc(
11881188
receipt: ReceiptWithBloom<Receipt<alloy_primitives::Log>>,
11891189
) -> ReceiptWithBloom<Receipt<alloy_rpc_types::Log>> {
1190-
let rpc_logs: Vec<alloy_rpc_types::Log> = receipt
1191-
.receipt
1192-
.logs
1193-
.into_iter()
1194-
.map(|log| alloy_rpc_types::Log {
1195-
inner: log,
1196-
block_hash: None,
1197-
block_number: None,
1198-
block_timestamp: None,
1199-
transaction_hash: None,
1200-
transaction_index: None,
1201-
log_index: None,
1202-
removed: false,
1203-
})
1204-
.collect();
1205-
1206-
ReceiptWithBloom {
1207-
receipt: Receipt {
1208-
status: receipt.receipt.status,
1209-
cumulative_gas_used: receipt.receipt.cumulative_gas_used,
1210-
logs: rpc_logs,
1211-
},
1212-
logs_bloom: receipt.logs_bloom,
1213-
}
1190+
receipt.map_logs(|log| alloy_rpc_types::Log {
1191+
inner: log,
1192+
block_hash: None,
1193+
block_number: None,
1194+
block_timestamp: None,
1195+
transaction_hash: None,
1196+
transaction_index: None,
1197+
log_index: None,
1198+
removed: false,
1199+
})
12141200
}
12151201

12161202
impl TypedReceiptRpc {

0 commit comments

Comments
 (0)