diff --git a/ui/app/selectors.js b/ui/app/selectors.js index 749f18d3b..fd203dbb4 100644 --- a/ui/app/selectors.js +++ b/ui/app/selectors.js @@ -1,7 +1,11 @@ +const valuesFor = require('./util').valuesFor + const selectors = { getSelectedAddress, getSelectedIdentity, getSelectedAccount, + conversionRateSelector, + transactionsSelector, } module.exports = selectors @@ -24,4 +28,18 @@ function getSelectedAccount(state) { const selectedAddress = getSelectedAddress(state) return accounts[selectedAddress] +} + +function conversionRateSelector(state) { + return state.metamask.conversionRate +} + +function transactionsSelector(state) { + const { network } = state.metamask + const unapprovedMsgs = valuesFor(state.metamask.unapprovedMsgs) + const shapeShiftTxList = (network === '1') ? state.metamask.shapeShiftTxList : undefined + const transactions = state.metamask.selectedAddressTxList || [] + const txsToRender = !shapeShiftTxList ? transactions.concat(unapprovedMsgs) : transactions.concat(unapprovedMsgs, shapeShiftTxList) + + return txsToRender.sort((a, b) => b.time - a.time) } \ No newline at end of file