Skip to content

Commit

Permalink
gaba: integrate AddressBookController
Browse files Browse the repository at this point in the history
  • Loading branch information
bitpshr committed Mar 2, 2019
1 parent cb2698d commit 5987eb3
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 163 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 @@ -440,7 +435,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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@
"file-loader": "^1.1.11",
"fs-extra": "^6.0.1",
"fs-promise": "^2.0.3",
"gaba": "1.0.0-beta.62",
"ganache-cli": "^6.1.0",
"ganache-core": "^2.3.1",
"geckodriver": "^1.14.1",
Expand Down
54 changes: 0 additions & 54 deletions test/unit/app/controllers/address-book-controller.js

This file was deleted.

0 comments on commit 5987eb3

Please sign in to comment.