Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: validate Ape has connected to the right network and client #1038

Merged
merged 10 commits into from
Sep 15, 2022
8 changes: 4 additions & 4 deletions src/ape/api/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,16 +681,16 @@ def estimate_gas_cost(self, txn: TransactionAPI, **kwargs) -> int:

@property
def chain_id(self) -> int:
if self.network.name not in (
if hasattr(self.web3, "eth"):
antazoey marked this conversation as resolved.
Show resolved Hide resolved
return self.web3.eth.chain_id

elif self.network.name not in (
"adhoc",
LOCAL_NETWORK_NAME,
) and not self.network.name.endswith("-fork"):
# If using a live network, the chain ID is hardcoded.
return self.network.chain_id

elif hasattr(self.web3, "eth"):
return self.web3.eth.chain_id

else:
raise ProviderNotConnectedError()

Expand Down