aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/background.js
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2016-06-22 04:14:21 +0800
committerkumavis <aaron@kumavis.me>2016-06-22 04:14:21 +0800
commit45d16d975b3e7b981821aabfe356efd2c7a06e6e (patch)
tree7f623db76b611e169b533c64c7da5dd0488f062c /app/scripts/background.js
parent6fdece459d1d2674acc5349b70e68c1d5033dd38 (diff)
downloadtangerine-wallet-browser-45d16d975b3e7b981821aabfe356efd2c7a06e6e.tar
tangerine-wallet-browser-45d16d975b3e7b981821aabfe356efd2c7a06e6e.tar.gz
tangerine-wallet-browser-45d16d975b3e7b981821aabfe356efd2c7a06e6e.tar.bz2
tangerine-wallet-browser-45d16d975b3e7b981821aabfe356efd2c7a06e6e.tar.lz
tangerine-wallet-browser-45d16d975b3e7b981821aabfe356efd2c7a06e6e.tar.xz
tangerine-wallet-browser-45d16d975b3e7b981821aabfe356efd2c7a06e6e.tar.zst
tangerine-wallet-browser-45d16d975b3e7b981821aabfe356efd2c7a06e6e.zip
background - batch rpc fix for origin domain
Diffstat (limited to 'app/scripts/background.js')
-rw-r--r--app/scripts/background.js27
1 files changed, 15 insertions, 12 deletions
diff --git a/app/scripts/background.js b/app/scripts/background.js
index 3ad95d3e9..66108c251 100644
--- a/app/scripts/background.js
+++ b/app/scripts/background.js
@@ -152,19 +152,22 @@ 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){
- logger(null, payload, response)
+ provider.sendAsync(request, function onPayloadHandled(err, response){
+ logger(null, request, response)
try {
stream.write(response)
} catch (err) {