mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Merge branch 'master' of github.com:MetaMask/metamask-plugin into AutoLint
This commit is contained in:
commit
3c01969fe3
@ -148,7 +148,10 @@ function setupPublicConfig (stream) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setupProviderConnection (stream, originDomain) {
|
function setupProviderConnection (stream, originDomain) {
|
||||||
stream.on('data', function onRpcRequest (payload) {
|
// decorate all payloads with origin domain
|
||||||
|
stream.on('data', function onRpcRequest (request) {
|
||||||
|
var payloads = Array.isArray(request) ? request : [request]
|
||||||
|
payloads.forEach(function (payload) {
|
||||||
// Append origin to rpc payload
|
// Append origin to rpc payload
|
||||||
payload.origin = originDomain
|
payload.origin = originDomain
|
||||||
// Append origin to signature request
|
// Append origin to signature request
|
||||||
@ -157,12 +160,13 @@ function setupProviderConnection (stream, originDomain) {
|
|||||||
} else if (payload.method === 'eth_sign') {
|
} else if (payload.method === 'eth_sign') {
|
||||||
payload.params.push({ origin: originDomain })
|
payload.params.push({ origin: originDomain })
|
||||||
}
|
}
|
||||||
|
})
|
||||||
// handle rpc request
|
// handle rpc request
|
||||||
provider.sendAsync(payload, function onPayloadHandled (err, response) {
|
provider.sendAsync(request, function onPayloadHandled (err, response) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return logger(err)
|
return logger(err)
|
||||||
}
|
}
|
||||||
logger(null, payload, response)
|
logger(null, request, response)
|
||||||
try {
|
try {
|
||||||
stream.write(response)
|
stream.write(response)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
Loading…
Reference in New Issue
Block a user