diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2019-01-17 22:53:17 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-17 22:53:17 +0800 |
commit | 0b23aaca2619b888dd4e15774d5c543f79f4588d (patch) | |
tree | 702418b680712fc7dfd949715f955e1fa7bc5dd7 /packages/sol-tracing-utils/src/utils.ts | |
parent | beaf0a4a8a1cd6800ac009bce4fed38ff3828f2a (diff) | |
parent | 8b69d918a968237571729725d3238529c0b7a7b2 (diff) | |
download | dexon-sol-tools-0b23aaca2619b888dd4e15774d5c543f79f4588d.tar dexon-sol-tools-0b23aaca2619b888dd4e15774d5c543f79f4588d.tar.gz dexon-sol-tools-0b23aaca2619b888dd4e15774d5c543f79f4588d.tar.bz2 dexon-sol-tools-0b23aaca2619b888dd4e15774d5c543f79f4588d.tar.lz dexon-sol-tools-0b23aaca2619b888dd4e15774d5c543f79f4588d.tar.xz dexon-sol-tools-0b23aaca2619b888dd4e15774d5c543f79f4588d.tar.zst dexon-sol-tools-0b23aaca2619b888dd4e15774d5c543f79f4588d.zip |
Merge pull request #1521 from 0xProject/feature/dev-tools-pre-release-fixes
0x Dev tools pre-release fixes
Diffstat (limited to 'packages/sol-tracing-utils/src/utils.ts')
-rw-r--r-- | packages/sol-tracing-utils/src/utils.ts | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/packages/sol-tracing-utils/src/utils.ts b/packages/sol-tracing-utils/src/utils.ts index 644321f32..89c158ee7 100644 --- a/packages/sol-tracing-utils/src/utils.ts +++ b/packages/sol-tracing-utils/src/utils.ts @@ -8,6 +8,7 @@ import { ContractData, LineColumn, SingleFileSourceRange } from './types'; // This is the minimum length of valid contract bytecode. The Solidity compiler // metadata is 86 bytes. If you add the '0x' prefix, we get 88. const MIN_CONTRACT_BYTECODE_LENGTH = 88; +const STATICCALL_GAS_COST = 40; export const utils = { compareLineColumn(lhs: LineColumn, rhs: LineColumn): number { @@ -76,10 +77,17 @@ export const utils = { normalizeStructLogs(structLogs: StructLog[]): StructLog[] { if (structLogs[0].depth === 1) { // Geth uses 1-indexed depth counter whilst ganache starts from 0 - const newStructLogs = _.map(structLogs, structLog => ({ - ...structLog, - depth: structLog.depth - 1, - })); + const newStructLogs = _.map(structLogs, structLog => { + const newStructLog = { + ...structLog, + depth: structLog.depth - 1, + }; + if (newStructLog.op === 'STATICCALL') { + // HACK(leo): Geth traces sometimes returns those gas costs incorrectly as very big numbers so we manually fix them. + newStructLog.gasCost = STATICCALL_GAS_COST; + } + return newStructLog; + }); return newStructLogs; } return structLogs; |