Skip to content

Commit

Permalink
Merge branch 'main' into feat/enable-stx-migration
Browse files Browse the repository at this point in the history
  • Loading branch information
httpJunkie committed Dec 13, 2024
2 parents cf008ed + bb1c77e commit 775fc85
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 32 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.

2 changes: 1 addition & 1 deletion ui/hooks/useTransactionDisplayData.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ export function useTransactionDisplayData(transactionGroup) {
primarySuffix = bridgeTokenDisplayData.sourceTokenSymbol;
primaryDisplayValue = formatAmount(
locale,
new BigNumber(bridgeTokenDisplayData.sourceTokenAmountSent),
new BigNumber(bridgeTokenDisplayData.sourceTokenAmountSent ?? 0),
);
secondaryDisplayValue = bridgeTokenDisplayData.displayCurrencyAmount;
} else {
Expand Down
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 @@ -63,9 +63,7 @@ import {
isHardwareWallet,
getHardwareWalletType,
getIsBridgeChain,
getMetaMetricsId,
getParticipateInMetaMetrics,
getDataCollectionForMarketing,
getIsBridgeEnabled,
} from '../../../selectors';
import {
getSmartTransactionsEnabled,
Expand All @@ -77,7 +75,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 { SmartTransactionsBannerAlert } from '../../confirmations/components/smart-transactions-banner-alert';
import QuotesLoadingAnimation from './quotes-loading-animation';
import ReviewQuote from './review-quote';
Expand All @@ -158,6 +156,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 @@ -177,6 +176,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 @@ -208,7 +208,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 @@ -227,8 +226,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 @@ -1064,41 +1061,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 775fc85

Please sign in to comment.