diff --git a/brownie/network/gas/bases.py b/brownie/network/gas/bases.py index 28d7ff008..66be3aca9 100644 --- a/brownie/network/gas/bases.py +++ b/brownie/network/gas/bases.py @@ -142,7 +142,7 @@ def _update_loop() -> None: gas_price = gas_strategy.update_gas_price(tx.gas_price, height - initial) if gas_price is not None: try: - tx = tx.replace(gas_price=gas_price, silent=True) + tx = tx.replace(gas_price=gas_price) latest = web3.eth.blockNumber except ValueError: pass @@ -152,7 +152,7 @@ def _update_loop() -> None: gas_price = gas_strategy.update_gas_price(tx.gas_price, time.time() - initial) if gas_price is not None: try: - tx = tx.replace(gas_price=gas_price, silent=True) + tx = tx.replace(gas_price=gas_price) latest = time.time() except ValueError: pass diff --git a/brownie/network/transaction.py b/brownie/network/transaction.py index dcc16f148..d287041ce 100644 --- a/brownie/network/transaction.py +++ b/brownie/network/transaction.py @@ -143,7 +143,7 @@ def __init__( if isinstance(txid, bytes): txid = HexBytes(txid).hex() if not self._silent: - print(f"Transaction sent: {color('bright blue')}{txid}{color}") + print(f"\rTransaction sent: {color('bright blue')}{txid}{color}") # this event is set once the transaction is confirmed or dropped # it is used to waiting during blocking transaction actions @@ -327,7 +327,7 @@ def wait(self, required_confs: int) -> None: return time.sleep(1) - self._await_confirmation(tx, required_confs) + self._await_confirmation(tx["blockNumber"], required_confs) def _raise_if_reverted(self, exc: Any) -> None: if self.status or CONFIG.mode == "console": @@ -369,22 +369,22 @@ def _await_transaction(self, required_confs: int, is_blocking: bool) -> None: # await confirmation of tx in a separate thread which is blocking if required_confs > 0 confirm_thread = threading.Thread( - target=self._await_confirmation, args=(tx, required_confs), daemon=True + target=self._await_confirmation, args=(tx["blockNumber"], required_confs), daemon=True ) confirm_thread.start() if is_blocking and required_confs > 0: confirm_thread.join() - def _await_confirmation(self, tx: Dict, required_confs: int = 1) -> None: - if not tx["blockNumber"] and not self._silent and required_confs > 0: + def _await_confirmation(self, block_number: int = None, required_confs: int = 1) -> None: + block_number = block_number or self.block_number + if not block_number and not self._silent and required_confs > 0: if required_confs == 1: - print("Waiting for confirmation...") + sys.stdout.write("\rWaiting for confirmation... ") else: sys.stdout.write( - f"\rRequired confirmations: {color('bright yellow')}0/" - f"{required_confs}{color}" + f"\rRequired confirmations: {color('bright yellow')}0/{required_confs}{color}" ) - sys.stdout.flush() + sys.stdout.flush() # await first confirmation while True: @@ -417,7 +417,7 @@ def _await_confirmation(self, tx: Dict, required_confs: int = 1) -> None: # check if tx is still in mempool, this will raise otherwise tx = web3.eth.getTransaction(self.txid) self.block_number = None - return self._await_confirmation(tx, required_confs) + return self._await_confirmation(tx["blockNumber"], required_confs) if required_confs - self.confirmations != remaining_confs: remaining_confs = required_confs - self.confirmations if not self._silent: @@ -494,7 +494,7 @@ def _confirm_output(self) -> str: if not self.status: status = f"({color('bright red')}{self.revert_msg or 'reverted'}{color}) " result = ( - f" {self._full_name()} confirmed {status}- " + f"\r {self._full_name()} confirmed {status}- " f"Block: {color('bright blue')}{self.block_number}{color} " f"Gas used: {color('bright blue')}{self.gas_used}{color} " f"({color('bright blue')}{self.gas_used / self.gas_limit:.2%}{color})"