aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/controllers/preferences.js
diff options
context:
space:
mode:
authorkumavis <kumavis@users.noreply.github.com>2018-05-22 05:58:37 +0800
committerGitHub <noreply@github.com>2018-05-22 05:58:37 +0800
commit7a65c22a024c799d4a2c2fb7184f185633d5eaa8 (patch)
treea4cc398b10a0ce00cc41c4c3a86b54731d5d824c /app/scripts/controllers/preferences.js
parent59c9852999293adaeee4c036b64ca65182879e92 (diff)
parent793737f5bc22188b8c1ee154830aa7a6f0a3c04f (diff)
downloadtangerine-wallet-browser-7a65c22a024c799d4a2c2fb7184f185633d5eaa8.tar.gz
tangerine-wallet-browser-7a65c22a024c799d4a2c2fb7184f185633d5eaa8.tar.zst
tangerine-wallet-browser-7a65c22a024c799d4a2c2fb7184f185633d5eaa8.zip
Merge branch 'develop' into ci-publish-release
Diffstat (limited to 'app/scripts/controllers/preferences.js')
-rw-r--r--app/scripts/controllers/preferences.js30
1 files changed, 28 insertions, 2 deletions
diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js
index 1d3308d36..a4ff1207e 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)
}
@@ -62,6 +63,16 @@ class PreferencesController {
this.store.updateState({ currentLocale: key })
}
+ setAddresses (addresses) {
+ const oldIdentities = this.store.getState().identities
+ const identities = addresses.reduce((ids, address, index) => {
+ const oldId = oldIdentities[address] || {}
+ ids[address] = {name: `Account ${index + 1}`, address, ...oldId}
+ return ids
+ }, {})
+ this.store.updateState({ identities })
+ }
+
/**
* Setter for the `selectedAddress` property
*
@@ -156,6 +167,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 +215,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) {