diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-01-23 05:05:30 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-01-30 23:01:36 +0800 |
commit | bc37cc8a91526b919c97eef06d9499ed285e5cfe (patch) | |
tree | 028d66939a91fb999cbb39768e48afa9fcd3f40d /packages/utils | |
parent | 387363283ca03ac1d6c9be5b7be2107790bbf79d (diff) | |
download | dexon-sol-tools-bc37cc8a91526b919c97eef06d9499ed285e5cfe.tar.gz dexon-sol-tools-bc37cc8a91526b919c97eef06d9499ed285e5cfe.tar.zst dexon-sol-tools-bc37cc8a91526b919c97eef06d9499ed285e5cfe.zip |
Remove duplicate code
Diffstat (limited to 'packages/utils')
-rw-r--r-- | packages/utils/src/transaction_utils.ts | 52 | ||||
-rw-r--r-- | packages/utils/src/types.ts | 3 |
2 files changed, 0 insertions, 55 deletions
diff --git a/packages/utils/src/transaction_utils.ts b/packages/utils/src/transaction_utils.ts deleted file mode 100644 index a1db90817..000000000 --- a/packages/utils/src/transaction_utils.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { AbiDecoder } from '@0xproject/abi-decoder'; -import { TransactionReceiptWithDecodedLogs } from '@0xproject/types'; -import { Web3Wrapper } from '@0xproject/web3-wrapper'; -import * as _ from 'lodash'; - -import { intervalUtils } from './interval_utils'; -import { TransactionError } from './types'; - -export const awaitTransactionMinedAsync = async ( - web3Wrapper: Web3Wrapper, - abiDecoder: AbiDecoder, - txHash: string, - pollingIntervalMs = 1000, - timeoutMs?: number, -) => { - 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(TransactionError.TransactionMiningTimeout); - } - - const transactionReceipt = await web3Wrapper.getTransactionReceiptAsync(txHash); - if (!_.isNull(transactionReceipt)) { - intervalUtils.clearAsyncExcludingInterval(intervalId); - const logsWithDecodedArgs = _.map( - transactionReceipt.logs, - abiDecoder.tryToDecodeLogOrNoop.bind(abiDecoder), - ); - const transactionReceiptWithDecodedLogArgs: TransactionReceiptWithDecodedLogs = { - ...transactionReceipt, - logs: logsWithDecodedArgs, - }; - resolve(transactionReceiptWithDecodedLogArgs); - } - }, - pollingIntervalMs, - (err: Error) => { - intervalUtils.clearAsyncExcludingInterval(intervalId); - reject(err); - }, - ); - }); - - return txReceiptPromise; -}; diff --git a/packages/utils/src/types.ts b/packages/utils/src/types.ts deleted file mode 100644 index 936256b61..000000000 --- a/packages/utils/src/types.ts +++ /dev/null @@ -1,3 +0,0 @@ -export enum TransactionError { - TransactionMiningTimeout = 'TRANSACTION_MINING_TIMEOUT', -} |