Add retry background method and action

feature/default_network_editable
Dan Finlay 7 years ago
parent a78cc013d1
commit 6ff580584a
  1. 4
      app/scripts/controllers/transactions.js
  2. 4
      app/scripts/lib/tx-state-manager.js
  3. 1
      app/scripts/metamask-controller.js
  4. 6
      ui/app/actions.js
  5. 10
      ui/app/components/transaction-list-item.js

@ -184,6 +184,10 @@ module.exports = class TransactionController extends EventEmitter {
return await this.txGasUtil.analyzeGasUsage(txMeta)
}
async retryTransaction (txId) {
return this.txStateManager.setTxStatusUnapproved(txId)
}
async updateAndApproveTransaction (txMeta) {
this.txStateManager.updateTx(txMeta, 'confTx: user approved transaction')
await this.approveTransaction(txMeta.id)

@ -187,6 +187,10 @@ module.exports = class TransactionStateManger extends EventEmitter {
this._setTxStatus(txId, 'rejected')
}
// should update the status of the tx to 'unapproved'.
setTxStatusUnapproved (txId) {
this._setTxStatus(txId, 'unapproved')
}
// should update the status of the tx to 'approved'.
setTxStatusApproved (txId) {
this._setTxStatus(txId, 'approved')

@ -363,6 +363,7 @@ module.exports = class MetamaskController extends EventEmitter {
// txController
cancelTransaction: nodeify(txController.cancelTransaction, txController),
updateAndApproveTransaction: nodeify(txController.updateAndApproveTransaction, txController),
retryTransaction: nodeify(txController.retryTransaction, txController),
// messageManager
signMessage: nodeify(this.signMessage, this),

@ -168,6 +168,7 @@ var actions = {
callBackgroundThenUpdate,
forceUpdateMetamaskState,
retryTransaction,
}
module.exports = actions
@ -759,6 +760,11 @@ function markAccountsFound () {
return callBackgroundThenUpdate(background.markAccountsFound)
}
function retryTransaction () {
log.debug(`background.retryTransaction`)
return callBackgroundThenUpdate(background.retryTransaction)
}
//
// config
//

@ -9,6 +9,7 @@ const CopyButton = require('./copyButton')
const vreme = new (require('vreme'))()
const Tooltip = require('./tooltip')
const numberToBN = require('number-to-bn')
const actions = require('../actions')
const TransactionIcon = require('./transaction-list-item-icon')
const ShiftListItem = require('./shift-list-item')
@ -21,6 +22,7 @@ function TransactionListItem () {
TransactionListItem.prototype.render = function () {
const { transaction, network, conversionRate, currentCurrency } = this.props
const { status } = transaction
if (transaction.key === 'shapeshift') {
if (network === '1') return h(ShiftListItem, transaction)
}
@ -32,7 +34,7 @@ TransactionListItem.prototype.render = function () {
var isMsg = ('msgParams' in transaction)
var isTx = ('txParams' in transaction)
var isPending = transaction.status === 'unapproved'
var isPending = status === 'unapproved'
let txParams
if (isTx) {
txParams = transaction.txParams
@ -97,10 +99,16 @@ TransactionListItem.prototype.render = function () {
showFiat: false,
style: {fontSize: '15px'},
}) : h('.flex-column'),
])
)
}
TransactionListItem.prototype.resubmit = function () {
const { transaction } = this.props
this.props.dispatch(actions.resubmitTx(transaction.id))
}
function domainField (txParams) {
return h('div', {
style: {

Loading…
Cancel
Save