diff --git a/ape_alchemy/provider.py b/ape_alchemy/provider.py index 56f771d..40f1d6b 100644 --- a/ape_alchemy/provider.py +++ b/ape_alchemy/provider.py @@ -80,8 +80,12 @@ def connection_str(self) -> str: def connect(self): self._web3 = Web3(HTTPProvider(self.uri)) try: - # optimism:mainnet, optimism:goerli, polygon:mainnet, or polygon:mumbai - if self._web3.eth.chain_id in (10, 420, 137, 80001): + # Any chain that *began* as PoA needs the middleware for pre-merge blocks + ethereum_goerli = 5 + optimism = (10, 420) + polygon = (137, 80001) + + if self._web3.eth.chain_id in (ethereum_goerli, *optimism, *polygon): self._web3.middleware_onion.inject(geth_poa_middleware, layer=0) self._web3.eth.set_gas_price_strategy(rpc_gas_price_strategy) diff --git a/tests/test_integration.py b/tests/test_integration.py index 58d43e7..d3867f3 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -24,4 +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") + assert provider.get_block(0)