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')
var yo = require('yo-yo')
var ui = require('./helpers/ui')
function BasicPanel (_name, _id, _width, _height) {
function BasicPanel (_name, _width, _height) {
this.data
this.name = _name
this.id = _id
this.width = _width
this.height = _height
this.view
......@@ -17,20 +16,20 @@ BasicPanel.prototype.update = function () {
}
BasicPanel.prototype.hide = function () {
document.getElementById(this.id + 'container').style.display = 'none'
this.view.style.display = 'none'
}
BasicPanel.prototype.show = function () {
document.getElementById(this.id + 'container').style.display = 'block'
this.view.style.display = 'block'
}
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)}>
${this.name}
</div>
<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>`
if (!this.view) {
......
'use strict'
var StoragePanel = require('./StoragePanel')
var BasicPanel = require('./BasicPanel')
var yo = require('yo-yo')
function FullStoragesChanges (_parent, _traceManager) {
this.parent = _parent
this.traceManager = _traceManager
this.addresses = []
this.view
this.traceLength
this.basicPanel = new BasicPanel('Full Storages Changes', '1205px', '100px')
this.init()
this.panels = {}
}
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 () {
var self = this
this.parent.register('newTraceLoaded', this, function (length) {
self.panels = {}
self.traceManager.getAddresses(function (addresses) {
for (var k in addresses) {
self.panels[addresses] = new StoragePanel(self.traceManager, self.traceManager, k)
self.panels[addresses].disable = true
self.panels = []
self.traceManager.getAddresses(function (error, addresses) {
if (!error) {
self.addresses = addresses
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 () {
if (index < 0) return
if (self.parent.currentStepIndex !== index) return
self.traceManager.getLength(function (error, length) {
if (index === self.traceLength - 1) {
var storageJSON = {}
for (var k in self.addresses) {
self.traceManager.getStorageAt(index, null, function (error, result) {
if (!error) {
for (var k in self.panels) {
self.panels[k].disabled = index !== length - 1
}
if (index !== length - 1) {
self.view = ''
if (self.view) {
storageJSON[self.addresses[k]] = result
self.basicPanel.data = JSON.stringify(storageJSON, null, '\t')
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
......@@ -20,7 +20,7 @@ function VmDebugger (_parent, _traceManager, _web3) {
this.callstackPanel = new CallstackPanel(_parent, _traceManager)
/* 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) {
var self = this
_traceManager.getReturnValue(index, function (error, returnValue) {
......@@ -56,6 +56,16 @@ VmDebugger.prototype.render = function () {
<table>
<tbody>
<tr>
<td colspan='2'>
${this.returnValuesPanel.render()}
</td>
</tr>
<tr>
<td colspan='2'>
${this.fullStoragesChangesPanel.render()}
</td>
</tr>
<tr>
<td>
${this.asmCode.render()}
</td>
......@@ -79,16 +89,6 @@ VmDebugger.prototype.render = function () {
${this.callstackPanel.render()}
</td>
</tr>
<tr>
<td colspan='2'>
${this.returnValuesPanel.render()}
</td>
</tr>
<tr>
<td colspan='2'>
${this.fullStoragesChangesPanel.render()}
</td>
</tr>
</tbody>
</table>
</div>
......
......@@ -16,6 +16,7 @@ TraceAnalyser.prototype.analyse = function (trace, tx, callback) {
lastCallIndex: 0
}
var callStack = [tx.to]
this.traceCache.pushCallChanges(0, 0, callStack[0])
this.traceCache.pushCallStack(0, {
callStack: callStack.slice(0)
})
......@@ -36,8 +37,8 @@ TraceAnalyser.prototype.analyse = function (trace, tx, callback) {
TraceAnalyser.prototype.buildReturnValues = function (index, step) {
if (traceHelper.isReturnInstruction(step)) {
var offset = 2 * parseInt(step.stack[step.stack.length - 1])
var size = 2 * parseInt(step.stack[step.stack.length - 2])
var offset = 2 * parseInt(step.stack[step.stack.length - 1], 16)
var size = 2 * parseInt(step.stack[step.stack.length - 2], 16)
var memory = this.trace[this.traceCache.memoryChanges[this.traceCache.memoryChanges.length - 1]].memory
this.traceCache.pushReturnValue(index, '0x' + memory.join('').substr(offset, size))
}
......@@ -76,7 +77,7 @@ TraceAnalyser.prototype.buildMemory = function (index, step) {
}
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)
if (calledAddress) {
context.currentStorageAddress = calledAddress
......
......@@ -78,9 +78,9 @@ TraceManager.prototype.getStorageAt = function (stepIndex, tx, callback, address
if (check) {
return callback(check, null)
}
if (!address) {
var stoChange = traceHelper.findLowerBound(stepIndex, this.traceCache.storageChanges)
if (stoChange === undefined) return callback('no storage found', null)
if (!address) {
address = this.traceCache.sstore[stoChange].address
}
var storage = {}
......@@ -107,9 +107,11 @@ TraceManager.prototype.getStorageAt = function (stepIndex, tx, callback, address
}
TraceManager.prototype.getAddresses = function (callback) {
var addresses = {}
var addresses = [ this.tx.to ]
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)
}
......
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