File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
crates/consensus/src/transaction Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,12 @@ impl PartialEq<u8> for TxType {
61
61
}
62
62
}
63
63
64
+ impl PartialEq < TxType > for u8 {
65
+ fn eq ( & self , other : & TxType ) -> bool {
66
+ * self == * other as Self
67
+ }
68
+ }
69
+
64
70
#[ cfg( any( test, feature = "arbitrary" ) ) ]
65
71
impl arbitrary:: Arbitrary < ' _ > for TxType {
66
72
fn arbitrary ( u : & mut arbitrary:: Unstructured < ' _ > ) -> arbitrary:: Result < Self > {
@@ -83,6 +89,23 @@ impl TryFrom<u8> for TxType {
83
89
}
84
90
}
85
91
92
+ impl Encodable for TxType {
93
+ fn encode ( & self , out : & mut dyn alloy_rlp:: BufMut ) {
94
+ ( * self as u8 ) . encode ( out) ;
95
+ }
96
+
97
+ fn length ( & self ) -> usize {
98
+ 1
99
+ }
100
+ }
101
+
102
+ impl Decodable for TxType {
103
+ fn decode ( buf : & mut & [ u8 ] ) -> alloy_rlp:: Result < Self > {
104
+ let ty = u8:: decode ( buf) ?;
105
+ Self :: try_from ( ty) . map_err ( |_| alloy_rlp:: Error :: Custom ( "invalid transaction type" ) )
106
+ }
107
+ }
108
+
86
109
/// The Ethereum [EIP-2718] Transaction Envelope.
87
110
///
88
111
/// # Note:
You can’t perform that action at this time.
0 commit comments