From cbb6c1047df6be632bed3325b3b0e380a51b07a6 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 6 Jun 2018 11:38:16 +0200 Subject: [PATCH 1/2] display raw value in former debugger --- remix-debugger/src/ui/StackPanel.js | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/remix-debugger/src/ui/StackPanel.js b/remix-debugger/src/ui/StackPanel.js index c07aa01094..de768dc616 100644 --- a/remix-debugger/src/ui/StackPanel.js +++ b/remix-debugger/src/ui/StackPanel.js @@ -1,7 +1,5 @@ 'use strict' var DropdownPanel = require('./DropdownPanel') -var remixLib = require('remix-lib') -var ui = remixLib.helpers.ui var yo = require('yo-yo') function StackPanel (_parent, _traceManager) { @@ -26,19 +24,10 @@ StackPanel.prototype.init = function () { self.basicPanel.update({}) console.log(error) } else if (self.parent.currentStepIndex === index) { - self.basicPanel.update(self.format(stack)) + self.basicPanel.update(stack) } }) }) } -StackPanel.prototype.format = function (stack) { - var ret = [] - stack.map(function (item, i) { - var hex = ui.normalizeHex(item) - ret.push(hex) - }) - return ret -} - module.exports = StackPanel From 21753bf2b2a01963ee5fff9cbdb8e2799ad250c4 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 6 Jun 2018 11:38:49 +0200 Subject: [PATCH 2/2] 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