1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-29 23:58:06 +01:00
metamask-extension/app/scripts/lib/createMetamaskMiddleware.js
Mark Stacey e223348fb3
Update eth-json-rpc-middleware from v9 to v10 (#17591)
This release only includes one breaking change, which is the renaming
of the package to be under the `@metamask` scope. It includes
improvements to the types that will unblock migrating our network
clients to TypeScript.
2023-02-27 13:19:08 -03:30

43 lines
1.2 KiB
JavaScript

import { createScaffoldMiddleware, mergeMiddleware } from 'json-rpc-engine';
import { createWalletMiddleware } from '@metamask/eth-json-rpc-middleware';
import {
createPendingNonceMiddleware,
createPendingTxMiddleware,
} from './middleware/pending';
export default function createMetamaskMiddleware({
version,
getAccounts,
processTransaction,
processEthSignMessage,
processTypedMessage,
processTypedMessageV3,
processTypedMessageV4,
processPersonalMessage,
processDecryptMessage,
processEncryptionPublicKey,
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;
}