1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-22 17:33:23 +01:00

Add selectors for txsToRender and conversionRate

This commit is contained in:
sdtsui 2017-08-10 19:35:01 -07:00
parent 95eda70efe
commit 77b72ee33f

View File

@ -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)
}