From 6af97171a5435b751421661a4a5b0c1c533daa5a Mon Sep 17 00:00:00 2001 From: banteg <4562643+banteg@users.noreply.github.com> Date: Fri, 10 May 2024 04:48:37 +0400 Subject: [PATCH] fix: crash when waiting for a tx confirmation --- brownie/network/transaction.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/brownie/network/transaction.py b/brownie/network/transaction.py index 9e561f65e..7926a0ca6 100644 --- a/brownie/network/transaction.py +++ b/brownie/network/transaction.py @@ -216,10 +216,10 @@ def __init__( # await confirmation of tx in a separate thread which is blocking if # required_confs > 0 or tx has already confirmed (`blockNumber` != None) confirm_thread = threading.Thread( - target=self._await_confirmation, args=(tx["blockNumber"], required_confs), daemon=True + target=self._await_confirmation, args=(tx.get("blockNumber"), required_confs), daemon=True ) confirm_thread.start() - if is_blocking and (required_confs > 0 or tx["blockNumber"]): + if is_blocking and (required_confs > 0 or tx.get("blockNumber")): confirm_thread.join() def __repr__(self) -> str: @@ -508,7 +508,7 @@ def _await_confirmation(self, block_number: int = None, required_confs: int = 1) # check if tx is still in mempool, this will raise otherwise tx = web3.eth.get_transaction(self.txid) self.block_number = None - return self._await_confirmation(tx["blockNumber"], required_confs) + return self._await_confirmation(tx.get("blockNumber"), required_confs) if required_confs - self.confirmations != remaining_confs: remaining_confs = required_confs - self.confirmations if not self._silent: