move global vars out of debugger logic

pull/3094/head
Iuri Matias 6 years ago
parent c3318ed5c0
commit b19742f480
  1. 25
      src/app/debugger/debugger.js
  2. 13
      src/app/debugger/debuggerUI.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) {

@ -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

Loading…
Cancel
Save