From 374e090531a987678a16919f49ed61bdeb757b57 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sat, 8 Sep 2018 15:17:21 -0400 Subject: [PATCH] move call data logic into caller --- src/app/debugger/debuggerUI/VmDebugger.js | 13 +++++++++++ .../debuggerUI/vmDebugger/CalldataPanel.js | 22 ++++--------------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/app/debugger/debuggerUI/VmDebugger.js b/src/app/debugger/debuggerUI/VmDebugger.js index 3623a0f8cd..256dad80b0 100644 --- a/src/app/debugger/debuggerUI/VmDebugger.js +++ b/src/app/debugger/debuggerUI/VmDebugger.js @@ -39,6 +39,19 @@ function VmDebugger (_parentUI, _traceManager, _codeManager, _solidityProxy, _ca }) this.calldataPanel = new CalldataPanel(_parentUI, _traceManager) + _parentUI.event.register('indexChanged', this, function (index) { + if (index < 0) return + if (_parentUI.currentStepIndex !== index) return + + _traceManager.getCallDataAt(index, function (error, calldata) { + if (error) { + console.log(error) + self.calldataPanel.update({}) + } else if (_parentUI.currentStepIndex === index) { + self.calldataPanel.update(calldata) + } + }) + }) this.stackPanel = new StackPanel(_parentUI, _traceManager) this.storagePanel = new StoragePanel(_parentUI, _traceManager) diff --git a/src/app/debugger/debuggerUI/vmDebugger/CalldataPanel.js b/src/app/debugger/debuggerUI/vmDebugger/CalldataPanel.js index 6207b078cb..afd072ba48 100644 --- a/src/app/debugger/debuggerUI/vmDebugger/CalldataPanel.js +++ b/src/app/debugger/debuggerUI/vmDebugger/CalldataPanel.js @@ -6,28 +6,14 @@ function CalldataPanel (_parentUI, _traceManager) { this._parentUI = _parentUI this.traceManager = _traceManager this.basicPanel = new DropdownPanel('Call Data', {json: true}) - this.init() } -CalldataPanel.prototype.render = function () { - return yo`
${this.basicPanel.render()}
` +CalldataPanel.prototype.update = function (calldata) { + this.basicPanel.update(calldata) } -CalldataPanel.prototype.init = function () { - var self = this - this._parentUI.event.register('indexChanged', this, function (index) { - if (index < 0) return - if (self._parentUI.currentStepIndex !== index) return - - self.traceManager.getCallDataAt(index, function (error, calldata) { - if (error) { - self.basicPanel.update({}) - console.log(error) - } else if (self._parentUI.currentStepIndex === index) { - self.basicPanel.update(calldata) - } - }) - }) +CalldataPanel.prototype.render = function () { + return yo`
${this.basicPanel.render()}
` } module.exports = CalldataPanel