aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/popup.js
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2016-04-15 12:22:04 +0800
committerkumavis <aaron@kumavis.me>2016-04-15 12:22:04 +0800
commit907e39e5abc301fa54e144c5c151b79c3affb788 (patch)
treefcefefc50d3bb7452e91e507b437805a48c9e929 /app/scripts/popup.js
parentcef1f2a65f27d594b12afd021dea73fcaf569af5 (diff)
downloadtangerine-wallet-browser-907e39e5abc301fa54e144c5c151b79c3affb788.tar
tangerine-wallet-browser-907e39e5abc301fa54e144c5c151b79c3affb788.tar.gz
tangerine-wallet-browser-907e39e5abc301fa54e144c5c151b79c3affb788.tar.bz2
tangerine-wallet-browser-907e39e5abc301fa54e144c5c151b79c3affb788.tar.lz
tangerine-wallet-browser-907e39e5abc301fa54e144c5c151b79c3affb788.tar.xz
tangerine-wallet-browser-907e39e5abc301fa54e144c5c151b79c3affb788.tar.zst
tangerine-wallet-browser-907e39e5abc301fa54e144c5c151b79c3affb788.zip
wiring - move to obj-multiplex
Diffstat (limited to 'app/scripts/popup.js')
-rw-r--r--app/scripts/popup.js18
1 files changed, 5 insertions, 13 deletions
diff --git a/app/scripts/popup.js b/app/scripts/popup.js
index 523ecbd8f..3049ff2c3 100644
--- a/app/scripts/popup.js
+++ b/app/scripts/popup.js
@@ -1,7 +1,7 @@
const url = require('url')
const EventEmitter = require('events').EventEmitter
const async = require('async')
-const Multiplex = require('multiplex')
+const ObjectMultiplex = require('./lib/obj-multiplex')
const Dnode = require('dnode')
const Web3 = require('web3')
const MetaMaskUi = require('../../ui')
@@ -9,8 +9,6 @@ const MetaMaskUiCss = require('../../ui/css')
const injectCss = require('inject-css')
const PortStream = require('./lib/port-stream.js')
const StreamProvider = require('./lib/stream-provider.js')
-const jsonParseStream = require('./lib/stream-utils.js').jsonParseStream
-const jsonStringifyStream = require('./lib/stream-utils.js').jsonStringifyStream
// setup app
var css = MetaMaskUiCss()
@@ -26,7 +24,7 @@ function connectToAccountManager(cb){
var pluginPort = chrome.runtime.connect({name: 'popup'})
var portStream = new PortStream(pluginPort)
// setup multiplexing
- var mx = Multiplex()
+ var mx = ObjectMultiplex()
portStream.pipe(mx).pipe(portStream)
mx.on('error', function(err) {
console.error(err)
@@ -36,19 +34,13 @@ function connectToAccountManager(cb){
console.error(err)
mx.destroy()
})
- var dnodeStream = mx.createSharedStream('dnode')
- var providerStream = mx.createSharedStream('provider')
- linkDnode(dnodeStream, cb)
- linkWeb3(providerStream)
+ linkDnode(mx.createStream('dnode'), cb)
+ linkWeb3(mx.createStream('provider'))
}
function linkWeb3(stream){
var remoteProvider = new StreamProvider()
- remoteProvider
- .pipe(jsonStringifyStream())
- .pipe(stream)
- .pipe(jsonParseStream())
- .pipe(remoteProvider)
+ remoteProvider.pipe(stream).pipe(remoteProvider)
stream.on('error', console.error.bind(console))
remoteProvider.on('error', console.error.bind(console))
global.web3 = new Web3(remoteProvider)