Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: disables "swap and send" for MMI #25886

Merged
merged 5 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/e2e/tests/multichain/asset-picker-send.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
import { Driver } from '../../webdriver/driver';
import { RECIPIENT_ADDRESS_MOCK } from '../simulation-details/types';

describe('AssetPickerSendFlow', function () {
describe('AssetPickerSendFlow @no-mmi', function () {
const chainId = CHAIN_IDS.MAINNET;

const fixtures = {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/tests/swap-send/swap-send-erc20.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { SWAP_SEND_QUOTES_RESPONSE_TST_ETH } from './mocks/erc20-data';

const RECIPIENT_ADDRESS = '0xc427D562164062a23a5cFf596A4a3208e72Acd28';

describe('Swap-Send ERC20', function () {
describe('Swap-Send ERC20 @no-mmi', function () {
describe('to non-contract address with data that matches swap data signature', function (this: Suite) {
it('submits a transaction successfully', async function () {
await withFixtures(
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/tests/swap-send/swap-send-eth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {

const RECIPIENT_ADDRESS = '0xc427D562164062a23a5cFf596A4a3208e72Acd28';

describe('Swap-Send ETH', function () {
describe('Swap-Send ETH @no-mmi', function () {
describe('to non-contract address with data that matches swap data signature', function (this: Suite) {
it('submits a transaction successfully', async function () {
await withFixtures(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ import {
import Tooltip from '../../../ui/tooltip';
import { LARGE_SYMBOL_LENGTH } from '../constants';
import { getAssetImageURL } from '../../../../helpers/utils/util';
///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask)
import { useI18nContext } from '../../../../hooks/useI18nContext';
///: END:ONLY_INCLUDE_IF
import { MetaMetricsContext } from '../../../../contexts/metametrics';
import {
MetaMetricsEventCategory,
Expand Down Expand Up @@ -66,7 +68,9 @@ export function AssetPicker({
sendingAsset,
isDisabled = false,
}: AssetPickerProps) {
///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask)
const t = useI18nContext();
///: END:ONLY_INCLUDE_IF
const trackEvent = useContext(MetaMetricsContext);
const sendAnalytics = useSelector(getSendAnalyticProperties);

Expand Down Expand Up @@ -119,6 +123,16 @@ export function AssetPicker({
const currentNetwork = useSelector(getCurrentNetwork);
const testNetworkBackgroundColor = useSelector(getTestNetworkBackgroundColor);

const handleAssetPickerTitle = (): string | undefined => {
///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask)
if (isDisabled) {
return t('swapTokenNotAvailable');
}
///: END:ONLY_INCLUDE_IF

return undefined;
};

return (
<>
{/* This is the Modal that ask to choose token to send */}
Expand Down Expand Up @@ -162,7 +176,7 @@ export function AssetPicker({
marginInlineStart: 0,
display: isDisabled ? Display.None : Display.InlineBlock,
}}
title={isDisabled ? t('swapTokenNotAvailable') : undefined}
title={handleAssetPickerTitle()}
>
<Box display={Display.Flex} alignItems={AlignItems.center} gap={3}>
<BadgeWrapper
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import React, { useCallback, useMemo, useRef } from 'react';
import React, {
useCallback,
///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask)
useMemo,
///: END:ONLY_INCLUDE_IF
useRef,
} from 'react';
import { useDispatch, useSelector } from 'react-redux';
import {
BannerAlert,
Expand All @@ -11,20 +17,25 @@ import {
acknowledgeRecipientWarning,
getBestQuote,
getCurrentDraftTransaction,
///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask)
getIsSwapAndSendDisabledForNetwork,
getSendAsset,
getSwapsBlockedTokens,
///: END:ONLY_INCLUDE_IF
getSendAsset,
} from '../../../../../ducks/send';
import { AssetType } from '../../../../../../shared/constants/transaction';
import { CONTRACT_ADDRESS_LINK } from '../../../../../helpers/constants/common';
import { Display } from '../../../../../helpers/constants/design-system';
import { useI18nContext } from '../../../../../hooks/useI18nContext';
import { AssetPickerAmount } from '../../..';
import { decimalToHex } from '../../../../../../shared/modules/conversion.utils';
///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask)
import {
getIsSwapsChain,
getUseExternalServices,
} from '../../../../../selectors';
///: END:ONLY_INCLUDE_IF

import type { Quote } from '../../../../../ducks/send/swap-and-send-utils';
import { isEqualCaseInsensitive } from '../../../../../../shared/modules/string-utils';
import { SendHexData, SendPageRow, QuoteCard } from '.';
Expand All @@ -45,6 +56,13 @@ export const SendPageRecipientContent = ({
isSwapQuoteLoading,
} = useSelector(getCurrentDraftTransaction);

let isSwapAllowed;

///: BEGIN:ONLY_INCLUDE_IF(build-mmi)
isSwapAllowed = false;
///: END:ONLY_INCLUDE_IF

///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask)
const isBasicFunctionality = useSelector(getUseExternalServices);
const isSwapsChain = useSelector(getIsSwapsChain);
const isSwapAndSendDisabledForNetwork = useSelector(
Expand All @@ -54,12 +72,14 @@ export const SendPageRecipientContent = ({
const memoizedSwapsBlockedTokens = useMemo(() => {
return new Set(swapsBlockedTokens);
}, [swapsBlockedTokens]);
const isSwapAllowed =

isSwapAllowed =
isSwapsChain &&
!isSwapAndSendDisabledForNetwork &&
[AssetType.token, AssetType.native].includes(sendAsset.type) &&
isBasicFunctionality &&
!memoizedSwapsBlockedTokens.has(sendAsset.details?.address?.toLowerCase());
///: END:ONLY_INCLUDE_IF

const bestQuote: Quote = useSelector(getBestQuote);

Expand Down
Loading