diff options
author | Thomas Huang <tmashuang@users.noreply.github.com> | 2017-12-14 10:07:57 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-14 10:07:57 +0800 |
commit | b33f516fb718afdea6ed0ebd18875922b9bae526 (patch) | |
tree | b5df434896aff38ce7e91ba38d57e850cd12b4f3 | |
parent | 0935e22d30d14d1185a89904df1271623e17985a (diff) | |
parent | 5df7dcd758c5a16b503a5ee237970c05c7e990c9 (diff) | |
download | tangerine-wallet-browser-b33f516fb718afdea6ed0ebd18875922b9bae526.tar.gz tangerine-wallet-browser-b33f516fb718afdea6ed0ebd18875922b9bae526.tar.zst tangerine-wallet-browser-b33f516fb718afdea6ed0ebd18875922b9bae526.zip |
Merge pull request #2743 from MetaMask/revert-2741-infura-block-tracker
Revert "network - for infura networks use the infura block tracker provider"
-rw-r--r-- | app/scripts/controllers/network.js | 57 | ||||
-rw-r--r-- | package.json | 3 |
2 files changed, 8 insertions, 52 deletions
diff --git a/app/scripts/controllers/network.js b/app/scripts/controllers/network.js index 65d58008a..cee918796 100644 --- a/app/scripts/controllers/network.js +++ b/app/scripts/controllers/network.js @@ -1,7 +1,6 @@ const assert = require('assert') const EventEmitter = require('events') const createMetamaskProvider = require('web3-provider-engine/zero.js') -const createInfuraProvider = require('eth-json-rpc-infura/src/createProvider') const ObservableStore = require('obs-store') const ComposedStore = require('obs-store/lib/composed') const extend = require('xtend') @@ -9,7 +8,6 @@ const EthQuery = require('eth-query') const createEventEmitterProxy = require('../lib/events-proxy.js') const RPC_ADDRESS_LIST = require('../config.js').network const DEFAULT_RPC = RPC_ADDRESS_LIST['rinkeby'] -const INFURA_PROVIDER_TYPES = ['ropsten', 'rinkeby', 'kovan', 'mainnet'] module.exports = class NetworkController extends EventEmitter { @@ -26,13 +24,8 @@ module.exports = class NetworkController extends EventEmitter { initializeProvider (_providerParams) { this._baseProviderParams = _providerParams - const { type, rpcTarget } = this.providerStore.getState() - // map rpcTarget to rpcUrl - const opts = { - type, - rpcUrl: rpcTarget, - } - this._configureProvider(opts) + const rpcUrl = this.getCurrentRpcAddress() + this._configureStandardProvider({ rpcUrl }) this._proxy.on('block', this._logBlock.bind(this)) this._proxy.on('error', this.verifyNetwork.bind(this)) this.ethQuery = new EthQuery(this._proxy) @@ -90,7 +83,7 @@ module.exports = class NetworkController extends EventEmitter { const rpcTarget = this.getRpcAddressForType(type) assert(rpcTarget, `NetworkController - unknown rpc address for type "${type}"`) this.providerStore.updateState({ type, rpcTarget }) - this._switchNetwork({ type }) + this._switchNetwork({ rpcUrl: rpcTarget }) } getProviderConfig () { @@ -106,50 +99,14 @@ module.exports = class NetworkController extends EventEmitter { // Private // - _switchNetwork (opts) { + _switchNetwork (providerParams) { this.setNetworkState('loading') - this._configureProvider(opts) + this._configureStandardProvider(providerParams) this.emit('networkDidChange') } - _configureProvider (opts) { - // type-based rpc endpoints - const { type } = opts - if (type) { - // type-based infura rpc endpoints - const isInfura = INFURA_PROVIDER_TYPES.includes(type) - opts.rpcUrl = this.getRpcAddressForType(type) - if (isInfura) { - this._configureInfuraProvider(opts) - // other type-based rpc endpoints - } else { - this._configureStandardProvider(opts) - } - // url-based rpc endpoints - } else { - this._configureStandardProvider(opts) - } - } - - _configureInfuraProvider (opts) { - console.log('_configureInfuraProvider', opts) - const blockTrackerProvider = createInfuraProvider({ - network: opts.type, - }) - const providerParams = extend(this._baseProviderParams, { - rpcUrl: opts.rpcUrl, - engineParams: { - pollingInterval: 8000, - blockTrackerProvider, - }, - }) - const provider = createMetamaskProvider(providerParams) - this._setProvider(provider) - } - - _configureStandardProvider ({ rpcUrl }) { - const providerParams = extend(this._baseProviderParams, { - rpcUrl, + _configureStandardProvider (_providerParams) { + const providerParams = extend(this._baseProviderParams, _providerParams, { engineParams: { pollingInterval: 8000, }, diff --git a/package.json b/package.json index 3a7e33b7a..ebe298aea 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,6 @@ "eth-contract-metadata": "^1.1.4", "eth-hd-keyring": "^1.2.1", "eth-json-rpc-filters": "^1.2.4", - "eth-json-rpc-infura": "^1.0.1", "eth-keyring-controller": "^2.1.2", "eth-phishing-detect": "^1.1.4", "eth-query": "^2.1.2", @@ -153,7 +152,7 @@ "valid-url": "^1.0.9", "vreme": "^3.0.2", "web3": "^0.20.1", - "web3-provider-engine": "^13.4.0", + "web3-provider-engine": "^13.3.4", "web3-stream-provider": "^3.0.1", "xtend": "^4.0.1" }, |