diff --git a/src/app/debugger/debuggerUI/VmDebugger.js b/src/app/debugger/debuggerUI/VmDebugger.js index ae5cb9af60..c13a7910d0 100644 --- a/src/app/debugger/debuggerUI/VmDebugger.js +++ b/src/app/debugger/debuggerUI/VmDebugger.js @@ -15,6 +15,7 @@ var remixDebug = require('remix-debug') var remixLib = require('remix-lib') var ui = remixLib.helpers.ui var StorageResolver = remixDebug.storage.StorageResolver +var StorageViewer = remixDebug.storage.StorageViewer var yo = require('yo-yo') var css = csjs` @@ -101,7 +102,30 @@ function VmDebugger (_parentUI, _traceManager, _codeManager, _solidityProxy, _ca }) this.storagePanel = new StoragePanel(_parentUI, _traceManager) - + _parentUI.event.register('indexChanged', this, function (index) { + if (index < 0) return + if (_parentUI.currentStepIndex !== index) return + if (!self.storageResolver) return + + _traceManager.getCurrentCalledAddressAt(index, (error, address) => { + if (error) return + var storageViewer = new StorageViewer({ + stepIndex: _parentUI.currentStepIndex, + tx: _parentUI.tx, + address: address + }, self.storageResolver, _traceManager) + + storageViewer.storageRange((error, storage) => { + if (error) { + console.log(error) + self.storagePanel.update({}) + } else if (_parentUI.currentStepIndex === index) { + var header = storageViewer.isComplete(address) ? 'completely loaded' : 'partially loaded...' + self.storagePanel.update(storage, header) + } + }) + }) + }) this.stepDetail = new StepDetail(_parentUI, _traceManager) this.solidityState = new SolidityState(_parentUI, _traceManager, _codeManager, _solidityProxy) @@ -127,11 +151,10 @@ function VmDebugger (_parentUI, _traceManager, _codeManager, _solidityProxy, _ca _parent.event.register('newTraceLoaded', this, function () { if (!self.view) return - var storageResolver = new StorageResolver({web3: _parent.web3}) - self.storagePanel.storageResolver = storageResolver - self.solidityState.storageResolver = storageResolver - self.solidityLocals.storageResolver = storageResolver - self.fullStoragesChangesPanel.storageResolver = storageResolver + self.storageResolver = new StorageResolver({web3: _parent.web3}) + self.solidityState.storageResolver = self.storageResolver + self.solidityLocals.storageResolver = self.storageResolver + self.fullStoragesChangesPanel.storageResolver = self.storageResolver self.asmCode.basicPanel.show() self.stackPanel.basicPanel.show() self.storagePanel.basicPanel.show() diff --git a/src/app/debugger/debuggerUI/vmDebugger/StoragePanel.js b/src/app/debugger/debuggerUI/vmDebugger/StoragePanel.js index 3fdb8218c5..af7d160e70 100644 --- a/src/app/debugger/debuggerUI/vmDebugger/StoragePanel.js +++ b/src/app/debugger/debuggerUI/vmDebugger/StoragePanel.js @@ -1,7 +1,5 @@ 'use strict' var DropdownPanel = require('./DropdownPanel') -var remixDebug = require('remix-debug') -var StorageViewer = remixDebug.storage.StorageViewer var yo = require('yo-yo') function StoragePanel (_parent, _traceManager) { @@ -9,42 +7,14 @@ function StoragePanel (_parent, _traceManager) { this.storageResolver = null this.traceManager = _traceManager this.basicPanel = new DropdownPanel('Storage', {json: true}) - this.init() - this.disabled = false } -StoragePanel.prototype.render = function () { - return yo`
${this.basicPanel.render()}
` +StoragePanel.prototype.update = function (storage, header) { + this.basicPanel.update(storage, header) } -StoragePanel.prototype.init = function () { - var self = this - this.parent.event.register('indexChanged', this, function (index) { - if (self.disabled) return - if (index < 0) return - if (self.parent.currentStepIndex !== index) return - if (!self.storageResolver) return - - this.traceManager.getCurrentCalledAddressAt(index, (error, address) => { - if (!error) { - var storageViewer = new StorageViewer({ - stepIndex: self.parent.currentStepIndex, - tx: self.parent.tx, - address: address - }, self.storageResolver, self.traceManager) - - storageViewer.storageRange((error, storage) => { - if (error) { - console.log(error) - self.basicPanel.update({}) - } else if (self.parent.currentStepIndex === index) { - var header = storageViewer.isComplete(address) ? 'completely loaded' : 'partially loaded...' - self.basicPanel.update(storage, header) - } - }) - } - }) - }) +StoragePanel.prototype.render = function () { + return yo`
${this.basicPanel.render()}
` } module.exports = StoragePanel