Skip to content

Commit

Permalink
gaba: integrate AddressBookController
Browse files Browse the repository at this point in the history
  • Loading branch information
bitpshr committed Nov 28, 2018
1 parent d59ac28 commit ad57e2b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 167 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 RecentBlocksController = require('./controllers/recent-blocks')
Expand Down Expand Up @@ -54,6 +53,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 @@ -165,11 +165,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 @@ -235,7 +231,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 @@ -255,7 +251,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 @@ -364,7 +360,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 @@ -421,7 +416,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
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,17 @@
"eth-block-tracker": "^4.1.0",
"eth-contract-metadata": "github:MetaMask/eth-contract-metadata#master",
"eth-ens-namehash": "^2.0.8",
"eth-hd-keyring": "^1.2.2",
"eth-hd-keyring": "^2.0.0",
"eth-json-rpc-filters": "^3.0.1",
"eth-json-rpc-infura": "^3.0.0",
"eth-keyring-controller": "^3.3.1",
"eth-keyring-controller": "^4.0.0",
"eth-ledger-bridge-keyring": "^0.1.1",
"eth-method-registry": "^1.0.0",
"eth-phishing-detect": "^1.1.4",
"eth-query": "^2.1.2",
"eth-trezor-keyring": "^0.2.0",
"eth-sig-util": "^2.0.2",
"eth-token-tracker": "^1.1.5",
"eth-trezor-keyring": "^0.2.0",
"ethereumjs-abi": "^0.6.4",
"ethereumjs-tx": "^1.3.0",
"ethereumjs-util": "github:ethereumjs/ethereumjs-util#ac5d0908536b447083ea422b435da27f26615de9",
Expand All @@ -145,6 +145,7 @@
"fast-levenshtein": "^2.0.6",
"file-loader": "^1.1.11",
"fuse.js": "^3.2.0",
"gaba": "^1.0.0-beta.45",
"gulp": "github:gulpjs/gulp#v4.0.0",
"gulp-autoprefixer": "^5.0.0",
"gulp-debug": "^3.2.0",
Expand Down Expand Up @@ -343,4 +344,4 @@
"node": "8.11.3",
"npm": "^6.1.0"
}
}
}
54 changes: 0 additions & 54 deletions test/unit/app/controllers/address-book-controller.js

This file was deleted.

0 comments on commit ad57e2b

Please sign in to comment.