diff --git a/src/app/execution/txLogger.js b/src/app/execution/txLogger.js index 13e76d97af..b33628afcc 100644 --- a/src/app/execution/txLogger.js +++ b/src/app/execution/txLogger.js @@ -263,13 +263,13 @@ function context (self, opts) { var block = data.tx.blockNumber || '' var i = data.tx.transactionIndex if (executionContext.getProvider() === 'vm') { - return yo`[vm] from:${from}, to:${to}, value:${typeConversion.hexToInt(val)} wei, data:${input}, ${logs} logs, hash:${hash}` + return yo`[vm] from:${from}, to:${to}, value:${typeConversion.toInt(val)} wei, data:${input}, ${logs} logs, hash:${hash}` } else if (executionContext.getProvider() !== 'vm' && data.resolvedData) { - return yo`[block:${block} txIndex:${i}] from:${from}, to:${to}, value:${typeConversion.hexToInt(val)} wei, ${logs} logs, data:${input}, hash:${hash}` + return yo`[block:${block} txIndex:${i}] from:${from}, to:${to}, value:${typeConversion.toInt(val)} wei, ${logs} logs, data:${input}, hash:${hash}` } else { to = helper.shortenHexData(to) hash = helper.shortenHexData(data.tx.blockHash) - return yo`[block:${block} txIndex:${i}] from:${from}, to:${to}, value:${typeConversion.hexToInt(val)} wei` + return yo`[block:${block} txIndex:${i}] from:${from}, to:${to}, value:${typeConversion.toInt(val)} wei` } } @@ -367,7 +367,7 @@ function createTable (opts) { ` if (opts.logs) table.appendChild(logs) - var val = typeConversion.hexToInt(opts.val) + var val = typeConversion.toInt(opts.val) val = yo` value diff --git a/src/lib/typeConversion.js b/src/lib/typeConversion.js index 238beca3f0..1b5d879fc3 100644 --- a/src/lib/typeConversion.js +++ b/src/lib/typeConversion.js @@ -3,8 +3,13 @@ var ethJSUtil = require('ethereumjs-util') var BN = ethJSUtil.BN module.exports = { - hexToInt: (h) => { - return (new BN(h.replace('0x', ''), 16)).toString(10) + toInt: (h) => { + if (h.indexOf && h.indexOf('0x') === 0) { + return (new BN(h.replace('0x', ''), 16)).toString(10) + } else if (h.constructor && h.constructor.name === 'BigNumber' || BN.isBN(h)) { + return h.toString(10) + } + return h }, stringify: stringify }