diff --git a/ui/pages/token-allowance/token-allowance.js b/ui/pages/token-allowance/token-allowance.js index cd1edd8cb46e..87151e5e6b3f 100644 --- a/ui/pages/token-allowance/token-allowance.js +++ b/ui/pages/token-allowance/token-allowance.js @@ -50,6 +50,10 @@ import { useGasFeeContext } from '../../contexts/gasFee'; import { getCustomTxParamsData } from '../confirm-approve/confirm-approve.util'; import { setCustomTokenAmount } from '../../ducks/app/app'; import { valuesFor } from '../../helpers/utils/util'; +import { ConfirmPageContainerNavigation } from '../../components/app/confirm-page-container'; +import { transactionMatchesNetwork } from '../../../shared/modules/transaction.utils'; +import { hexToDecimal } from '../../../shared/lib/metamask-controller-utils'; +import { CONFIRM_TRANSACTION_ROUTE } from '../../helpers/constants/routes'; export default function TokenAllowance({ origin, @@ -208,6 +212,38 @@ export default function TokenAllowance({ const isEmpty = customTokenAmount === ''; + const network = hexToDecimal(fullTxData.chainId); + + const currentNetworkUnapprovedTxs = Object.keys(unapprovedTxs) + .filter((key) => + transactionMatchesNetwork( + unapprovedTxs[key], + fullTxData.chainId, + network, + ), + ) + .reduce((acc, key) => ({ ...acc, [key]: unapprovedTxs[key] }), {}); + + const enumUnapprovedTxs = Object.keys(currentNetworkUnapprovedTxs); + const currentPosition = enumUnapprovedTxs.indexOf( + fullTxData.id ? fullTxData.id.toString() : '', + ); + + const totalTx = enumUnapprovedTxs.length; + const positionOfCurrentTx = currentPosition + 1; + const nextTxId = enumUnapprovedTxs[currentPosition + 1]; + const prevTxId = enumUnapprovedTxs[currentPosition - 1]; + const showNavigation = enumUnapprovedTxs.length > 1; + const firstTx = enumUnapprovedTxs[0]; + const lastTx = enumUnapprovedTxs[enumUnapprovedTxs.length - 1]; + + const handleNextTx = (txId) => { + if (txId) { + dispatch(clearConfirmTransaction()); + history.push(`${CONFIRM_TRANSACTION_ROUTE}/${txId}`); + } + }; + const renderContractTokenValues = ( + + handleNextTx(txId)} + firstTx={firstTx} + lastTx={lastTx} + ofText={t('ofTextNofM')} + requestsWaitingText={t('requestsAwaitingAcknowledgement')} + /> +