1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-26 20:39:08 +01:00
metamask-extension/app/scripts/lib/createMetamaskMiddleware.js

43 lines
1.2 KiB
JavaScript
Raw Normal View History

import { createScaffoldMiddleware, mergeMiddleware } from 'json-rpc-engine';
import { createWalletMiddleware } from '@metamask/eth-json-rpc-middleware';
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({
eth_syncing: false,
web3_clientVersion: `MetaMask/v${version}`,
}),
createWalletMiddleware({
getAccounts,
processTransaction,
processEthSignMessage,
processTypedMessage,
processTypedMessageV3,
processTypedMessageV4,
processPersonalMessage,
processDecryptMessage,
processEncryptionPublicKey,
}),
createPendingNonceMiddleware({ getPendingNonce }),
createPendingTxMiddleware({ getPendingTransactionByHash }),
]);
return metamaskMiddleware;
}