From a1eed9850d155f3847d2a77bbbbc78495a171f79 Mon Sep 17 00:00:00 2001 From: antazoey Date: Mon, 13 Jan 2025 08:33:36 -0600 Subject: [PATCH] fix: adhoc network connection fix (#2468) Co-authored-by: antazoey --- src/ape_ethereum/provider.py | 3 +-- tests/functional/test_provider.py | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ape_ethereum/provider.py b/src/ape_ethereum/provider.py index 4b96f2850c..da4a919805 100644 --- a/src/ape_ethereum/provider.py +++ b/src/ape_ethereum/provider.py @@ -572,8 +572,7 @@ def estimate_gas_cost(self, txn: TransactionAPI, block_id: Optional["BlockID"] = @cached_property def chain_id(self) -> int: default_chain_id = None - - if self.network.is_custom or not self.network.is_dev: + if (not self.network.is_adhoc and self.network.is_custom) or not self.network.is_dev: # If using a live network, the chain ID is hardcoded. default_chain_id = self.network.chain_id diff --git a/tests/functional/test_provider.py b/tests/functional/test_provider.py index ae959ec3af..0876172d05 100644 --- a/tests/functional/test_provider.py +++ b/tests/functional/test_provider.py @@ -145,6 +145,11 @@ def test_chain_id_when_disconnected(eth_tester_provider): eth_tester_provider.connect() +def test_chain_id_adhoc(networks): + with networks.parse_network_choice("https://www.shibrpc.com") as bor: + assert bor.chain_id == 109 + + def test_get_receipt_not_exists_with_timeout(eth_tester_provider): unknown_txn = "0x053cba5c12172654d894f66d5670bab6215517a94189a9ffc09bc40a589ec04d" expected = (