From 47406871679c86acc27bdd65c18086a1b2e0eb21 Mon Sep 17 00:00:00 2001 From: tim Date: Wed, 19 Mar 2025 21:05:19 -0400 Subject: [PATCH] account release bugfix --- src/dexorder/bin/mirror.py | 2 +- src/dexorder/contract/contract_proxy.py | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/dexorder/bin/mirror.py b/src/dexorder/bin/mirror.py index 6562b28..e9f1f36 100644 --- a/src/dexorder/bin/mirror.py +++ b/src/dexorder/bin/mirror.py @@ -201,7 +201,7 @@ async def main(): addr, inverted = mirror_pools[pool] log.debug(f'Mirrored {addr} {price}') except Exception as x: - log.debug(f'Could not update {pool}: {x}') + log.debug(f'Could not update {pool}: {x} {tx}') if tx is not None: tx.account.reset_nonce() tx.account.release() diff --git a/src/dexorder/contract/contract_proxy.py b/src/dexorder/contract/contract_proxy.py index 01b5cf8..ceed163 100644 --- a/src/dexorder/contract/contract_proxy.py +++ b/src/dexorder/contract/contract_proxy.py @@ -81,14 +81,17 @@ def transact_wrapper(addr, name, func): account = await Account.acquire() if account is None: raise ValueError(f'No account to sign transaction {addr}.{name}()') - await ct.sign(account) try: - tx_id = await current_w3.get().eth.send_raw_transaction(ct.data) - assert tx_id == ct.id_bytes - return ct - except Web3Exception as e: - e.args += addr, name - raise e + await ct.sign(account) + try: + tx_id = await current_w3.get().eth.send_raw_transaction(ct.data) + assert tx_id == ct.id_bytes + return ct + except Web3Exception as e: + e.args += addr, name + raise e + finally: + account.release() return f