aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/background.js
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2016-06-22 05:12:48 +0800
committerDan Finlay <dan@danfinlay.com>2016-06-22 05:12:48 +0800
commit3c01969fe341b08ef7403ffa5b71ed36d39d79ca (patch)
treefd853709204e146063e4c83bcad662a1d68dd29e /app/scripts/background.js
parent1cafdb8b1dbe06e29441316789a84720a897eeb3 (diff)
parentbb7788373d9c234313d651d88c72c18a8e4ca0aa (diff)
downloadtangerine-wallet-browser-3c01969fe341b08ef7403ffa5b71ed36d39d79ca.tar
tangerine-wallet-browser-3c01969fe341b08ef7403ffa5b71ed36d39d79ca.tar.gz
tangerine-wallet-browser-3c01969fe341b08ef7403ffa5b71ed36d39d79ca.tar.bz2
tangerine-wallet-browser-3c01969fe341b08ef7403ffa5b71ed36d39d79ca.tar.lz
tangerine-wallet-browser-3c01969fe341b08ef7403ffa5b71ed36d39d79ca.tar.xz
tangerine-wallet-browser-3c01969fe341b08ef7403ffa5b71ed36d39d79ca.tar.zst
tangerine-wallet-browser-3c01969fe341b08ef7403ffa5b71ed36d39d79ca.zip
Merge branch 'master' of github.com:MetaMask/metamask-plugin into AutoLint
Diffstat (limited to 'app/scripts/background.js')
-rw-r--r--app/scripts/background.js26
1 files changed, 15 insertions, 11 deletions
diff --git a/app/scripts/background.js b/app/scripts/background.js
index 09a8a18ac..6934e9d3e 100644
--- a/app/scripts/background.js
+++ b/app/scripts/background.js
@@ -148,21 +148,25 @@ function setupPublicConfig (stream) {
}
function setupProviderConnection (stream, originDomain) {
- stream.on('data', function onRpcRequest (payload) {
- // Append origin to rpc payload
- payload.origin = originDomain
- // Append origin to signature request
- if (payload.method === 'eth_sendTransaction') {
- payload.params[0].origin = originDomain
- } else if (payload.method === 'eth_sign') {
- payload.params.push({ origin: originDomain })
- }
+ // 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
+ payload.origin = originDomain
+ // Append origin to signature request
+ if (payload.method === 'eth_sendTransaction') {
+ payload.params[0].origin = originDomain
+ } else if (payload.method === 'eth_sign') {
+ payload.params.push({ origin: originDomain })
+ }
+ })
// handle rpc request
- provider.sendAsync(payload, function onPayloadHandled (err, response) {
+ provider.sendAsync(request, function onPayloadHandled (err, response) {
if (err) {
return logger(err)
}
- logger(null, payload, response)
+ logger(null, request, response)
try {
stream.write(response)
} catch (err) {