add callbacks so each step of the debugger is only called when it's ready

pull/7/head
Iuri Matias 6 years ago
parent 8b8943fc35
commit 0046453a42
  1. 3
      remix-debug/src/cmdline/contextManager.js
  2. 9
      remix-debug/src/cmdline/index.js
  3. 2
      remix-lib/src/trace/traceManager.js

@ -33,7 +33,7 @@ class ContextManager {
this.event.trigger('providerAdded', [type])
}
switchProvider (type) {
switchProvider (type, cb) {
var self = this
this.web3Providers.get(type, function (error, obj) {
if (error) {
@ -48,6 +48,7 @@ class ContextManager {
self.web3 = (!webDebugNode ? obj : webDebugNode)
}
self.event.trigger('providerChanged', [type, self.web3])
if (cb) return cb();
})
self.event.trigger('providerChanged', [type, self.web3])
}

@ -20,7 +20,7 @@ class CmdLine {
this.compilation.lastCompilationResult = compilationResult
}
initDebugger () {
initDebugger (cb) {
const self = this
this.contextManager = new ContextManager()
@ -36,7 +36,7 @@ class CmdLine {
this.contextManager.initProviders()
this.contextManager.addProvider('debugger_web3', this.web3)
this.contextManager.switchProvider('debugger_web3')
this.contextManager.switchProvider('debugger_web3', cb)
}
getSource() {
@ -44,7 +44,7 @@ class CmdLine {
let lineColumnPos = this.lineColumnPos
if (!lineColumnPos || !lineColumnPos.start) return;
if (!lineColumnPos || !lineColumnPos.start) return [];
let content = self.compilation.lastCompilationResult.source.sources[this.filename].content.split("\n")
@ -74,7 +74,7 @@ class CmdLine {
}
// TODO: is filename really necessary?
startDebug(txNumber, filename) {
startDebug(txNumber, filename, cb) {
const self = this
this.filename = filename
this.debugger.debug(null, txNumber, null, () => {
@ -96,6 +96,7 @@ class CmdLine {
self.events.emit("locals", data)
});
cb()
})
}

@ -120,7 +120,7 @@ TraceManager.prototype.getStackAt = function (stepIndex, callback) {
return callback(check, null)
}
var stack
if (this.trace[stepIndex].stack) { // there's always a stack
if (this.trace[stepIndex] && this.trace[stepIndex].stack) { // there's always a stack
stack = this.trace[stepIndex].stack.slice(0)
stack.reverse()
callback(null, stack)

Loading…
Cancel
Save