Skip to content

Commit

Permalink
feat!: Handle 0.7 breaking changes and updates [APE-1543] (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
NotPeopling2day authored Dec 19, 2023
1 parent 4abb349 commit dca5aa9
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 25 deletions.
1 change: 0 additions & 1 deletion .mdformat.toml

This file was deleted.

6 changes: 3 additions & 3 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.4.0
rev: v4.5.0
hooks:
- id: check-yaml

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

- repo: https://github.com/psf/black
rev: 23.9.1
rev: 23.12.0
hooks:
- id: black
name: black
Expand All @@ -21,7 +21,7 @@ repos:
- id: flake8

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.5.1
rev: v1.7.1
hooks:
- id: mypy
additional_dependencies: [types-PyYAML, types-requests, pydantic, types-setuptools]
Expand Down
13 changes: 7 additions & 6 deletions ape_alchemy/provider.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
from typing import Any, Dict, Optional
from typing import Any, Dict, List, Optional

from ape.api import ReceiptAPI, TransactionAPI, UpstreamProvider, Web3Provider
from ape.api import ReceiptAPI, TransactionAPI, UpstreamProvider
from ape.exceptions import (
APINotImplementedError,
ContractLogicError,
Expand All @@ -10,8 +10,9 @@
)
from ape.logging import logger
from ape.types import CallTreeNode
from ape_ethereum.provider import Web3Provider
from eth_pydantic_types import HexBytes
from eth_typing import HexStr
from ethpm_types import HexBytes
from evm_trace import (
ParityTraceList,
get_calltree_from_geth_call_trace,
Expand Down Expand Up @@ -132,7 +133,7 @@ def get_call_tree(self, txn_hash: str) -> CallTreeNode:

def _get_calltree_using_parity_style(self, txn_hash: str) -> CallTreeNode:
raw_trace_list = self._make_request("trace_transaction", [txn_hash])
trace_list = ParityTraceList.parse_obj(raw_trace_list)
trace_list = ParityTraceList.model_validate(raw_trace_list)
evm_call = get_calltree_from_parity_trace(trace_list)
return self._create_call_tree_node(evm_call)

Expand Down Expand Up @@ -178,11 +179,11 @@ def get_virtual_machine_error(self, exception: Exception, **kwargs) -> VirtualMa

return VirtualMachineError(message=message, txn=txn)

def _make_request(self, endpoint: str, parameters: list) -> Any:
def _make_request(self, endpoint: str, parameters: Optional[List] = None) -> Any:
try:
return super()._make_request(endpoint, parameters)
except HTTPError as err:
response_data = err.response.json()
response_data = err.response.json() if err.response else {}
if "error" not in response_data:
raise AlchemyProviderError(str(err)) from err

Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ force_grid_wrap = 0
include_trailing_comma = true
multi_line_output = 3
use_parentheses = true

[tool.mdformat]
number = true
33 changes: 19 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,35 @@
"ape-arbitrum", # Needed for testing Arbitrum integration
"ape-base", # Needed for testing Base integration
"ape-optimism", # Needed for testing Optimism integration
"ape-polygon", # Neblack .eded for testing Polygon integration
"ape-polygon", # Needed for testing Polygon integration
"pytest>=6.0", # Core testing package
"pytest-xdist", # multi-process runner
"pytest-xdist", # Multi-process runner
"pytest-cov", # Coverage analyzer plugin
"pytest-mock", # For creating mocks
"hypothesis>=6.2.0,<7.0", # Strategy-based fuzzer
"websocket-client", # Used for web socket integration testing
],
"lint": [
"black>=23.9.1,<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
"black>=23.12.0,<24", # Auto-formatter and linter
"mypy>=1.7.1,<2", # Static type analyzer
"types-setuptools", # Needed for mypy type shed
"types-requests", # Needed for mypy type shed
"flake8>=6.1.0,<7", # Style linter
"flake8-breakpoint>=1.1.0", # detect breakpoints left in code
"flake8-print>=4.0.0", # detect print statements left in code
"flake8-breakpoint>=1.1.0,<2", # Detect breakpoints left in code
"flake8-print>=5.0.0,<6", # Detect print statements left in code
"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
"mdformat-pyproject>=0.0.1", # Allows configuring in pyproject.toml
],
"doc": [
"myst-parser>=0.17.0,<0.18", # Tools for parsing markdown files in the docs
"sphinx-click>=3.1.0,<4.0", # For documenting CLI
"Sphinx>=4.4.0,<5.0", # Documentation generator
"sphinx_rtd_theme>=1.0.0,<2", # Readthedocs.org theme
"myst-parser>=1.0.0,<2", # Parse markdown docs
"sphinx-click>=4.4.0,<5", # For documenting CLI
"Sphinx>=6.1.3,<7", # Documentation generator
"sphinx_rtd_theme>=1.2.0,<2", # Readthedocs.org theme
"sphinxcontrib-napoleon>=0.7", # Allow Google-style documentation
"sphinx-plausible>=0.1.2,<0.2",
],
"release": [ # `release` GitHub Action job uses this
"setuptools", # Installation tool
Expand Down Expand Up @@ -74,8 +76,11 @@
url="https://github.com/ApeWorX/ape-alchemy",
include_package_data=True,
install_requires=[
"eth-ape>=0.6.5,<0.7",
"web3", # Get web3 version from ape
"eth-ape>=0.7.0,<0.8",
"eth-pydantic-types", # Use same version as eth-ape
"ethpm-types", # Use same version as eth-ape
"evm-trace", # Use same version as eth-ape
"web3", # Use same version as eth-ape
"requests",
],
python_requires=">=3.8,<4",
Expand Down
3 changes: 2 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ def networks():


@pytest.fixture
def missing_token(mocker):
def missing_token(alchemy_provider, mocker):
env = os.environ.copy()
mock = mocker.patch("os.environ.get")

def side_effect(key, *args, **kwargs):
return None if "WEB3" in key else env.get(key, *args, **kwargs)

alchemy_provider.network_uris = {}
mock.side_effect = side_effect
return mock

Expand Down

0 comments on commit dca5aa9

Please sign in to comment.