Commit 973907b8 authored by Iuri Matias's avatar Iuri Matias

move global vars out of debugger logic

parent e82ef923
......@@ -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) {
......
......@@ -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
......
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