#[repr(u8)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum TransactionType {
Legacy = 0,
Eip2930,
Eip1559,
Eip4844,
Eip7702,
Custom,
}
impl PartialEq<u8> for TransactionType {
fn eq(&self, other: &u8) -> bool { (*self as u8) == *other }
}
impl PartialEq<TransactionType> for u8 {
fn eq(&self, other: &TransactionType) -> bool { *self == (*other as u8) }
}
impl From<TransactionType> for u8 {
fn from(tx_type: TransactionType) -> u8 { tx_type as u8 }
}
impl From<u8> for TransactionType {
fn from(value: u8) -> Self {
match value {
0 => Self::Legacy,
1 => Self::Eip2930,
2 => Self::Eip1559,
3 => Self::Eip4844,
4 => Self::Eip7702,
_ => Self::Custom,
}
}
}