aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sol-trace/src
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2019-01-30 20:55:58 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2019-01-30 21:12:31 +0800
commitea5e78b217fdb43c50be13a80417e77ff06c970e (patch)
tree343aa3de79a6420c6a125a6f5021b45a556ca3cc /packages/sol-trace/src
parentc9a7ef18dc75675bb1880734ce786ba126359ae6 (diff)
downloaddexon-0x-contracts-ea5e78b217fdb43c50be13a80417e77ff06c970e.tar.gz
dexon-0x-contracts-ea5e78b217fdb43c50be13a80417e77ff06c970e.tar.zst
dexon-0x-contracts-ea5e78b217fdb43c50be13a80417e77ff06c970e.zip
Improve error messages when unable to find bytecode
Diffstat (limited to 'packages/sol-trace/src')
-rw-r--r--packages/sol-trace/src/revert_trace_subprovider.ts17
1 files changed, 15 insertions, 2 deletions
diff --git a/packages/sol-trace/src/revert_trace_subprovider.ts b/packages/sol-trace/src/revert_trace_subprovider.ts
index 046dad812..899a92814 100644
--- a/packages/sol-trace/src/revert_trace_subprovider.ts
+++ b/packages/sol-trace/src/revert_trace_subprovider.ts
@@ -11,6 +11,7 @@ import {
TraceCollectionSubprovider,
utils,
} from '@0x/sol-tracing-utils';
+import chalk from 'chalk';
import { stripHexPrefix } from 'ethereumjs-util';
import * as _ from 'lodash';
import { getLogger, levels, Logger } from 'loglevel';
@@ -71,9 +72,21 @@ export class RevertTraceSubprovider extends TraceCollectionSubprovider {
const bytecode = await this._web3Wrapper.getContractCodeAsync(evmCallStackEntry.address);
const contractData = utils.getContractDataIfExists(this._contractsData, bytecode);
if (_.isUndefined(contractData)) {
+ const shortenHex = (hex: string) => {
+ /**
+ * Length chooses so that both error messages are of the same length
+ * and it's enough data to figure out which artifact has a problem.
+ */
+ const length = 18;
+ return `${hex.substr(0, length + 2)}...${hex.substr(hex.length - length, length)}`;
+ };
const errMsg = isContractCreation
- ? `Unknown contract creation transaction`
- : `Transaction to an unknown address: ${evmCallStackEntry.address}`;
+ ? `Unable to find matching bytecode for contract creation ${chalk.bold(
+ shortenHex(bytecode),
+ )}, please check your artifacts. Ignoring...`
+ : `Unable to find matching bytecode for contract address ${chalk.bold(
+ evmCallStackEntry.address,
+ )}, please check your artifacts. Ignoring...`;
this._logger.warn(errMsg);
continue;
}