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