diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/images/ethereum-network.jpg | bin | 0 -> 10807 bytes | |||
-rw-r--r-- | app/images/morden-test-network.jpg | bin | 0 -> 10517 bytes | |||
-rw-r--r-- | app/images/no-connection.jpg | bin | 0 -> 6946 bytes | |||
-rw-r--r-- | app/images/unknown-private-network.jpg | bin | 0 -> 3962 bytes | |||
-rw-r--r-- | app/scripts/background.js | 13 | ||||
-rw-r--r-- | app/scripts/lib/idStore.js | 16 |
6 files changed, 21 insertions, 8 deletions
diff --git a/app/images/ethereum-network.jpg b/app/images/ethereum-network.jpg Binary files differnew file mode 100644 index 000000000..61cb000ed --- /dev/null +++ b/app/images/ethereum-network.jpg diff --git a/app/images/morden-test-network.jpg b/app/images/morden-test-network.jpg Binary files differnew file mode 100644 index 000000000..458708c78 --- /dev/null +++ b/app/images/morden-test-network.jpg diff --git a/app/images/no-connection.jpg b/app/images/no-connection.jpg Binary files differnew file mode 100644 index 000000000..a5d21242b --- /dev/null +++ b/app/images/no-connection.jpg diff --git a/app/images/unknown-private-network.jpg b/app/images/unknown-private-network.jpg Binary files differnew file mode 100644 index 000000000..b8a5a9bbf --- /dev/null +++ b/app/images/unknown-private-network.jpg diff --git a/app/scripts/background.js b/app/scripts/background.js index 432040c53..f64209ecc 100644 --- a/app/scripts/background.js +++ b/app/scripts/background.js @@ -76,13 +76,20 @@ var providerOpts = { var provider = MetaMaskProvider(providerOpts) var web3 = new Web3(provider) idStore.web3 = web3 -idStore.getNetwork(3) +idStore.getNetwork() // log new blocks provider.on('block', function(block){ console.log('BLOCK CHANGED:', '#'+block.number.toString('hex'), '0x'+block.hash.toString('hex')) + + // Check network when restoring connectivity: + if (idStore._currentState.network === 'loading') { + idStore.getNetwork() + } }) +provider.on('error', idStore.getNetwork.bind(idStore)) + var ethStore = new EthStore(provider) idStore.setStore(ethStore) @@ -292,13 +299,13 @@ function addUnconfirmedMsg(msgParams, cb){ function setRpcTarget(rpcTarget){ configManager.setRpcTarget(rpcTarget) chrome.runtime.reload() - idStore.getNetwork(3) // 3 retry attempts + idStore.getNetwork() } function setProviderType(type) { configManager.setProviderType(type) chrome.runtime.reload() - idStore.getNetwork(3) + idStore.getNetwork() } function useEtherscanProvider() { diff --git a/app/scripts/lib/idStore.js b/app/scripts/lib/idStore.js index e9fc10cea..33d842d54 100644 --- a/app/scripts/lib/idStore.js +++ b/app/scripts/lib/idStore.js @@ -137,16 +137,22 @@ IdentityStore.prototype.revealAccount = function(cb) { cb(null) } -IdentityStore.prototype.getNetwork = function(tries) { - if (tries === 0) { - this._currentState.network = 'error' - return +IdentityStore.prototype.getNetwork = function(err) { + + if (err) { + this._currentState.network = 'loading' + this._didUpdate() } + this.web3.version.getNetwork((err, network) => { if (err) { - return this.getNetwork(tries - 1, cb) + this._currentState.network = 'loading' + return this._didUpdate() } + + console.log('web3.getNetwork returned ' + network) this._currentState.network = network + this._didUpdate() }) } |