2021-02-04 19:15:23 +01:00
|
|
|
import { createScaffoldMiddleware, mergeMiddleware } from 'json-rpc-engine';
|
2021-11-11 21:26:49 +01:00
|
|
|
import { createWalletMiddleware } from 'eth-json-rpc-middleware';
|
2020-11-03 00:41:28 +01:00
|
|
|
import {
|
|
|
|
createPendingNonceMiddleware,
|
|
|
|
createPendingTxMiddleware,
|
2021-02-04 19:15:23 +01:00
|
|
|
} from './middleware/pending';
|
2020-01-09 04:34:58 +01:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export default function createMetamaskMiddleware({
|
2018-05-17 05:46:34 +02:00
|
|
|
version,
|
|
|
|
getAccounts,
|
|
|
|
processTransaction,
|
|
|
|
processEthSignMessage,
|
|
|
|
processTypedMessage,
|
2018-10-25 05:03:55 +02:00
|
|
|
processTypedMessageV3,
|
2019-08-20 21:52:59 +02:00
|
|
|
processTypedMessageV4,
|
2018-05-17 05:46:34 +02:00
|
|
|
processPersonalMessage,
|
2020-02-19 19:24:16 +01:00
|
|
|
processDecryptMessage,
|
|
|
|
processEncryptionPublicKey,
|
2018-05-17 06:08:19 +02:00
|
|
|
getPendingNonce,
|
2019-10-30 23:15:54 +01:00
|
|
|
getPendingTransactionByHash,
|
2018-05-17 05:46:34 +02:00
|
|
|
}) {
|
|
|
|
const metamaskMiddleware = mergeMiddleware([
|
|
|
|
createScaffoldMiddleware({
|
|
|
|
eth_syncing: false,
|
|
|
|
web3_clientVersion: `MetaMask/v${version}`,
|
|
|
|
}),
|
2021-11-11 21:26:49 +01:00
|
|
|
createWalletMiddleware({
|
2018-05-17 05:46:34 +02:00
|
|
|
getAccounts,
|
|
|
|
processTransaction,
|
|
|
|
processEthSignMessage,
|
|
|
|
processTypedMessage,
|
2018-10-25 05:03:55 +02:00
|
|
|
processTypedMessageV3,
|
2019-08-20 21:52:59 +02:00
|
|
|
processTypedMessageV4,
|
2018-05-17 05:46:34 +02:00
|
|
|
processPersonalMessage,
|
2020-02-19 19:24:16 +01:00
|
|
|
processDecryptMessage,
|
|
|
|
processEncryptionPublicKey,
|
2018-05-17 05:46:34 +02:00
|
|
|
}),
|
|
|
|
createPendingNonceMiddleware({ getPendingNonce }),
|
2019-10-30 23:15:54 +01:00
|
|
|
createPendingTxMiddleware({ getPendingTransactionByHash }),
|
2021-02-04 19:15:23 +01:00
|
|
|
]);
|
|
|
|
return metamaskMiddleware;
|
2018-05-17 05:46:34 +02:00
|
|
|
}
|