renew the storage after each new trace

pull/7/head
yann300 8 years ago
parent 519b7d03d8
commit 097a0a4a09
  1. 5
      src/storage/storageResolver.js
  2. 5
      src/ui/FullStoragesChanges.js
  3. 8
      src/ui/SolidityLocals.js
  4. 9
      src/ui/SolidityState.js
  5. 11
      src/ui/StoragePanel.js
  6. 14
      src/ui/VmDebugger.js

@ -4,12 +4,9 @@ var helper = require('../helpers/util')
var util = require('../helpers/global') var util = require('../helpers/global')
class StorageResolver { class StorageResolver {
constructor (_debugger, _traceManager) { constructor (_traceManager) {
this.traceManager = _traceManager this.traceManager = _traceManager
this.clear() this.clear()
_debugger.event.register('newTraceLoaded', () => {
this.clear()
})
} }
/** /**

@ -3,8 +3,8 @@ var DropdownPanel = require('./DropdownPanel')
var StorageViewer = require('../storage/storageViewer') var StorageViewer = require('../storage/storageViewer')
var yo = require('yo-yo') var yo = require('yo-yo')
function FullStoragesChanges (_parent, _traceManager, _storageResolver) { function FullStoragesChanges (_parent, _traceManager) {
this.storageResolver = _storageResolver this.storageResolver = null
this.parent = _parent this.parent = _parent
this.traceManager = _traceManager this.traceManager = _traceManager
this.addresses = [] this.addresses = []
@ -43,6 +43,7 @@ FullStoragesChanges.prototype.init = function () {
this.parent.event.register('indexChanged', this, function (index) { this.parent.event.register('indexChanged', this, function (index) {
if (index < 0) return if (index < 0) return
if (self.parent.currentStepIndex !== index) return if (self.parent.currentStepIndex !== index) return
if (!self.storageResolver) return
if (index === self.traceLength - 1) { if (index === self.traceLength - 1) {
var storageJSON = {} var storageJSON = {}

@ -7,10 +7,10 @@ var yo = require('yo-yo')
class SolidityLocals { class SolidityLocals {
constructor (_parent, _traceManager, _internalTreeCall, _storageResolver) { constructor (_parent, _traceManager, _internalTreeCall) {
this.parent = _parent this.parent = _parent
this.internalTreeCall = _internalTreeCall this.internalTreeCall = _internalTreeCall
this.storageResolver = _storageResolver this.storageResolver = null
this.traceManager = _traceManager this.traceManager = _traceManager
this.basicPanel = new DropdownPanel('Solidity Locals', { this.basicPanel = new DropdownPanel('Solidity Locals', {
json: true, json: true,
@ -33,6 +33,10 @@ class SolidityLocals {
this.parent.event.register('sourceLocationChanged', this, (sourceLocation) => { this.parent.event.register('sourceLocationChanged', this, (sourceLocation) => {
var warningDiv = this.view.querySelector('#warning') var warningDiv = this.view.querySelector('#warning')
warningDiv.innerHTML = '' warningDiv.innerHTML = ''
if (!this.storageResolver) {
warningDiv.innerHTML = 'storage not ready'
return
}
this.traceManager.waterfall([ this.traceManager.waterfall([
this.traceManager.getStackAt, this.traceManager.getStackAt,
this.traceManager.getMemoryAt], this.traceManager.getMemoryAt],

@ -5,8 +5,8 @@ var solidityTypeFormatter = require('./SolidityTypeFormatter')
var StorageViewer = require('../storage/storageViewer') var StorageViewer = require('../storage/storageViewer')
var yo = require('yo-yo') var yo = require('yo-yo')
function SolidityState (_parent, _traceManager, _codeManager, _solidityProxy, _storageResolver) { function SolidityState (_parent, _traceManager, _codeManager, _solidityProxy) {
this.storageResolver = _storageResolver this.storageResolver = null
this.parent = _parent this.parent = _parent
this.traceManager = _traceManager this.traceManager = _traceManager
this.codeManager = _codeManager this.codeManager = _codeManager
@ -44,6 +44,11 @@ SolidityState.prototype.init = function () {
return return
} }
if (!self.storageResolver) {
warningDiv.innerHTML = 'storage not ready'
return
}
self.traceManager.getCurrentCalledAddressAt(self.parent.currentStepIndex, (error, result) => { self.traceManager.getCurrentCalledAddressAt(self.parent.currentStepIndex, (error, result) => {
if (error) { if (error) {
self.basicPanel.update({}) self.basicPanel.update({})

@ -3,9 +3,9 @@ var DropdownPanel = require('./DropdownPanel')
var StorageViewer = require('../storage/storageViewer') var StorageViewer = require('../storage/storageViewer')
var yo = require('yo-yo') var yo = require('yo-yo')
function StoragePanel (_parent, _traceManager, _storageResolver) { function StoragePanel (_parent, _traceManager) {
this.parent = _parent this.parent = _parent
this.storageResolver = _storageResolver this.storageResolver = null
this.traceManager = _traceManager this.traceManager = _traceManager
this.basicPanel = new DropdownPanel('Storage', {json: true}) this.basicPanel = new DropdownPanel('Storage', {json: true})
this.init() this.init()
@ -22,11 +22,12 @@ StoragePanel.prototype.init = function () {
if (self.disabled) return if (self.disabled) return
if (index < 0) return if (index < 0) return
if (self.parent.currentStepIndex !== index) return if (self.parent.currentStepIndex !== index) return
if (!self.storageResolver) return
var storageViewer = new StorageViewer({ var storageViewer = new StorageViewer({
stepIndex: this.parent.currentStepIndex, stepIndex: self.parent.currentStepIndex,
tx: this.parent.tx tx: self.parent.tx
}, this.storageResolver) }, self.storageResolver)
storageViewer.storageRange((error, storage) => { storageViewer.storageRange((error, storage) => {
if (error) { if (error) {

@ -14,16 +14,15 @@ var StorageResolver = require('../storage/storageResolver.js')
var yo = require('yo-yo') var yo = require('yo-yo')
function VmDebugger (_parent, _traceManager, _codeManager, _solidityProxy, _callTree) { function VmDebugger (_parent, _traceManager, _codeManager, _solidityProxy, _callTree) {
var storageResolver = new StorageResolver(_parent, _traceManager)
this.asmCode = new CodeListView(_parent, _codeManager) this.asmCode = new CodeListView(_parent, _codeManager)
this.stackPanel = new StackPanel(_parent, _traceManager) this.stackPanel = new StackPanel(_parent, _traceManager)
this.storagePanel = new StoragePanel(_parent, _traceManager, storageResolver) this.storagePanel = new StoragePanel(_parent, _traceManager)
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)
this.stepDetail = new StepDetail(_parent, _traceManager) this.stepDetail = new StepDetail(_parent, _traceManager)
this.solidityState = new SolidityState(_parent, _traceManager, _codeManager, _solidityProxy, storageResolver) this.solidityState = new SolidityState(_parent, _traceManager, _codeManager, _solidityProxy)
this.solidityLocals = new SolidityLocals(_parent, _traceManager, _callTree, storageResolver) this.solidityLocals = new SolidityLocals(_parent, _traceManager, _callTree)
/* Return values - */ /* Return values - */
this.returnValuesPanel = new DropdownPanel('Return Value', {json: true}) this.returnValuesPanel = new DropdownPanel('Return Value', {json: true})
@ -40,11 +39,16 @@ function VmDebugger (_parent, _traceManager, _codeManager, _solidityProxy, _call
}) })
/* Return values - */ /* Return values - */
this.fullStoragesChangesPanel = new FullStoragesChangesPanel(_parent, _traceManager, storageResolver) this.fullStoragesChangesPanel = new FullStoragesChangesPanel(_parent, _traceManager)
this.view this.view
var self = this var self = this
_parent.event.register('newTraceLoaded', this, function () { _parent.event.register('newTraceLoaded', this, function () {
var storageResolver = new StorageResolver(_traceManager)
self.storagePanel.storageResolver = storageResolver
self.solidityState.storageResolver = storageResolver
self.solidityLocals.storageResolver = storageResolver
self.fullStoragesChangesPanel.storageResolver = storageResolver
self.view.style.display = 'block' self.view.style.display = 'block'
}) })
_parent.event.register('traceUnloaded', this, function () { _parent.event.register('traceUnloaded', this, function () {

Loading…
Cancel
Save