aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/background.js
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2016-06-04 06:18:20 +0800
committerDan Finlay <dan@danfinlay.com>2016-06-04 06:18:20 +0800
commitd49ef1a2e54b0a9ac7a3d23d7744990543246ec6 (patch)
tree38970967e820a5365c8fcde7e134c2fccf705301 /app/scripts/background.js
parent2422c78ce20a032a81545bf8cc03394e12c599d5 (diff)
downloadtangerine-wallet-browser-d49ef1a2e54b0a9ac7a3d23d7744990543246ec6.tar
tangerine-wallet-browser-d49ef1a2e54b0a9ac7a3d23d7744990543246ec6.tar.gz
tangerine-wallet-browser-d49ef1a2e54b0a9ac7a3d23d7744990543246ec6.tar.bz2
tangerine-wallet-browser-d49ef1a2e54b0a9ac7a3d23d7744990543246ec6.tar.lz
tangerine-wallet-browser-d49ef1a2e54b0a9ac7a3d23d7744990543246ec6.tar.xz
tangerine-wallet-browser-d49ef1a2e54b0a9ac7a3d23d7744990543246ec6.tar.zst
tangerine-wallet-browser-d49ef1a2e54b0a9ac7a3d23d7744990543246ec6.zip
Blockchain status now updates on availability change
Diffstat (limited to 'app/scripts/background.js')
-rw-r--r--app/scripts/background.js19
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() {