@@ -43,6 +43,7 @@ class TypedReceipt(ReceiptAPI, ReceiptDecoderAPI):
43
43
type_id : int
44
44
rlp_type = Binary (min_length = 1 ) # must have at least one byte for the type
45
45
_inner : ReceiptAPI
46
+ codecs = TYPED_RECEIPT_BODY_CODECS
46
47
47
48
def __init__ (self , type_id : int , proxy_target : ReceiptAPI ) -> None :
48
49
self .type_id = type_id
@@ -69,8 +70,8 @@ def encode(self) -> bytes:
69
70
70
71
@classmethod
71
72
def get_payload_codec (cls , type_id : int ) -> Type [ReceiptDecoderAPI ]:
72
- if type_id in TYPED_RECEIPT_BODY_CODECS :
73
- return TYPED_RECEIPT_BODY_CODECS [type_id ]
73
+ if type_id in cls . codecs :
74
+ return cls . codecs [type_id ]
74
75
elif type_id in VALID_TRANSACTION_TYPES :
75
76
raise UnrecognizedTransactionType (type_id , "Unknown receipt type" )
76
77
else :
@@ -124,23 +125,23 @@ def __eq__(self, other: Any) -> bool:
124
125
125
126
class BerlinReceiptBuilder (ReceiptBuilderAPI ):
126
127
legacy_sedes = Receipt
127
- codecs = TYPED_RECEIPT_BODY_CODECS
128
+ typed_receipt_class = TypedReceipt
128
129
129
130
@classmethod
130
131
def decode (cls , encoded : bytes ) -> ReceiptAPI :
131
132
if len (encoded ) == 0 :
132
133
raise ValidationError ("Encoded receipt was empty, which makes it invalid" )
133
134
134
135
type_id = to_int (encoded [0 ])
135
- if type_id in cls .codecs :
136
- return TypedReceipt .decode (encoded )
136
+ if type_id in cls .typed_receipt_class . codecs :
137
+ return cls . typed_receipt_class .decode (encoded )
137
138
else :
138
139
return rlp .decode (encoded , sedes = cls .legacy_sedes )
139
140
140
141
@classmethod
141
142
def deserialize (cls , encoded : DecodedZeroOrOneLayerRLP ) -> ReceiptAPI :
142
143
if isinstance (encoded , bytes ):
143
- return TypedReceipt .deserialize (encoded )
144
+ return cls . typed_receipt_class .deserialize (encoded )
144
145
else :
145
146
return cls .legacy_sedes .deserialize (encoded )
146
147
0 commit comments