diff options
Blockchain status now updates on availability change
Diffstat (limited to 'app/scripts/background.js')
-rw-r--r-- | app/scripts/background.js | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/app/scripts/background.js b/app/scripts/background.js index bfd1fc92b..209360a2d 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) @@ -145,7 +152,7 @@ function setupPublicConfig(stream){ } function setupProviderConnection(stream, originDomain){ - + stream.on('data', function onRpcRequest(payload){ // Append origin to rpc payload payload.origin = originDomain @@ -246,7 +253,7 @@ function newUnsignedTransaction(txParams, cb){ }) var txId = idStore.addUnconfirmedTransaction(txParams, cb) } else { - addUnconfirmedTx(txParams, cb) + addUnconfirmedTx(txParams, cb) } } @@ -258,7 +265,7 @@ function newUnsignedMessage(msgParams, cb){ }) var msgId = idStore.addUnconfirmedMessage(msgParams, cb) } else { - addUnconfirmedMsg(msgParams, cb) + addUnconfirmedMsg(msgParams, cb) } } @@ -290,13 +297,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() { |