From 0a0814a4a8c8371de3074a9c9b8204ad57d28213 Mon Sep 17 00:00:00 2001 From: antazoey Date: Wed, 18 Dec 2024 23:59:17 +0700 Subject: [PATCH] fix: issue where used `SharedBlobReceipt` instead of `Receipt` (#2421) --- src/ape_ethereum/ecosystem.py | 27 ++++++--------------------- tests/functional/test_ecosystem.py | 6 ++++++ 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/src/ape_ethereum/ecosystem.py b/src/ape_ethereum/ecosystem.py index 165aef43b4..ac29bfaf4c 100644 --- a/src/ape_ethereum/ecosystem.py +++ b/src/ape_ethereum/ecosystem.py @@ -589,29 +589,14 @@ def decode_receipt(self, data: dict) -> "ReceiptAPI": } receipt_cls: type[Receipt] - if any( - x in data - for x in ( - "blobGasPrice", - "blobGasUsed", - "blobVersionedHashes", - "maxFeePerBlobGas", - "blob_gas_price", - "blob_gas_used", - ) - ): - blob_gas_price = data.get("blob_gas_price", data.get("blobGasPrice")) + if data.get("type") == 3: + receipt_cls = SharedBlobReceipt + blob_gas_price = data.get("blob_gas_price") if blob_gas_price is None: - # Not actually a blob-receipt? Some providers may give you - # empty values here when meaning the other types of receipts. - receipt_cls = Receipt + blob_gas_price = data.get("blobGasPrice") - else: - receipt_cls = SharedBlobReceipt - receipt_kwargs["blobGasPrice"] = blob_gas_price - receipt_kwargs["blobGasUsed"] = ( - data.get("blob_gas_used", data.get("blobGasUsed")) or 0 - ) + receipt_kwargs["blobGasPrice"] = blob_gas_price + receipt_kwargs["blobGasUsed"] = data.get("blob_gas_used", data.get("blobGasUsed")) or 0 else: receipt_cls = Receipt diff --git a/tests/functional/test_ecosystem.py b/tests/functional/test_ecosystem.py index c7498af6a1..00c31d59c9 100644 --- a/tests/functional/test_ecosystem.py +++ b/tests/functional/test_ecosystem.py @@ -630,6 +630,12 @@ def test_decode_receipt_shared_blob(ethereum, blob_gas_used, blob_gas_key): # when None, should also default to 0. assert actual.blob_gas_used == 0 + # Show type=3 is required. + data["type"] = 2 + actual = ethereum.decode_receipt(data) + assert not isinstance(actual, SharedBlobReceipt) + assert isinstance(actual, Receipt) + def test_decode_receipt_misleading_blob_receipt(ethereum): """