Skip to content

Commit

Permalink
feat(types): add timeout parameter to transaction wait()
Browse files Browse the repository at this point in the history
  • Loading branch information
petarTxFusion committed Aug 27, 2024
1 parent 69730d6 commit 2e55d0b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,18 @@ export class TransactionResponse extends ethers.TransactionResponse {
* @param confirmations The number of confirmation blocks. Defaults to 1.
* @returns A promise that resolves to the transaction receipt.
*/
override async wait(confirmations?: number): Promise<TransactionReceipt> {
override async wait(
confirmations?: number,
timeout?: number
): Promise<TransactionReceipt> {
timeout ??= 500;
// eslint-disable-next-line no-constant-condition
while (true) {
const receipt = (await super.wait(confirmations)) as TransactionReceipt;
if (receipt && receipt.blockNumber) {
return receipt;
}
await sleep(500);
await sleep(timeout);
}
}

Expand Down

0 comments on commit 2e55d0b

Please sign in to comment.