Skip to content

Commit

Permalink
fix: for APE-1796, adds in gas_used_for_L1 to arbitrum receipt (#32)
Browse files Browse the repository at this point in the history
* fix: for APE-1796, adds in gas_used_for_L1 to arbitrum receipt

* fix: implements PR requested changes

* fix: adds default value to pydantic field

* updates flake8 config to exclude .venv

* updates test for L1 gas field

---------

Co-authored-by: slush <[email protected]>
  • Loading branch information
bitwise-constructs and slush committed Aug 12, 2024
1 parent 7d1bf19 commit 7c5e8e8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion ape_arbitrum/ecosystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from ape.api.transactions import ConfirmationsProgressBar, ReceiptAPI, TransactionAPI
from ape.exceptions import ApeException, TransactionError
from ape.logging import logger
from ape.types import GasLimit, TransactionSignature
from ape.types import GasLimit, HexInt, TransactionSignature
from ape_ethereum.ecosystem import BaseEthereumConfig, Ethereum, NetworkConfig
from ape_ethereum.transactions import (
AccessListTransaction,
Expand Down Expand Up @@ -40,6 +40,8 @@ class ApeArbitrumError(ApeException):


class ArbitrumReceipt(Receipt):
gas_used_for_L1: HexInt = Field(default=0, alias="gasUsedForL1")

def await_confirmations(self) -> "ReceiptAPI":
"""
Overridden to handle skipping nonce-check for internal txns.
Expand Down Expand Up @@ -257,6 +259,7 @@ def decode_receipt(self, data: dict) -> ReceiptAPI:
gas_limit=data.get("gas", data.get("gas_limit", data.get("gasLimit"))) or 0,
gas_price=data.get("gas_price", data.get("gasPrice")) or 0,
gas_used=data.get("gas_used", data.get("gasUsed")) or 0,
gasUsedForL1=data.get("gas_used_for_L1", data.get("gasUsedForL1")) or 0,
logs=data.get("logs", []),
status=status,
txn_hash=txn_hash,
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[flake8]
max-line-length = 100
exclude =
.venv*
venv*
.eggs
docs
Expand Down
5 changes: 4 additions & 1 deletion tests/test_ecosystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ def test_decode_receipt(arbitrum):
),
"status": 1,
"l1BlockNumber": "0x11148fc",
"gasUsedForL1": "0x0",
"gasUsedForL1": "0x7",
}
actual = arbitrum.decode_receipt(data)
assert isinstance(actual, ArbitrumReceipt)

# Check that the receipt decodes HexInt correctly
assert actual.gas_used_for_L1 == 7

0 comments on commit 7c5e8e8

Please sign in to comment.