aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sol-tracing-utils/src/trace_collection_subprovider.ts
diff options
context:
space:
mode:
authorSteve Klebanoff <steve.klebanoff@gmail.com>2019-01-16 02:43:55 +0800
committerSteve Klebanoff <steve.klebanoff@gmail.com>2019-01-16 02:43:55 +0800
commit600b44c9620494c976b5aac6e8a1912543cda81c (patch)
treefd78c65dd2fdd7b1cbee1b5eff97a95a984a9186 /packages/sol-tracing-utils/src/trace_collection_subprovider.ts
parent8a8a5332d76ae8429d1c6449e0ea693a2e8c8a8a (diff)
parentf570f80674c22f69712c45e8e3c48e948b51f357 (diff)
downloaddexon-0x-contracts-600b44c9620494c976b5aac6e8a1912543cda81c.tar
dexon-0x-contracts-600b44c9620494c976b5aac6e8a1912543cda81c.tar.gz
dexon-0x-contracts-600b44c9620494c976b5aac6e8a1912543cda81c.tar.bz2
dexon-0x-contracts-600b44c9620494c976b5aac6e8a1912543cda81c.tar.lz
dexon-0x-contracts-600b44c9620494c976b5aac6e8a1912543cda81c.tar.xz
dexon-0x-contracts-600b44c9620494c976b5aac6e8a1912543cda81c.tar.zst
dexon-0x-contracts-600b44c9620494c976b5aac6e8a1912543cda81c.zip
Merge branch 'development' into feature/instant/asset-buyer-check-liquidity
Diffstat (limited to 'packages/sol-tracing-utils/src/trace_collection_subprovider.ts')
-rw-r--r--packages/sol-tracing-utils/src/trace_collection_subprovider.ts24
1 files changed, 21 insertions, 3 deletions
diff --git a/packages/sol-tracing-utils/src/trace_collection_subprovider.ts b/packages/sol-tracing-utils/src/trace_collection_subprovider.ts
index 25e38768d..323e1523c 100644
--- a/packages/sol-tracing-utils/src/trace_collection_subprovider.ts
+++ b/packages/sol-tracing-utils/src/trace_collection_subprovider.ts
@@ -1,5 +1,6 @@
import { BlockchainLifecycle } from '@0x/dev-utils';
import { Callback, ErrorCallback, NextCallback, Subprovider } from '@0x/subproviders';
+import { logUtils } from '@0x/utils';
import { CallDataRPC, marshaller, Web3Wrapper } from '@0x/web3-wrapper';
import { JSONRPCRequestPayload, Provider, TxData } from 'ethereum-types';
import * as _ from 'lodash';
@@ -20,6 +21,23 @@ export interface TraceCollectionSubproviderConfig {
shouldCollectGasEstimateTraces: boolean;
}
+type AsyncFunc = (...args: any[]) => Promise<void>;
+
+// HACK: This wrapper outputs errors to console even if the promise gets ignored
+// we need this because web3-provider-engine does not handle promises in
+// the after function of next(after).
+function logAsyncErrors(fn: AsyncFunc): AsyncFunc {
+ async function wrappedAsync(...args: any[]): Promise<void> {
+ try {
+ await fn(...args);
+ } catch (err) {
+ logUtils.log(err);
+ throw err;
+ }
+ }
+ return wrappedAsync;
+}
+
// Because there is no notion of a call trace in the Ethereum rpc - we collect them in a rather non-obvious/hacky way.
// On each call - we create a snapshot, execute the call as a transaction, get the trace, revert the snapshot.
// That allows us to avoid influencing test behaviour.
@@ -74,7 +92,7 @@ export abstract class TraceCollectionSubprovider extends Subprovider {
next();
} else {
const txData = payload.params[0];
- next(this._onTransactionSentAsync.bind(this, txData));
+ next(logAsyncErrors(this._onTransactionSentAsync.bind(this, txData)));
}
return;
@@ -83,7 +101,7 @@ export abstract class TraceCollectionSubprovider extends Subprovider {
next();
} else {
const callData = payload.params[0];
- next(this._onCallOrGasEstimateExecutedAsync.bind(this, callData));
+ next(logAsyncErrors(this._onCallOrGasEstimateExecutedAsync.bind(this, callData)));
}
return;
@@ -92,7 +110,7 @@ export abstract class TraceCollectionSubprovider extends Subprovider {
next();
} else {
const estimateGasData = payload.params[0];
- next(this._onCallOrGasEstimateExecutedAsync.bind(this, estimateGasData));
+ next(logAsyncErrors(this._onCallOrGasEstimateExecutedAsync.bind(this, estimateGasData)));
}
return;