diff options
Diffstat (limited to 'packages/sol-tracing-utils/src')
-rw-r--r-- | packages/sol-tracing-utils/src/trace_collector.ts | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/packages/sol-tracing-utils/src/trace_collector.ts b/packages/sol-tracing-utils/src/trace_collector.ts index f5dde8762..2a1f15b83 100644 --- a/packages/sol-tracing-utils/src/trace_collector.ts +++ b/packages/sol-tracing-utils/src/trace_collector.ts @@ -1,4 +1,5 @@ import { promisify } from '@0x/utils'; +import chalk from 'chalk'; import { stripHexPrefix } from 'ethereumjs-util'; import * as fs from 'fs'; import { Collector } from 'istanbul'; @@ -71,9 +72,21 @@ export class TraceCollector { : (traceInfo as TraceInfoExistingContract).runtimeBytecode; 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: ${traceInfo.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( + traceInfo.address, + )}, please check your artifacts. Ignoring...`; this._logger.warn(errMsg); return; } |