refactor step detail

pull/1/head
Iuri Matias 6 years ago committed by yann300
parent de1e1b6ca5
commit 5f8b191a13
  1. 75
      src/app/debugger/debuggerUI/vmDebugger/StepDetail.js

@ -9,11 +9,25 @@ function StepDetail (_parentUI, _traceManager) {
this.basicPanel = new DropdownPanel('Step detail', {json: true, displayContentOnly: true}) this.basicPanel = new DropdownPanel('Step detail', {json: true, displayContentOnly: true})
this.detail = initDetail() this.detail = {
'vm trace step': '-', 'execution step': '-', 'add memory': '', 'gas': '', 'remaining gas': '-', 'loaded address': '-'
}
this.view this.view
this.init() this.init()
} }
StepDetail.prototype.reset = function () {
this.detail = {
'vm trace step': '-', 'execution step': '-', 'add memory': '', 'gas': '', 'remaining gas': '-', 'loaded address': '-'
}
this.basicPanel.update(this.detail)
}
StepDetail.prototype.updateField = function (key, value) {
this.detail[key] = value
this.basicPanel.update(this.detail)
}
StepDetail.prototype.render = function () { StepDetail.prototype.render = function () {
return yo`<div id='stepdetail' >${this.basicPanel.render()}</div>` return yo`<div id='stepdetail' >${this.basicPanel.render()}</div>`
} }
@ -21,81 +35,38 @@ StepDetail.prototype.render = function () {
StepDetail.prototype.init = function () { StepDetail.prototype.init = function () {
var self = this var self = this
this.debugger.event.register('traceUnloaded', this, function () { this.debugger.event.register('traceUnloaded', this, function () {
self.detail = initDetail() self.reset()
self.basicPanel.update(self.detail)
}) })
this.debugger.event.register('newTraceLoaded', this, function () { this.debugger.event.register('newTraceLoaded', this, function () {
self.detail = initDetail() self.reset()
self.basicPanel.update(self.detail)
}) })
this.parentUI.event.register('indexChanged', this, function (index) { this.parentUI.event.register('indexChanged', this, function (index) {
if (index < 0) return if (index < 0) return
self.detail['vm trace step'] = index self.updateField('vm trace step', index)
self.traceManager.getCurrentStep(index, function (error, step) { self.traceManager.getCurrentStep(index, function (error, step) {
if (error) { self.updateField('execution step', (error ? '-' : step))
console.log(error)
self.detail['execution step'] = '-'
} else {
self.detail['execution step'] = step
}
self.basicPanel.update(self.detail)
}) })
self.traceManager.getMemExpand(index, function (error, addmem) { self.traceManager.getMemExpand(index, function (error, addmem) {
if (error) { self.updateField('add memory', (error ? '-' : addmem))
console.log(error)
self.detail['add memory'] = '-'
} else {
self.detail['add memory'] = addmem
}
self.basicPanel.update(self.detail)
}) })
self.traceManager.getStepCost(index, function (error, gas) { self.traceManager.getStepCost(index, function (error, gas) {
if (error) { self.updateField('gas', (error ? '-' : gas))
console.log(error)
self.detail.gas = '-'
} else {
self.detail.gas = gas
}
self.basicPanel.update(self.detail)
}) })
self.traceManager.getCurrentCalledAddressAt(index, function (error, address) { self.traceManager.getCurrentCalledAddressAt(index, function (error, address) {
if (error) { self.updateField('loaded address', (error ? '-' : address))
console.log(error)
self.detail['loaded address'] = '-'
} else {
self.detail['loaded address'] = address
}
self.basicPanel.update(self.detail)
}) })
self.traceManager.getRemainingGas(index, function (error, remaingas) { self.traceManager.getRemainingGas(index, function (error, remaingas) {
if (error) { self.updateField('remaining gas', (error ? '-' : remaingas))
console.log(error)
self.detail['remaining gas'] = '-'
} else {
self.detail['remaining gas'] = remaingas
}
self.basicPanel.update(self.detail)
}) })
}) })
} }
function initDetail () {
return {
'vm trace step': '-',
'execution step': '-',
'add memory': '',
'gas': '',
'remaining gas': '-',
'loaded address': '-'
}
}
module.exports = StepDetail module.exports = StepDetail

Loading…
Cancel
Save