diff --git a/src/routes/safe/components/Transactions/TxsTable/index.jsx b/src/routes/safe/components/Transactions/TxsTable/index.jsx index f1358261..c8f3345f 100644 --- a/src/routes/safe/components/Transactions/TxsTable/index.jsx +++ b/src/routes/safe/components/Transactions/TxsTable/index.jsx @@ -27,8 +27,8 @@ import Table from '~/components/Table' import { type Column, cellWidth } from '~/components/Table/TableHead' import Block from '~/components/layout/Block' import Row from '~/components/layout/Row' -import { extendedTransactionsSelector } from '~/routes/safe/container/selector' import { safeCancellationTransactionsSelector } from '~/routes/safe/store/selectors' +import { extendedTransactionsSelector } from '~/routes/safe/store/selectors/transactions' export const TRANSACTION_ROW_TEST_ID = 'transaction-row' diff --git a/src/routes/safe/container/selector.js b/src/routes/safe/container/selector.js index 801070c0..4c221993 100644 --- a/src/routes/safe/container/selector.js +++ b/src/routes/safe/container/selector.js @@ -7,45 +7,15 @@ import { tokensSelector } from '~/logic/tokens/store/selectors' import { getEthAsToken } from '~/logic/tokens/utils/tokenHelpers' import { isUserOwner } from '~/logic/wallets/ethAddresses' import { userAccountSelector } from '~/logic/wallets/store/selectors' -import type { IncomingTransaction } from '~/routes/safe/store/models/incomingTransaction' import { type Safe } from '~/routes/safe/store/models/safe' -import { type Transaction, type TransactionStatus } from '~/routes/safe/store/models/transaction' import { type RouterProps, safeActiveTokensSelector, safeBalancesSelector, - safeCancellationTransactionsSelector, - safeIncomingTransactionsSelector, safeSelector, - safeTransactionsSelector, } from '~/routes/safe/store/selectors' import { type GlobalState } from '~/store' -const getTxStatus = (tx: Transaction, userAddress: string, safe: Safe): TransactionStatus => { - let txStatus - if (tx.executionTxHash) { - txStatus = 'success' - } else if (tx.cancelled) { - txStatus = 'cancelled' - } else if (tx.confirmations.size === safe.threshold) { - txStatus = 'awaiting_execution' - } else if (tx.creationTx) { - txStatus = 'success' - } else if (!tx.confirmations.size) { - txStatus = 'pending' - } else { - const userConfirmed = tx.confirmations.filter((conf) => conf.owner === userAddress).size === 1 - const userIsSafeOwner = safe.owners.filter((owner) => owner.address === userAddress).size === 1 - txStatus = !userConfirmed && userIsSafeOwner ? 'awaiting_your_confirmation' : 'awaiting_confirmations' - } - - if (tx.isSuccessful === false) { - txStatus = 'failed' - } - - return txStatus -} - export const grantedSelector: Selector = createSelector( userAccountSelector, safeSelector, @@ -87,35 +57,3 @@ export const extendedSafeTokensSelector: Selector, -> = createSelector( - safeSelector, - userAccountSelector, - safeTransactionsSelector, - safeCancellationTransactionsSelector, - safeIncomingTransactionsSelector, - (safe, userAddress, transactions, cancellationTransactions, incomingTransactions) => { - const cancellationTransactionsByNonce = cancellationTransactions.reduce((acc, tx) => acc.set(tx.nonce, tx), Map()) - const extendedTransactions = transactions.map((tx: Transaction) => { - let extendedTx = tx - - if (!tx.isExecuted) { - if ( - (cancellationTransactionsByNonce.get(tx.nonce) && - cancellationTransactionsByNonce.get(tx.nonce).get('isExecuted')) || - transactions.find((safeTx) => tx.nonce === safeTx.nonce && safeTx.isExecuted) - ) { - extendedTx = tx.set('cancelled', true) - } - } - - return extendedTx.set('status', getTxStatus(extendedTx, userAddress, safe)) - }) - - return List([...extendedTransactions, ...incomingTransactions]) - }, -) diff --git a/src/routes/safe/store/actions/transactions/fetchTransactions/index.js b/src/routes/safe/store/actions/transactions/fetchTransactions/index.js index 943623d8..d0e82b6b 100644 --- a/src/routes/safe/store/actions/transactions/fetchTransactions/index.js +++ b/src/routes/safe/store/actions/transactions/fetchTransactions/index.js @@ -12,6 +12,7 @@ import { type SafeTransactionsType, loadOutgoingTransactions } from './loadOutgo import { addCancellationTransactions } from '~/routes/safe/store/actions/transactions/addCancellationTransactions' import { type IncomingTransaction } from '~/routes/safe/store/models/incomingTransaction' import { type GlobalState } from '~/store' + export default (safeAddress: string) => async (dispatch: ReduxDispatch, getState: GetState) => { const transactions: SafeTransactionsType | typeof undefined = await loadOutgoingTransactions(safeAddress, getState) if (transactions) {