1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-03 06:34:27 +01:00
metamask-extension/app/scripts/controllers/network/createMetamaskMiddleware.js

39 lines
1.2 KiB
JavaScript
Raw Normal View History

const mergeMiddleware = require('json-rpc-engine/src/mergeMiddleware')
const createScaffoldMiddleware = require('json-rpc-engine/src/createScaffoldMiddleware')
const createWalletSubprovider = require('eth-json-rpc-middleware/wallet')
const { createPendingNonceMiddleware, createPendingTxMiddleware } = require('./middleware/pending')
module.exports = createMetamaskMiddleware
2018-05-17 06:08:19 +02:00
function createMetamaskMiddleware ({
version,
getAccounts,
processTransaction,
processEthSignMessage,
processTypedMessage,
processTypedMessageV3,
processTypedMessageV4,
processPersonalMessage,
2018-05-17 06:08:19 +02:00
getPendingNonce,
getPendingTransactionByHash,
}) {
const metamaskMiddleware = mergeMiddleware([
createScaffoldMiddleware({
// staticSubprovider
eth_syncing: false,
web3_clientVersion: `MetaMask/v${version}`,
}),
createWalletSubprovider({
getAccounts,
processTransaction,
processEthSignMessage,
processTypedMessage,
processTypedMessageV3,
processTypedMessageV4,
processPersonalMessage,
}),
createPendingNonceMiddleware({ getPendingNonce }),
createPendingTxMiddleware({ getPendingTransactionByHash }),
2018-05-17 06:08:19 +02:00
])
return metamaskMiddleware
}