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:
parent
5f74564deb
commit
be116ecfbd
27
ui/app/selectors.js
Normal file
27
ui/app/selectors.js
Normal 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]
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user