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

chore: replace portfolio links to bridge with native bridge exp #29175

Merged
merged 1 commit into from
Dec 13, 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
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
Loading