Skip to content

Commit

Permalink
Merge branch 'main' of github.com:wakamex/ape-alchemy
Browse files Browse the repository at this point in the history
  • Loading branch information
wakamex committed Nov 9, 2022
2 parents f7e464b + 1b010ac commit 0c08e6f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions ape_alchemy/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 0c08e6f

Please sign in to comment.