aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/scripts/background.js1
-rw-r--r--app/scripts/controllers/computed-balances.js120
-rw-r--r--app/scripts/metamask-controller.js11
3 files changed, 0 insertions, 132 deletions
diff --git a/app/scripts/background.js b/app/scripts/background.js
index 02497d487..db2d9e8bb 100644
--- a/app/scripts/background.js
+++ b/app/scripts/background.js
@@ -133,7 +133,6 @@ setupMetamaskMeshMetrics()
* @property {number} unapprovedTypedMsgCount - The number of messages in unapprovedTypedMsgs.
* @property {string[]} keyringTypes - An array of unique keyring identifying strings, representing available strategies for creating accounts.
* @property {Keyring[]} keyrings - An array of keyring descriptions, summarizing the accounts that are available for use, and what keyrings they belong to.
- * @property {Object} computedBalances - Maps accounts to their balances, accounting for balance changes from pending transactions.
* @property {string} currentAccountTab - A view identifying string for displaying the current displayed view, allows user to have a preferred tab in the old UI (between tokens and history).
* @property {string} selectedAddress - A lower case hex string of the currently selected address.
* @property {string} currentCurrency - A string identifying the user's preferred display currency, for use in showing conversion rates.
diff --git a/app/scripts/controllers/computed-balances.js b/app/scripts/controllers/computed-balances.js
deleted file mode 100644
index caa061df4..000000000
--- a/app/scripts/controllers/computed-balances.js
+++ /dev/null
@@ -1,120 +0,0 @@
-const ObservableStore = require('obs-store')
-const extend = require('xtend')
-const BalanceController = require('./balance')
-
-/**
- * @typedef {Object} ComputedBalancesOptions
- * @property {Object} accountTracker Account tracker store reference
- * @property {Object} txController Token controller reference
- * @property {Object} blockTracker Block tracker reference
- * @property {Object} initState Initial state to populate this internal store with
- */
-
-/**
- * Background controller responsible for syncing
- * and computing ETH balances for all accounts
- */
-class ComputedbalancesController {
- /**
- * Creates a new controller instance
- *
- * @param {ComputedBalancesOptions} [opts] Controller configuration parameters
- */
- constructor (opts = {}) {
- const { accountTracker, txController, blockTracker } = opts
- this.accountTracker = accountTracker
- this.txController = txController
- this.blockTracker = blockTracker
-
- const initState = extend({
- computedBalances: {},
- }, opts.initState)
- this.store = new ObservableStore(initState)
- this.balances = {}
-
- this._initBalanceUpdating()
- }
-
- /**
- * Updates balances associated with each internal address
- */
- updateAllBalances () {
- Object.keys(this.balances).forEach((balance) => {
- const address = balance.address
- this.balances[address].updateBalance()
- })
- }
-
- /**
- * Initializes internal address tracking
- *
- * @private
- */
- _initBalanceUpdating () {
- const store = this.accountTracker.store.getState()
- this.syncAllAccountsFromStore(store)
- this.accountTracker.store.subscribe(this.syncAllAccountsFromStore.bind(this))
- }
-
- /**
- * Uses current account state to sync and track all
- * addresses associated with the current account
- *
- * @param {{ accounts: Object }} store Account tracking state
- */
- syncAllAccountsFromStore (store) {
- const upstream = Object.keys(store.accounts)
- const balances = Object.keys(this.balances)
- .map(address => this.balances[address])
-
- // Follow new addresses
- for (const address in balances) {
- this.trackAddressIfNotAlready(address)
- }
-
- // Unfollow old ones
- balances.forEach(({ address }) => {
- if (!upstream.includes(address)) {
- delete this.balances[address]
- }
- })
- }
-
- /**
- * Conditionally establishes a new subscription
- * to track an address associated with the current
- * account
- *
- * @param {string} address Address to conditionally subscribe to
- */
- trackAddressIfNotAlready (address) {
- const state = this.store.getState()
- if (!(address in state.computedBalances)) {
- this.trackAddress(address)
- }
- }
-
- /**
- * Establishes a new subscription to track an
- * address associated with the current account
- *
- * @param {string} address Address to conditionally subscribe to
- */
- trackAddress (address) {
- const updater = new BalanceController({
- address,
- accountTracker: this.accountTracker,
- txController: this.txController,
- blockTracker: this.blockTracker,
- })
- updater.store.subscribe((accountBalance) => {
- const newState = this.store.getState()
- newState.computedBalances[address] = accountBalance
- this.store.updateState(newState)
- })
- this.balances[address] = updater
- updater.updateBalance()
- }
-}
-
-module.exports = ComputedbalancesController
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index 1bf34a074..b9b44ea80 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -35,7 +35,6 @@ const MessageManager = require('./lib/message-manager')
const PersonalMessageManager = require('./lib/personal-message-manager')
const TypedMessageManager = require('./lib/typed-message-manager')
const TransactionController = require('./controllers/transactions')
-const BalancesController = require('./controllers/computed-balances')
const TokenRatesController = require('./controllers/token-rates')
const DetectTokensController = require('./controllers/detect-tokens')
const ProviderApprovalController = require('./controllers/provider-approval')
@@ -235,17 +234,9 @@ module.exports = class MetamaskController extends EventEmitter {
}
})
- // computed balances (accounting for pending transactions)
- this.balancesController = new BalancesController({
- accountTracker: this.accountTracker,
- txController: this.txController,
- blockTracker: this.blockTracker,
- })
this.networkController.on('networkDidChange', () => {
- this.balancesController.updateAllBalances()
this.setCurrentCurrency(this.currencyRateController.state.currentCurrency, function () {})
})
- this.balancesController.updateAllBalances()
this.shapeshiftController = new ShapeShiftController(undefined, initState.ShapeShiftController)
@@ -288,7 +279,6 @@ module.exports = class MetamaskController extends EventEmitter {
NetworkController: this.networkController.store,
AccountTracker: this.accountTracker.store,
TxController: this.txController.memStore,
- BalancesController: this.balancesController.store,
CachedBalancesController: this.cachedBalancesController.store,
TokenRatesController: this.tokenRatesController.store,
MessageManager: this.messageManager.memStore,
@@ -724,7 +714,6 @@ module.exports = class MetamaskController extends EventEmitter {
}
await this.preferencesController.syncAddresses(accounts)
- await this.balancesController.updateAllBalances()
await this.txController.pendingTxTracker.updatePendingTxs()
return this.keyringController.fullUpdate()
}