Skip to content

Commit

Permalink
Fixed 0 confirmation waiting (#346).
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed Nov 13, 2018
1 parent 24757f1 commit 048c571
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src.ts/providers/base-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -751,8 +751,9 @@ export class BaseProvider extends Provider {
if (confirmations == null) { confirmations = 1; }
return poll(() => {
return this.getTransactionReceipt(transactionHash).then((receipt) => {
if (receipt == null && confirmations !== 0) {
if (receipt.confirmations < confirmations) { return undefined; }
if (confirmations === 0) { return receipt; }
if (receipt == null || receipt.confirmations < confirmations) {
return undefined;
}
return receipt;
});
Expand Down Expand Up @@ -874,6 +875,7 @@ export class BaseProvider extends Provider {
}

return this.waitForTransaction(tx.hash, confirmations).then((receipt) => {
if (receipt == null && confirmations === 0) { return null; }

// No longer pending, allow the polling loop to garbage collect this
this._emitted['t:' + tx.hash] = receipt.blockNumber;
Expand Down

0 comments on commit 048c571

Please sign in to comment.