1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-24 02:58:09 +01:00
metamask-extension/app/scripts/controllers/network/createMetamaskMiddleware.js

40 lines
1.2 KiB
JavaScript
Raw Normal View History

import mergeMiddleware from 'json-rpc-engine/src/mergeMiddleware'
import createScaffoldMiddleware from 'json-rpc-engine/src/createScaffoldMiddleware'
import createWalletSubprovider from 'eth-json-rpc-middleware/wallet'
import { createPendingNonceMiddleware, createPendingTxMiddleware } from './middleware/pending'
export default 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
}