remix-project mirror
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
remix-project/remix-debugger/src/ui/StepDetail.js

101 lines
2.5 KiB

8 years ago
'use strict'
var yo = require('yo-yo')
var DropdownPanel = require('./DropdownPanel')
function StepDetail (_parent, _traceManager) {
this.parent = _parent
this.traceManager = _traceManager
this.basicPanel = new DropdownPanel('Step detail', {json: true})
8 years ago
this.detail = initDetail()
this.view
this.init()
}
StepDetail.prototype.render = function () {
8 years ago
return yo`<div id='stepdetail' >${this.basicPanel.render()}</div>`
8 years ago
}
StepDetail.prototype.init = function () {
var self = this
this.parent.event.register('traceUnloaded', this, function () {
8 years ago
self.detail = initDetail()
8 years ago
self.basicPanel.update(self.detail)
8 years ago
})
this.parent.event.register('newTraceLoaded', this, function () {
8 years ago
self.detail = initDetail()
8 years ago
self.basicPanel.update(self.detail)
8 years ago
})
this.parent.event.register('indexChanged', this, function (index) {
8 years ago
if (index < 0) return
8 years ago
self.detail['vm trace step'] = index
8 years ago
self.traceManager.getCurrentStep(index, function (error, step) {
if (error) {
console.log(error)
8 years ago
self.detail['execution step'] = '-'
8 years ago
} else {
8 years ago
self.detail['execution step'] = step
8 years ago
}
8 years ago
self.basicPanel.update(self.detail)
8 years ago
})
self.traceManager.getMemExpand(index, function (error, addmem) {
if (error) {
console.log(error)
8 years ago
self.detail['add memory'] = '-'
8 years ago
} else {
8 years ago
self.detail['add memory'] = addmem
8 years ago
}
8 years ago
self.basicPanel.update(self.detail)
8 years ago
})
self.traceManager.getStepCost(index, function (error, gas) {
if (error) {
console.log(error)
self.detail.gas = '-'
} else {
self.detail.gas = gas
}
8 years ago
self.basicPanel.update(self.detail)
8 years ago
})
self.traceManager.getCurrentCalledAddressAt(index, function (error, address) {
if (error) {
console.log(error)
8 years ago
self.detail['loaded address'] = '-'
8 years ago
} else {
8 years ago
self.detail['loaded address'] = address
8 years ago
}
8 years ago
self.basicPanel.update(self.detail)
8 years ago
})
self.traceManager.getRemainingGas(index, function (error, remaingas) {
if (error) {
console.log(error)
8 years ago
self.detail['remaining gas'] = '-'
8 years ago
} else {
8 years ago
self.detail['remaining gas'] = remaingas
8 years ago
}
8 years ago
self.basicPanel.update(self.detail)
8 years ago
})
})
}
module.exports = StepDetail
function initDetail () {
return {
8 years ago
'vm trace step': '-',
'execution step': '-',
'add memory': '',
'gas': '',
'remaining gas': '-',
'loaded address': '-'
8 years ago
}
}