diff --git a/app/scripts/controllers/swaps.js b/app/scripts/controllers/swaps.js index e3d0198e4..a8063bdce 100644 --- a/app/scripts/controllers/swaps.js +++ b/app/scripts/controllers/swaps.js @@ -270,14 +270,16 @@ export default class SwapsController { fetchParams.fromAddress, chainId, ); + const [firstQuote] = Object.values(newQuotes); // For a user to be able to swap a token, they need to have approved the MetaSwap contract to withdraw that token. // _getERC20Allowance() returns the amount of the token they have approved for withdrawal. If that amount is greater // than 0, it means that approval has already occurred and is not needed. Otherwise, for tokens to be swapped, a new // call of the ERC-20 approve method is required. approvalRequired = + firstQuote.approvalNeeded && allowance.eq(0) && - Object.values(newQuotes)[0].aggregator !== 'wrappedNative'; + firstQuote.aggregator !== 'wrappedNative'; if (!approvalRequired) { newQuotes = mapValues(newQuotes, (quote) => ({ ...quote, @@ -285,7 +287,7 @@ export default class SwapsController { })); } else if (!isPolledRequest) { const { gasLimit: approvalGas } = await this.timedoutGasReturn( - Object.values(newQuotes)[0].approvalNeeded, + firstQuote.approvalNeeded, ); newQuotes = mapValues(newQuotes, (quote) => ({ diff --git a/ui/components/app/transaction-status/transaction-status.component.js b/ui/components/app/transaction-status/transaction-status.component.js index 584989adb..000c84a28 100644 --- a/ui/components/app/transaction-status/transaction-status.component.js +++ b/ui/components/app/transaction-status/transaction-status.component.js @@ -57,7 +57,7 @@ export default function TransactionStatus({ const statusText = statusKey === TRANSACTION_STATUSES.CONFIRMED && !statusOnly ? date - : t(statusKey); + : statusKey && t(statusKey); return ( { + onClick={async () => { makeAnotherSwapEvent(); - dispatch(navigateBackToBuildQuote(history)); + await dispatch(navigateBackToBuildQuote(history)); + dispatch(setSwapsFromToken(defaultSwapsToken)); }} > {t('makeAnotherSwap')} diff --git a/ui/pages/swaps/build-quote/build-quote.js b/ui/pages/swaps/build-quote/build-quote.js index 04fb4553a..a0ac92318 100644 --- a/ui/pages/swaps/build-quote/build-quote.js +++ b/ui/pages/swaps/build-quote/build-quote.js @@ -454,6 +454,7 @@ export default function BuildQuote({ !isFeatureFlagLoaded || !Number(fromTokenInputValue) || !selectedToToken?.address || + !fromTokenAddress || Number(maxSlippage) < 0 || Number(maxSlippage) > MAX_ALLOWED_SLIPPAGE || (toTokenIsNotDefault && occurrences < 2 && !verificationClicked);