Fixed 0 confirmation waiting (#346).

This commit is contained in:
Richard Moore 2018-11-13 07:48:37 -05:00
parent 24757f1064
commit 048c571d3d
No known key found for this signature in database
GPG Key ID: 525F70A6FCABC295

@ -751,8 +751,9 @@ export class BaseProvider extends Provider {
if (confirmations == null) { confirmations = 1; } if (confirmations == null) { confirmations = 1; }
return poll(() => { return poll(() => {
return this.getTransactionReceipt(transactionHash).then((receipt) => { return this.getTransactionReceipt(transactionHash).then((receipt) => {
if (receipt == null && confirmations !== 0) { if (confirmations === 0) { return receipt; }
if (receipt.confirmations < confirmations) { return undefined; } if (receipt == null || receipt.confirmations < confirmations) {
return undefined;
} }
return receipt; return receipt;
}); });
@ -874,6 +875,7 @@ export class BaseProvider extends Provider {
} }
return this.waitForTransaction(tx.hash, confirmations).then((receipt) => { 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 // No longer pending, allow the polling loop to garbage collect this
this._emitted['t:' + tx.hash] = receipt.blockNumber; this._emitted['t:' + tx.hash] = receipt.blockNumber;