From be116ecfbd687dffd5a1dfd2987a027b606e09cd Mon Sep 17 00:00:00 2001 From: sdtsui Date: Wed, 9 Aug 2017 21:40:01 -0700 Subject: Add new selectors for addresses, identities, and accounts --- ui/app/selectors.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 ui/app/selectors.js (limited to 'ui/app') diff --git a/ui/app/selectors.js b/ui/app/selectors.js new file mode 100644 index 000000000..749f18d3b --- /dev/null +++ b/ui/app/selectors.js @@ -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] +} \ No newline at end of file -- cgit v1.2.3