Skip to content

Commit

Permalink
Cherry pick: Remove unnecessary redirection / code from Swaps, update…
Browse files Browse the repository at this point in the history
… content (#21945)

## **Description**
Cherry pick of this code:
#21935
  • Loading branch information
dan437 authored Nov 22, 2023
1 parent 0130693 commit 6d00e61
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 32 deletions.
6 changes: 3 additions & 3 deletions app/_locales/en/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 0 additions & 28 deletions ui/pages/swaps/prepare-swap-page/review-quote.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import {
signAndSendTransactions,
getBackgroundSwapRouteState,
swapsQuoteSelected,
getSwapsQuoteRefreshTime,
getReviewSwapClickedTimestamp,
getSmartTransactionsOptInStatus,
signAndSendSwapsSmartTransaction,
Expand Down Expand Up @@ -68,17 +67,14 @@ import {
} from '../../../selectors';
import { getNativeCurrency, getTokens } from '../../../ducks/metamask/metamask';
import {
safeRefetchQuotes,
setCustomApproveTxData,
setSwapsErrorKey,
showModal,
setSwapsQuotesPollingLimitEnabled,
} from '../../../store/actions';
import {
ASSET_ROUTE,
DEFAULT_ROUTE,
AWAITING_SWAP_ROUTE,
SWAPS_NOTIFICATION_ROUTE,
PREPARE_SWAP_ROUTE,
} from '../../../helpers/constants/routes';
import { CHAIN_IDS } from '../../../../shared/constants/network';
Expand All @@ -98,7 +94,6 @@ import {
} from '../swaps.util';
import { useTokenTracker } from '../../../hooks/useTokenTracker';
import {
QUOTES_EXPIRED_ERROR,
SLIPPAGE_HIGH_ERROR,
SLIPPAGE_LOW_ERROR,
MAX_ALLOWED_SLIPPAGE,
Expand Down Expand Up @@ -157,7 +152,6 @@ export default function ReviewQuote({ setReceiveToAmount }) {
const t = useContext(I18nContext);
const trackEvent = useContext(MetaMetricsContext);

const [dispatchedSafeRefetch, setDispatchedSafeRefetch] = useState(false);
const [submitClicked, setSubmitClicked] = useState(false);
const [selectQuotePopoverShown, setSelectQuotePopoverShown] = useState(false);
const [warningHidden] = useState(false); // TODO: Check when to use setWarningHidden
Expand Down Expand Up @@ -215,7 +209,6 @@ export default function ReviewQuote({ setReceiveToAmount }) {
const topQuote = useSelector(getTopQuote, isEqual);
const usedQuote = selectedQuote || topQuote;
const tradeValue = usedQuote?.trade?.value ?? '0x0';
const swapsQuoteRefreshTime = useSelector(getSwapsQuoteRefreshTime);
const defaultSwapsToken = useSelector(getSwapsDefaultToken, isEqual);
const chainId = useSelector(getCurrentChainId);
const nativeCurrencySymbol = useSelector(getNativeCurrency);
Expand Down Expand Up @@ -558,27 +551,6 @@ export default function ReviewQuote({ setReceiveToAmount }) {
balanceError,
]);

useEffect(() => {
const currentTime = Date.now();
const timeSinceLastFetched = currentTime - quotesLastFetched;
if (
timeSinceLastFetched > swapsQuoteRefreshTime &&
!dispatchedSafeRefetch
) {
setDispatchedSafeRefetch(true);
dispatch(safeRefetchQuotes());
} else if (timeSinceLastFetched > swapsQuoteRefreshTime) {
dispatch(setSwapsErrorKey(QUOTES_EXPIRED_ERROR));
history.push(SWAPS_NOTIFICATION_ROUTE);
}
}, [
quotesLastFetched,
dispatchedSafeRefetch,
dispatch,
history,
swapsQuoteRefreshTime,
]);

useEffect(() => {
if (!originalApproveAmount && approveAmount) {
setOriginalApproveAmount(approveAmount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export default function SmartTransactionsPopover({
onClick={onStartSwapping}
width={BlockSize.Full}
>
{t('startSwapping')}
{t('enableSmartSwaps')}
</Button>
<Button
type="link"
Expand Down

0 comments on commit 6d00e61

Please sign in to comment.