aboutsummaryrefslogtreecommitdiffstats
path: root/src/0x.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-09-05 01:08:14 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-09-05 01:08:14 +0800
commitc9e490bdaec53e3a93b5da8daaaf0b1d87d9de76 (patch)
tree49aa1f687e3b0727ff9a00815848c92cb64311f3 /src/0x.ts
parent6325a038188293658ad3d209cb95a2741911f5b9 (diff)
downloaddexon-sol-tools-c9e490bdaec53e3a93b5da8daaaf0b1d87d9de76.tar
dexon-sol-tools-c9e490bdaec53e3a93b5da8daaaf0b1d87d9de76.tar.gz
dexon-sol-tools-c9e490bdaec53e3a93b5da8daaaf0b1d87d9de76.tar.bz2
dexon-sol-tools-c9e490bdaec53e3a93b5da8daaaf0b1d87d9de76.tar.lz
dexon-sol-tools-c9e490bdaec53e3a93b5da8daaaf0b1d87d9de76.tar.xz
dexon-sol-tools-c9e490bdaec53e3a93b5da8daaaf0b1d87d9de76.tar.zst
dexon-sol-tools-c9e490bdaec53e3a93b5da8daaaf0b1d87d9de76.zip
Implement zeroEx.awaitTransactionMined
Diffstat (limited to 'src/0x.ts')
-rw-r--r--src/0x.ts14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/0x.ts b/src/0x.ts
index 3cf672a1b..e92c92e1f 100644
--- a/src/0x.ts
+++ b/src/0x.ts
@@ -1,5 +1,6 @@
import * as _ from 'lodash';
import * as BigNumber from 'bignumber.js';
+import * as Web3 from 'web3';
import {SchemaValidator, schemas} from '0x-json-schemas';
import {bigNumberConfigs} from './bignumber_config';
import * as ethUtil from 'ethereumjs-util';
@@ -248,4 +249,17 @@ export class ZeroEx {
throw new Error(ZeroExError.InvalidSignature);
}
+ public async awaitTransactionMined(txHash: string,
+ pollingIntervalMs: number = 500): Promise<Web3.TransactionReceipt> {
+ const txReceiptPromise = new Promise((resolve: (receipt: Web3.TransactionReceipt) => void, reject) => {
+ const intervalId = setInterval(async () => {
+ const transactionReceipt = await this._web3Wrapper.getTransactionReceiptAsync(txHash);
+ if (!_.isNull(transactionReceipt)) {
+ clearInterval(intervalId);
+ resolve(transactionReceipt);
+ }
+ }, pollingIntervalMs);
+ });
+ return txReceiptPromise;
+ }
}