Merge pull request #839 from ethereum/fixHexNormalization

Fix hex normalization
pull/3094/head
yann300 7 years ago committed by GitHub
commit ff50d7762f
  1. 13
      remix-debugger/src/ui/StackPanel.js
  2. 2
      remix-lib/src/helpers/traceHelper.js
  3. 12
      remix-lib/src/helpers/uiHelper.js
  4. 2
      remix-lib/src/web3Provider/web3VmProvider.js

@ -1,7 +1,5 @@
'use strict' 'use strict'
var DropdownPanel = require('./DropdownPanel') var DropdownPanel = require('./DropdownPanel')
var remixLib = require('remix-lib')
var ui = remixLib.helpers.ui
var yo = require('yo-yo') var yo = require('yo-yo')
function StackPanel (_parent, _traceManager) { function StackPanel (_parent, _traceManager) {
@ -26,19 +24,10 @@ StackPanel.prototype.init = function () {
self.basicPanel.update({}) self.basicPanel.update({})
console.log(error) console.log(error)
} else if (self.parent.currentStepIndex === index) { } 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 module.exports = StackPanel

@ -8,7 +8,7 @@ module.exports = {
return this.contractCreationToken(vmTraceIndex) return this.contractCreationToken(vmTraceIndex)
} else if (this.isCallInstruction(step)) { } else if (this.isCallInstruction(step)) {
var stack = step.stack // callcode, delegatecall, ... var stack = step.stack // callcode, delegatecall, ...
return ui.normalizeHex(stack[stack.length - 2]) return ui.normalizeHexAddress(stack[stack.length - 2])
} }
return undefined return undefined
}, },

@ -68,6 +68,18 @@ module.exports = {
return '0x' + hex 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 () { runInBrowser: function () {
return typeof window !== 'undefined' return typeof window !== 'undefined'
} }

@ -168,7 +168,7 @@ web3VmProvider.prototype.pushTrace = function (self, data) {
this.processingAddress = traceHelper.contractCreationToken(this.processingIndex) this.processingAddress = traceHelper.contractCreationToken(this.processingIndex)
this.storageCache[this.processingHash][this.processingAddress] = {} this.storageCache[this.processingHash][this.processingAddress] = {}
} else { } 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]) { if (!self.storageCache[self.processingHash][this.processingAddress]) {
self.vm.stateManager.dumpStorage(this.processingAddress, function (storage) { self.vm.stateManager.dumpStorage(this.processingAddress, function (storage) {
self.storageCache[self.processingHash][self.processingAddress] = storage self.storageCache[self.processingHash][self.processingAddress] = storage

Loading…
Cancel
Save