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

Merge pull request #6401 from MetaMask/provider-error-fix

metamask-controller - use improved provider-as-middleware utility
This commit is contained in:
kumavis 2019-04-05 11:13:51 +08:00 committed by GitHub
commit d610dfa870
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 18 deletions

View File

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

View File

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