From d6ddb83d0506fb555834b0701ff4a6bfa7ca8f75 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sat, 8 Sep 2018 17:04:01 -0400 Subject: [PATCH] move step detail logic into caller --- src/app/debugger/debuggerUI/VmDebugger.js | 32 ++++++++++++++++ .../debuggerUI/vmDebugger/StepDetail.js | 38 ------------------- 2 files changed, 32 insertions(+), 38 deletions(-) diff --git a/src/app/debugger/debuggerUI/VmDebugger.js b/src/app/debugger/debuggerUI/VmDebugger.js index 083cc5e1f0..8c86744c0e 100644 --- a/src/app/debugger/debuggerUI/VmDebugger.js +++ b/src/app/debugger/debuggerUI/VmDebugger.js @@ -128,6 +128,38 @@ function VmDebugger (_parentUI, _traceManager, _codeManager, _solidityProxy, _ca }) this.stepDetail = new StepDetail(_parentUI, _traceManager) + _parentUI.debugger.event.register('traceUnloaded', this, function () { + self.stepDetail.reset() + }) + _parentUI.debugger.event.register('newTraceLoaded', this, function () { + self.stepDetail.reset() + }) + + _parentUI.event.register('indexChanged', this, function (index) { + if (index < 0) return + + self.stepDetail.updateField('vm trace step', index) + + _traceManager.getCurrentStep(index, function (error, step) { + self.stepDetail.updateField('execution step', (error ? '-' : step)) + }) + + _traceManager.getMemExpand(index, function (error, addmem) { + self.stepDetail.updateField('add memory', (error ? '-' : addmem)) + }) + + _traceManager.getStepCost(index, function (error, gas) { + self.stepDetail.updateField('gas', (error ? '-' : gas)) + }) + + _traceManager.getCurrentCalledAddressAt(index, function (error, address) { + self.stepDetail.updateField('loaded address', (error ? '-' : address)) + }) + + _traceManager.getRemainingGas(index, function (error, remaingas) { + self.stepDetail.updateField('remaining gas', (error ? '-' : remaingas)) + }) + }) this.solidityState = new SolidityState(_parentUI, _traceManager, _codeManager, _solidityProxy) this.solidityLocals = new SolidityLocals(_parentUI, _traceManager, _callTree) diff --git a/src/app/debugger/debuggerUI/vmDebugger/StepDetail.js b/src/app/debugger/debuggerUI/vmDebugger/StepDetail.js index 78f9feb4fa..961583c393 100644 --- a/src/app/debugger/debuggerUI/vmDebugger/StepDetail.js +++ b/src/app/debugger/debuggerUI/vmDebugger/StepDetail.js @@ -13,7 +13,6 @@ function StepDetail (_parentUI, _traceManager) { 'vm trace step': '-', 'execution step': '-', 'add memory': '', 'gas': '', 'remaining gas': '-', 'loaded address': '-' } this.view - this.init() } StepDetail.prototype.reset = function () { @@ -32,41 +31,4 @@ StepDetail.prototype.render = function () { return yo`
${this.basicPanel.render()}
` } -StepDetail.prototype.init = function () { - var self = this - this.debugger.event.register('traceUnloaded', this, function () { - self.reset() - }) - - this.debugger.event.register('newTraceLoaded', this, function () { - self.reset() - }) - - this.parentUI.event.register('indexChanged', this, function (index) { - if (index < 0) return - - self.updateField('vm trace step', index) - - self.traceManager.getCurrentStep(index, function (error, step) { - self.updateField('execution step', (error ? '-' : step)) - }) - - self.traceManager.getMemExpand(index, function (error, addmem) { - self.updateField('add memory', (error ? '-' : addmem)) - }) - - self.traceManager.getStepCost(index, function (error, gas) { - self.updateField('gas', (error ? '-' : gas)) - }) - - self.traceManager.getCurrentCalledAddressAt(index, function (error, address) { - self.updateField('loaded address', (error ? '-' : address)) - }) - - self.traceManager.getRemainingGas(index, function (error, remaingas) { - self.updateField('remaining gas', (error ? '-' : remaingas)) - }) - }) -} - module.exports = StepDetail