diff options
author | Dan J Miller <danjm.com@gmail.com> | 2018-12-01 06:51:24 +0800 |
---|---|---|
committer | Dan Finlay <542863+danfinlay@users.noreply.github.com> | 2018-12-01 06:51:24 +0800 |
commit | 4c2455554540b9d0dd979bad329892279fddd8b9 (patch) | |
tree | e3b101ec86a65500023d8b7e99dd5973a9473626 /app/scripts/metamask-controller.js | |
parent | 45a9f40aa614753e274275eaeb4dd6c0251dcf45 (diff) | |
download | tangerine-wallet-browser-4c2455554540b9d0dd979bad329892279fddd8b9.tar tangerine-wallet-browser-4c2455554540b9d0dd979bad329892279fddd8b9.tar.gz tangerine-wallet-browser-4c2455554540b9d0dd979bad329892279fddd8b9.tar.bz2 tangerine-wallet-browser-4c2455554540b9d0dd979bad329892279fddd8b9.tar.lz tangerine-wallet-browser-4c2455554540b9d0dd979bad329892279fddd8b9.tar.xz tangerine-wallet-browser-4c2455554540b9d0dd979bad329892279fddd8b9.tar.zst tangerine-wallet-browser-4c2455554540b9d0dd979bad329892279fddd8b9.zip |
Save recent network balances in local storage (#5843)
* Use selector for state.metamask.accounts in all cases.
* Default to cached balance when selecting metamask accounts
* Adds the cached-balances controller
* Documentation and small codes fixes for #5843
Co-Authored-By: danjm <danjm.com@gmail.com>
Diffstat (limited to 'app/scripts/metamask-controller.js')
-rw-r--r-- | app/scripts/metamask-controller.js | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 7d6f06f92..fe806e47e 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -29,6 +29,7 @@ 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') const RecentBlocksController = require('./controllers/recent-blocks') const MessageManager = require('./lib/message-manager') const PersonalMessageManager = require('./lib/personal-message-manager') @@ -142,6 +143,12 @@ module.exports = class MetamaskController extends EventEmitter { } }) + this.cachedBalancesController = new CachedBalancesController({ + accountTracker: this.accountTracker, + getNetwork: this.networkController.getNetworkState.bind(this.networkController), + initState: initState.CachedBalancesController, + }) + // ensure accountTracker updates balances after network change this.networkController.on('networkDidChange', () => { this.accountTracker._updateAccounts() @@ -241,6 +248,7 @@ module.exports = class MetamaskController extends EventEmitter { ShapeShiftController: this.shapeshiftController.store, NetworkController: this.networkController.store, InfuraController: this.infuraController.store, + CachedBalancesController: this.cachedBalancesController.store, }) this.memStore = new ComposableObservableStore(null, { @@ -248,6 +256,7 @@ module.exports = class MetamaskController extends EventEmitter { AccountTracker: this.accountTracker.store, TxController: this.txController.memStore, BalancesController: this.balancesController.store, + CachedBalancesController: this.cachedBalancesController.store, TokenRatesController: this.tokenRatesController.store, MessageManager: this.messageManager.memStore, PersonalMessageManager: this.personalMessageManager.memStore, |