mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-24 02:58:09 +01:00
6f47fece56
Implement `eth_decrypt` and `eth_getEncryptionPublicKey`. This allows decryption backed by the user's private key. The message decryption uses a confirmation flow similar to the messaging signing flow, where the message to be decrypted is also able to be decrypted inline for the user to read directly before confirming.
44 lines
1.3 KiB
JavaScript
44 lines
1.3 KiB
JavaScript
import mergeMiddleware from 'json-rpc-engine/src/mergeMiddleware'
|
|
import createScaffoldMiddleware from 'json-rpc-engine/src/createScaffoldMiddleware'
|
|
import createWalletSubprovider from 'eth-json-rpc-middleware/wallet'
|
|
import { createPendingNonceMiddleware, createPendingTxMiddleware } from './middleware/pending'
|
|
|
|
export default createMetamaskMiddleware
|
|
|
|
function createMetamaskMiddleware ({
|
|
version,
|
|
getAccounts,
|
|
processTransaction,
|
|
processEthSignMessage,
|
|
processTypedMessage,
|
|
processTypedMessageV3,
|
|
processTypedMessageV4,
|
|
processPersonalMessage,
|
|
processDecryptMessage,
|
|
processEncryptionPublicKey,
|
|
getPendingNonce,
|
|
getPendingTransactionByHash,
|
|
}) {
|
|
const metamaskMiddleware = mergeMiddleware([
|
|
createScaffoldMiddleware({
|
|
// staticSubprovider
|
|
eth_syncing: false,
|
|
web3_clientVersion: `MetaMask/v${version}`,
|
|
}),
|
|
createWalletSubprovider({
|
|
getAccounts,
|
|
processTransaction,
|
|
processEthSignMessage,
|
|
processTypedMessage,
|
|
processTypedMessageV3,
|
|
processTypedMessageV4,
|
|
processPersonalMessage,
|
|
processDecryptMessage,
|
|
processEncryptionPublicKey,
|
|
}),
|
|
createPendingNonceMiddleware({ getPendingNonce }),
|
|
createPendingTxMiddleware({ getPendingTransactionByHash }),
|
|
])
|
|
return metamaskMiddleware
|
|
}
|