From 6faab82ca92fe9bf83b93446dc84087e762c2d16 Mon Sep 17 00:00:00 2001 From: Eric <5089238+emizzle@users.noreply.github.com> Date: Thu, 14 Sep 2023 16:37:08 +1000 Subject: [PATCH] debugging: switch echo to trace --- ethers/contract.nim | 5 ++++- ethers/providers/jsonrpc.nim | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ethers/contract.nim b/ethers/contract.nim index 963932a..2a7fca1 100644 --- a/ethers/contract.nim +++ b/ethers/contract.nim @@ -254,8 +254,8 @@ proc confirm*(tx: Future[?TransactionResponse], let receipt = await response.confirm(confirmations, timeout) - echo "[ether/contract.confirm] receipt.status: ", receipt.status if receipt.status != TransactionStatus.Success: + trace "transaction failed", status = receipt.status without blockNumber =? receipt.blockNumber: raiseContractError "Transaction reverted with unknown reason" @@ -264,8 +264,11 @@ proc confirm*(tx: Future[?TransactionResponse], raiseContractError "Transaction reverted with unknown reason" try: + trace "replaying transaction to get revert reason" await provider.replay(transaction, blockNumber) + trace "transaction replay completed, no revert reason obtained" except ProviderError as e: + trace "transaction revert reason obtained", reason = e.msg # should contain the revert reason raiseContractError e.msg diff --git a/ethers/providers/jsonrpc.nim b/ethers/providers/jsonrpc.nim index b1441b2..ab72bae 100644 --- a/ethers/providers/jsonrpc.nim +++ b/ethers/providers/jsonrpc.nim @@ -43,12 +43,12 @@ template convertError(nonce = none UInt256, body) = try: body except JsonRpcError as error: - echo "[jsonrpc.convertError] error encountered (nonce: ", nonce, "): ", error.msg + trace "jsonrpc error", nonce, error = error.msg raiseProviderError(error.msg, nonce) # Catch all ValueErrors for now, at least until JsonRpcError is actually # raised. PR created: https://github.com/status-im/nim-json-rpc/pull/151 except ValueError as error: - echo "[jsonrpc.convertError] error encountered (nonce: ", nonce, "): ", error.msg + trace "jsonrpc error (from rpc client)", nonce, error = error.msg raiseProviderError(error.msg, nonce) template convertError(body) = @@ -268,5 +268,5 @@ method sendTransaction*(signer: JsonRpcSigner, client = await signer.provider.client hash = await client.eth_sendTransaction(transaction) - echo "[jsonrpc.sendTransaction] RESPONSE send transaction -- nonce: ", transaction.nonce, ", hash: ", hash.to0xHex + trace "jsonrpc sendTransaction RESPONSE", nonce = transaction.nonce, hash = hash.to0xHex return TransactionResponse(hash: hash, provider: signer.provider)