mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-10-23 03:36:18 +02:00
Merge pull request #1607 from MetaMask/i1567-FixInaccurateError
Do not mark slowly mined txs as failed.
This commit is contained in:
commit
7ec7e12266
@ -3,6 +3,7 @@
|
|||||||
## Current Master
|
## Current Master
|
||||||
|
|
||||||
- Add a warning to JSON file import.
|
- Add a warning to JSON file import.
|
||||||
|
- Fix bug where slowly mined txs would sometimes be incorrectly marked as failed.
|
||||||
|
|
||||||
## 3.7.8 2017-6-12
|
## 3.7.8 2017-6-12
|
||||||
|
|
||||||
|
@ -25,11 +25,11 @@ module.exports = class TransactionController extends EventEmitter {
|
|||||||
this.query = opts.ethQuery
|
this.query = opts.ethQuery
|
||||||
this.txProviderUtils = new TxProviderUtil(this.query)
|
this.txProviderUtils = new TxProviderUtil(this.query)
|
||||||
this.blockTracker.on('rawBlock', this.checkForTxInBlock.bind(this))
|
this.blockTracker.on('rawBlock', this.checkForTxInBlock.bind(this))
|
||||||
this.blockTracker.on('block', this.resubmitPendingTxs.bind(this))
|
this.blockTracker.on('latest', this.resubmitPendingTxs.bind(this))
|
||||||
this.blockTracker.on('sync', this.queryPendingTxs.bind(this))
|
this.blockTracker.on('sync', this.queryPendingTxs.bind(this))
|
||||||
this.signEthTx = opts.signTransaction
|
this.signEthTx = opts.signTransaction
|
||||||
this.nonceLock = Semaphore(1)
|
this.nonceLock = Semaphore(1)
|
||||||
|
this.ethStore = opts.ethStore
|
||||||
// memstore is computed from a few different stores
|
// memstore is computed from a few different stores
|
||||||
this._updateMemstore()
|
this._updateMemstore()
|
||||||
this.store.subscribe(() => this._updateMemstore())
|
this.store.subscribe(() => this._updateMemstore())
|
||||||
@ -413,33 +413,31 @@ module.exports = class TransactionController extends EventEmitter {
|
|||||||
const pending = this.getTxsByMetaData('status', 'submitted')
|
const pending = this.getTxsByMetaData('status', 'submitted')
|
||||||
// only try resubmitting if their are transactions to resubmit
|
// only try resubmitting if their are transactions to resubmit
|
||||||
if (!pending.length) return
|
if (!pending.length) return
|
||||||
const resubmit = denodeify(this.resubmitTx.bind(this))
|
const resubmit = denodeify(this._resubmitTx.bind(this))
|
||||||
Promise.all(pending.map(txMeta => resubmit(txMeta)))
|
Promise.all(pending.map(txMeta => resubmit(txMeta)))
|
||||||
.catch((reason) => {
|
.catch((reason) => {
|
||||||
log.info('Problem resubmitting tx', reason)
|
log.info('Problem resubmitting tx', reason)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
resubmitTx (txMeta, cb) {
|
_resubmitTx (txMeta, cb) {
|
||||||
// Increment a try counter.
|
const address = txMeta.txParams.from
|
||||||
if (!('retryCount' in txMeta)) {
|
const balance = this.ethStore.getState().accounts[address].balance
|
||||||
txMeta.retryCount = 0
|
const nonce = Number.parseInt(this.ethStore.getState().accounts[address].nonce)
|
||||||
}
|
const txNonce = Number.parseInt(txMeta.txParams.nonce)
|
||||||
|
const gtBalance = Number.parseInt(txMeta.txParams.value) > Number.parseInt(balance)
|
||||||
|
if (!('retryCount' in txMeta)) txMeta.retryCount = 0
|
||||||
|
|
||||||
|
// if the value of the transaction is greater then the balance
|
||||||
|
// or the nonce of the transaction is lower then the accounts nonce
|
||||||
|
// dont resubmit the tx
|
||||||
|
if (gtBalance || txNonce < nonce) return cb()
|
||||||
// Only auto-submit already-signed txs:
|
// Only auto-submit already-signed txs:
|
||||||
if (!('rawTx' in txMeta)) {
|
if (!('rawTx' in txMeta)) return cb()
|
||||||
return cb()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (txMeta.retryCount > RETRY_LIMIT) {
|
if (txMeta.retryCount > RETRY_LIMIT) return
|
||||||
txMeta.err = {
|
|
||||||
isWarning: true,
|
|
||||||
message: 'Gave up submitting tx.',
|
|
||||||
}
|
|
||||||
this.updateTx(txMeta)
|
|
||||||
return log.error(txMeta.err.message)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Increment a try counter.
|
||||||
txMeta.retryCount++
|
txMeta.retryCount++
|
||||||
const rawTx = txMeta.rawTx
|
const rawTx = txMeta.rawTx
|
||||||
this.txProviderUtils.publishTransaction(rawTx, cb)
|
this.txProviderUtils.publishTransaction(rawTx, cb)
|
||||||
|
@ -102,6 +102,7 @@ module.exports = class MetamaskController extends EventEmitter {
|
|||||||
provider: this.provider,
|
provider: this.provider,
|
||||||
blockTracker: this.provider,
|
blockTracker: this.provider,
|
||||||
ethQuery: this.ethQuery,
|
ethQuery: this.ethQuery,
|
||||||
|
ethStore: this.ethStore,
|
||||||
})
|
})
|
||||||
|
|
||||||
// notices
|
// notices
|
||||||
|
@ -64,7 +64,7 @@
|
|||||||
"eth-bin-to-ops": "^1.0.1",
|
"eth-bin-to-ops": "^1.0.1",
|
||||||
"eth-contract-metadata": "^1.0.0",
|
"eth-contract-metadata": "^1.0.0",
|
||||||
"eth-hd-keyring": "^1.1.1",
|
"eth-hd-keyring": "^1.1.1",
|
||||||
"eth-query": "^2.1.1",
|
"eth-query": "^2.1.2",
|
||||||
"eth-sig-util": "^1.1.1",
|
"eth-sig-util": "^1.1.1",
|
||||||
"eth-simple-keyring": "^1.1.1",
|
"eth-simple-keyring": "^1.1.1",
|
||||||
"ethereumjs-tx": "^1.3.0",
|
"ethereumjs-tx": "^1.3.0",
|
||||||
|
Loading…
Reference in New Issue
Block a user