|
|
@ -10,6 +10,8 @@ import { |
|
|
|
addEth, |
|
|
|
addEth, |
|
|
|
} from '../helpers/utils/confirm-tx.util'; |
|
|
|
} from '../helpers/utils/confirm-tx.util'; |
|
|
|
import { sumHexes } from '../helpers/utils/transactions.util'; |
|
|
|
import { sumHexes } from '../helpers/utils/transactions.util'; |
|
|
|
|
|
|
|
import { transactionMatchesNetwork } from '../../../shared/modules/transaction.utils'; |
|
|
|
|
|
|
|
import { getCurrentChainId, getCurrentNetworkId } from './selectors'; |
|
|
|
import { getNativeCurrency } from '.'; |
|
|
|
import { getNativeCurrency } from '.'; |
|
|
|
|
|
|
|
|
|
|
|
const unapprovedTxsSelector = (state) => state.metamask.unapprovedTxs; |
|
|
|
const unapprovedTxsSelector = (state) => state.metamask.unapprovedTxs; |
|
|
@ -22,7 +24,6 @@ const unapprovedEncryptionPublicKeyMsgsSelector = (state) => |
|
|
|
state.metamask.unapprovedEncryptionPublicKeyMsgs; |
|
|
|
state.metamask.unapprovedEncryptionPublicKeyMsgs; |
|
|
|
const unapprovedTypedMessagesSelector = (state) => |
|
|
|
const unapprovedTypedMessagesSelector = (state) => |
|
|
|
state.metamask.unapprovedTypedMessages; |
|
|
|
state.metamask.unapprovedTypedMessages; |
|
|
|
const networkSelector = (state) => state.metamask.network; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const unconfirmedTransactionsListSelector = createSelector( |
|
|
|
export const unconfirmedTransactionsListSelector = createSelector( |
|
|
|
unapprovedTxsSelector, |
|
|
|
unapprovedTxsSelector, |
|
|
@ -31,7 +32,8 @@ export const unconfirmedTransactionsListSelector = createSelector( |
|
|
|
unapprovedDecryptMsgsSelector, |
|
|
|
unapprovedDecryptMsgsSelector, |
|
|
|
unapprovedEncryptionPublicKeyMsgsSelector, |
|
|
|
unapprovedEncryptionPublicKeyMsgsSelector, |
|
|
|
unapprovedTypedMessagesSelector, |
|
|
|
unapprovedTypedMessagesSelector, |
|
|
|
networkSelector, |
|
|
|
getCurrentNetworkId, |
|
|
|
|
|
|
|
getCurrentChainId, |
|
|
|
( |
|
|
|
( |
|
|
|
unapprovedTxs = {}, |
|
|
|
unapprovedTxs = {}, |
|
|
|
unapprovedMsgs = {}, |
|
|
|
unapprovedMsgs = {}, |
|
|
@ -40,6 +42,7 @@ export const unconfirmedTransactionsListSelector = createSelector( |
|
|
|
unapprovedEncryptionPublicKeyMsgs = {}, |
|
|
|
unapprovedEncryptionPublicKeyMsgs = {}, |
|
|
|
unapprovedTypedMessages = {}, |
|
|
|
unapprovedTypedMessages = {}, |
|
|
|
network, |
|
|
|
network, |
|
|
|
|
|
|
|
chainId, |
|
|
|
) => |
|
|
|
) => |
|
|
|
txHelper( |
|
|
|
txHelper( |
|
|
|
unapprovedTxs, |
|
|
|
unapprovedTxs, |
|
|
@ -49,6 +52,7 @@ export const unconfirmedTransactionsListSelector = createSelector( |
|
|
|
unapprovedEncryptionPublicKeyMsgs, |
|
|
|
unapprovedEncryptionPublicKeyMsgs, |
|
|
|
unapprovedTypedMessages, |
|
|
|
unapprovedTypedMessages, |
|
|
|
network, |
|
|
|
network, |
|
|
|
|
|
|
|
chainId, |
|
|
|
) || [], |
|
|
|
) || [], |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
@ -59,7 +63,8 @@ export const unconfirmedTransactionsHashSelector = createSelector( |
|
|
|
unapprovedDecryptMsgsSelector, |
|
|
|
unapprovedDecryptMsgsSelector, |
|
|
|
unapprovedEncryptionPublicKeyMsgsSelector, |
|
|
|
unapprovedEncryptionPublicKeyMsgsSelector, |
|
|
|
unapprovedTypedMessagesSelector, |
|
|
|
unapprovedTypedMessagesSelector, |
|
|
|
networkSelector, |
|
|
|
getCurrentNetworkId, |
|
|
|
|
|
|
|
getCurrentChainId, |
|
|
|
( |
|
|
|
( |
|
|
|
unapprovedTxs = {}, |
|
|
|
unapprovedTxs = {}, |
|
|
|
unapprovedMsgs = {}, |
|
|
|
unapprovedMsgs = {}, |
|
|
@ -68,13 +73,15 @@ export const unconfirmedTransactionsHashSelector = createSelector( |
|
|
|
unapprovedEncryptionPublicKeyMsgs = {}, |
|
|
|
unapprovedEncryptionPublicKeyMsgs = {}, |
|
|
|
unapprovedTypedMessages = {}, |
|
|
|
unapprovedTypedMessages = {}, |
|
|
|
network, |
|
|
|
network, |
|
|
|
|
|
|
|
chainId, |
|
|
|
) => { |
|
|
|
) => { |
|
|
|
const filteredUnapprovedTxs = Object.keys(unapprovedTxs).reduce( |
|
|
|
const filteredUnapprovedTxs = Object.keys(unapprovedTxs).reduce( |
|
|
|
(acc, address) => { |
|
|
|
(acc, address) => { |
|
|
|
const { metamaskNetworkId } = unapprovedTxs[address]; |
|
|
|
|
|
|
|
const transactions = { ...acc }; |
|
|
|
const transactions = { ...acc }; |
|
|
|
|
|
|
|
|
|
|
|
if (metamaskNetworkId === network) { |
|
|
|
if ( |
|
|
|
|
|
|
|
transactionMatchesNetwork(unapprovedTxs[address], chainId, network) |
|
|
|
|
|
|
|
) { |
|
|
|
transactions[address] = unapprovedTxs[address]; |
|
|
|
transactions[address] = unapprovedTxs[address]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -111,7 +118,8 @@ export const unconfirmedTransactionsCountSelector = createSelector( |
|
|
|
unapprovedDecryptMsgCountSelector, |
|
|
|
unapprovedDecryptMsgCountSelector, |
|
|
|
unapprovedEncryptionPublicKeyMsgCountSelector, |
|
|
|
unapprovedEncryptionPublicKeyMsgCountSelector, |
|
|
|
unapprovedTypedMessagesCountSelector, |
|
|
|
unapprovedTypedMessagesCountSelector, |
|
|
|
networkSelector, |
|
|
|
getCurrentNetworkId, |
|
|
|
|
|
|
|
getCurrentChainId, |
|
|
|
( |
|
|
|
( |
|
|
|
unapprovedTxs = {}, |
|
|
|
unapprovedTxs = {}, |
|
|
|
unapprovedMsgCount = 0, |
|
|
|
unapprovedMsgCount = 0, |
|
|
@ -120,12 +128,10 @@ export const unconfirmedTransactionsCountSelector = createSelector( |
|
|
|
unapprovedEncryptionPublicKeyMsgCount = 0, |
|
|
|
unapprovedEncryptionPublicKeyMsgCount = 0, |
|
|
|
unapprovedTypedMessagesCount = 0, |
|
|
|
unapprovedTypedMessagesCount = 0, |
|
|
|
network, |
|
|
|
network, |
|
|
|
|
|
|
|
chainId, |
|
|
|
) => { |
|
|
|
) => { |
|
|
|
const filteredUnapprovedTxIds = Object.keys(unapprovedTxs).filter( |
|
|
|
const filteredUnapprovedTxIds = Object.keys(unapprovedTxs).filter((txId) => |
|
|
|
(txId) => { |
|
|
|
transactionMatchesNetwork(unapprovedTxs[txId], chainId, network), |
|
|
|
const { metamaskNetworkId } = unapprovedTxs[txId]; |
|
|
|
|
|
|
|
return metamaskNetworkId === network; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|