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

Add new selectors for addresses, identities, and accounts

This commit is contained in:
sdtsui 2017-08-09 21:40:01 -07:00
parent 5f74564deb
commit be116ecfbd

27
ui/app/selectors.js Normal file
View File

@ -0,0 +1,27 @@
const selectors = {
getSelectedAddress,
getSelectedIdentity,
getSelectedAccount,
}
module.exports = selectors
function getSelectedAddress(state) {
const selectedAddress = state.metamask.selectedAddress || Object.keys(accounts)[0]
return selectedAddress
}
function getSelectedIdentity(state) {
const selectedAddress = getSelectedAddress(state)
const identities = state.metamask.identities
return identities[selectedAddress]
}
function getSelectedAccount(state) {
const accounts = state.metamask.accounts
const selectedAddress = getSelectedAddress(state)
return accounts[selectedAddress]
}