mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 18:00:18 +01:00
Manually debugged refactor
This commit is contained in:
parent
122018a96a
commit
d3e0e7fe45
@ -90,14 +90,15 @@ function setupControllerConnection (stream) {
|
||||
var api = controller.getApi()
|
||||
var dnode = Dnode(api)
|
||||
stream.pipe(dnode).pipe(stream)
|
||||
dnode.on('remote', () => {
|
||||
dnode.on('remote', (remote) => {
|
||||
// push updates to popup
|
||||
controller.ethStore.on('update', controller.sendUpdate)
|
||||
idStore.on('update', controller.sendUpdate)
|
||||
controller.ethStore.on('update', controller.sendUpdate.bind(controller))
|
||||
controller.remote = remote
|
||||
idStore.on('update', controller.sendUpdate.bind(controller))
|
||||
|
||||
// teardown on disconnect
|
||||
eos(stream, () => {
|
||||
controller.ethStore.removeListener('update', controller.sendUpdate)
|
||||
controller.ethStore.removeListener('update', controller.sendUpdate.bind(controller))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@ -7,18 +7,16 @@ const HostStore = require('./lib/remote-store.js').HostStore
|
||||
const Web3 = require('web3')
|
||||
const ConfigManager = require('./lib/config-manager')
|
||||
|
||||
module.exports = MetamaskController
|
||||
|
||||
class MetamaskController {
|
||||
module.exports = class MetamaskController {
|
||||
|
||||
constructor (opts) {
|
||||
this.configManager = new ConfigManager(opts)
|
||||
this.provider = this.initializeProvider(opts)
|
||||
this.ethStore = new EthStore(this.provider)
|
||||
this.idStore = new IdentityStore({
|
||||
configManager: this.configManager,
|
||||
ethStore: this.ethStore,
|
||||
})
|
||||
this.provider = this.initializeProvider(opts)
|
||||
this.ethStore = new EthStore(this.provider)
|
||||
this.idStore.setStore(this.ethStore)
|
||||
this.messageManager = messageManager
|
||||
this.publicConfigStore = this.initPublicConfigStore()
|
||||
}
|
||||
@ -35,7 +33,7 @@ class MetamaskController {
|
||||
const idStore = this.idStore
|
||||
|
||||
return {
|
||||
getState: function (cb) { cb(null, this.getState()) },
|
||||
getState: (cb) => { cb(null, this.getState()) },
|
||||
setRpcTarget: this.setRpcTarget.bind(this),
|
||||
setProviderType: this.setProviderType.bind(this),
|
||||
useEtherscanProvider: this.useEtherscanProvider.bind(this),
|
||||
@ -99,8 +97,10 @@ class MetamaskController {
|
||||
}
|
||||
|
||||
sendUpdate () {
|
||||
if (this.remote) {
|
||||
this.remote.sendUpdate(this.getState())
|
||||
}
|
||||
}
|
||||
|
||||
initializeProvider (opts) {
|
||||
const idStore = this.idStore
|
||||
@ -126,7 +126,7 @@ class MetamaskController {
|
||||
idStore.web3 = web3
|
||||
idStore.getNetwork()
|
||||
|
||||
provider.on('block', this.processBlock)
|
||||
provider.on('block', this.processBlock.bind(this))
|
||||
provider.on('error', idStore.getNetwork.bind(idStore))
|
||||
|
||||
return provider
|
||||
|
Loading…
Reference in New Issue
Block a user