From daae155ce2800a0533f7050ec79e5b0d91cb706f Mon Sep 17 00:00:00 2001
From: Paul Bouchon <mail@bitpshr.net>
Date: Tue, 12 Mar 2019 00:40:41 -0400
Subject: GABA: Integrate AddressBookController (#5847)

* gaba: integrate AddressBookController

* pin gaba version and update lockfile
---
 app/scripts/metamask-controller.js | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

(limited to 'app/scripts/metamask-controller.js')

diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index 653868066..540aee936 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -26,7 +26,6 @@ const PreferencesController = require('./controllers/preferences')
 const CurrencyController = require('./controllers/currency')
 const NoticeController = require('./notice-controller')
 const ShapeShiftController = require('./controllers/shapeshift')
-const AddressBookController = require('./controllers/address-book')
 const InfuraController = require('./controllers/infura')
 const BlacklistController = require('./controllers/blacklist')
 const CachedBalancesController = require('./controllers/cached-balances')
@@ -55,6 +54,7 @@ const HW_WALLETS_KEYRINGS = [TrezorKeyring.type, LedgerBridgeKeyring.type]
 const EthQuery = require('eth-query')
 const ethUtil = require('ethereumjs-util')
 const sigUtil = require('eth-sig-util')
+const { AddressBookController } = require('gaba')
 
 
 module.exports = class MetamaskController extends EventEmitter {
@@ -175,11 +175,7 @@ module.exports = class MetamaskController extends EventEmitter {
       keyringMemStore: this.keyringController.memStore,
     })
 
-    // address book controller
-    this.addressBookController = new AddressBookController({
-      initState: initState.AddressBookController,
-      preferencesStore: this.preferencesController.store,
-    })
+    this.addressBookController = new AddressBookController(undefined, initState.AddressBookController)
 
     // tx mgmt
     this.txController = new TransactionController({
@@ -245,7 +241,7 @@ module.exports = class MetamaskController extends EventEmitter {
       TransactionController: this.txController.store,
       KeyringController: this.keyringController.store,
       PreferencesController: this.preferencesController.store,
-      AddressBookController: this.addressBookController.store,
+      AddressBookController: this.addressBookController,
       CurrencyController: this.currencyController.store,
       NoticeController: this.noticeController.store,
       ShapeShiftController: this.shapeshiftController.store,
@@ -267,7 +263,7 @@ module.exports = class MetamaskController extends EventEmitter {
       KeyringController: this.keyringController.memStore,
       PreferencesController: this.preferencesController.store,
       RecentBlocksController: this.recentBlocksController.store,
-      AddressBookController: this.addressBookController.store,
+      AddressBookController: this.addressBookController,
       CurrencyController: this.currencyController.store,
       NoticeController: this.noticeController.memStore,
       ShapeshiftController: this.shapeshiftController.store,
@@ -376,7 +372,6 @@ module.exports = class MetamaskController extends EventEmitter {
     const preferencesController = this.preferencesController
     const txController = this.txController
     const noticeController = this.noticeController
-    const addressBookController = this.addressBookController
     const networkController = this.networkController
     const providerApprovalController = this.providerApprovalController
 
@@ -443,7 +438,7 @@ module.exports = class MetamaskController extends EventEmitter {
       whitelistPhishingDomain: this.whitelistPhishingDomain.bind(this),
 
       // AddressController
-      setAddressBook: nodeify(addressBookController.setAddressBook, addressBookController),
+      setAddressBook: this.addressBookController.set.bind(this.addressBookController),
 
       // KeyringController
       setLocked: nodeify(this.setLocked, this),
-- 
cgit