Commit 74d19ed8 authored by yann300's avatar yann300

use normalizeHexAddress

parent c0664b63
...@@ -8,7 +8,7 @@ module.exports = { ...@@ -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 = { ...@@ -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) { ...@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment