aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2017-09-28 05:10:58 +0800
committerkumavis <aaron@kumavis.me>2017-09-28 05:10:58 +0800
commitc781e11c7a4b8c6d0c74cc741af4d805d8bac00f (patch)
treec3b4d285f97d75882fb50002b434bac0792ecf1d /app/scripts
parent7e9c6e96a1c0c7ef864bf9b5b04421369de71023 (diff)
downloadtangerine-wallet-browser-c781e11c7a4b8c6d0c74cc741af4d805d8bac00f.tar
tangerine-wallet-browser-c781e11c7a4b8c6d0c74cc741af4d805d8bac00f.tar.gz
tangerine-wallet-browser-c781e11c7a4b8c6d0c74cc741af4d805d8bac00f.tar.bz2
tangerine-wallet-browser-c781e11c7a4b8c6d0c74cc741af4d805d8bac00f.tar.lz
tangerine-wallet-browser-c781e11c7a4b8c6d0c74cc741af4d805d8bac00f.tar.xz
tangerine-wallet-browser-c781e11c7a4b8c6d0c74cc741af4d805d8bac00f.tar.zst
tangerine-wallet-browser-c781e11c7a4b8c6d0c74cc741af4d805d8bac00f.zip
network - remove getter/setter
Diffstat (limited to 'app/scripts')
-rw-r--r--app/scripts/controllers/network.js37
1 files changed, 14 insertions, 23 deletions
diff --git a/app/scripts/controllers/network.js b/app/scripts/controllers/network.js
index dc9978043..253a365e2 100644
--- a/app/scripts/controllers/network.js
+++ b/app/scripts/controllers/network.js
@@ -11,8 +11,8 @@ const DEFAULT_RPC = RPC_ADDRESS_LIST['rinkeby']
module.exports = class NetworkController extends EventEmitter {
constructor (config) {
super()
- this.networkStore = new ObservableStore('loading')
config.provider.rpcTarget = this.getRpcAddressForType(config.provider.type, config.provider)
+ this.networkStore = new ObservableStore('loading')
this.providerStore = new ObservableStore(config.provider)
this.store = new ComposedStore({ provider: this.providerStore, network: this.networkStore })
this._providerListeners = {}
@@ -21,42 +21,33 @@ module.exports = class NetworkController extends EventEmitter {
this.providerStore.subscribe((state) => this.switchNetwork({rpcUrl: state.rpcTarget}))
}
- get provider () {
- return this._proxy
- }
-
- set provider (provider) {
- this._provider = provider
- }
-
initializeProvider (opts, providerContructor = MetaMaskProvider) {
- this.providerInit = opts
+ this._providerInit = opts
this._provider = providerContructor(opts)
this._proxy = createEventEmitterProxy(this._provider)
- this.provider._blockTracker = createEventEmitterProxy(this._provider._blockTracker)
- this.provider.on('block', this._logBlock.bind(this))
- this.provider.on('error', this.verifyNetwork.bind(this))
- this.ethQuery = new EthQuery(this.provider)
+ this._proxy._blockTracker = createEventEmitterProxy(this._provider._blockTracker)
+ this._proxy.on('block', this._logBlock.bind(this))
+ this._proxy.on('error', this.verifyNetwork.bind(this))
+ this.ethQuery = new EthQuery(this._proxy)
this.lookupNetwork()
- return this.provider
+ return this._proxy
}
switchNetwork (providerInit) {
this.setNetworkState('loading')
- const newInit = extend(this.providerInit, providerInit)
- this.providerInit = newInit
+ const newInit = extend(this._providerInit, providerInit)
+ this._providerInit = newInit
- this._provider.removeAllListeners()
- this._provider.stop()
+ this._proxy.removeAllListeners()
+ this._proxy.stop()
this._provider = MetaMaskProvider(newInit)
// apply the listners created by other controllers
- const blockTrackerHandlers = this.provider._blockTracker.proxyEventHandlers
- this.provider.setTarget(this._provider)
- this.provider._blockTracker = createEventEmitterProxy(this._provider._blockTracker, blockTrackerHandlers)
+ const blockTrackerHandlers = this._proxy._blockTracker.proxyEventHandlers
+ this._proxy.setTarget(this._provider)
+ this._proxy._blockTracker = createEventEmitterProxy(this._provider._blockTracker, blockTrackerHandlers)
this.emit('networkDidChange')
}
-
verifyNetwork () {
// Check network when restoring connectivity:
if (this.isNetworkLoading()) this.lookupNetwork()