1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Add retry background method and action

This commit is contained in:
Dan Finlay 2017-12-06 22:20:11 -05:00
parent a78cc013d1
commit 6ff580584a
5 changed files with 24 additions and 1 deletions

View File

@ -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)

View File

@ -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')

View File

@ -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),

View File

@ -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
//

View File

@ -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: {