aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2019-04-04 22:11:28 +0800
committerkumavis <aaron@kumavis.me>2019-04-04 22:11:28 +0800
commit89693a23151d4ff37295f14b04d7c64297d842c5 (patch)
tree12ac41f2d299e8d5b51160d8b07386385e7ad370
parentcf4eac3f2c693269e8a5025d4f5f2240d7be13e7 (diff)
downloadtangerine-wallet-browser-89693a23151d4ff37295f14b04d7c64297d842c5.tar
tangerine-wallet-browser-89693a23151d4ff37295f14b04d7c64297d842c5.tar.gz
tangerine-wallet-browser-89693a23151d4ff37295f14b04d7c64297d842c5.tar.bz2
tangerine-wallet-browser-89693a23151d4ff37295f14b04d7c64297d842c5.tar.lz
tangerine-wallet-browser-89693a23151d4ff37295f14b04d7c64297d842c5.tar.xz
tangerine-wallet-browser-89693a23151d4ff37295f14b04d7c64297d842c5.tar.zst
tangerine-wallet-browser-89693a23151d4ff37295f14b04d7c64297d842c5.zip
metamask-controller - use improved provider-as-middleware utility
-rw-r--r--app/scripts/lib/createProviderMiddleware.js16
-rw-r--r--app/scripts/metamask-controller.js4
2 files changed, 2 insertions, 18 deletions
diff --git a/app/scripts/lib/createProviderMiddleware.js b/app/scripts/lib/createProviderMiddleware.js
deleted file mode 100644
index 8a939ba4e..000000000
--- a/app/scripts/lib/createProviderMiddleware.js
+++ /dev/null
@@ -1,16 +0,0 @@
-module.exports = createProviderMiddleware
-
-/**
- * Forwards an HTTP request to the current Web3 provider
- *
- * @param {{ provider: Object }} config Configuration containing current Web3 provider
- */
-function createProviderMiddleware ({ provider }) {
- return (req, res, next, end) => {
- provider.sendAsync(req, (err, _res) => {
- if (err) return end(err)
- res.result = _res.result
- end()
- })
- }
-}
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index 4108ed4c0..d2a55acaa 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -18,7 +18,7 @@ const createFilterMiddleware = require('eth-json-rpc-filters')
const createSubscriptionManager = require('eth-json-rpc-filters/subscriptionManager')
const createOriginMiddleware = require('./lib/createOriginMiddleware')
const createLoggerMiddleware = require('./lib/createLoggerMiddleware')
-const createProviderMiddleware = require('./lib/createProviderMiddleware')
+const providerAsMiddleware = require('eth-json-rpc-middleware/providerAsMiddleware')
const {setupMultiplex} = require('./lib/stream-utils.js')
const KeyringController = require('eth-keyring-controller')
const NetworkController = require('./controllers/network')
@@ -1373,7 +1373,7 @@ module.exports = class MetamaskController extends EventEmitter {
// watch asset
engine.push(this.preferencesController.requestWatchAsset.bind(this.preferencesController))
// forward to metamask primary provider
- engine.push(createProviderMiddleware({ provider }))
+ engine.push(providerAsMiddleware(provider))
// setup connection
const providerStream = createEngineStream({ engine })