1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//! Types for the provider crate.
//! For the `FetchedTransactionProof` and `FetchedTransactionReceiptProof` types.
//!
//! We need this type to bind encoded transaction and receipts to the block number and proofs.

use alloy::{
    consensus::TxType,
    primitives::{BlockNumber, Bytes, TxIndex},
};

#[derive(Debug, Clone)]
pub struct FetchedTransactionProof {
    pub block_number: BlockNumber,
    pub tx_index: TxIndex,
    pub encoded_transaction: Vec<u8>,
    pub transaction_proof: Vec<Bytes>,
    pub tx_type: TxType,
}

impl FetchedTransactionProof {
    pub fn new(
        block_number: BlockNumber,
        tx_index: TxIndex,
        encoded_transaction: Vec<u8>,
        transaction_proof: Vec<Bytes>,
        tx_type: TxType,
    ) -> Self {
        Self {
            block_number,
            tx_index,
            encoded_transaction,
            transaction_proof,
            tx_type,
        }
    }
}

#[derive(Debug, Clone)]
pub struct FetchedTransactionReceiptProof {
    pub block_number: BlockNumber,
    pub tx_index: TxIndex,
    pub encoded_receipt: Vec<u8>,
    pub receipt_proof: Vec<Bytes>,
    pub tx_type: TxType,
}

impl FetchedTransactionReceiptProof {
    pub fn new(
        block_number: BlockNumber,
        tx_index: TxIndex,
        encoded_receipt: Vec<u8>,
        receipt_proof: Vec<Bytes>,
        tx_type: TxType,
    ) -> Self {
        Self {
            block_number,
            tx_index,
            encoded_receipt,
            receipt_proof,
            tx_type,
        }
    }
}