Skip to content

Commit

Permalink
fix: trying to access an undefined object in swaps review quote compo…
Browse files Browse the repository at this point in the history
…nent
  • Loading branch information
jclancy93 committed Oct 8, 2024
1 parent e354ad5 commit 05ab643
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions ui/pages/swaps/prepare-swap-page/prepare-swap-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useContext, useEffect, useState, useCallback } from 'react';
import BigNumber from 'bignumber.js';
import PropTypes from 'prop-types';
import { shallowEqual, useDispatch, useSelector } from 'react-redux';
import { uniqBy, isEqual } from 'lodash';
import { uniqBy, isEqual, isEmpty } from 'lodash';
import { useHistory } from 'react-router-dom';
import { getTokenTrackerLink } from '@metamask/etherscan-link';
import classnames from 'classnames';
Expand Down Expand Up @@ -52,6 +52,7 @@ import {
getTransactionSettingsOpened,
setTransactionSettingsOpened,
getLatestAddedTokenTo,
getUsedQuote,
} from '../../../ducks/swaps/swaps';
import {
getSwapsDefaultToken,
Expand Down Expand Up @@ -190,9 +191,19 @@ export default function PrepareSwapPage({
const rpcPrefs = useSelector(getRpcPrefsForCurrentProvider, shallowEqual);
const tokenList = useSelector(getTokenList, isEqual);
const quotes = useSelector(getQuotes, isEqual);
const usedQuote = useSelector(getUsedQuote, isEqual)
const latestAddedTokenTo = useSelector(getLatestAddedTokenTo, isEqual);
const numberOfQuotes = Object.keys(quotes).length;
const areQuotesPresent = numberOfQuotes > 0;
const areQuotesPresent =
numberOfQuotes > 0 &&
Object.keys(quotes).filter((quote) => !isEmpty(quote)).length > 0 &&
usedQuote;
console.log({
test1: numberOfQuotes > 0,
test2: Object.keys(quotes).filter((quote) => !isEmpty(quote)).length > 0,
test3: usedQuote,
test4: quotes,
});
const swapsErrorKey = useSelector(getSwapsErrorKey);
const aggregatorMetadata = useSelector(getAggregatorMetadata, shallowEqual);
const transactionSettingsOpened = useSelector(
Expand Down

0 comments on commit 05ab643

Please sign in to comment.