From c12237fd66d112fb3124f491ced4a39736427760 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Regadas?= Date: Wed, 17 Jul 2024 15:46:09 +0100 Subject: [PATCH] fix: disables "swap and send" for MMI (#25886) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** We need to disable the Swap & Send functionality for MMI, as we don't support the swaps flow in MM. ## **Related issues** Fixes: ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** ### **Before** ### **After** ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --- .../multichain/asset-picker-send.spec.ts | 2 +- .../tests/swap-send/swap-send-erc20.spec.ts | 2 +- .../e2e/tests/swap-send/swap-send-eth.spec.ts | 2 +- .../asset-picker/asset-picker.tsx | 16 +++++++++++- .../send/components/recipient-content.tsx | 26 ++++++++++++++++--- 5 files changed, 41 insertions(+), 7 deletions(-) diff --git a/test/e2e/tests/multichain/asset-picker-send.spec.ts b/test/e2e/tests/multichain/asset-picker-send.spec.ts index 9740cd1c9878..8358e8242f69 100644 --- a/test/e2e/tests/multichain/asset-picker-send.spec.ts +++ b/test/e2e/tests/multichain/asset-picker-send.spec.ts @@ -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 = { diff --git a/test/e2e/tests/swap-send/swap-send-erc20.spec.ts b/test/e2e/tests/swap-send/swap-send-erc20.spec.ts index e8b416b9604e..8fbfe1e45dcb 100644 --- a/test/e2e/tests/swap-send/swap-send-erc20.spec.ts +++ b/test/e2e/tests/swap-send/swap-send-erc20.spec.ts @@ -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( diff --git a/test/e2e/tests/swap-send/swap-send-eth.spec.ts b/test/e2e/tests/swap-send/swap-send-eth.spec.ts index e4be22ae1fa3..a0398094ac4e 100644 --- a/test/e2e/tests/swap-send/swap-send-eth.spec.ts +++ b/test/e2e/tests/swap-send/swap-send-eth.spec.ts @@ -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( diff --git a/ui/components/multichain/asset-picker-amount/asset-picker/asset-picker.tsx b/ui/components/multichain/asset-picker-amount/asset-picker/asset-picker.tsx index 5cf53d522d98..85115498a1a7 100644 --- a/ui/components/multichain/asset-picker-amount/asset-picker/asset-picker.tsx +++ b/ui/components/multichain/asset-picker-amount/asset-picker/asset-picker.tsx @@ -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, @@ -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); @@ -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 */} @@ -162,7 +176,7 @@ export function AssetPicker({ marginInlineStart: 0, display: isDisabled ? Display.None : Display.InlineBlock, }} - title={isDisabled ? t('swapTokenNotAvailable') : undefined} + title={handleAssetPickerTitle()} > { 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);