diff options
author | frankiebee <frankie.diamond@gmail.com> | 2017-06-28 04:10:56 +0800 |
---|---|---|
committer | frankiebee <frankie.diamond@gmail.com> | 2017-06-28 04:10:56 +0800 |
commit | 847a4282a2c0db6561972147bd366622424f5d28 (patch) | |
tree | 2eefd2831cb627b9fd41e8858fe82714d85d399b /app/scripts/controllers | |
parent | abbbe1156c03700c4476d0618e65aa2eed2c264e (diff) | |
parent | 48f7cff8c0e765e85532c860c5f3061ca1d6deb7 (diff) | |
download | tangerine-wallet-browser-847a4282a2c0db6561972147bd366622424f5d28.tar tangerine-wallet-browser-847a4282a2c0db6561972147bd366622424f5d28.tar.gz tangerine-wallet-browser-847a4282a2c0db6561972147bd366622424f5d28.tar.bz2 tangerine-wallet-browser-847a4282a2c0db6561972147bd366622424f5d28.tar.lz tangerine-wallet-browser-847a4282a2c0db6561972147bd366622424f5d28.tar.xz tangerine-wallet-browser-847a4282a2c0db6561972147bd366622424f5d28.tar.zst tangerine-wallet-browser-847a4282a2c0db6561972147bd366622424f5d28.zip |
Merge branch 'master' into nonce-tracker
Diffstat (limited to 'app/scripts/controllers')
-rw-r--r-- | app/scripts/controllers/infura.js | 42 | ||||
-rw-r--r-- | app/scripts/controllers/preferences.js | 8 | ||||
-rw-r--r-- | app/scripts/controllers/transactions.js | 1 |
3 files changed, 51 insertions, 0 deletions
diff --git a/app/scripts/controllers/infura.js b/app/scripts/controllers/infura.js new file mode 100644 index 000000000..98375b446 --- /dev/null +++ b/app/scripts/controllers/infura.js @@ -0,0 +1,42 @@ +const ObservableStore = require('obs-store') +const extend = require('xtend') + +// every ten minutes +const POLLING_INTERVAL = 300000 + +class InfuraController { + + constructor (opts = {}) { + const initState = extend({ + infuraNetworkStatus: {}, + }, opts.initState) + this.store = new ObservableStore(initState) + } + + // + // PUBLIC METHODS + // + + // Responsible for retrieving the status of Infura's nodes. Can return either + // ok, degraded, or down. + checkInfuraNetworkStatus () { + return fetch('https://api.infura.io/v1/status/metamask') + .then(response => response.json()) + .then((parsedResponse) => { + this.store.updateState({ + infuraNetworkStatus: parsedResponse, + }) + }) + } + + scheduleInfuraNetworkCheck () { + if (this.conversionInterval) { + clearInterval(this.conversionInterval) + } + this.conversionInterval = setInterval(() => { + this.checkInfuraNetworkStatus() + }, POLLING_INTERVAL) + } +} + +module.exports = InfuraController diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index 7212c7c43..aa8e05fcc 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -7,6 +7,7 @@ class PreferencesController { constructor (opts = {}) { const initState = extend({ frequentRpcList: [], + currentAccountTab: 'history', }, opts.initState) this.store = new ObservableStore(initState) } @@ -35,6 +36,13 @@ class PreferencesController { }) } + setCurrentAccountTab (currentAccountTab) { + return new Promise((resolve, reject) => { + this.store.updateState({ currentAccountTab }) + resolve() + }) + } + addToFrequentRpcList (_url) { const rpcList = this.getFrequentRpcList() const index = rpcList.findIndex((element) => { return element === _url }) diff --git a/app/scripts/controllers/transactions.js b/app/scripts/controllers/transactions.js index 59c8be8b7..651565519 100644 --- a/app/scripts/controllers/transactions.js +++ b/app/scripts/controllers/transactions.js @@ -384,6 +384,7 @@ module.exports = class TransactionController extends EventEmitter { // - `'signed'` the tx is signed // - `'submitted'` the tx is sent to a server // - `'confirmed'` the tx has been included in a block. + // - `'failed'` the tx failed for some reason, included on tx data. _setTxStatus (txId, status) { var txMeta = this.getTx(txId) txMeta.status = status |