mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-24 11:01:41 +01:00
66 lines
1.9 KiB
JavaScript
66 lines
1.9 KiB
JavaScript
import { createSelector } from 'reselect'
|
|
import txHelper from '../../lib/tx-helper'
|
|
|
|
const unapprovedTxsSelector = state => state.metamask.unapprovedTxs
|
|
const unapprovedMsgsSelector = state => state.metamask.unapprovedMsgs
|
|
const unapprovedPersonalMsgsSelector = state => state.metamask.unapprovedPersonalMsgs
|
|
const unapprovedTypedMessagesSelector = state => state.metamask.unapprovedTypedMessages
|
|
const networkSelector = state => state.metamask.network
|
|
|
|
export const unconfirmedTransactionsListSelector = createSelector(
|
|
unapprovedTxsSelector,
|
|
unapprovedMsgsSelector,
|
|
unapprovedPersonalMsgsSelector,
|
|
unapprovedTypedMessagesSelector,
|
|
networkSelector,
|
|
(
|
|
unapprovedTxs = {},
|
|
unapprovedMsgs = {},
|
|
unapprovedPersonalMsgs = {},
|
|
unapprovedTypedMessages = {},
|
|
network
|
|
) => txHelper(
|
|
unapprovedTxs,
|
|
unapprovedMsgs,
|
|
unapprovedPersonalMsgs,
|
|
unapprovedTypedMessages,
|
|
network
|
|
) || []
|
|
)
|
|
|
|
export const unconfirmedTransactionsHashSelector = createSelector(
|
|
unapprovedTxsSelector,
|
|
unapprovedMsgsSelector,
|
|
unapprovedPersonalMsgsSelector,
|
|
unapprovedTypedMessagesSelector,
|
|
networkSelector,
|
|
(
|
|
unapprovedTxs = {},
|
|
unapprovedMsgs = {},
|
|
unapprovedPersonalMsgs = {},
|
|
unapprovedTypedMessages = {},
|
|
network
|
|
) => {
|
|
const filteredUnapprovedTxs = Object.keys(unapprovedTxs).reduce((acc, address) => {
|
|
const { metamaskNetworkId } = unapprovedTxs[address]
|
|
const transactions = { ...acc }
|
|
|
|
if (metamaskNetworkId === network) {
|
|
transactions[address] = unapprovedTxs[address]
|
|
}
|
|
|
|
return transactions
|
|
}, {})
|
|
|
|
return {
|
|
...filteredUnapprovedTxs,
|
|
...unapprovedMsgs,
|
|
...unapprovedPersonalMsgs,
|
|
...unapprovedTypedMessages,
|
|
}
|
|
}
|
|
)
|
|
|
|
export const currentCurrencySelector = state => state.metamask.currentCurrency
|
|
export const conversionRateSelector = state => state.metamask.conversionRate
|