Skip to content

Commit

Permalink
GABA: Integrate AddressBookController (#5847)
Browse files Browse the repository at this point in the history
* gaba: integrate AddressBookController

* pin gaba version and update lockfile
  • Loading branch information
bitpshr authored and frankiebee committed Mar 12, 2019
1 parent 59dbb9b commit daae155
Show file tree
Hide file tree
Showing 6 changed files with 532 additions and 221 deletions.
98 changes: 0 additions & 98 deletions app/scripts/controllers/address-book.js

This file was deleted.

4 changes: 3 additions & 1 deletion app/scripts/lib/ComposableObservableStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ class ComposableObservableStore extends ObservableStore {
getFlatState () {
let flatState = {}
for (const key in this.config) {
flatState = { ...flatState, ...this.config[key].getState() }
const controller = this.config[key]
const state = controller.getState ? controller.getState() : controller.state
flatState = { ...flatState, ...state }
}
return flatState
}
Expand Down
15 changes: 5 additions & 10 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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),
Expand Down
Loading

0 comments on commit daae155

Please sign in to comment.