aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/selectors/confirm-transaction.js
diff options
context:
space:
mode:
authorbrunobar79 <brunobar79@gmail.com>2018-07-13 00:54:08 +0800
committerbrunobar79 <brunobar79@gmail.com>2018-07-13 00:54:08 +0800
commit07d8bfaec51a798e090bd2521debeddaf53bf2f9 (patch)
tree735338e1dbaa38601376024ed6e4fa4d89c66a2c /ui/app/selectors/confirm-transaction.js
parent2a0a7853249284cb27831890f3b62847ea27eb83 (diff)
parent0d4dbbec2abfa8c8015063d6e4a5ff0d34abe7b9 (diff)
downloadtangerine-wallet-browser-07d8bfaec51a798e090bd2521debeddaf53bf2f9.tar
tangerine-wallet-browser-07d8bfaec51a798e090bd2521debeddaf53bf2f9.tar.gz
tangerine-wallet-browser-07d8bfaec51a798e090bd2521debeddaf53bf2f9.tar.bz2
tangerine-wallet-browser-07d8bfaec51a798e090bd2521debeddaf53bf2f9.tar.lz
tangerine-wallet-browser-07d8bfaec51a798e090bd2521debeddaf53bf2f9.tar.xz
tangerine-wallet-browser-07d8bfaec51a798e090bd2521debeddaf53bf2f9.tar.zst
tangerine-wallet-browser-07d8bfaec51a798e090bd2521debeddaf53bf2f9.zip
Merge branch 'develop' of github.com:MetaMask/metamask-extension into initial-trezor-support
Diffstat (limited to 'ui/app/selectors/confirm-transaction.js')
-rw-r--r--ui/app/selectors/confirm-transaction.js65
1 files changed, 65 insertions, 0 deletions
diff --git a/ui/app/selectors/confirm-transaction.js b/ui/app/selectors/confirm-transaction.js
new file mode 100644
index 000000000..cde83804d
--- /dev/null
+++ b/ui/app/selectors/confirm-transaction.js
@@ -0,0 +1,65 @@
+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