Commit cf76ba27 authored by yann300's avatar yann300

- fix ui

- display full storage changes at the last RETURN - fix bug (display RETURN VALUE) - fix ui
parent 9305829a
...@@ -3,10 +3,9 @@ var style = require('./styles/basicStyles') ...@@ -3,10 +3,9 @@ var style = require('./styles/basicStyles')
var yo = require('yo-yo') var yo = require('yo-yo')
var ui = require('./helpers/ui') var ui = require('./helpers/ui')
function BasicPanel (_name, _id, _width, _height) { function BasicPanel (_name, _width, _height) {
this.data this.data
this.name = _name this.name = _name
this.id = _id
this.width = _width this.width = _width
this.height = _height this.height = _height
this.view this.view
...@@ -17,20 +16,20 @@ BasicPanel.prototype.update = function () { ...@@ -17,20 +16,20 @@ BasicPanel.prototype.update = function () {
} }
BasicPanel.prototype.hide = function () { BasicPanel.prototype.hide = function () {
document.getElementById(this.id + 'container').style.display = 'none' this.view.style.display = 'none'
} }
BasicPanel.prototype.show = function () { BasicPanel.prototype.show = function () {
document.getElementById(this.id + 'container').style.display = 'block' this.view.style.display = 'block'
} }
BasicPanel.prototype.render = function () { BasicPanel.prototype.render = function () {
var view = yo`<div id='${this.id}container' style=${ui.formatCss({'width': this.width}, style.panel.container)}> var view = yo`<div id='container' style=${ui.formatCss({'width': this.width}, style.panel.container)}>
<div style=${ui.formatCss(style.panel.title)}> <div style=${ui.formatCss(style.panel.title)}>
${this.name} ${this.name}
</div> </div>
<div style=${ui.formatCss({'height': this.height}, style.panel.tableContainer)}> <div style=${ui.formatCss({'height': this.height}, style.panel.tableContainer)}>
<pre style=${ui.formatCss(style.panel.table, style.font)} id='basicpanel' >${this.data}</pre> <pre style=${ui.formatCss({'width': this.width}, style.panel.table, style.font)} id='basicpanel' >${this.data}</pre>
</div> </div>
</div>` </div>`
if (!this.view) { if (!this.view) {
......
'use strict' 'use strict'
var StoragePanel = require('./StoragePanel') var BasicPanel = require('./BasicPanel')
var yo = require('yo-yo') var yo = require('yo-yo')
function FullStoragesChanges (_parent, _traceManager) { function FullStoragesChanges (_parent, _traceManager) {
this.parent = _parent this.parent = _parent
this.traceManager = _traceManager this.traceManager = _traceManager
this.addresses = []
this.view
this.traceLength
this.basicPanel = new BasicPanel('Full Storages Changes', '1205px', '100px')
this.init() this.init()
this.panels = {}
} }
FullStoragesChanges.prototype.render = function () { FullStoragesChanges.prototype.render = function () {
return yo`<div><div>Full Storages Changes</div><div>${this.view}</div></div>` var view = yo`<div id='fullstorageschangespanel' >${this.basicPanel.render()}</div>`
if (!this.view) {
this.view = view
}
return view
}
FullStoragesChanges.prototype.hide = function () {
this.view.style.display = 'none'
}
FullStoragesChanges.prototype.show = function () {
this.view.style.display = 'block'
} }
FullStoragesChanges.prototype.init = function () { FullStoragesChanges.prototype.init = function () {
var self = this var self = this
this.parent.register('newTraceLoaded', this, function (length) { this.parent.register('newTraceLoaded', this, function (length) {
self.panels = {} self.panels = []
self.traceManager.getAddresses(function (addresses) { self.traceManager.getAddresses(function (error, addresses) {
for (var k in addresses) { if (!error) {
self.panels[addresses] = new StoragePanel(self.traceManager, self.traceManager, k) self.addresses = addresses
self.panels[addresses].disable = true self.basicPanel.data = ''
yo.update(self.view, self.render())
self.hide()
}
})
self.traceManager.getLength(function (error, length) {
if (!error) {
self.traceLength = length
} }
}) })
}) })
...@@ -29,29 +52,22 @@ FullStoragesChanges.prototype.init = function () { ...@@ -29,29 +52,22 @@ FullStoragesChanges.prototype.init = function () {
if (index < 0) return if (index < 0) return
if (self.parent.currentStepIndex !== index) return if (self.parent.currentStepIndex !== index) return
self.traceManager.getLength(function (error, length) { if (index === self.traceLength - 1) {
if (!error) { var storageJSON = {}
for (var k in self.panels) { for (var k in self.addresses) {
self.panels[k].disabled = index !== length - 1 self.traceManager.getStorageAt(index, null, function (error, result) {
} if (!error) {
if (index !== length - 1) { storageJSON[self.addresses[k]] = result
self.view = '' self.basicPanel.data = JSON.stringify(storageJSON, null, '\t')
if (self.view) {
yo.update(self.view, self.render()) yo.update(self.view, self.render())
self.show()
} }
} }, self.addresses[k])
} }
}) } else {
self.hide()
}
}) })
} }
FullStoragesChanges.prototype.renderAssemblyItems = function () {
if (this.panels) {
this.codeView = this.panels.map(function (item, i) {
return yo`<div>${item.render()}</div>`
})
return this.codeView
}
}
module.exports = FullStoragesChanges module.exports = FullStoragesChanges
...@@ -18,9 +18,9 @@ function VmDebugger (_parent, _traceManager, _web3) { ...@@ -18,9 +18,9 @@ function VmDebugger (_parent, _traceManager, _web3) {
this.memoryPanel = new MemoryPanel(_parent, _traceManager) this.memoryPanel = new MemoryPanel(_parent, _traceManager)
this.calldataPanel = new CalldataPanel(_parent, _traceManager) this.calldataPanel = new CalldataPanel(_parent, _traceManager)
this.callstackPanel = new CallstackPanel(_parent, _traceManager) this.callstackPanel = new CallstackPanel(_parent, _traceManager)
/* Return values - */ /* Return values - */
this.returnValuesPanel = new BasicPanel('Return Values', 'returnvalues', 'auto', '100px') this.returnValuesPanel = new BasicPanel('Return Value', '1205px', '100px')
_parent.register('indexChanged', this.returnValuesPanel, function (index) { _parent.register('indexChanged', this.returnValuesPanel, function (index) {
var self = this var self = this
_traceManager.getReturnValue(index, function (error, returnValue) { _traceManager.getReturnValue(index, function (error, returnValue) {
...@@ -37,9 +37,9 @@ function VmDebugger (_parent, _traceManager, _web3) { ...@@ -37,9 +37,9 @@ function VmDebugger (_parent, _traceManager, _web3) {
}) })
}) })
/* Return values - */ /* Return values - */
this.fullStoragesChangesPanel = new FullStoragesChangesPanel(_parent, _traceManager) this.fullStoragesChangesPanel = new FullStoragesChangesPanel(_parent, _traceManager)
this.view this.view
var self = this var self = this
_parent.register('newTraceLoaded', this, function () { _parent.register('newTraceLoaded', this, function () {
...@@ -54,7 +54,17 @@ VmDebugger.prototype.render = function () { ...@@ -54,7 +54,17 @@ VmDebugger.prototype.render = function () {
var view = yo`<div id='vmdebugger' style='display:none'> var view = yo`<div id='vmdebugger' style='display:none'>
<div style=${ui.formatCss(style.container)}> <div style=${ui.formatCss(style.container)}>
<table> <table>
<tbody> <tbody>
<tr>
<td colspan='2'>
${this.returnValuesPanel.render()}
</td>
</tr>
<tr>
<td colspan='2'>
${this.fullStoragesChangesPanel.render()}
</td>
</tr>
<tr> <tr>
<td> <td>
${this.asmCode.render()} ${this.asmCode.render()}
...@@ -78,17 +88,7 @@ VmDebugger.prototype.render = function () { ...@@ -78,17 +88,7 @@ VmDebugger.prototype.render = function () {
<td> <td>
${this.callstackPanel.render()} ${this.callstackPanel.render()}
</td> </td>
</tr> </tr>
<tr>
<td colspan='2'>
${this.returnValuesPanel.render()}
</td>
</tr>
<tr>
<td colspan='2'>
${this.fullStoragesChangesPanel.render()}
</td>
</tr>
</tbody> </tbody>
</table> </table>
</div> </div>
......
...@@ -16,6 +16,7 @@ TraceAnalyser.prototype.analyse = function (trace, tx, callback) { ...@@ -16,6 +16,7 @@ TraceAnalyser.prototype.analyse = function (trace, tx, callback) {
lastCallIndex: 0 lastCallIndex: 0
} }
var callStack = [tx.to] var callStack = [tx.to]
this.traceCache.pushCallChanges(0, 0, callStack[0])
this.traceCache.pushCallStack(0, { this.traceCache.pushCallStack(0, {
callStack: callStack.slice(0) callStack: callStack.slice(0)
}) })
...@@ -36,8 +37,8 @@ TraceAnalyser.prototype.analyse = function (trace, tx, callback) { ...@@ -36,8 +37,8 @@ TraceAnalyser.prototype.analyse = function (trace, tx, callback) {
TraceAnalyser.prototype.buildReturnValues = function (index, step) { TraceAnalyser.prototype.buildReturnValues = function (index, step) {
if (traceHelper.isReturnInstruction(step)) { if (traceHelper.isReturnInstruction(step)) {
var offset = 2 * parseInt(step.stack[step.stack.length - 1]) var offset = 2 * parseInt(step.stack[step.stack.length - 1], 16)
var size = 2 * parseInt(step.stack[step.stack.length - 2]) var size = 2 * parseInt(step.stack[step.stack.length - 2], 16)
var memory = this.trace[this.traceCache.memoryChanges[this.traceCache.memoryChanges.length - 1]].memory var memory = this.trace[this.traceCache.memoryChanges[this.traceCache.memoryChanges.length - 1]].memory
this.traceCache.pushReturnValue(index, '0x' + memory.join('').substr(offset, size)) this.traceCache.pushReturnValue(index, '0x' + memory.join('').substr(offset, size))
} }
...@@ -76,7 +77,7 @@ TraceAnalyser.prototype.buildMemory = function (index, step) { ...@@ -76,7 +77,7 @@ TraceAnalyser.prototype.buildMemory = function (index, step) {
} }
TraceAnalyser.prototype.buildStorage = function (index, step, context) { TraceAnalyser.prototype.buildStorage = function (index, step, context) {
if (traceHelper.newContextStorage(step)) { if (traceHelper.newContextStorage(step) && !traceHelper.isCallToPrecompiledContract(index, this.trace)) {
var calledAddress = traceHelper.resolveCalledAddress(index, this.trace) var calledAddress = traceHelper.resolveCalledAddress(index, this.trace)
if (calledAddress) { if (calledAddress) {
context.currentStorageAddress = calledAddress context.currentStorageAddress = calledAddress
......
...@@ -78,9 +78,9 @@ TraceManager.prototype.getStorageAt = function (stepIndex, tx, callback, address ...@@ -78,9 +78,9 @@ TraceManager.prototype.getStorageAt = function (stepIndex, tx, callback, address
if (check) { if (check) {
return callback(check, null) return callback(check, null)
} }
var stoChange = traceHelper.findLowerBound(stepIndex, this.traceCache.storageChanges)
if (stoChange === undefined) return callback('no storage found', null)
if (!address) { if (!address) {
var stoChange = traceHelper.findLowerBound(stepIndex, this.traceCache.storageChanges)
if (stoChange === undefined) return callback('no storage found', null)
address = this.traceCache.sstore[stoChange].address address = this.traceCache.sstore[stoChange].address
} }
var storage = {} var storage = {}
...@@ -107,9 +107,11 @@ TraceManager.prototype.getStorageAt = function (stepIndex, tx, callback, address ...@@ -107,9 +107,11 @@ TraceManager.prototype.getStorageAt = function (stepIndex, tx, callback, address
} }
TraceManager.prototype.getAddresses = function (callback) { TraceManager.prototype.getAddresses = function (callback) {
var addresses = {} var addresses = [ this.tx.to ]
for (var k in this.traceCache.calls) { for (var k in this.traceCache.calls) {
addresses[this.traceCache.calls[k].address] = '' if (this.traceCache.calls[k].address) {
addresses.push(this.traceCache.calls[k].address)
}
} }
callback(null, addresses) callback(null, addresses)
} }
......
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