Skip to content

Commit

Permalink
chore: replace portfolio links to bridge with native bridge exp (#29175)
Browse files Browse the repository at this point in the history
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/29175?quickstart=1)

This PR replaces a link in Swaps to the Portfolio Bridge with a link to
the native Bridge experience.

## **Related issues**

Fixes:

## **Manual testing steps**

1. Go to Swaps
2. Click on the Bridge link
3. Get directed to native Bridge exp

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->


https://github.com/user-attachments/assets/6f27cefd-d43b-4872-a523-5b2d868ea09c



## **Pre-merge author checklist**

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] 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
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.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.
  • Loading branch information
infiniteflower authored Dec 13, 2024
1 parent b7c2198 commit bb1c77e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 31 deletions.
3 changes: 3 additions & 0 deletions app/_locales/en/messages.json

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

40 changes: 9 additions & 31 deletions ui/pages/swaps/prepare-swap-page/prepare-swap-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ import {
isHardwareWallet,
getHardwareWalletType,
getIsBridgeChain,
getMetaMetricsId,
getParticipateInMetaMetrics,
getDataCollectionForMarketing,
getIsBridgeEnabled,
} from '../../../selectors';
import {
getSmartTransactionsEnabled,
Expand All @@ -78,7 +76,6 @@ import {
hexToDecimal,
} from '../../../../shared/modules/conversion.utils';
import { getURLHostName } from '../../../helpers/utils/util';
import { getPortfolioUrl } from '../../../helpers/utils/portfolio';
import { usePrevious } from '../../../hooks/usePrevious';
import { useTokenTracker } from '../../../hooks/useTokenTracker';
import { useTokenFiatAmount } from '../../../hooks/useTokenFiatAmount';
Expand Down Expand Up @@ -143,6 +140,7 @@ import SwapsFooter from '../swaps-footer';
import SelectedToken from '../selected-token/selected-token';
import ListWithSearch from '../list-with-search/list-with-search';
import { CHAIN_IDS } from '../../../../shared/constants/network';
import useBridging from '../../../hooks/bridge/useBridging';
import QuotesLoadingAnimation from './quotes-loading-animation';
import ReviewQuote from './review-quote';

Expand All @@ -157,6 +155,7 @@ export default function PrepareSwapPage({
const dispatch = useDispatch();
const history = useHistory();
const trackEvent = useContext(MetaMetricsContext);
const { openBridgeExperience } = useBridging();

const [fetchedTokenExchangeRate, setFetchedTokenExchangeRate] =
useState(undefined);
Expand All @@ -176,6 +175,7 @@ export default function PrepareSwapPage({
const [prefetchingQuotes, setPrefetchingQuotes] = useState(false);
const [rotateSwitchTokens, setRotateSwitchTokens] = useState(false);

const isBridgeSupported = useSelector(getIsBridgeEnabled);
const isFeatureFlagLoaded = useSelector(getIsFeatureFlagLoaded);
const balanceError = useSelector(getBalanceError);
const fetchParams = useSelector(getFetchParams, isEqual);
Expand Down Expand Up @@ -207,7 +207,6 @@ export default function PrepareSwapPage({
? Object.keys(aggregatorMetadata).length
: 0;
const isBridgeChain = useSelector(getIsBridgeChain);
const metaMetricsId = useSelector(getMetaMetricsId);

const tokenConversionRates = useSelector(getTokenExchangeRates, isEqual);
const conversionRate = useSelector(getConversionRate);
Expand All @@ -226,8 +225,6 @@ export default function PrepareSwapPage({
const currentCurrency = useSelector(getCurrentCurrency);
const fetchingQuotes = useSelector(getFetchingQuotes);
const loadingComplete = !fetchingQuotes && areQuotesPresent;
const isMetaMetricsEnabled = useSelector(getParticipateInMetaMetrics);
const isMarketingEnabled = useSelector(getDataCollectionForMarketing);

const fetchParamsFromToken = isSwapsDefaultTokenAddress(
sourceTokenInfo?.address,
Expand Down Expand Up @@ -1060,41 +1057,22 @@ export default function PrepareSwapPage({
</div>
{showCrossChainSwapsLink && (
<ButtonLink
endIconName={IconName.Export}
endIconName={isBridgeSupported ? undefined : IconName.Export}
endIconProps={{
size: IconSize.Xs,
}}
variant={TextVariant.bodySm}
marginTop={2}
fontWeight={FontWeight.Normal}
onClick={() => {
const portfolioUrl = getPortfolioUrl(
'bridge',
'ext_bridge_prepare_swap_link',
metaMetricsId,
isMetaMetricsEnabled,
isMarketingEnabled,
);

global.platform.openTab({
url: `${portfolioUrl}&token=${fromTokenAddress}`,
});

trackEvent({
category: MetaMetricsEventCategory.Swaps,
event: MetaMetricsEventName.BridgeLinkClicked,
properties: {
location: 'Swaps',
text: 'Swap across networks with MetaMask Portfolio',
chain_id: chainId,
token_symbol: fromTokenSymbol,
},
});
openBridgeExperience('Swaps', fromToken);
}}
target="_blank"
data-testid="prepare-swap-page-cross-chain-swaps-link"
>
{t('crossChainSwapsLink')}
{isBridgeSupported
? t('crossChainSwapsLinkNative')
: t('crossChainSwapsLink')}
</ButtonLink>
)}
{!showReviewQuote && toTokenIsNotDefault && occurrences < 2 && (
Expand Down

0 comments on commit bb1c77e

Please sign in to comment.