revm_context_interface/transaction/
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 = 1,
10    /// EIP-1559 Fee market change transaction type
11    Eip1559 = 2,
12    /// EIP-4844 Blob transaction type
13    Eip4844 = 3,
14    /// EIP-7702 Set EOA account code transaction type
15    Eip7702 = 4,
16    // TODO(EOF)
17    // /// EOF - TXCREATE and InitcodeTransaction type
18    // Eip7873 = INITCODE_TX_TYPE,
19    /// Custom type means that the transaction trait was extended and has custom types
20    Custom = 0xFF,
21}
22
23impl PartialEq<u8> for TransactionType {
24    fn eq(&self, other: &u8) -> bool {
25        (*self as u8) == *other
26    }
27}
28
29impl PartialEq<TransactionType> for u8 {
30    fn eq(&self, other: &TransactionType) -> bool {
31        *self == (*other as u8)
32    }
33}
34
35impl From<TransactionType> for u8 {
36    fn from(tx_type: TransactionType) -> u8 {
37        tx_type as u8
38    }
39}
40
41impl From<u8> for TransactionType {
42    fn from(value: u8) -> Self {
43        match value {
44            0 => Self::Legacy,
45            1 => Self::Eip2930,
46            2 => Self::Eip1559,
47            3 => Self::Eip4844,
48            4 => Self::Eip7702,
49            // TODO(EOF)
50            //INITCODE_TX_TYPE => Self::Eip7873,
51            _ => Self::Custom,
52        }
53    }
54}