Commit 8bb7e18b authored by Iuri Matias's avatar Iuri Matias

refactor decodeLocalsAt

parent 57f715f9
...@@ -88,58 +88,25 @@ Ethdebugger.prototype.extractLocalsAt = function (step, callback) { ...@@ -88,58 +88,25 @@ Ethdebugger.prototype.extractLocalsAt = function (step, callback) {
} }
Ethdebugger.prototype.decodeLocalsAt = function (step, sourceLocation, callback) { Ethdebugger.prototype.decodeLocalsAt = function (step, sourceLocation, callback) {
const self = this try {
this.traceManager.waterfall([ const stack = this.traceManager.getStackAt(step)
function getStackAt (stepIndex, callback) { const memory = this.traceManager.getMemoryAt(step)
try { const address = this.traceManager.getCurrentCalledAddressAt(step)
const result = self.traceManager.getStackAt(stepIndex) try {
callback(null, result) const storageViewer = new StorageViewer({ stepIndex: step, tx: this.tx, address: address }, this.storageResolver, this.traceManager)
} catch (error) { localDecoder.solidityLocals(step, this.callTree, stack, memory, storageViewer, sourceLocation).then((locals) => {
callback(error) if (!locals.error) {
} callback(null, locals)
}, } else {
function getMemoryAt (stepIndex, callback) { callback(locals.error)
try {
const result = self.traceManager.getMemoryAt(stepIndex)
callback(null, result)
} catch (error) {
callback(error)
}
},
function getCurrentCalledAddressAt (stepIndex, next) {
try {
const address = self.traceManager.getCurrentCalledAddressAt(stepIndex)
next(null, address)
} catch (error) {
next(error)
}
}],
step,
(error, result) => {
if (!error) {
const stack = result[0].value
const memory = result[1].value
try {
const storageViewer = new StorageViewer({
stepIndex: step,
tx: this.tx,
address: result[2].value
}, this.storageResolver, this.traceManager)
localDecoder.solidityLocals(step, this.callTree, stack, memory, storageViewer, sourceLocation).then((locals) => {
if (!locals.error) {
callback(null, locals)
} else {
callback(locals.error)
}
})
} catch (e) {
callback(e.message)
} }
} else { })
callback(error) } catch (e) {
} callback(e.message)
}) }
} catch (error) {
callback(error)
}
} }
/* decode state */ /* decode state */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment