diff options
Diffstat (limited to 'packages/sol-tracing-utils')
-rw-r--r-- | packages/sol-tracing-utils/CHANGELOG.json | 8 | ||||
-rw-r--r-- | packages/sol-tracing-utils/package.json | 1 | ||||
-rw-r--r-- | packages/sol-tracing-utils/src/ast_visitor.ts | 4 | ||||
-rw-r--r-- | packages/sol-tracing-utils/src/trace_collector.ts | 17 |
4 files changed, 27 insertions, 3 deletions
diff --git a/packages/sol-tracing-utils/CHANGELOG.json b/packages/sol-tracing-utils/CHANGELOG.json index 16a12ca63..89a5b6876 100644 --- a/packages/sol-tracing-utils/CHANGELOG.json +++ b/packages/sol-tracing-utils/CHANGELOG.json @@ -17,6 +17,14 @@ { "note": "Print resasonable error message on bytecode collision", "pr": 1535 + }, + { + "note": "Fix the bug in `ASTVisitor` causing the 'cannot read property `range` of `null`' error", + "pr": 1557 + }, + { + "note": "Improve error messages when unable to find matching bytecode", + "pr": 1558 } ] }, diff --git a/packages/sol-tracing-utils/package.json b/packages/sol-tracing-utils/package.json index 4b0fff222..929c73b84 100644 --- a/packages/sol-tracing-utils/package.json +++ b/packages/sol-tracing-utils/package.json @@ -53,6 +53,7 @@ "ethereum-types": "^1.1.6", "ethereumjs-util": "^5.1.1", "glob": "^7.1.2", + "chalk": "^2.3.0", "istanbul": "^0.4.5", "lodash": "^4.17.5", "loglevel": "^1.6.1", diff --git a/packages/sol-tracing-utils/src/ast_visitor.ts b/packages/sol-tracing-utils/src/ast_visitor.ts index 1ac9cd1de..27f19378b 100644 --- a/packages/sol-tracing-utils/src/ast_visitor.ts +++ b/packages/sol-tracing-utils/src/ast_visitor.ts @@ -89,7 +89,9 @@ export class ASTVisitor { this._visitStatement(ast); } public ExpressionStatement(ast: Parser.ExpressionStatement): void { - this._visitStatement(ast.expression); + if (!_.isNull(ast.expression)) { + this._visitStatement(ast.expression); + } } public InlineAssemblyStatement(ast: Parser.InlineAssemblyStatement): void { this._visitStatement(ast); 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; } |