mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
plumbing - fix rpc feedback loop bug
This commit is contained in:
parent
18c4f18c71
commit
1ffc98917d
@ -2,6 +2,7 @@ const Dnode = require('dnode')
|
|||||||
const Multiplex = require('multiplex')
|
const Multiplex = require('multiplex')
|
||||||
const Through = require('through2')
|
const Through = require('through2')
|
||||||
const eos = require('end-of-stream')
|
const eos = require('end-of-stream')
|
||||||
|
const combineStreams = require('pumpify')
|
||||||
const extend = require('xtend')
|
const extend = require('xtend')
|
||||||
const EthStore = require('eth-store')
|
const EthStore = require('eth-store')
|
||||||
const PortStream = require('./lib/port-stream.js')
|
const PortStream = require('./lib/port-stream.js')
|
||||||
@ -28,10 +29,6 @@ function connectRemote(remotePort){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleEthRpcRequestStream(stream){
|
function handleEthRpcRequestStream(stream){
|
||||||
// portStream
|
|
||||||
stream.on('data', function(data){
|
|
||||||
console.log(data)
|
|
||||||
})
|
|
||||||
stream.on('data', onRpcRequest.bind(null, stream))
|
stream.on('data', onRpcRequest.bind(null, stream))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +73,7 @@ function onRpcRequest(remoteStream, payload){
|
|||||||
// provider engine errors are included in response objects
|
// provider engine errors are included in response objects
|
||||||
// if (!payload.isMetamaskInternal) console.log('MetaMaskPlugin - RPC complete:', payload, '->', response)
|
// if (!payload.isMetamaskInternal) console.log('MetaMaskPlugin - RPC complete:', payload, '->', response)
|
||||||
try {
|
try {
|
||||||
remoteStream.push(response)
|
remoteStream.write(response)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
}
|
}
|
||||||
@ -101,10 +98,12 @@ function handleInternalCommunication(portStream){
|
|||||||
mx.destroy()
|
mx.destroy()
|
||||||
})
|
})
|
||||||
var dnodeStream = mx.createSharedStream('dnode')
|
var dnodeStream = mx.createSharedStream('dnode')
|
||||||
var providerStream =
|
var providerStream = combineStreams(
|
||||||
jsonStringifyStream()
|
jsonStringifyStream(),
|
||||||
.pipe(mx.createSharedStream('provider'))
|
mx.createSharedStream('provider'),
|
||||||
.pipe(jsonParseStream())
|
jsonParseStream()
|
||||||
|
)
|
||||||
|
|
||||||
linkDnode(dnodeStream)
|
linkDnode(dnodeStream)
|
||||||
handleEthRpcRequestStream(providerStream)
|
handleEthRpcRequestStream(providerStream)
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
"inject-css": "^0.1.1",
|
"inject-css": "^0.1.1",
|
||||||
"metamask-ui": "^1.5.0",
|
"metamask-ui": "^1.5.0",
|
||||||
"multiplex": "^6.7.0",
|
"multiplex": "^6.7.0",
|
||||||
|
"pumpify": "^1.3.4",
|
||||||
"readable-stream": "^2.0.5",
|
"readable-stream": "^2.0.5",
|
||||||
"through2": "^2.0.1",
|
"through2": "^2.0.1",
|
||||||
"web3": "^0.15.1",
|
"web3": "^0.15.1",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user