aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2016-05-23 09:02:27 +0800
committerkumavis <aaron@kumavis.me>2016-05-23 09:02:27 +0800
commit2a62d63b4f70bea12126e4b15d78ebbf9dbddefb (patch)
tree6292c1261538162f5bd0001e0258324186a4d623 /app/scripts/lib
parent41df7bb8f622e1fdd9e1bb2b1687347e5f359c47 (diff)
downloadtangerine-wallet-browser-2a62d63b4f70bea12126e4b15d78ebbf9dbddefb.tar
tangerine-wallet-browser-2a62d63b4f70bea12126e4b15d78ebbf9dbddefb.tar.gz
tangerine-wallet-browser-2a62d63b4f70bea12126e4b15d78ebbf9dbddefb.tar.bz2
tangerine-wallet-browser-2a62d63b4f70bea12126e4b15d78ebbf9dbddefb.tar.lz
tangerine-wallet-browser-2a62d63b4f70bea12126e4b15d78ebbf9dbddefb.tar.xz
tangerine-wallet-browser-2a62d63b4f70bea12126e4b15d78ebbf9dbddefb.tar.zst
tangerine-wallet-browser-2a62d63b4f70bea12126e4b15d78ebbf9dbddefb.zip
deps - use web3-stream-provider module
Diffstat (limited to 'app/scripts/lib')
-rw-r--r--app/scripts/lib/inpage-provider.js2
-rw-r--r--app/scripts/lib/stream-provider.js72
2 files changed, 1 insertions, 73 deletions
diff --git a/app/scripts/lib/inpage-provider.js b/app/scripts/lib/inpage-provider.js
index 66681c3a9..70b0d80dd 100644
--- a/app/scripts/lib/inpage-provider.js
+++ b/app/scripts/lib/inpage-provider.js
@@ -1,7 +1,7 @@
const HttpProvider = require('web3/lib/web3/httpprovider')
const Streams = require('mississippi')
const ObjectMultiplex = require('./obj-multiplex')
-const StreamProvider = require('./stream-provider.js')
+const StreamProvider = require('web3-stream-provider')
const RemoteStore = require('./remote-store.js').RemoteStore
const MetamaskConfig = require('../config.js')
diff --git a/app/scripts/lib/stream-provider.js b/app/scripts/lib/stream-provider.js
deleted file mode 100644
index 505e45d1f..000000000
--- a/app/scripts/lib/stream-provider.js
+++ /dev/null
@@ -1,72 +0,0 @@
-const Duplex = require('readable-stream').Duplex
-const inherits = require('util').inherits
-
-module.exports = StreamProvider
-
-
-inherits(StreamProvider, Duplex)
-
-function StreamProvider(){
- Duplex.call(this, {
- objectMode: true,
- })
-
- this._payloads = {}
-}
-
-// public
-
-StreamProvider.prototype.send = function(payload){
- throw new Error('StreamProvider - does not support synchronous RPC calls. called: "'+payload.method+'"')
-}
-
-StreamProvider.prototype.sendAsync = function(payload, callback){
- // console.log('StreamProvider - sending payload', payload)
- var id = payload.id
- if (Array.isArray(payload)) {
- id = 'batch'+payload[0].id
- }
- this._payloads[id] = [payload, callback]
- // console.log('payload for plugin:', payload)
- this.push(payload)
-}
-
-StreamProvider.prototype.isConnected = function(){
- return true
-}
-
-// private
-
-StreamProvider.prototype._onResponse = function(response){
- // console.log('StreamProvider - got response', payload)
- var id = response.id
- if (Array.isArray(response)) {
- id = 'batch'+response[0].id
- }
- var data = this._payloads[id]
- if (!data) throw new Error('StreamProvider - Unknown response id')
- delete this._payloads[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
-
-StreamProvider.prototype._read = noop
-
-StreamProvider.prototype._write = function(msg, encoding, cb){
- this._onResponse(msg)
- cb()
-}
-
-// util
-
-function noop(){} \ No newline at end of file