From 39dd2b4b536f8ae3016586c36b26e835cd06cef9 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Mon, 1 Oct 2018 14:05:30 -0400 Subject: [PATCH] move storageview state data into logic class --- src/app/debugger/debuggerUI/VmDebugger.js | 56 ++++++++++++----------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/src/app/debugger/debuggerUI/VmDebugger.js b/src/app/debugger/debuggerUI/VmDebugger.js index b0e0d8eead..8b63b1e784 100644 --- a/src/app/debugger/debuggerUI/VmDebugger.js +++ b/src/app/debugger/debuggerUI/VmDebugger.js @@ -164,17 +164,44 @@ class VmDebuggerLogic { listenToFullStorageChanges () { const self = this + this.address = [] + this.traceLength = 0 + self._parentUI.debugger.event.register('newTraceLoaded', function (length) { self._traceManager.getAddresses(function (error, addresses) { if (error) return self.event.trigger('traceAddressesUpdate', [addresses]) + self.addresses = addresses }) self._traceManager.getLength(function (error, length) { if (error) return self.event.trigger('traceLengthUpdate', [length]) + self.traceLength = length }) }) + + self._parentUI.debugger.event.register('indexChanged', this, function (index) { + if (index < 0) return + if (self._parent.currentStepIndex !== index) return + if (!self.storageResolver) return + + if (index === self.traceLength - 1) { + var storageJSON = {} + for (var k in self.addresses) { + var address = self.addresses[k] + var storageViewer = new StorageViewer({ stepIndex: self._parent.currentStepIndex, tx: self._parent.tx, address: address }, self.storageResolver, self._traceManager) + storageViewer.storageRange(function (error, result) { + if (!error) { + storageJSON[address] = result + self.event.trigger('traceLengthUpdate', [storageJSON]) + } + }) + } + } else { + self.event.trigger('traceLengthUpdate', [{}]) + } + }) } } @@ -265,35 +292,12 @@ function VmDebugger (_parentUI, _traceManager, _codeManager, _solidityProxy, _ca this.fullStoragesChangesPanel = new FullStoragesChangesPanel(_parentUI, _traceManager) this.addresses = [] - this.vmDebuggerLogic.event.register('traceAddressesUpdate', function (addresses) { - self.addresses = addresses + this.vmDebuggerLogic.event.register('traceAddressesUpdate', function (_addresses) { self.fullStoragesChangesPanel.update({}) }) - this.vmDebuggerLogic.event.register('traceLengthUpdate', function (length) { - self.traceLength = length - }) - - _parentUI.debugger.event.register('indexChanged', this, function (index) { - if (index < 0) return - if (_parent.currentStepIndex !== index) return - if (!self.vmDebuggerLogic.storageResolver) return - - if (index === self.traceLength - 1) { - var storageJSON = {} - for (var k in self.addresses) { - var address = self.addresses[k] - var storageViewer = new StorageViewer({ stepIndex: _parent.currentStepIndex, tx: _parent.tx, address: address }, self.vmDebuggerLogic.storageResolver, _traceManager) - storageViewer.storageRange(function (error, result) { - if (!error) { - storageJSON[address] = result - self.fullStoragesChangesPanel.update(storageJSON) - } - }) - } - } else { - self.fullStoragesChangesPanel.update({}) - } + this.vmDebuggerLogic.event.register('traceStorageUpdate', function (data) { + self.fullStoragesChangesPanel.update(data) }) _parent.event.register('newTraceLoaded', this, function () {