1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-23 03:36:18 +02:00
metamask-extension/app/scripts/controllers/network/createMetamaskMiddleware.js
Frankie 514be408f8
I#6704 eth_getTransactionByHash will now check metamask's local history for pending transactions (#7327)
* tests - create tests for pending middlewares

* transactions - add r,s,v values to the txMeta to match the JSON rpc response

* network - add new middleware for eth_getTransactionByHash that the checks pending tx's for a response value

* transactions/pending - use getTransactionReceipt for checking if tx is in a block

* meta - file rename
2019-10-30 12:15:54 -10:00

39 lines
1.2 KiB
JavaScript

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
}