1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

testing continues

This commit is contained in:
kumavis 2015-12-20 16:22:18 -08:00
parent 72a747165d
commit 09644408c2
4 changed files with 23 additions and 13 deletions

View File

@ -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('-------------------------------')

View File

@ -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')

View File

@ -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

View File

@ -10,7 +10,7 @@
"object.entries": "^1.0.2",
"readable-stream": "^2.0.5",
"web3": "^0.15.1",
"web3-provider-engine": "^1.0.0"
"web3-provider-engine": "^1.1.0"
},
"devDependencies": {
"grunt": "~0.4.1",