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:
parent
72a747165d
commit
09644408c2
@ -1,4 +1,4 @@
|
|||||||
const ZeroClientProvider = require('web3-provider-skeleton')
|
const ZeroClientProvider = require('web3-provider-engine')
|
||||||
// const PortStream = require('./lib/port-stream.js')
|
// const PortStream = require('./lib/port-stream.js')
|
||||||
const identitiesUrl = 'https://alpha.metamask.io/identities/'
|
const identitiesUrl = 'https://alpha.metamask.io/identities/'
|
||||||
|
|
||||||
@ -21,7 +21,8 @@ function connectRemote(remotePort){
|
|||||||
function onRpcRequest(remotePort, payload){
|
function onRpcRequest(remotePort, payload){
|
||||||
zeroClient.sendAsync(payload, function onPayloadHandled(err, response){
|
zeroClient.sendAsync(payload, function onPayloadHandled(err, response){
|
||||||
if (err) throw err
|
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 (typeof response !== 'object') {
|
||||||
// if (!response) {
|
// if (!response) {
|
||||||
// console.warn('-------------------------------')
|
// console.warn('-------------------------------')
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
const LocalMessageDuplexStream = require('./lib/local-message-stream.js')
|
const LocalMessageDuplexStream = require('./lib/local-message-stream.js')
|
||||||
const PortStream = require('./lib/port-stream.js')
|
const PortStream = require('./lib/port-stream.js')
|
||||||
|
|
||||||
console.log('content script!')
|
|
||||||
|
|
||||||
// inject in-page script
|
// inject in-page script
|
||||||
var scriptTag = document.createElement('script')
|
var scriptTag = document.createElement('script')
|
||||||
|
@ -11,7 +11,7 @@ function StreamProvider(){
|
|||||||
objectMode: true,
|
objectMode: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
this._handlers = {}
|
this._payloads = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
// public
|
// public
|
||||||
@ -21,19 +21,29 @@ StreamProvider.prototype.send = function(payload){
|
|||||||
}
|
}
|
||||||
|
|
||||||
StreamProvider.prototype.sendAsync = function(payload, callback){
|
StreamProvider.prototype.sendAsync = function(payload, callback){
|
||||||
// console.log('StreamProvider - sending payload', payload)
|
// console.log('StreamProvider - sending payload', payload)
|
||||||
this._handlers[payload.id] = callback
|
this._payloads[payload.id] = [payload, callback]
|
||||||
|
// console.log('payload for plugin:', payload)
|
||||||
this.push(payload)
|
this.push(payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
// private
|
// private
|
||||||
|
|
||||||
StreamProvider.prototype._onResponse = function(payload){
|
StreamProvider.prototype._onResponse = function(response){
|
||||||
// console.log('StreamProvider - got response', payload)
|
// console.log('StreamProvider - got response', payload)
|
||||||
var callback = this._handlers[payload.id]
|
var data = this._payloads[response.id]
|
||||||
if (!callback) throw new Error('StreamProvider - Unknown response id')
|
if (!data) throw new Error('StreamProvider - Unknown response id')
|
||||||
delete this._handlers[payload.id]
|
delete this._payloads[response.id]
|
||||||
callback(null, payload)
|
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
|
// stream plumbing
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
"object.entries": "^1.0.2",
|
"object.entries": "^1.0.2",
|
||||||
"readable-stream": "^2.0.5",
|
"readable-stream": "^2.0.5",
|
||||||
"web3": "^0.15.1",
|
"web3": "^0.15.1",
|
||||||
"web3-provider-engine": "^1.0.0"
|
"web3-provider-engine": "^1.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"grunt": "~0.4.1",
|
"grunt": "~0.4.1",
|
||||||
|
Loading…
Reference in New Issue
Block a user