revm_context_interface/transaction/
alloy_types.rs

1use super::{AccessListItemTr, AuthorizationTr};
2use either::{for_both, Either};
3use primitives::{Address, B256, U256};
4
5pub use alloy_eip2930::{AccessList, AccessListItem};
6pub use alloy_eip7702::{
7    Authorization, RecoveredAuthority, RecoveredAuthorization, SignedAuthorization,
8};
9
10impl AccessListItemTr for AccessListItem {
11    fn address(&self) -> &Address {
12        &self.address
13    }
14
15    fn storage_slots(&self) -> impl Iterator<Item = &B256> {
16        self.storage_keys.iter()
17    }
18}
19
20impl AuthorizationTr for SignedAuthorization {
21    fn authority(&self) -> Option<Address> {
22        self.recover_authority().ok()
23    }
24
25    fn chain_id(&self) -> U256 {
26        self.chain_id
27    }
28
29    fn nonce(&self) -> u64 {
30        self.nonce
31    }
32
33    fn address(&self) -> Address {
34        self.address
35    }
36}
37
38impl AuthorizationTr for RecoveredAuthorization {
39    fn authority(&self) -> Option<Address> {
40        self.authority()
41    }
42
43    fn chain_id(&self) -> U256 {
44        self.chain_id
45    }
46
47    fn nonce(&self) -> u64 {
48        self.nonce
49    }
50
51    fn address(&self) -> Address {
52        self.address
53    }
54}
55
56impl<L: AuthorizationTr, R: AuthorizationTr> AuthorizationTr for Either<L, R> {
57    fn authority(&self) -> Option<Address> {
58        for_both!(self, s => s.authority())
59    }
60
61    fn chain_id(&self) -> U256 {
62        for_both!(self, s => s.chain_id())
63    }
64
65    fn nonce(&self) -> u64 {
66        for_both!(self, s => s.nonce())
67    }
68
69    fn address(&self) -> Address {
70        for_both!(self, s => s.address())
71    }
72}