diff options
author | frankiebee <frankie.diamond@gmail.com> | 2017-08-02 23:41:29 +0800 |
---|---|---|
committer | frankiebee <frankie.diamond@gmail.com> | 2017-08-02 23:41:29 +0800 |
commit | 25cffd21f8defdf5a1bf139bdc2e3b1cfd08c220 (patch) | |
tree | 8e8f6225578722fb825ec0d98b2ff73b94f543d9 /app/scripts/controllers | |
parent | ece9200c72cd0b53ee237263933b2b9a24ae5802 (diff) | |
parent | d15e402ed87bf7533250c49a7972a7b1a12c99c2 (diff) | |
download | tangerine-wallet-browser-25cffd21f8defdf5a1bf139bdc2e3b1cfd08c220.tar tangerine-wallet-browser-25cffd21f8defdf5a1bf139bdc2e3b1cfd08c220.tar.gz tangerine-wallet-browser-25cffd21f8defdf5a1bf139bdc2e3b1cfd08c220.tar.bz2 tangerine-wallet-browser-25cffd21f8defdf5a1bf139bdc2e3b1cfd08c220.tar.lz tangerine-wallet-browser-25cffd21f8defdf5a1bf139bdc2e3b1cfd08c220.tar.xz tangerine-wallet-browser-25cffd21f8defdf5a1bf139bdc2e3b1cfd08c220.tar.zst tangerine-wallet-browser-25cffd21f8defdf5a1bf139bdc2e3b1cfd08c220.zip |
Merge branch 'master' into transactionControllerRefractor
Diffstat (limited to 'app/scripts/controllers')
-rw-r--r-- | app/scripts/controllers/infura.js | 14 | ||||
-rw-r--r-- | app/scripts/controllers/transactions.js | 13 |
2 files changed, 26 insertions, 1 deletions
diff --git a/app/scripts/controllers/infura.js b/app/scripts/controllers/infura.js index b34b0bc03..97b2ab7e3 100644 --- a/app/scripts/controllers/infura.js +++ b/app/scripts/controllers/infura.js @@ -1,5 +1,6 @@ const ObservableStore = require('obs-store') const extend = require('xtend') +const recentBlacklist = require('etheraddresslookup/blacklists/domains.json') // every ten minutes const POLLING_INTERVAL = 300000 @@ -9,6 +10,7 @@ class InfuraController { constructor (opts = {}) { const initState = extend({ infuraNetworkStatus: {}, + blacklist: recentBlacklist, }, opts.initState) this.store = new ObservableStore(initState) } @@ -30,12 +32,24 @@ class InfuraController { }) } + updateLocalBlacklist () { + return fetch('https://api.infura.io/v1/blacklist') + .then(response => response.json()) + .then((parsedResponse) => { + this.store.updateState({ + blacklist: parsedResponse, + }) + return parsedResponse + }) + } + scheduleInfuraNetworkCheck () { if (this.conversionInterval) { clearInterval(this.conversionInterval) } this.conversionInterval = setInterval(() => { this.checkInfuraNetworkStatus() + this.updateLocalBlacklist() }, POLLING_INTERVAL) } } diff --git a/app/scripts/controllers/transactions.js b/app/scripts/controllers/transactions.js index 43dfb9360..8855dfd5b 100644 --- a/app/scripts/controllers/transactions.js +++ b/app/scripts/controllers/transactions.js @@ -25,7 +25,6 @@ module.exports = class TransactionController extends EventEmitter { this.blockTracker = opts.blockTracker this.nonceTracker = new NonceTracker({ provider: this.provider, - blockTracker: this.provider._blockTracker, getPendingTransactions: (address) => { return this.getFilteredTxList({ from: address, @@ -104,8 +103,16 @@ module.exports = class TransactionController extends EventEmitter { } updateTx (txMeta) { + // create txMeta snapshot for history const txMetaForHistory = clone(txMeta) + // dont include previous history in this snapshot + delete txMetaForHistory.history + // add stack to help understand why tx was updated txMetaForHistory.stack = getStack() + // add snapshot to tx history + if (!txMeta.history) txMeta.history = [] + txMeta.history.push(txMetaForHistory) + const txId = txMeta.id const txList = this.getFullTxList() const index = txList.findIndex(txData => txData.id === txId) @@ -192,8 +199,12 @@ module.exports = class TransactionController extends EventEmitter { // get next nonce const txMeta = this.getTx(txId) const fromAddress = txMeta.txParams.from + // wait for a nonce nonceLock = await this.nonceTracker.getNonceLock(fromAddress) + // add nonce to txParams txMeta.txParams.nonce = nonceLock.nextNonce + // add nonce debugging information to txMeta + txMeta.nonceDetails = nonceLock.nonceDetails this.updateTx(txMeta) // sign transaction const rawTx = await this.signTransaction(txId) |