aboutsummaryrefslogtreecommitdiffstats
path: root/src/0x.ts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2017-11-12 00:14:09 +0800
committerFabio Berger <me@fabioberger.com>2017-11-12 00:14:09 +0800
commitc6f97f20fb7ada5135350c9120bfe203f78c0970 (patch)
tree9028936fd1ad8acb56625e0b4c633a88c18a5212 /src/0x.ts
parentb66600338e0057baa6964328bdf337a905aa5ff9 (diff)
parent76b66872d8f797ee3b0efe0fa2ca914cf44ee46c (diff)
downloaddexon-sol-tools-c6f97f20fb7ada5135350c9120bfe203f78c0970.tar
dexon-sol-tools-c6f97f20fb7ada5135350c9120bfe203f78c0970.tar.gz
dexon-sol-tools-c6f97f20fb7ada5135350c9120bfe203f78c0970.tar.bz2
dexon-sol-tools-c6f97f20fb7ada5135350c9120bfe203f78c0970.tar.lz
dexon-sol-tools-c6f97f20fb7ada5135350c9120bfe203f78c0970.tar.xz
dexon-sol-tools-c6f97f20fb7ada5135350c9120bfe203f78c0970.tar.zst
dexon-sol-tools-c6f97f20fb7ada5135350c9120bfe203f78c0970.zip
Merge branch 'development' into orderWatcher
* development: 0.22.6 Add new changes to CHANGELOG use util fn no race, reject from interval cb and clear allow timeout for await transaction mined # Conflicts: # src/types.ts
Diffstat (limited to 'src/0x.ts')
-rw-r--r--src/0x.ts14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/0x.ts b/src/0x.ts
index 59688e948..a1841eaa8 100644
--- a/src/0x.ts
+++ b/src/0x.ts
@@ -285,13 +285,24 @@ export class ZeroEx {
* Waits for a transaction to be mined and returns the transaction receipt.
* @param txHash Transaction hash
* @param pollingIntervalMs How often (in ms) should we check if the transaction is mined.
+ * @param timeoutMs How long (in ms) to poll for transaction mined until aborting.
* @return Transaction receipt with decoded log args.
*/
public async awaitTransactionMinedAsync(
- txHash: string, pollingIntervalMs: number = 1000): Promise<TransactionReceiptWithDecodedLogs> {
+ txHash: string, pollingIntervalMs = 1000, timeoutMs?: number): Promise<TransactionReceiptWithDecodedLogs> {
+ let timeoutExceeded = false;
+ if (timeoutMs) {
+ setTimeout(() => timeoutExceeded = true, timeoutMs);
+ }
+
const txReceiptPromise = new Promise(
(resolve: (receipt: TransactionReceiptWithDecodedLogs) => void, reject) => {
const intervalId = intervalUtils.setAsyncExcludingInterval(async () => {
+ if (timeoutExceeded) {
+ intervalUtils.clearAsyncExcludingInterval(intervalId);
+ return reject(ZeroExError.TransactionMiningTimeout);
+ }
+
const transactionReceipt = await this._web3Wrapper.getTransactionReceiptAsync(txHash);
if (!_.isNull(transactionReceipt)) {
intervalUtils.clearAsyncExcludingInterval(intervalId);
@@ -307,6 +318,7 @@ export class ZeroEx {
}
}, pollingIntervalMs);
});
+
return txReceiptPromise;
}
/*