def get_payload_codec(cls, type_id: int) -> Type[TransactionDecoderAPI]: if type_id in cls.decoders: return cls.decoders[type_id] elif type_id in VALID_TRANSACTION_TYPES: raise UnrecognizedTransactionType(type_id, "Unknown transaction type") else: raise ValidationError(f"Cannot build typed transaction with {hex(type_id)} >= 0x80")
def get_payload_codec(cls, type_id: int) -> Type[ReceiptDecoderAPI]: if type_id in TYPED_RECEIPT_BODY_CODECS: return TYPED_RECEIPT_BODY_CODECS[type_id] elif type_id in VALID_TRANSACTION_TYPES: raise UnrecognizedTransactionType(type_id, "Unknown receipt type") else: raise ValidationError( f"Cannot build typed receipt with {hex(type_id)} >= 0x80")
def deserialize(cls, encoded: bytes) -> SignedTransactionAPI: if len(encoded) == 0: raise DeserializationError( "Encoded transaction was empty, which makes it invalid", encoded, ) if isinstance(encoded, bytes): transaction_type = to_int(encoded[0]) if transaction_type == 1: raise UnrecognizedTransactionType(transaction_type, "TODO: Implement EIP-2930") elif transaction_type in range(0, 0x80): raise UnrecognizedTransactionType(transaction_type, "Unknown transaction type") else: raise DeserializationError( f"Typed Transaction must start with 0-0x7f, but got {hex(transaction_type)}", encoded, ) else: return cls.legacy_signed.deserialize(encoded)