1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-14 21:57:12 +01:00
metamask-extension/app/scripts/controllers/network/createMetamaskMiddleware.js

44 lines
1.2 KiB
JavaScript
Raw Normal View History

import { createScaffoldMiddleware, mergeMiddleware } from 'json-rpc-engine';
import createWalletSubprovider from 'eth-json-rpc-middleware/wallet';
2020-11-03 00:41:28 +01:00
import {
createPendingNonceMiddleware,
createPendingTxMiddleware,
} from './middleware/pending';
2020-11-03 00:41:28 +01:00
export default function createMetamaskMiddleware({
version,
getAccounts,
processTransaction,
processEthSignMessage,
processTypedMessage,
processTypedMessageV3,
processTypedMessageV4,
processPersonalMessage,
processDecryptMessage,
processEncryptionPublicKey,
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,
processDecryptMessage,
processEncryptionPublicKey,
}),
createPendingNonceMiddleware({ getPendingNonce }),
createPendingTxMiddleware({ getPendingTransactionByHash }),
]);
return metamaskMiddleware;
}