chore: bidirectional eq for TxType (#7876)

This commit is contained in:
Matthias Seitz
2024-04-25 15:56:42 +02:00
committed by GitHub
parent 6f22621f43
commit 29e5df81a4

View File

@ -85,17 +85,17 @@ impl TryFrom<u8> for TxType {
fn try_from(value: u8) -> Result<Self, Self::Error> {
#[cfg(feature = "optimism")]
if value == TxType::Deposit as u8 {
if value == TxType::Deposit {
return Ok(TxType::Deposit)
}
if value == TxType::Legacy as u8 {
if value == TxType::Legacy {
return Ok(TxType::Legacy)
} else if value == TxType::Eip2930 as u8 {
} else if value == TxType::Eip2930 {
return Ok(TxType::Eip2930)
} else if value == TxType::Eip1559 as u8 {
} else if value == TxType::Eip1559 {
return Ok(TxType::Eip1559)
} else if value == TxType::Eip4844 as u8 {
} else if value == TxType::Eip4844 {
return Ok(TxType::Eip4844)
}
@ -175,6 +175,12 @@ impl PartialEq<u8> for TxType {
}
}
impl PartialEq<TxType> for u8 {
fn eq(&self, other: &TxType) -> bool {
*self == *other as u8
}
}
#[cfg(test)]
mod tests {
use super::*;