aboutsummaryrefslogtreecommitdiffstats
path: root/packages/web3-wrapper/src/web3_wrapper.ts
diff options
context:
space:
mode:
authorAlex Browne <stephenalexbrowne@gmail.com>2018-06-12 08:04:47 +0800
committerAlex Browne <stephenalexbrowne@gmail.com>2018-06-12 08:07:28 +0800
commit3cc30f91a99578b626d95811a26ee7b19f404455 (patch)
tree11fe1b3e7f57ba6a6e098e8bc22e7570c713d8c3 /packages/web3-wrapper/src/web3_wrapper.ts
parentbc0ae6be318a15bf8670a6da9a59d9bdb12cadae (diff)
downloaddexon-sol-tools-3cc30f91a99578b626d95811a26ee7b19f404455.tar
dexon-sol-tools-3cc30f91a99578b626d95811a26ee7b19f404455.tar.gz
dexon-sol-tools-3cc30f91a99578b626d95811a26ee7b19f404455.tar.bz2
dexon-sol-tools-3cc30f91a99578b626d95811a26ee7b19f404455.tar.lz
dexon-sol-tools-3cc30f91a99578b626d95811a26ee7b19f404455.tar.xz
dexon-sol-tools-3cc30f91a99578b626d95811a26ee7b19f404455.tar.zst
dexon-sol-tools-3cc30f91a99578b626d95811a26ee7b19f404455.zip
Speedup awaitTransactionMinedAsync and reduce polling interval in contracts tests
Diffstat (limited to 'packages/web3-wrapper/src/web3_wrapper.ts')
-rw-r--r--packages/web3-wrapper/src/web3_wrapper.ts17
1 files changed, 16 insertions, 1 deletions
diff --git a/packages/web3-wrapper/src/web3_wrapper.ts b/packages/web3-wrapper/src/web3_wrapper.ts
index 780695091..5d2eedcb3 100644
--- a/packages/web3-wrapper/src/web3_wrapper.ts
+++ b/packages/web3-wrapper/src/web3_wrapper.ts
@@ -402,6 +402,21 @@ export class Web3Wrapper {
pollingIntervalMs: number = 1000,
timeoutMs?: number,
): Promise<TransactionReceiptWithDecodedLogs> {
+ // Immediately check if the transaction has already been mined.
+ let transactionReceipt = await this.getTransactionReceiptAsync(txHash);
+ if (!_.isNull(transactionReceipt)) {
+ const logsWithDecodedArgs = _.map(
+ transactionReceipt.logs,
+ this.abiDecoder.tryToDecodeLogOrNoop.bind(this.abiDecoder),
+ );
+ const transactionReceiptWithDecodedLogArgs: TransactionReceiptWithDecodedLogs = {
+ ...transactionReceipt,
+ logs: logsWithDecodedArgs,
+ };
+ return transactionReceiptWithDecodedLogArgs;
+ }
+
+ // Otherwise, check again every pollingIntervalMs.
let wasTimeoutExceeded = false;
if (timeoutMs) {
setTimeout(() => (wasTimeoutExceeded = true), timeoutMs);
@@ -416,7 +431,7 @@ export class Web3Wrapper {
return reject(Web3WrapperErrors.TransactionMiningTimeout);
}
- const transactionReceipt = await this.getTransactionReceiptAsync(txHash);
+ transactionReceipt = await this.getTransactionReceiptAsync(txHash);
if (!_.isNull(transactionReceipt)) {
intervalUtils.clearAsyncExcludingInterval(intervalId);
const logsWithDecodedArgs = _.map(