mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
inpage - use obj-multiplex module
This commit is contained in:
parent
671dafea9e
commit
ef3bf810bf
@ -3,7 +3,7 @@ const RpcEngine = require('json-rpc-engine')
|
|||||||
const createIdRemapMiddleware = require('json-rpc-engine/src/idRemapMiddleware')
|
const createIdRemapMiddleware = require('json-rpc-engine/src/idRemapMiddleware')
|
||||||
const createStreamMiddleware = require('json-rpc-middleware-stream')
|
const createStreamMiddleware = require('json-rpc-middleware-stream')
|
||||||
const LocalStorageStore = require('obs-store')
|
const LocalStorageStore = require('obs-store')
|
||||||
const ObjectMultiplex = require('./obj-multiplex')
|
const ObjectMultiplex = require('obj-multiplex')
|
||||||
|
|
||||||
module.exports = MetamaskInpageProvider
|
module.exports = MetamaskInpageProvider
|
||||||
|
|
||||||
@ -11,10 +11,10 @@ function MetamaskInpageProvider (connectionStream) {
|
|||||||
const self = this
|
const self = this
|
||||||
|
|
||||||
// setup connectionStream multiplexing
|
// setup connectionStream multiplexing
|
||||||
var multiStream = self.multiStream = ObjectMultiplex()
|
const mux = self.mux = new ObjectMultiplex()
|
||||||
pump(
|
pump(
|
||||||
connectionStream,
|
connectionStream,
|
||||||
multiStream,
|
mux,
|
||||||
connectionStream,
|
connectionStream,
|
||||||
(err) => logStreamDisconnectWarning('MetaMask', err)
|
(err) => logStreamDisconnectWarning('MetaMask', err)
|
||||||
)
|
)
|
||||||
@ -22,19 +22,19 @@ function MetamaskInpageProvider (connectionStream) {
|
|||||||
// subscribe to metamask public config (one-way)
|
// subscribe to metamask public config (one-way)
|
||||||
self.publicConfigStore = new LocalStorageStore({ storageKey: 'MetaMask-Config' })
|
self.publicConfigStore = new LocalStorageStore({ storageKey: 'MetaMask-Config' })
|
||||||
pump(
|
pump(
|
||||||
multiStream.createStream('publicConfig'),
|
mux.createStream('publicConfig'),
|
||||||
self.publicConfigStore,
|
self.publicConfigStore,
|
||||||
(err) => logStreamDisconnectWarning('MetaMask PublicConfigStore', err)
|
(err) => logStreamDisconnectWarning('MetaMask PublicConfigStore', err)
|
||||||
)
|
)
|
||||||
|
|
||||||
// ignore phishing warning message (handled elsewhere)
|
// ignore phishing warning message (handled elsewhere)
|
||||||
multiStream.ignoreStream('phishing')
|
mux.ignoreStream('phishing')
|
||||||
|
|
||||||
// connect to async provider
|
// connect to async provider
|
||||||
const streamMiddleware = createStreamMiddleware()
|
const streamMiddleware = createStreamMiddleware()
|
||||||
pump(
|
pump(
|
||||||
streamMiddleware.stream,
|
streamMiddleware.stream,
|
||||||
multiStream.createStream('provider'),
|
mux.createStream('provider'),
|
||||||
streamMiddleware.stream,
|
streamMiddleware.stream,
|
||||||
(err) => logStreamDisconnectWarning('MetaMask RpcProvider', err)
|
(err) => logStreamDisconnectWarning('MetaMask RpcProvider', err)
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user