From 2653610b6b382d4a8503c9e1d114b08aa5272fda Mon Sep 17 00:00:00 2001 From: Mark Spanbroek Date: Mon, 23 May 2022 17:24:49 +0200 Subject: [PATCH] Raise EthersError instead of JsonRpcProviderError --- ethers/providers/jsonrpc.nim | 9 ++++++--- testmodule/testJsonRpcProvider.nim | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ethers/providers/jsonrpc.nim b/ethers/providers/jsonrpc.nim index 39a387b..ebc5a96 100644 --- a/ethers/providers/jsonrpc.nim +++ b/ethers/providers/jsonrpc.nim @@ -232,7 +232,7 @@ proc confirm*(tx: TransactionResponse, wantedConfirms: Positive = EthersDefaultConfirmations, timeoutInBlocks: Natural = EthersReceiptTimeoutBlks): Future[TransactionReceipt] - {.async, upraises: [JsonRpcProviderError].} = # raises for clarity + {.async, upraises: [EthersError].} = # raises for clarity ## Waits for a transaction to be mined and for the specified number of blocks ## to pass since it was mined (confirmations). ## A timeout, in blocks, can be specified that will raise a @@ -271,7 +271,7 @@ proc confirm*(tx: TransactionResponse, if not retFut.finished: let message = "Transaction was not mined in " & $timeoutInBlocks & " blocks" - retFut.fail(newException(JsonRpcProviderError, message)) + retFut.fail(newException(EthersError, message)) # If our tx is already mined, return the receipt. Otherwise, check each # new block to see if the tx has been mined @@ -305,6 +305,9 @@ proc confirm*(tx: Future[?TransactionResponse], ## .confirm(3)` without txResp =? (await tx): - raiseProviderError("Transaction hash required. Possibly was a call instead of a send?") + raise newException( + EthersError, + "Transaction hash required. Possibly was a call instead of a send?" + ) return await txResp.confirm(wantedConfirms, timeoutInBlocks) diff --git a/testmodule/testJsonRpcProvider.nim b/testmodule/testJsonRpcProvider.nim index 7df5d3d..e4d6e0b 100644 --- a/testmodule/testJsonRpcProvider.nim +++ b/testmodule/testJsonRpcProvider.nim @@ -95,7 +95,7 @@ suite "JsonRpcProvider": timeoutInBlocks = 5) await futMined - except JsonRpcProviderError as e: + except EthersError as e: check e.msg == "Transaction was not mined in 5 blocks" let endBlock = await provider.getBlockNumber()