decode locals 500ms after the last step change

pull/7/head
yann300 7 years ago
parent 6cdfb38ec9
commit 4fccd6f432
  1. 44
      src/ui/SolidityLocals.js

@ -23,49 +23,57 @@ class SolidityLocals {
render () { render () {
this.view = yo`<div id='soliditylocals' > this.view = yo`<div id='soliditylocals' >
<div id='warning'></div>
${this.basicPanel.render()} ${this.basicPanel.render()}
</div>` </div>`
return this.view return this.view
} }
init () { init () {
var decodeTimeout = null
this.parent.event.register('sourceLocationChanged', this, (sourceLocation) => { this.parent.event.register('sourceLocationChanged', this, (sourceLocation) => {
var warningDiv = this.view.querySelector('#warning') this.basicPanel.setMessage('')
warningDiv.innerHTML = ''
if (!this.storageResolver) { if (!this.storageResolver) {
warningDiv.innerHTML = 'storage not ready' this.basicPanel.setMessage('storage not ready')
return return
} }
this.traceManager.waterfall([ if (decodeTimeout) {
this.traceManager.getStackAt, window.clearTimeout(decodeTimeout)
this.traceManager.getMemoryAt, }
this.traceManager.getCurrentCalledAddressAt], this.basicPanel.setLoading()
this.parent.currentStepIndex, decodeTimeout = setTimeout(() => {
decode(this, sourceLocation)
}, 500)
})
}
}
function decode (self, sourceLocation) {
self.traceManager.waterfall([
self.traceManager.getStackAt,
self.traceManager.getMemoryAt,
self.traceManager.getCurrentCalledAddressAt],
self.parent.currentStepIndex,
(error, result) => { (error, result) => {
if (!error) { if (!error) {
var stack = result[0].value var stack = result[0].value
var memory = result[1].value var memory = result[1].value
try { try {
var storageViewer = new StorageViewer({ var storageViewer = new StorageViewer({
stepIndex: this.parent.currentStepIndex, stepIndex: self.parent.currentStepIndex,
tx: this.parent.tx, tx: self.parent.tx,
address: result[2].value address: result[2].value
}, this.storageResolver, this.traceManager) }, self.storageResolver, self.traceManager)
localDecoder.solidityLocals(this.parent.currentStepIndex, this.internalTreeCall, stack, memory, storageViewer, sourceLocation).then((locals) => { localDecoder.solidityLocals(self.parent.currentStepIndex, self.internalTreeCall, stack, memory, storageViewer, sourceLocation).then((locals) => {
if (!locals.error) { if (!locals.error) {
this.basicPanel.update(locals) self.basicPanel.update(locals)
} }
}) })
} catch (e) { } catch (e) {
warningDiv.innerHTML = e.message self.basicPanel.setMessage(e.message)
} }
} else { } else {
console.log(error) console.log(error)
} }
}) })
})
} }
}
module.exports = SolidityLocals module.exports = SolidityLocals

Loading…
Cancel
Save