listen to providerChanged and update web3 object

pull/1/head
Iuri Matias 6 years ago
parent 332cee0ab0
commit f4bd89392c
  1. 89
      src/app/debugger/debuggerUI.js

@ -2,7 +2,6 @@ var TxBrowser = require('./debuggerUI/TxBrowser')
var StepManagerUI = require('./debuggerUI/StepManager')
var VmDebugger = require('./debuggerUI/VmDebugger')
//var Debugger = require('./debugger/debugger')
var Debugger = require('remix-debug').TransactionDebugger
var SourceHighlighter = require('../editor/sourceHighlighter')
@ -33,28 +32,13 @@ var css = csjs`
class ContextManager {
constructor () {
this.web3 = executionContext.web3()
this.executionContext = executionContext
this.web3 = this.executionContext.web3()
this.event = new EventManager()
}
}
class DebuggerUI {
constructor (container) {
this.registry = globalRegistry
this.event = new EventManager()
this.executionContext = executionContext
this.debugger = new Debugger({
web3: executionContext.web3(),
offsetToLineColumnConverter: this.registry.get('offsettolinecolumnconverter').api,
compiler: this.registry.get('compiler').api,
compilersArtefacts: this.registry.get('compilersartefacts').api
})
initProviders () {
this.web3Providers = new Web3Providers()
this.executionContext = this.executionContext
this.addProvider('DUMMYWEB3', new DummyProvider())
this.switchProvider('DUMMYWEB3')
@ -62,25 +46,11 @@ class DebuggerUI {
this.addProvider('injected', this.executionContext.internalWeb3())
this.addProvider('web3', this.executionContext.internalWeb3())
this.switchProvider(this.executionContext.getProvider())
this.isActive = false
this.sourceHighlighter = new SourceHighlighter()
this.startTxBrowser()
this.stepManager = null
this.statusMessage = ''
this.view
container.appendChild(this.render())
this.setEditor()
this.listenToEvents()
}
getWeb3 () {
return this.web3
}
addProvider (type, obj) {
this.web3Providers.addProvider(type, obj)
@ -93,22 +63,61 @@ class DebuggerUI {
if (error) {
console.log('provider ' + type + ' not defined')
} else {
self.debugger.updateWeb3(obj)
self.web3 = obj
self.executionContext.detectNetwork((error, network) => {
if (error || !network) {
self.debugger.debugger.updateWeb3(obj)
self.web3 = obj
} else {
var webDebugNode = init.web3DebugNode(network.name)
self.debugger.updateWeb3(!webDebugNode ? obj : webDebugNode)
self.web3 = (!webDebugNode ? obj : webDebugNode)
}
self.event.trigger('providerChanged', [type, self.web3])
})
self.event.trigger('providerChanged', [type])
self.event.trigger('providerChanged', [type, self.web3])
}
})
}
}
class DebuggerUI {
constructor (container) {
this.registry = globalRegistry
this.event = new EventManager()
this.executionContext = executionContext
this.contextManager = new ContextManager()
this.debugger = new Debugger({
web3: this.contextManager.getWeb3(),
offsetToLineColumnConverter: this.registry.get('offsettolinecolumnconverter').api,
compiler: this.registry.get('compiler').api
})
this.contextManager.initProviders()
this.contextManager.event.register('providerChanged', () => {
this.debugger.updateWeb3(this.contextManager.getWeb3())
})
this.isActive = false
this.sourceHighlighter = new SourceHighlighter()
this.startTxBrowser()
this.stepManager = null
this.statusMessage = ''
this.view
container.appendChild(this.render())
this.setEditor()
this.listenToEvents()
}
setEditor () {
const self = this

Loading…
Cancel
Save