debug logging

This commit is contained in:
Eric 2023-09-20 14:50:29 +10:00
parent 458e969397
commit 45959cf608
No known key found for this signature in database
2 changed files with 10 additions and 0 deletions

View File

@ -14,6 +14,9 @@ export basics
export provider
export events
logScope:
topics = "ethers contract"
type
Contract* = ref object of RootObj
provider: Provider
@ -256,6 +259,7 @@ proc confirm*(tx: Future[?TransactionResponse],
let receipt = await response.confirm(confirmations, timeout)
if receipt.status != TransactionStatus.Success:
echo "[ethers contract] transaction failed, status: ", receipt.status
trace "transaction failed", status = receipt.status
without blockNumber =? receipt.blockNumber:
raiseContractError "Transaction reverted with unknown reason"
@ -265,10 +269,13 @@ proc confirm*(tx: Future[?TransactionResponse],
raiseContractError "Transaction reverted with unknown reason"
try:
echo "[ethers contract] replaying transaction to get revert reason"
trace "replaying transaction to get revert reason"
await provider.replay(transaction, blockNumber)
echo "transaction replay completed, no revert reason obtained"
trace "transaction replay completed, no revert reason obtained"
except ProviderError as e:
echo "transaction revert reason obtained, reason: ", e.msg
trace "transaction revert reason obtained", reason = e.msg
# should contain the revert reason
raiseContractError e.msg

View File

@ -19,6 +19,9 @@ export chronicles
push: {.upraises: [].}
logScope:
topics = "ethers jsonrpc"
type
JsonRpcProvider* = ref object of Provider
client: Future[RpcClient]