diff options
Diffstat (limited to 'app/scripts/controllers/network/network.js')
-rw-r--r-- | app/scripts/controllers/network/network.js | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/app/scripts/controllers/network/network.js b/app/scripts/controllers/network/network.js index 2c68e4378..b0c742e1f 100644 --- a/app/scripts/controllers/network/network.js +++ b/app/scripts/controllers/network/network.js @@ -21,8 +21,11 @@ const { MAINNET, LOCALHOST, GOERLI, + TANGERINE_TESTNET, + TANGERINE_TESTNET_RPC, } = require('./enums') const INFURA_PROVIDER_TYPES = [ROPSTEN, RINKEBY, KOVAN, MAINNET, GOERLI] +const TANGERINE_PROVIDER_TYPES = [TANGERINE_TESTNET] const env = process.env.METAMASK_ENV const METAMASK_DEBUG = process.env.METAMASK_DEBUG @@ -31,9 +34,9 @@ let defaultProviderConfigType if (process.env.IN_TEST === 'true') { defaultProviderConfigType = LOCALHOST } else if (METAMASK_DEBUG || env === 'test') { - defaultProviderConfigType = RINKEBY + defaultProviderConfigType = TANGERINE_TESTNET } else { - defaultProviderConfigType = MAINNET + defaultProviderConfigType = TANGERINE_TESTNET } const defaultProviderConfig = { @@ -142,9 +145,17 @@ module.exports = class NetworkController extends EventEmitter { } async setProviderType (type, rpcTarget = '', ticker = 'ETH', nickname = '') { + console.log('1') assert.notEqual(type, 'rpc', `NetworkController - cannot call "setProviderType" with type 'rpc'. use "setRpcTarget"`) - assert(INFURA_PROVIDER_TYPES.includes(type) || type === LOCALHOST, `NetworkController - Unknown rpc type "${type}"`) + console.log('2') + + if (INFURA_PROVIDER_TYPES.includes(type)) { + assert(INFURA_PROVIDER_TYPES.includes(type) || type === LOCALHOST, `NetworkController - Unknown rpc type "${type}"`) + } else { + assert(TANGERINE_PROVIDER_TYPES.includes(type) || type === LOCALHOST, `NetworkController - Unknown rpc type "${type}"`) + } const providerConfig = { type, rpcTarget, ticker, nickname } + console.log('providerConfig', providerConfig) this.providerConfig = providerConfig } @@ -174,8 +185,13 @@ module.exports = class NetworkController extends EventEmitter { _configureProvider (opts) { const { type, rpcTarget, chainId, ticker, nickname } = opts // infura type-based endpoints + const isInfura = INFURA_PROVIDER_TYPES.includes(type) - if (isInfura) { + const isTangerine = TANGERINE_PROVIDER_TYPES.includes(type) + console.log('_configureProvider', opts, isTangerine) + if (isTangerine) { + this._configureTangerineProvider(opts) + } else if (isInfura) { this._configureInfuraProvider(opts) // other type-based rpc endpoints } else if (type === LOCALHOST) { @@ -199,6 +215,13 @@ module.exports = class NetworkController extends EventEmitter { this.networkConfig.putState(settings) } + _configureTangerineProvider ({ type }) { + log.info('NetworkController - configureTangerineProvider', type) + const networkClient = createJsonRpcClient({ rpcUrl: TANGERINE_TESTNET_RPC }) + this._setNetworkClient(networkClient) + } + + _configureLocalhostProvider () { log.info('NetworkController - configureLocalhostProvider') const networkClient = createLocalhostClient() |