diff --git a/app/scripts/lib/account-tracker.js b/app/scripts/lib/account-tracker.js index 2d97a1382..599baa86c 100644 --- a/app/scripts/lib/account-tracker.js +++ b/app/scripts/lib/account-tracker.js @@ -14,7 +14,7 @@ import log from 'loglevel' import pify from 'pify' import Web3 from 'web3' import SINGLE_CALL_BALANCES_ABI from 'single-call-balance-checker-abi' -import { MAINNET_NETWORK_ID, RINKEBY_NETWORK_ID, ROPSTEN_NETWORK_ID, KOVAN_NETWORK_ID } from '../controllers/network/enums' +import { MAINNET_CHAIN_ID, RINKEBY_CHAIN_ID, ROPSTEN_CHAIN_ID, KOVAN_CHAIN_ID } from '../controllers/network/enums' import { SINGLE_CALL_BALANCES_ADDRESS, @@ -61,7 +61,7 @@ export default class AccountTracker { }) // bind function for easier listener syntax this._updateForBlock = this._updateForBlock.bind(this) - this.network = opts.network + this.getCurrentChainId = opts.getCurrentChainId this.web3 = new Web3(this._provider) } @@ -196,22 +196,22 @@ export default class AccountTracker { async _updateAccounts () { const { accounts } = this.store.getState() const addresses = Object.keys(accounts) - const currentNetwork = this.network.getNetworkState() + const chainId = this.getCurrentChainId() - switch (currentNetwork) { - case MAINNET_NETWORK_ID.toString(): + switch (chainId) { + case MAINNET_CHAIN_ID: await this._updateAccountsViaBalanceChecker(addresses, SINGLE_CALL_BALANCES_ADDRESS) break - case RINKEBY_NETWORK_ID.toString(): + case RINKEBY_CHAIN_ID: await this._updateAccountsViaBalanceChecker(addresses, SINGLE_CALL_BALANCES_ADDRESS_RINKEBY) break - case ROPSTEN_NETWORK_ID.toString(): + case ROPSTEN_CHAIN_ID: await this._updateAccountsViaBalanceChecker(addresses, SINGLE_CALL_BALANCES_ADDRESS_ROPSTEN) break - case KOVAN_NETWORK_ID.toString(): + case KOVAN_CHAIN_ID: await this._updateAccountsViaBalanceChecker(addresses, SINGLE_CALL_BALANCES_ADDRESS_KOVAN) break diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index b4166bde5..f66091d80 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -168,7 +168,7 @@ export default class MetamaskController extends EventEmitter { this.accountTracker = new AccountTracker({ provider: this.provider, blockTracker: this.blockTracker, - network: this.networkController, + getCurrentChainId: this.networkController.getCurrentChainId.bind(this.networkController), }) // start and stop polling for balances based on activeControllerConnections