aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2018-05-03 09:03:59 +0800
committerkumavis <aaron@kumavis.me>2018-05-03 09:03:59 +0800
commitfec4c50657c0be5bdae9dd211ef4b1a6ebb1be43 (patch)
tree04d268363861c0199e76e09dec625604d1bd7f5d /app
parent53caa49666e00ecb21a5a999da01355a6c7485e3 (diff)
downloadtangerine-wallet-browser-fec4c50657c0be5bdae9dd211ef4b1a6ebb1be43.tar
tangerine-wallet-browser-fec4c50657c0be5bdae9dd211ef4b1a6ebb1be43.tar.gz
tangerine-wallet-browser-fec4c50657c0be5bdae9dd211ef4b1a6ebb1be43.tar.bz2
tangerine-wallet-browser-fec4c50657c0be5bdae9dd211ef4b1a6ebb1be43.tar.lz
tangerine-wallet-browser-fec4c50657c0be5bdae9dd211ef4b1a6ebb1be43.tar.xz
tangerine-wallet-browser-fec4c50657c0be5bdae9dd211ef4b1a6ebb1be43.tar.zst
tangerine-wallet-browser-fec4c50657c0be5bdae9dd211ef4b1a6ebb1be43.zip
controllers - network - move default config out of first-time-state
Diffstat (limited to 'app')
-rw-r--r--app/scripts/controllers/network/network.js17
-rw-r--r--app/scripts/first-time-state.js9
2 files changed, 15 insertions, 11 deletions
diff --git a/app/scripts/controllers/network/network.js b/app/scripts/controllers/network/network.js
index 826ce89c3..5496f8a68 100644
--- a/app/scripts/controllers/network/network.js
+++ b/app/scripts/controllers/network/network.js
@@ -19,14 +19,27 @@ const {
const LOCALHOST_RPC_URL = 'http://localhost:8545'
const INFURA_PROVIDER_TYPES = [ROPSTEN, RINKEBY, KOVAN, MAINNET]
+const env = process.env.METAMASK_ENV
+const METAMASK_DEBUG = process.env.METAMASK_DEBUG
+const testMode = (METAMASK_DEBUG || env === 'test')
+
+const defaultProviderConfig = {
+ type: testMode ? RINKEBY : MAINNET,
+}
+
module.exports = class NetworkController extends EventEmitter {
- constructor (config) {
+ constructor (opts = {}) {
super()
+ // parse options
+ const providerConfig = opts.provider || defaultProviderConfig
+ console.log('providerStore:', providerConfig)
+ // create stores
+ this.providerStore = new ObservableStore(providerConfig)
this.networkStore = new ObservableStore('loading')
- this.providerStore = new ObservableStore(config.provider)
this.store = new ComposedStore({ provider: this.providerStore, network: this.networkStore })
+ // create event emitter proxy
this._proxy = createEventEmitterProxy()
this.on('networkDidChange', this.lookupNetwork)
diff --git a/app/scripts/first-time-state.js b/app/scripts/first-time-state.js
index c49d89288..13119bc04 100644
--- a/app/scripts/first-time-state.js
+++ b/app/scripts/first-time-state.js
@@ -1,7 +1,3 @@
-// test and development environment variables
-const env = process.env.METAMASK_ENV
-const METAMASK_DEBUG = process.env.METAMASK_DEBUG
-const { DEFAULT_NETWORK, MAINNET } = require('./controllers/network/enums')
/**
* @typedef {Object} FirstTimeState
@@ -14,11 +10,6 @@ const { DEFAULT_NETWORK, MAINNET } = require('./controllers/network/enums')
*/
const initialState = {
config: {},
- NetworkController: {
- provider: {
- type: (METAMASK_DEBUG || env === 'test') ? DEFAULT_NETWORK : MAINNET,
- },
- },
}
module.exports = initialState