aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/app/selectors.js27
1 files changed, 27 insertions, 0 deletions
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