From 220a82b53f0108fad0e4a30d9bc1a8d934878801 Mon Sep 17 00:00:00 2001 From: David Walsh Date: Wed, 28 Oct 2020 16:56:58 -0500 Subject: [PATCH] Fix 9435 - Allow speeding up of underpriced transactions (#9687) --- ui/app/selectors/transactions.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ui/app/selectors/transactions.js b/ui/app/selectors/transactions.js index 7d62d4979..a19d71ad0 100644 --- a/ui/app/selectors/transactions.js +++ b/ui/app/selectors/transactions.js @@ -2,6 +2,7 @@ import { createSelector } from 'reselect' import { SUBMITTED_STATUS, CONFIRMED_STATUS, + FAILED_STATUS, PRIORITY_STATUS_HASH, PENDING_STATUS_HASH, } from '../helpers/constants/transactions' @@ -227,12 +228,13 @@ export const nonceSortedTransactionsSelector = createSelector( const nonceProps = nonceToTransactionsMap[nonce] insertTransactionByTime(nonceProps.transactions, transaction) - if (status in PRIORITY_STATUS_HASH) { - const { primaryTransaction: { time: primaryTxTime = 0 } = {} } = nonceProps + const { primaryTransaction: { time: primaryTxTime = 0 } = {} } = nonceProps - if (status === CONFIRMED_STATUS || txTime > primaryTxTime) { - nonceProps.primaryTransaction = transaction - } + const previousPrimaryIsNetworkFailure = nonceProps.primaryTransaction.status === FAILED_STATUS && nonceProps.primaryTransaction?.txReceipt?.status !== '0x0' + const currentTransactionIsOnChainFailure = transaction?.txReceipt?.status === '0x0' + + if (status === CONFIRMED_STATUS || currentTransactionIsOnChainFailure || previousPrimaryIsNetworkFailure || (txTime > primaryTxTime && status in PRIORITY_STATUS_HASH)) { + nonceProps.primaryTransaction = transaction } const { initialTransaction: { time: initialTxTime = 0 } = {} } = nonceProps