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:
commit
d610dfa870
@ -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()
|
||||
})
|
||||
}
|
||||
}
|
@ -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 })
|
||||
|
Loading…
Reference in New Issue
Block a user