diff --git a/crates/edr_eth/src/transaction.rs b/crates/edr_eth/src/transaction.rs index b159e8660..53cc1f62d 100644 --- a/crates/edr_eth/src/transaction.rs +++ b/crates/edr_eth/src/transaction.rs @@ -84,6 +84,25 @@ impl TryFrom for Type { } } +impl<'deserializer> serde::Deserialize<'deserializer> for Type { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'deserializer>, + { + let value = U8::deserialize(deserializer)?; + Type::try_from(value.to::()).map_err(serde::de::Error::custom) + } +} + +impl serde::Serialize for Type { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + U8::serialize(&U8::from(u8::from(*self)), serializer) + } +} + pub trait SignedTransaction: Transaction { /// The effective gas price of the transaction, calculated using the /// provided block base fee.