Skip to content

Commit

Permalink
fix: source tb on traced calls
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Aug 25, 2023
1 parent 06e0054 commit d528691
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
rev: v4.4.0
hooks:
- id: check-yaml

Expand All @@ -10,24 +10,24 @@ repos:
- id: isort

- repo: https://github.com/psf/black
rev: 23.3.0
rev: 23.7.0
hooks:
- id: black
name: black

- repo: https://github.com/pycqa/flake8
rev: 6.0.0
rev: 6.1.0
hooks:
- id: flake8

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.991
rev: v1.5.1
hooks:
- id: mypy
additional_dependencies: [types-PyYAML, types-requests, types-setuptools, pydantic]

- repo: https://github.com/executablebooks/mdformat
rev: 0.7.14
rev: 0.7.17
hooks:
- id: mdformat
additional_dependencies: [mdformat-gfm, mdformat-frontmatter]
Expand Down
11 changes: 9 additions & 2 deletions ape_foundry/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -802,10 +802,17 @@ def _eth_call(self, arguments: List) -> bytes:
try:
result = self._make_request("eth_call", arguments)
except Exception as err:
trace = (self._create_trace_frame(x) for x in self._trace_call(arguments)[1])
trace, trace2 = tee(self._create_trace_frame(x) for x in self._trace_call(arguments)[1])
contract_address = arguments[0]["to"]
contract_type = self.chain_manager.contracts.get(contract_address)
method_id = arguments[0].get("data", "")[:10] or None
tb = (
SourceTraceback.create(contract_type, trace, method_id)
if method_id and contract_type
else None
)
raise self.get_virtual_machine_error(
err, trace=trace, contract_address=contract_address
err, trace=trace2, contract_address=contract_address, source_traceback=tb
) from err

return HexBytes(result)
Expand Down
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
"ape-polygon", # For running polygon fork tests
],
"lint": [
"black>=23.3.0,<24", # auto-formatter and linter
"mypy>=0.991,<1", # Static type analyzer
"black>=23.7.0,<24", # auto-formatter and linter
"mypy>=1.5.1,<2", # Static type analyzer
"types-requests", # Needed due to mypy typeshed
"types-setuptools", # Needed due to mypy typeshed
"types-PyYAML", # Needed due to mypy typeshed
"flake8>=6.0.0,<7", # Style linter
"isort>=5.10.1,<6", # Import sorting linter
"mdformat>=0.7.16", # Auto-formatter for markdown
"flake8>=6.0.1,<7", # Style linter
"isort>=<5.10.1,<6", # Import sorting linter
"mdformat>=0.7.17", # Auto-formatter for markdown
"mdformat-gfm>=0.3.5", # Needed for formatting GitHub-flavored markdown
"mdformat-frontmatter>=0.4.1", # Needed for frontmatters-style headers in issue templates
],
Expand Down
2 changes: 1 addition & 1 deletion tests/test_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def test_set_code(connected_provider, contract_container, owner):
contract = contract_container.deploy(sender=owner)
provider = connected_provider
code = provider.get_code(contract.address)
assert type(code) == HexBytes
assert type(code) is HexBytes
assert provider.set_code(contract.address, "0x00") is True
assert provider.get_code(contract.address) != code
assert provider.set_code(contract.address, code) is True
Expand Down

0 comments on commit d528691

Please sign in to comment.