eest_types/
transaction_type.rs

1/// Transaction types of all Ethereum transaction
2#[repr(u8)]
3#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
4#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
5pub enum TransactionType {
6    /// Legacy transaction type
7    Legacy = 0,
8    /// EIP-2930 Access List transaction type
9    Eip2930,
10    /// EIP-1559 Fee market change transaction type
11    Eip1559,
12    /// EIP-4844 Blob transaction type
13    Eip4844,
14    /// EIP-7702 Set EOA account code transaction type
15    Eip7702,
16    /// Custom type means that the transaction trait was extended and has
17    /// custom types
18    Custom,
19}
20
21impl PartialEq<u8> for TransactionType {
22    fn eq(&self, other: &u8) -> bool { (*self as u8) == *other }
23}
24
25impl PartialEq<TransactionType> for u8 {
26    fn eq(&self, other: &TransactionType) -> bool { *self == (*other as u8) }
27}
28
29impl From<TransactionType> for u8 {
30    fn from(tx_type: TransactionType) -> u8 { tx_type as u8 }
31}
32
33impl From<u8> for TransactionType {
34    fn from(value: u8) -> Self {
35        match value {
36            0 => Self::Legacy,
37            1 => Self::Eip2930,
38            2 => Self::Eip1559,
39            3 => Self::Eip4844,
40            4 => Self::Eip7702,
41            _ => Self::Custom,
42        }
43    }
44}