aboutsummaryrefslogtreecommitdiffstats
path: root/app
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
commitcbe4d0d88c83ee1d8dd8efde537ee753bf19596a (patch)
treed840a52d33e4729003cb5fb7b743364d286c869c /app
parent924cc1fcf7de1896ac09bbe7a400d5ff5df0b50d (diff)
downloadtangerine-wallet-browser-cbe4d0d88c83ee1d8dd8efde537ee753bf19596a.tar
tangerine-wallet-browser-cbe4d0d88c83ee1d8dd8efde537ee753bf19596a.tar.gz
tangerine-wallet-browser-cbe4d0d88c83ee1d8dd8efde537ee753bf19596a.tar.bz2
tangerine-wallet-browser-cbe4d0d88c83ee1d8dd8efde537ee753bf19596a.tar.lz
tangerine-wallet-browser-cbe4d0d88c83ee1d8dd8efde537ee753bf19596a.tar.xz
tangerine-wallet-browser-cbe4d0d88c83ee1d8dd8efde537ee753bf19596a.tar.zst
tangerine-wallet-browser-cbe4d0d88c83ee1d8dd8efde537ee753bf19596a.zip
Update AddressBookController to read from preferences store
Diffstat (limited to 'app')
-rw-r--r--app/scripts/controllers/address-book.js27
-rw-r--r--app/scripts/metamask-controller.js3
2 files changed, 8 insertions, 22 deletions
diff --git a/app/scripts/controllers/address-book.js b/app/scripts/controllers/address-book.js
index c91e6b2e4..4697e074c 100644
--- a/app/scripts/controllers/address-book.js
+++ b/app/scripts/controllers/address-book.js
@@ -13,19 +13,17 @@ class AddressBookController {
* @param {object} opts Overrides the defaults for the initial state of this.store
* @property {array} opts.initState initializes the the state of the AddressBookController. Can contain an
* addressBook property to initialize the addressBook array
- * @param {KeyringController} keyringController (Soon to be deprecated) The keyringController used in the current
- * MetamaskController. Contains the identities used in this AddressBookController.
+ * @property {object} opts.preferencesStore the {@code PreferencesController} store
* @property {object} store The the store of the current users address book
* @property {array} store.addressBook An array of addresses and nicknames. These are set by the user when sending
* to a new address.
*
*/
- constructor (opts = {}, keyringController) {
- const initState = extend({
+ constructor ({initState, preferencesStore}) {
+ this.store = new ObservableStore(extend({
addressBook: [],
- }, opts.initState)
- this.store = new ObservableStore(initState)
- this.keyringController = keyringController
+ }, initState))
+ this._preferencesStore = preferencesStore
}
//
@@ -62,7 +60,7 @@ class AddressBookController {
*/
_addToAddressBook (address, name) {
const addressBook = this._getAddressBook()
- const identities = this._getIdentities()
+ const {identities} = this._preferencesStore.getState()
const addressBookIndex = addressBook.findIndex((element) => { return element.address.toLowerCase() === address.toLowerCase() || element.name === name })
const identitiesIndex = Object.keys(identities).findIndex((element) => { return element.toLowerCase() === address.toLowerCase() })
@@ -95,19 +93,6 @@ class AddressBookController {
_getAddressBook () {
return this.store.getState().addressBook
}
-
- /**
- * Retrieves identities from the keyring controller in order to avoid
- * duplication
- *
- * @deprecated
- * @returns {array} Returns the identies array from the keyringContoller's state
- *
- */
- _getIdentities () {
- return this.keyringController.memStore.getState().identities
- }
-
}
module.exports = AddressBookController
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index 4dcec8ef7..06ee6c47a 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -144,7 +144,8 @@ module.exports = class MetamaskController extends EventEmitter {
// address book controller
this.addressBookController = new AddressBookController({
initState: initState.AddressBookController,
- }, this.keyringController)
+ preferencesStore: this.preferencesController.store,
+ })
// tx mgmt
this.txController = new TransactionController({