mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
linting && format fixing
This commit is contained in:
parent
3ad67d1b14
commit
9e0c0745ab
@ -1,5 +1,4 @@
|
||||
const EventEmitter = require('events')
|
||||
const extend = require('xtend')
|
||||
const ObservableStore = require('obs-store')
|
||||
const ethUtil = require('ethereumjs-util')
|
||||
const Transaction = require('ethereumjs-tx')
|
||||
@ -60,17 +59,14 @@ module.exports = class TransactionController extends EventEmitter {
|
||||
this.pendingTxTracker = new PendingTransactionTracker({
|
||||
provider: this.provider,
|
||||
nonceTracker: this.nonceTracker,
|
||||
retryLimit: 3500, // Retry 3500 blocks, or about 1 day.
|
||||
getBalance: (address) => {
|
||||
const account = this.ethStore.getState().accounts[address]
|
||||
if (!account) return
|
||||
return account.balance
|
||||
},
|
||||
publishTransaction: this.query.sendRawTransaction,
|
||||
publishTransaction: (rawTx) => this.query.sendRawTransaction(rawTx),
|
||||
getPendingTransactions: this.txStateManager.getPendingTransactions.bind(this.txStateManager),
|
||||
giveUpOnTransaction: (txId) => {
|
||||
const err = new Error(`Gave up submitting after 3500 blocks un-mined.`)
|
||||
this.setTxStatusFailed(txId, err)
|
||||
},
|
||||
})
|
||||
|
||||
this.txStateManager.store.subscribe(() => this.emit('updateBadge'))
|
||||
@ -193,7 +189,7 @@ module.exports = class TransactionController extends EventEmitter {
|
||||
// wait for a nonce
|
||||
nonceLock = await this.nonceTracker.getNonceLock(fromAddress)
|
||||
// add nonce to txParams
|
||||
txMeta.txParams.nonce = nonceLock.nextNonce
|
||||
txMeta.txParams.nonce = ethUtil.addHexPrefix(nonceLock.nextNonce.toString(16))
|
||||
// add nonce debugging information to txMeta
|
||||
txMeta.nonceDetails = nonceLock.nonceDetails
|
||||
this.txStateManager.updateTx(txMeta)
|
||||
|
@ -1,7 +1,6 @@
|
||||
const EventEmitter = require('events')
|
||||
const EthQuery = require('ethjs-query')
|
||||
const sufficientBalance = require('./util').sufficientBalance
|
||||
const RETRY_LIMIT = 3500 // Retry 3500 blocks, or about 1 day.
|
||||
/*
|
||||
|
||||
Utility class for tracking the transactions as they
|
||||
@ -25,11 +24,10 @@ module.exports = class PendingTransactionTracker extends EventEmitter {
|
||||
super()
|
||||
this.query = new EthQuery(config.provider)
|
||||
this.nonceTracker = config.nonceTracker
|
||||
|
||||
this.retryLimit = config.retryLimit || Infinity
|
||||
this.getBalance = config.getBalance
|
||||
this.getPendingTransactions = config.getPendingTransactions
|
||||
this.publishTransaction = config.publishTransaction
|
||||
this.giveUpOnTransaction = config.giveUpOnTransaction
|
||||
}
|
||||
|
||||
// checks if a signed tx is in a block and
|
||||
@ -102,8 +100,9 @@ module.exports = class PendingTransactionTracker extends EventEmitter {
|
||||
if (balance === undefined) return
|
||||
if (!('retryCount' in txMeta)) txMeta.retryCount = 0
|
||||
|
||||
if (txMeta.retryCount > RETRY_LIMIT) {
|
||||
return this.giveUpOnTransaction(txMeta.id)
|
||||
if (txMeta.retryCount > this.retryLimit) {
|
||||
const err = new Error(`Gave up submitting after ${this.retryLimit} blocks un-mined.`)
|
||||
return this.emit('txFailed', txMeta.id, err)
|
||||
}
|
||||
|
||||
// if the value of the transaction is greater then the balance, fail.
|
||||
|
Loading…
Reference in New Issue
Block a user