From b64269bd46b638a77dc288620cc38c3ecb8cff1a Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 19 Sep 2018 20:20:54 -0400 Subject: [PATCH] add new FullStorageChanges --- src/app/debugger/debuggerUI/VmDebugger.js | 2 +- .../vmDebugger/FullStoragesChanges.js | 72 +++++++++++++++++++ 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 src/app/debugger/debuggerUI/vmDebugger/FullStoragesChanges.js diff --git a/src/app/debugger/debuggerUI/VmDebugger.js b/src/app/debugger/debuggerUI/VmDebugger.js index a91f502b31..a820430e68 100644 --- a/src/app/debugger/debuggerUI/VmDebugger.js +++ b/src/app/debugger/debuggerUI/VmDebugger.js @@ -13,7 +13,7 @@ var DebuggerSolidityLocals = require('../solidityLocals') var SolidityState = require('./vmDebugger/SolidityState') var SolidityLocals = require('./vmDebugger/SolidityLocals') -var FullStoragesChangesPanel = require('../remix-debugger/src/ui/FullStoragesChanges') +var FullStoragesChangesPanel = require('./vmDebugger/FullStoragesChanges') var DropdownPanel = require('./vmDebugger/DropdownPanel') var remixDebug = require('remix-debug') var remixLib = require('remix-lib') diff --git a/src/app/debugger/debuggerUI/vmDebugger/FullStoragesChanges.js b/src/app/debugger/debuggerUI/vmDebugger/FullStoragesChanges.js new file mode 100644 index 0000000000..7051efac05 --- /dev/null +++ b/src/app/debugger/debuggerUI/vmDebugger/FullStoragesChanges.js @@ -0,0 +1,72 @@ +'use strict' +var DropdownPanel = require('./DropdownPanel') +var remixDebug = require('remix-debug') +var StorageViewer = remixDebug.storage.StorageViewer +var yo = require('yo-yo') + +function FullStoragesChanges (_parent, _traceManager) { + this.storageResolver = null + this.parent = _parent + this.debugger = _parent.debugger + this.traceManager = _traceManager + this.addresses = [] + this.view + this.traceLength + this.basicPanel = new DropdownPanel('Full Storages Changes', {json: true}) + this.init() +} + +FullStoragesChanges.prototype.render = function () { + var view = yo`
${this.basicPanel.render()}
` + if (!this.view) { + this.view = view + } + return view +} + +FullStoragesChanges.prototype.init = function () { + var self = this + this.debugger.event.register('newTraceLoaded', this, function (length) { + self.panels = [] + self.traceManager.getAddresses(function (error, addresses) { + if (!error) { + self.addresses = addresses + self.basicPanel.update({}) + } + }) + + self.traceManager.getLength(function (error, length) { + if (!error) { + self.traceLength = length + } + }) + }) + + this.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.basicPanel.update(storageJSON) + } + }) + } + } else { + self.basicPanel.update({}) + } + }) +} + +module.exports = FullStoragesChanges