From fff0d189a54df3380d7b03f442ac5051bb484004 Mon Sep 17 00:00:00 2001 From: Mark Spanbroek Date: Mon, 23 May 2022 16:58:45 +0200 Subject: [PATCH] Ensure that `confirm` future is only finished once Should fix CI failure https://github.com/status-im/nim-ethers/runs/6557104597 --- ethers/providers/jsonrpc.nim | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ethers/providers/jsonrpc.nim b/ethers/providers/jsonrpc.nim index 2456f15..6686710 100644 --- a/ethers/providers/jsonrpc.nim +++ b/ethers/providers/jsonrpc.nim @@ -261,15 +261,17 @@ method confirm*(tx: TransactionResponse, if receipt.hasBeenMined(blkNum, wantedConfirms): # fire and forget discard subscription.unsubscribe() - retFut.complete(receipt.get) + if not retFut.finished: + retFut.complete(receipt.get) elif timeoutInBlocks > 0: let blocksPassed = (blkNum - startBlock) + 1 if blocksPassed >= timeoutInBlocks.u256: discard subscription.unsubscribe() - retFut.fail( - newException(JsonRpcProviderError, "Transaction was not mined in " & - $timeoutInBlocks & " blocks")) + if not retFut.finished: + let message = + "Transaction was not mined in " & $timeoutInBlocks & " blocks" + retFut.fail(newException(JsonRpcProviderError, message)) # If our tx is already mined, return the receipt. Otherwise, check each # new block to see if the tx has been mined