arb_evm/
receipt.rs

1use alloy_evm::{
2    eth::receipt_builder::{ReceiptBuilder, ReceiptBuilderCtx},
3    Evm,
4};
5use alloy_primitives::Log;
6
7use arb_primitives::{signed_tx::ArbTxTypeLocal, ArbReceipt, ArbReceiptKind, ArbTransactionSigned};
8
9/// Builds `ArbReceipt` from execution results.
10#[derive(Debug, Clone, Copy, Default)]
11pub struct ArbReceiptBuilder;
12
13impl ReceiptBuilder for ArbReceiptBuilder {
14    type Transaction = ArbTransactionSigned;
15    type Receipt = ArbReceipt;
16
17    fn build_receipt<E: Evm>(
18        &self,
19        ctx: ReceiptBuilderCtx<'_, ArbTxTypeLocal, E>,
20    ) -> Self::Receipt {
21        let ReceiptBuilderCtx {
22            tx_type,
23            result,
24            cumulative_gas_used,
25            ..
26        } = ctx;
27        let success = result.is_success();
28        let logs: Vec<Log> = result.into_logs();
29
30        let inner = alloy_consensus::Receipt {
31            status: alloy_consensus::Eip658Value::Eip658(success),
32            cumulative_gas_used,
33            logs,
34        };
35
36        let kind = match tx_type {
37            ArbTxTypeLocal::Legacy => ArbReceiptKind::Legacy(inner),
38            ArbTxTypeLocal::Eip2930 => ArbReceiptKind::Eip2930(inner),
39            ArbTxTypeLocal::Eip1559 => ArbReceiptKind::Eip1559(inner),
40            ArbTxTypeLocal::Eip4844 => ArbReceiptKind::Eip1559(inner),
41            ArbTxTypeLocal::Eip7702 => ArbReceiptKind::Eip7702(inner),
42            ArbTxTypeLocal::Deposit => ArbReceiptKind::Deposit(arb_primitives::ArbDepositReceipt),
43            ArbTxTypeLocal::Unsigned => ArbReceiptKind::Unsigned(inner),
44            ArbTxTypeLocal::Contract => ArbReceiptKind::Contract(inner),
45            ArbTxTypeLocal::Retry => ArbReceiptKind::Retry(inner),
46            ArbTxTypeLocal::SubmitRetryable => ArbReceiptKind::SubmitRetryable(inner),
47            ArbTxTypeLocal::Internal => ArbReceiptKind::Internal(inner),
48        };
49
50        // gas_used_for_l1 is populated later by the block executor.
51        ArbReceipt::new(kind)
52    }
53}