diff --git a/app/scripts/background.js b/app/scripts/background.js index 6eedeeea4..cf273d31a 100644 --- a/app/scripts/background.js +++ b/app/scripts/background.js @@ -134,7 +134,6 @@ initialize().catch(log.error) * @property {string} currentCurrency - A string identifying the user's preferred display currency, for use in showing conversion rates. * @property {number} conversionRate - A number representing the current exchange rate from the user's preferred currency to Ether. * @property {number} conversionDate - A unix epoch date (ms) for the time the current conversion rate was last retrieved. - * @property {Object} infuraNetworkStatus - An object of infura network status checks. * @property {boolean} forgottenPassword - Returns true if the user has initiated the password recovery screen, is recovering from seed phrase. */ diff --git a/app/scripts/controllers/infura.js b/app/scripts/controllers/infura.js deleted file mode 100644 index 75be7ef3c..000000000 --- a/app/scripts/controllers/infura.js +++ /dev/null @@ -1,39 +0,0 @@ -import ObservableStore from 'obs-store' -import log from 'loglevel' - -// every ten minutes -const POLLING_INTERVAL = 10 * 60 * 1000 - -export default class InfuraController { - - constructor (opts = {}) { - const initState = Object.assign({ - infuraNetworkStatus: {}, - }, opts.initState) - this.store = new ObservableStore(initState) - } - - // - // PUBLIC METHODS - // - - // Responsible for retrieving the status of Infura's nodes. Can return either - // ok, degraded, or down. - async checkInfuraNetworkStatus () { - const response = await window.fetch('https://api.infura.io/v1/status/metamask') - const parsedResponse = await response.json() - this.store.updateState({ - infuraNetworkStatus: parsedResponse, - }) - return parsedResponse - } - - scheduleInfuraNetworkCheck () { - if (this.conversionInterval) { - clearInterval(this.conversionInterval) - } - this.conversionInterval = setInterval(() => { - this.checkInfuraNetworkStatus().catch(log.warn) - }, POLLING_INTERVAL) - } -} diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index e6f973e59..5c36d8d23 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -29,7 +29,6 @@ import EnsController from './controllers/ens' import NetworkController from './controllers/network' import PreferencesController from './controllers/preferences' import AppStateController from './controllers/app-state' -import InfuraController from './controllers/infura' import CachedBalancesController from './controllers/cached-balances' import AlertController from './controllers/alert' import OnboardingController from './controllers/onboarding' @@ -128,11 +127,6 @@ export default class MetamaskController extends EventEmitter { this.currencyRateController = new CurrencyRateController(undefined, initState.CurrencyController) - this.infuraController = new InfuraController({ - initState: initState.InfuraController, - }) - this.infuraController.scheduleInfuraNetworkCheck() - this.phishingController = new PhishingController() // now we can initialize the RPC provider, which other controllers require @@ -292,7 +286,6 @@ export default class MetamaskController extends EventEmitter { AddressBookController: this.addressBookController, CurrencyController: this.currencyRateController, NetworkController: this.networkController.store, - InfuraController: this.infuraController.store, CachedBalancesController: this.cachedBalancesController.store, AlertController: this.alertController.store, OnboardingController: this.onboardingController.store, @@ -318,7 +311,6 @@ export default class MetamaskController extends EventEmitter { PreferencesController: this.preferencesController.store, AddressBookController: this.addressBookController, CurrencyController: this.currencyRateController, - InfuraController: this.infuraController.store, AlertController: this.alertController.store, OnboardingController: this.onboardingController.store, IncomingTransactionsController: this.incomingTransactionsController.store, diff --git a/test/unit/app/controllers/infura-controller-test.js b/test/unit/app/controllers/infura-controller-test.js deleted file mode 100644 index 26ee91e5b..000000000 --- a/test/unit/app/controllers/infura-controller-test.js +++ /dev/null @@ -1,66 +0,0 @@ -import assert from 'assert' -import sinon from 'sinon' -import InfuraController from '../../../../app/scripts/controllers/infura' - -describe('infura-controller', function () { - let infuraController, networkStatus - const response = { 'mainnet': 'degraded', 'ropsten': 'ok', 'kovan': 'ok', 'rinkeby': 'down', 'goerli': 'ok' } - - describe('Network status queries', function () { - before(async function () { - infuraController = new InfuraController() - sinon.stub(infuraController, 'checkInfuraNetworkStatus').resolves(response) - networkStatus = await infuraController.checkInfuraNetworkStatus() - }) - - describe('Mainnet', function () { - it('should have Mainnet', function () { - assert.equal(Object.keys(networkStatus)[0], 'mainnet') - }) - - it('should have a value for Mainnet status', function () { - assert.equal(networkStatus.mainnet, 'degraded') - }) - }) - - describe('Ropsten', function () { - it('should have Ropsten', function () { - assert.equal(Object.keys(networkStatus)[1], 'ropsten') - }) - - it('should have a value for Ropsten status', function () { - assert.equal(networkStatus.ropsten, 'ok') - }) - }) - - describe('Kovan', function () { - it('should have Kovan', function () { - assert.equal(Object.keys(networkStatus)[2], 'kovan') - }) - - it('should have a value for Kovan status', function () { - assert.equal(networkStatus.kovan, 'ok') - }) - }) - - describe('Rinkeby', function () { - it('should have Rinkeby', function () { - assert.equal(Object.keys(networkStatus)[3], 'rinkeby') - }) - - it('should have a value for Rinkeby status', function () { - assert.equal(networkStatus.rinkeby, 'down') - }) - }) - - describe('Goerli', function () { - it('should have Goerli', function () { - assert.equal(Object.keys(networkStatus)[4], 'goerli') - }) - - it('should have a value for Goerli status', function () { - assert.equal(networkStatus.goerli, 'ok') - }) - }) - }) -})