diff --git a/src/app/debugger/debugger.js b/src/app/debugger/debugger.js index 58cda21350..b81f20c929 100644 --- a/src/app/debugger/debugger.js +++ b/src/app/debugger/debugger.js @@ -2,20 +2,18 @@ var Ethdebugger = require('remix-debug').EthDebugger var remixLib = require('remix-lib') var EventManager = remixLib.EventManager -var executionContext = require('../../execution-context') -var globalRegistry = require('../../global/registry') -function Debugger () { +function Debugger (options) { var self = this this.event = new EventManager() - this.registry = globalRegistry - this.offsetToLineColumnConverter = this.registry.get('offsettolinecolumnconverter').api - this.compiler = this.registry.get('compiler').api + this.executionContext = options.executionContext + this.offsetToLineColumnConverter = options.offsetToLineColumnConverter + this.compiler = options.compiler this.debugger = new Ethdebugger( { - executionContext: executionContext, + executionContext: this.executionContext, compilationResult: () => { var compilationResult = this.compiler.lastCompilationResult if (compilationResult) { @@ -33,8 +31,9 @@ function Debugger () { this.debugger.setBreakpointManager(this.breakPointManager) - executionContext.event.register('contextChanged', this, function (context) { - self.switchProvider(context) + this.executionContext.event.register('contextChanged', this, function (context) { + // TODO: was already broken + //self.switchProvider(context) }) this.debugger.event.register('newTraceLoaded', this, function () { @@ -45,10 +44,10 @@ function Debugger () { self.event.trigger('debuggerStatus', [false]) }) - this.debugger.addProvider('vm', executionContext.vm()) - this.debugger.addProvider('injected', executionContext.internalWeb3()) - this.debugger.addProvider('web3', executionContext.internalWeb3()) - this.debugger.switchProvider(executionContext.getProvider()) + this.debugger.addProvider('vm', this.executionContext.vm()) + this.debugger.addProvider('injected', this.executionContext.internalWeb3()) + this.debugger.addProvider('web3', this.executionContext.internalWeb3()) + this.debugger.switchProvider(this.executionContext.getProvider()) } Debugger.prototype.registerAndHighlightCodeItem = function (index) { diff --git a/src/app/debugger/debuggerUI.js b/src/app/debugger/debuggerUI.js index ae99d2a0e8..b8e8e535bf 100644 --- a/src/app/debugger/debuggerUI.js +++ b/src/app/debugger/debuggerUI.js @@ -12,6 +12,7 @@ var EventManager = remixLib.EventManager var executionContext = require('../../execution-context') var globalRegistry = require('../../global/registry') +var executionContext = require('../../execution-context') var globalRegistry = require('../../global/registry') var yo = require('yo-yo') @@ -57,6 +58,18 @@ class DebuggerUI { this.listenToEvents() } + setupExecutionContext () { + this.executionContext.event.register('contextChanged', this, function (context) { + // TODO: was already broken + //self.switchProvider(context) + }) + + this.debugger.addProvider('vm', this.executionContext.vm()) + this.debugger.addProvider('injected', this.executionContext.internalWeb3()) + this.debugger.addProvider('web3', this.executionContext.internalWeb3()) + this.debugger.switchProvider(this.executionContext.getProvider()) + } + setEditor () { const self = this this.editor = this.registry.get('editor').api