From ceb358d70e8c7b709e898c87576563db49a3ddbd Mon Sep 17 00:00:00 2001 From: Juliya Smith Date: Mon, 24 Oct 2022 14:41:52 -0500 Subject: [PATCH] fix: add PoA middleware where needed (#34) --- .pre-commit-config.yaml | 6 +++--- ape_alchemy/provider.py | 4 +++- setup.py | 6 +++--- tests/test_integration.py | 1 + 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 29caddf..c41bcac 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,18 +10,18 @@ repos: - id: isort - repo: https://github.com/psf/black - rev: 22.6.0 + rev: 22.10.0 hooks: - id: black name: black - repo: https://gitlab.com/pycqa/flake8 - rev: 4.0.1 + rev: 5.0.4 hooks: - id: flake8 - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.971 + rev: v0.982 hooks: - id: mypy additional_dependencies: [types-PyYAML, types-requests] diff --git a/ape_alchemy/provider.py b/ape_alchemy/provider.py index 9c7f6ad..5d5ed2c 100644 --- a/ape_alchemy/provider.py +++ b/ape_alchemy/provider.py @@ -73,8 +73,10 @@ def connection_str(self) -> str: def connect(self): self._web3 = Web3(HTTPProvider(self.uri)) try: - if self._web3.eth.chain_id in (4, 5, 42): + # optimism:mainnet, optimism:goerli, polygon:mainnet, or polygon:mumbai + if self._web3.eth.chain_id in (10, 420, 137, 80001): self._web3.middleware_onion.inject(geth_poa_middleware, layer=0) + self._web3.eth.set_gas_price_strategy(rpc_gas_price_strategy) except Exception as err: raise ProviderError(f"Failed to connect to Alchemy.\n{repr(err)}") from err diff --git a/setup.py b/setup.py index 3b02738..f91d20c 100644 --- a/setup.py +++ b/setup.py @@ -14,10 +14,10 @@ "hypothesis>=6.2.0,<7.0", # Strategy-based fuzzer ], "lint": [ - "black>=22.6.0", # auto-formatter and linter - "mypy>=0.971", # Static type analyzer + "black>=22.10.0", # auto-formatter and linter + "mypy>=0.982", # Static type analyzer "types-requests", # NOTE: Needed due to mypy typeshed - "flake8>=4.0.1", # Style linter + "flake8>=5.0.4", # Style linter "flake8-breakpoint>=1.1.0", # detect breakpoints left in code "flake8-print>=4.0.0", # detect print statements left in code "isort>=5.10.1", # Import sorting linter diff --git a/tests/test_integration.py b/tests/test_integration.py index 3fbaec3..58d43e7 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -24,3 +24,4 @@ def test_alchemy(ecosystem, network): with network_cls.use_provider("alchemy") as provider: assert isinstance(provider, Alchemy) assert provider.get_balance(ZERO_ADDRESS) > 0 + assert provider.get_block("latest")