aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/controllers
diff options
context:
space:
mode:
authorWhymarrh Whitby <whymarrh.whitby@gmail.com>2018-04-19 11:33:51 +0800
committerWhymarrh Whitby <whymarrh.whitby@gmail.com>2018-05-17 23:27:39 +0800
commit924cc1fcf7de1896ac09bbe7a400d5ff5df0b50d (patch)
tree2a0f33c2ccd450bdd620b59df5510e5bbb670a9a /app/scripts/controllers
parent708422432c634ffbd4c73388f980c43f766b3355 (diff)
downloadtangerine-wallet-browser-924cc1fcf7de1896ac09bbe7a400d5ff5df0b50d.tar
tangerine-wallet-browser-924cc1fcf7de1896ac09bbe7a400d5ff5df0b50d.tar.gz
tangerine-wallet-browser-924cc1fcf7de1896ac09bbe7a400d5ff5df0b50d.tar.bz2
tangerine-wallet-browser-924cc1fcf7de1896ac09bbe7a400d5ff5df0b50d.tar.lz
tangerine-wallet-browser-924cc1fcf7de1896ac09bbe7a400d5ff5df0b50d.tar.xz
tangerine-wallet-browser-924cc1fcf7de1896ac09bbe7a400d5ff5df0b50d.tar.zst
tangerine-wallet-browser-924cc1fcf7de1896ac09bbe7a400d5ff5df0b50d.zip
Move setAccountLabel into PreferencesController
Diffstat (limited to 'app/scripts/controllers')
-rw-r--r--app/scripts/controllers/preferences.js20
1 files changed, 18 insertions, 2 deletions
diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js
index 1d3308d36..55416d15f 100644
--- a/app/scripts/controllers/preferences.js
+++ b/app/scripts/controllers/preferences.js
@@ -27,6 +27,7 @@ class PreferencesController {
useBlockie: false,
featureFlags: {},
currentLocale: opts.initLangCode,
+ identities: {},
}, opts.initState)
this.store = new ObservableStore(initState)
}
@@ -156,6 +157,21 @@ class PreferencesController {
}
/**
+ * Sets a custom label for an account
+ * @param {string} account the account to set a label for
+ * @param {string} label the custom label for the account
+ * @return {Promise<string>}
+ */
+ setAccountLabel (account, label) {
+ const address = normalizeAddress(account)
+ const {identities} = this.store.getState()
+ identities[address] = identities[address] || {}
+ identities[address].name = label
+ this.store.updateState({ identities })
+ return Promise.resolve(label)
+ }
+
+ /**
* Gets an updated rpc list from this.addToFrequentRpcList() and sets the `frequentRpcList` to this update list.
*
* @param {string} _url The the new rpc url to add to the updated list
@@ -189,8 +205,8 @@ class PreferencesController {
* The returned list will have a max length of 2. If the _url currently exists it the list, it will be moved to the
* end of the list. The current list is modified and returned as a promise.
*
- * @param {string} _url The rpc url to add to the frequentRpcList.
- * @returns {Promise<array>} The updated frequentRpcList.
+ * @param {string} _url The rpc url to add to the frequentRpcList.
+ * @returns {Promise<array>} The updated frequentRpcList.
*
*/
addToFrequentRpcList (_url) {