revm_context_interface/transaction/
either.rs

1use super::Transaction;
2use either::Either;
3use primitives::{Address, Bytes, TxKind, B256, U256};
4
5impl<L, R> Transaction for Either<L, R>
6where
7    L: Transaction + 'static,
8    R: for<'a> Transaction<
9            AccessListItem<'a> = L::AccessListItem<'a>,
10            Authorization<'a> = L::Authorization<'a>,
11        > + 'static,
12{
13    type AccessListItem<'a>
14        = L::AccessListItem<'a>
15    where
16        Self: 'a;
17
18    type Authorization<'a>
19        = L::Authorization<'a>
20    where
21        Self: 'a;
22
23    fn tx_type(&self) -> u8 {
24        match self {
25            Either::Left(l) => l.tx_type(),
26            Either::Right(r) => r.tx_type(),
27        }
28    }
29
30    fn caller(&self) -> Address {
31        match self {
32            Either::Left(l) => l.caller(),
33            Either::Right(r) => r.caller(),
34        }
35    }
36
37    fn gas_limit(&self) -> u64 {
38        match self {
39            Either::Left(l) => l.gas_limit(),
40            Either::Right(r) => r.gas_limit(),
41        }
42    }
43
44    fn value(&self) -> U256 {
45        match self {
46            Either::Left(l) => l.value(),
47            Either::Right(r) => r.value(),
48        }
49    }
50
51    fn input(&self) -> &Bytes {
52        match self {
53            Either::Left(l) => l.input(),
54            Either::Right(r) => r.input(),
55        }
56    }
57
58    fn nonce(&self) -> u64 {
59        match self {
60            Either::Left(l) => l.nonce(),
61            Either::Right(r) => r.nonce(),
62        }
63    }
64
65    fn kind(&self) -> TxKind {
66        match self {
67            Either::Left(l) => l.kind(),
68            Either::Right(r) => r.kind(),
69        }
70    }
71
72    fn chain_id(&self) -> Option<u64> {
73        match self {
74            Either::Left(l) => l.chain_id(),
75            Either::Right(r) => r.chain_id(),
76        }
77    }
78
79    fn gas_price(&self) -> u128 {
80        match self {
81            Either::Left(l) => l.gas_price(),
82            Either::Right(r) => r.gas_price(),
83        }
84    }
85
86    fn access_list(&self) -> Option<impl Iterator<Item = Self::AccessListItem<'_>>> {
87        match self {
88            Either::Left(l) => l.access_list().map(Either::Left),
89            Either::Right(r) => r.access_list().map(Either::Right),
90        }
91    }
92
93    fn blob_versioned_hashes(&self) -> &[B256] {
94        match self {
95            Either::Left(l) => l.blob_versioned_hashes(),
96            Either::Right(r) => r.blob_versioned_hashes(),
97        }
98    }
99
100    fn max_fee_per_blob_gas(&self) -> u128 {
101        match self {
102            Either::Left(l) => l.max_fee_per_blob_gas(),
103            Either::Right(r) => r.max_fee_per_blob_gas(),
104        }
105    }
106
107    fn authorization_list_len(&self) -> usize {
108        match self {
109            Either::Left(l) => l.authorization_list_len(),
110            Either::Right(r) => r.authorization_list_len(),
111        }
112    }
113
114    fn authorization_list(&self) -> impl Iterator<Item = Self::Authorization<'_>> {
115        match self {
116            Either::Left(l) => Either::Left(l.authorization_list()),
117            Either::Right(r) => Either::Right(r.authorization_list()),
118        }
119    }
120
121    fn max_priority_fee_per_gas(&self) -> Option<u128> {
122        match self {
123            Either::Left(l) => l.max_priority_fee_per_gas(),
124            Either::Right(r) => r.max_priority_fee_per_gas(),
125        }
126    }
127}