aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2015-12-21 08:22:18 +0800
committerkumavis <aaron@kumavis.me>2015-12-21 08:22:18 +0800
commit09644408c2c083324cbacb04b09d91e20e04335a (patch)
tree327c296831a009a362ff50517acd5beacd7a6dda /app/scripts
parent72a747165dda417aa7968e44b404eb90707202a2 (diff)
downloadtangerine-wallet-browser-09644408c2c083324cbacb04b09d91e20e04335a.tar
tangerine-wallet-browser-09644408c2c083324cbacb04b09d91e20e04335a.tar.gz
tangerine-wallet-browser-09644408c2c083324cbacb04b09d91e20e04335a.tar.bz2
tangerine-wallet-browser-09644408c2c083324cbacb04b09d91e20e04335a.tar.lz
tangerine-wallet-browser-09644408c2c083324cbacb04b09d91e20e04335a.tar.xz
tangerine-wallet-browser-09644408c2c083324cbacb04b09d91e20e04335a.tar.zst
tangerine-wallet-browser-09644408c2c083324cbacb04b09d91e20e04335a.zip
testing continues
Diffstat (limited to 'app/scripts')
-rw-r--r--app/scripts/background.js5
-rw-r--r--app/scripts/contentscript.js1
-rw-r--r--app/scripts/lib/stream-provider.js28
3 files changed, 22 insertions, 12 deletions
diff --git a/app/scripts/background.js b/app/scripts/background.js
index c439558c8..8efe79207 100644
--- a/app/scripts/background.js
+++ b/app/scripts/background.js
@@ -1,4 +1,4 @@
-const ZeroClientProvider = require('web3-provider-skeleton')
+const ZeroClientProvider = require('web3-provider-engine')
// const PortStream = require('./lib/port-stream.js')
const identitiesUrl = 'https://alpha.metamask.io/identities/'
@@ -21,7 +21,8 @@ function connectRemote(remotePort){
function onRpcRequest(remotePort, payload){
zeroClient.sendAsync(payload, function onPayloadHandled(err, response){
if (err) throw err
- // console.log('MetaMaskPlugin - RPC complete:', payload, '->', response)
+ console.log('MetaMaskPlugin - RPC complete:', payload, '->', response)
+ if (response.result === true) debugger
// if (typeof response !== 'object') {
// if (!response) {
// console.warn('-------------------------------')
diff --git a/app/scripts/contentscript.js b/app/scripts/contentscript.js
index cce5c1274..065c9f7d0 100644
--- a/app/scripts/contentscript.js
+++ b/app/scripts/contentscript.js
@@ -1,7 +1,6 @@
const LocalMessageDuplexStream = require('./lib/local-message-stream.js')
const PortStream = require('./lib/port-stream.js')
-console.log('content script!')
// inject in-page script
var scriptTag = document.createElement('script')
diff --git a/app/scripts/lib/stream-provider.js b/app/scripts/lib/stream-provider.js
index 3e7f443c8..b0a922397 100644
--- a/app/scripts/lib/stream-provider.js
+++ b/app/scripts/lib/stream-provider.js
@@ -11,7 +11,7 @@ function StreamProvider(){
objectMode: true,
})
- this._handlers = {}
+ this._payloads = {}
}
// public
@@ -21,19 +21,29 @@ StreamProvider.prototype.send = function(payload){
}
StreamProvider.prototype.sendAsync = function(payload, callback){
-// console.log('StreamProvider - sending payload', payload)
- this._handlers[payload.id] = callback
+ // console.log('StreamProvider - sending payload', payload)
+ this._payloads[payload.id] = [payload, callback]
+ // console.log('payload for plugin:', payload)
this.push(payload)
}
// private
-StreamProvider.prototype._onResponse = function(payload){
-// console.log('StreamProvider - got response', payload)
- var callback = this._handlers[payload.id]
- if (!callback) throw new Error('StreamProvider - Unknown response id')
- delete this._handlers[payload.id]
- callback(null, payload)
+StreamProvider.prototype._onResponse = function(response){
+ // console.log('StreamProvider - got response', payload)
+ var data = this._payloads[response.id]
+ if (!data) throw new Error('StreamProvider - Unknown response id')
+ delete this._payloads[response.id]
+ var payload = data[0]
+ var callback = data[1]
+
+ // logging
+ var res = Array.isArray(response) ? response : [response]
+ ;(Array.isArray(payload) ? payload : [payload]).forEach(function(payload, index){
+ console.log('plugin response:', payload.id, payload.method, payload.params, '->', res[index].result)
+ })
+
+ callback(null, response)
}
// stream plumbing