2018-05-17 05:46:34 +02:00
|
|
|
const mergeMiddleware = require('json-rpc-engine/src/mergeMiddleware')
|
2018-05-17 07:46:11 +02:00
|
|
|
const createScaffoldMiddleware = require('json-rpc-engine/src/createScaffoldMiddleware')
|
2018-05-17 05:46:34 +02:00
|
|
|
const createWalletSubprovider = require('eth-json-rpc-middleware/wallet')
|
2019-10-30 23:15:54 +01:00
|
|
|
const { createPendingNonceMiddleware, createPendingTxMiddleware } = require('./middleware/pending')
|
2018-05-17 05:46:34 +02:00
|
|
|
module.exports = createMetamaskMiddleware
|
|
|
|
|
2018-05-17 06:08:19 +02:00
|
|
|
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,
|
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({
|
|
|
|
// staticSubprovider
|
|
|
|
eth_syncing: false,
|
|
|
|
web3_clientVersion: `MetaMask/v${version}`,
|
|
|
|
}),
|
|
|
|
createWalletSubprovider({
|
|
|
|
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,
|
|
|
|
}),
|
|
|
|
createPendingNonceMiddleware({ getPendingNonce }),
|
2019-10-30 23:15:54 +01:00
|
|
|
createPendingTxMiddleware({ getPendingTransactionByHash }),
|
2018-05-17 06:08:19 +02:00
|
|
|
])
|
2018-05-17 05:46:34 +02:00
|
|
|
return metamaskMiddleware
|
|
|
|
}
|