diff --git a/remix-debug/src/cmdline/contextManager.js b/remix-debug/src/cmdline/contextManager.js index 82e165df34..0785724588 100644 --- a/remix-debug/src/cmdline/contextManager.js +++ b/remix-debug/src/cmdline/contextManager.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]) } diff --git a/remix-debug/src/cmdline/index.js b/remix-debug/src/cmdline/index.js index 89baf560cb..94a1d22ab0 100644 --- a/remix-debug/src/cmdline/index.js +++ b/remix-debug/src/cmdline/index.js @@ -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() }) } diff --git a/remix-lib/src/trace/traceManager.js b/remix-lib/src/trace/traceManager.js index 98785c54e4..90662b1132 100644 --- a/remix-lib/src/trace/traceManager.js +++ b/remix-lib/src/trace/traceManager.js @@ -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)