From 21753bf2b2a01963ee5fff9cbdb8e2799ad250c4 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 6 Jun 2018 11:38:49 +0200 Subject: [PATCH] use normalizeHexAddress --- remix-lib/src/helpers/traceHelper.js | 2 +- remix-lib/src/helpers/uiHelper.js | 12 ++++++++++++ remix-lib/src/web3Provider/web3VmProvider.js | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/remix-lib/src/helpers/traceHelper.js b/remix-lib/src/helpers/traceHelper.js index c3eef50e91..a4fb9695eb 100644 --- a/remix-lib/src/helpers/traceHelper.js +++ b/remix-lib/src/helpers/traceHelper.js @@ -8,7 +8,7 @@ module.exports = { return this.contractCreationToken(vmTraceIndex) } else if (this.isCallInstruction(step)) { var stack = step.stack // callcode, delegatecall, ... - return ui.normalizeHex(stack[stack.length - 2]) + return ui.normalizeHexAddress(stack[stack.length - 2]) } return undefined }, diff --git a/remix-lib/src/helpers/uiHelper.js b/remix-lib/src/helpers/uiHelper.js index 492ae252a0..99dfeb5970 100644 --- a/remix-lib/src/helpers/uiHelper.js +++ b/remix-lib/src/helpers/uiHelper.js @@ -68,6 +68,18 @@ module.exports = { return '0x' + hex }, + normalizeHexAddress: function (hex) { + if (hex.indexOf('0x') === 0) hex = hex.replace('0x', '') + if (hex.length >= 40) { + var reg = /(.{40})$/.exec(hex) + if (reg) { + return '0x' + reg[0] + } + } else { + return '0x' + (new Array(40 - hex.length + 1).join('0')) + hex + } + }, + runInBrowser: function () { return typeof window !== 'undefined' } diff --git a/remix-lib/src/web3Provider/web3VmProvider.js b/remix-lib/src/web3Provider/web3VmProvider.js index b7dec2cb21..5294e925f3 100644 --- a/remix-lib/src/web3Provider/web3VmProvider.js +++ b/remix-lib/src/web3Provider/web3VmProvider.js @@ -168,7 +168,7 @@ web3VmProvider.prototype.pushTrace = function (self, data) { this.processingAddress = traceHelper.contractCreationToken(this.processingIndex) this.storageCache[this.processingHash][this.processingAddress] = {} } else { - this.processingAddress = uiutil.normalizeHex(step.stack[step.stack.length - 2]) + this.processingAddress = uiutil.normalizeHexAddress(step.stack[step.stack.length - 2]) if (!self.storageCache[self.processingHash][this.processingAddress]) { self.vm.stateManager.dumpStorage(this.processingAddress, function (storage) { self.storageCache[self.processingHash][self.processingAddress] = storage