You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.2 KiB
38 lines
1.2 KiB
const mergeMiddleware = require('json-rpc-engine/src/mergeMiddleware')
|
|
const createScaffoldMiddleware = require('json-rpc-engine/src/createScaffoldMiddleware')
|
|
const createWalletSubprovider = require('eth-json-rpc-middleware/wallet')
|
|
const { createPendingNonceMiddleware, createPendingTxMiddleware } = require('./middleware/pending')
|
|
module.exports = createMetamaskMiddleware
|
|
|
|
function createMetamaskMiddleware ({
|
|
version,
|
|
getAccounts,
|
|
processTransaction,
|
|
processEthSignMessage,
|
|
processTypedMessage,
|
|
processTypedMessageV3,
|
|
processTypedMessageV4,
|
|
processPersonalMessage,
|
|
getPendingNonce,
|
|
getPendingTransactionByHash,
|
|
}) {
|
|
const metamaskMiddleware = mergeMiddleware([
|
|
createScaffoldMiddleware({
|
|
// staticSubprovider
|
|
eth_syncing: false,
|
|
web3_clientVersion: `MetaMask/v${version}`,
|
|
}),
|
|
createWalletSubprovider({
|
|
getAccounts,
|
|
processTransaction,
|
|
processEthSignMessage,
|
|
processTypedMessage,
|
|
processTypedMessageV3,
|
|
processTypedMessageV4,
|
|
processPersonalMessage,
|
|
}),
|
|
createPendingNonceMiddleware({ getPendingNonce }),
|
|
createPendingTxMiddleware({ getPendingTransactionByHash }),
|
|
])
|
|
return metamaskMiddleware
|
|
}
|
|
|