From 05095dd65d2215949c1973ce6a4b937394c02240 Mon Sep 17 00:00:00 2001 From: Mike Shultz Date: Sat, 20 Apr 2024 12:43:07 -0600 Subject: [PATCH] fix: fail gracefully trying to fetch contract type in Web3Provider.estimate_gas_cost() (#2018) --- src/ape_ethereum/provider.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ape_ethereum/provider.py b/src/ape_ethereum/provider.py index 286598b055..ab32ed4b5e 100644 --- a/src/ape_ethereum/provider.py +++ b/src/ape_ethereum/provider.py @@ -294,8 +294,13 @@ def estimate_gas_cost(self, txn: TransactionAPI, block_id: Optional[BlockID] = N tb = None if call_trace and txn_params.get("to"): traces = (self._create_trace_frame(t) for t in call_trace[1]) - if contract_type := self.chain_manager.contracts.get(txn_params["to"]): - tb = SourceTraceback.create(contract_type, traces, HexBytes(txn_params["data"])) + try: + if contract_type := self.chain_manager.contracts.get(txn_params["to"]): + tb = SourceTraceback.create( + contract_type, traces, HexBytes(txn_params["data"]) + ) + except ProviderNotConnectedError: + pass tx_error = self.get_virtual_machine_error( err,