1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 01:39:44 +01:00

Update popup-core script to use ES6 destructuring, const, let

This commit is contained in:
Whymarrh Whitby 2019-02-12 10:35:30 -03:30
parent ade96fda41
commit 92cc60f425

View File

@ -1,11 +1,11 @@
const EventEmitter = require('events').EventEmitter
const {EventEmitter} = require('events')
const async = require('async')
const Dnode = require('dnode')
const Eth = require('ethjs')
const EthQuery = require('eth-query')
const launchMetamaskUi = require('../../ui')
const StreamProvider = require('web3-stream-provider')
const setupMultiplex = require('./lib/stream-utils.js').setupMultiplex
const {setupMultiplex} = require('./lib/stream-utils.js')
module.exports = initializePopup
@ -32,7 +32,7 @@ function initializePopup ({ container, connectionStream }, cb) {
function connectToAccountManager (connectionStream, cb) {
// setup communication with background
// setup multiplexing
var mx = setupMultiplex(connectionStream)
const mx = setupMultiplex(connectionStream)
// connect features
setupControllerConnection(mx.createStream('controller'), cb)
setupWeb3Connection(mx.createStream('provider'))
@ -44,7 +44,7 @@ function connectToAccountManager (connectionStream, cb) {
* @param {PortDuplexStream} connectionStream PortStream instance establishing a background connection
*/
function setupWeb3Connection (connectionStream) {
var providerStream = new StreamProvider()
const providerStream = new StreamProvider()
providerStream.pipe(connectionStream).pipe(providerStream)
connectionStream.on('error', console.error.bind(console))
providerStream.on('error', console.error.bind(console))
@ -62,8 +62,8 @@ function setupWeb3Connection (connectionStream) {
function setupControllerConnection (connectionStream, cb) {
// this is a really sneaky way of adding EventEmitter api
// to a bi-directional dnode instance
var eventEmitter = new EventEmitter()
var accountManagerDnode = Dnode({
const eventEmitter = new EventEmitter()
const accountManagerDnode = Dnode({
sendUpdate: function (state) {
eventEmitter.emit('update', state)
},