Skip to content

Commit 531643c

Browse files
chore: xchain tx details use short names (#29413)
<!-- 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/29413?quickstart=1) This PR uses short names for networks to improve spacing. ## **Related issues** Fixes: ## **Manual testing steps** 1. Do a bridge tx 2. Click on bridge tx in Activity 3. Observe shorter names ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ![Screenshot 2024-12-20 at 5 19 46 PM](https://github.com/user-attachments/assets/2fb314ba-a926-4992-91c1-97cda321fae3) ![Screenshot 2024-12-20 at 5 19 54 PM](https://github.com/user-attachments/assets/47eea644-a60f-4a87-b7dd-4fd17ad2609b) ### **After** <!-- [screenshots/recordings] --> ![Screenshot 2024-12-20 at 5 20 13 PM](https://github.com/user-attachments/assets/714ffbd6-caa4-4e0f-8e31-248f72e8b6af) ![Screenshot 2024-12-20 at 5 20 20 PM](https://github.com/user-attachments/assets/54dfc06c-c53d-4f1d-86d7-e73335b2f1d9) ## **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.
1 parent de10c46 commit 531643c

File tree

4 files changed

+46
-14
lines changed

4 files changed

+46
-14
lines changed

ui/hooks/useTransactionDisplayData.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import { selectBridgeHistoryForAccount } from '../ducks/bridge-status/selectors'
4040
import { useBridgeTokenDisplayData } from '../pages/bridge/hooks/useBridgeTokenDisplayData';
4141
import { formatAmount } from '../pages/confirmations/components/simulation-details/formatAmount';
4242
import { getIntlLocale } from '../ducks/locale/locale';
43+
import { NETWORK_TO_SHORT_NETWORK_NAME_MAP } from '../../shared/constants/bridge';
4344
import { useI18nContext } from './useI18nContext';
4445
import { useTokenFiatAmount } from './useTokenFiatAmount';
4546
import { useUserPreferencedCurrency } from './useUserPreferencedCurrency';
@@ -122,7 +123,7 @@ export function useTransactionDisplayData(transactionGroup) {
122123
bridgeHistoryItem,
123124
srcTxMeta: transactionGroup.initialTransaction,
124125
});
125-
const destChainName = destNetwork?.name;
126+
const destChainName = NETWORK_TO_SHORT_NETWORK_NAME_MAP[destNetwork?.chainId];
126127

127128
const { initialTransaction, primaryTransaction } = transactionGroup;
128129
// initialTransaction contains the data we need to derive the primary purpose of this transaction group

ui/pages/bridge/transaction-details/bridge-step-description.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ import {
2020
TextColor,
2121
} from '../../../helpers/constants/design-system';
2222
import { useI18nContext } from '../../../hooks/useI18nContext';
23+
import {
24+
AllowedBridgeChainIds,
25+
NETWORK_TO_SHORT_NETWORK_NAME_MAP,
26+
} from '../../../../shared/constants/bridge';
2327

2428
type I18nFunction = (
2529
key: string,
@@ -49,14 +53,19 @@ const getBridgeActionText = (
4953
? networkConfigurationsByChainId[hexDestChainId]
5054
: undefined;
5155

56+
const destChainName =
57+
NETWORK_TO_SHORT_NETWORK_NAME_MAP[
58+
destNetworkConfiguration?.chainId as AllowedBridgeChainIds
59+
];
60+
5261
return stepStatus === StatusTypes.COMPLETE
5362
? t('bridgeStepActionBridgeComplete', [
5463
step.destAsset.symbol,
55-
destNetworkConfiguration?.name,
64+
destChainName,
5665
])
5766
: t('bridgeStepActionBridgePending', [
5867
step.destAsset.symbol,
59-
destNetworkConfiguration?.name,
68+
destChainName,
6069
]);
6170
};
6271

ui/pages/bridge/transaction-details/transaction-detail-row.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
AlignItems,
88
TextAlign,
99
TextVariant,
10+
BlockSize,
1011
} from '../../../helpers/constants/design-system';
1112

1213
type TransactionDetailRowProps = {
@@ -20,21 +21,24 @@ export default function TransactionDetailRow({
2021
}: TransactionDetailRowProps) {
2122
return (
2223
<Box display={Display.Flex} justifyContent={JustifyContent.spaceBetween}>
23-
<Box style={{ maxWidth: '40%' }} paddingRight={1}>
24-
<Text variant={TextVariant.bodyMd}>{title}</Text>
25-
</Box>
26-
<Box
24+
<Text
25+
width={BlockSize.OneFourth}
26+
paddingRight={1}
27+
variant={TextVariant.bodyMd}
28+
>
29+
{title}
30+
</Text>
31+
<Text
2732
display={Display.Flex}
33+
width={BlockSize.ThreeFourths}
2834
flexDirection={FlexDirection.Column}
2935
alignItems={AlignItems.flexEnd}
3036
textAlign={TextAlign.Right}
3137
paddingLeft={1}
32-
style={{
33-
maxWidth: '60%',
34-
}}
38+
variant={TextVariant.bodyMd}
3539
>
36-
<Text variant={TextVariant.bodyMd}>{value}</Text>
37-
</Box>
40+
{value}
41+
</Text>
3842
</Box>
3943
);
4044
}

ui/pages/bridge/transaction-details/transaction-details.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ import {
3939
AlignItems,
4040
Display,
4141
FlexDirection,
42+
FlexWrap,
43+
JustifyContent,
4244
TextColor,
4345
TextTransform,
4446
} from '../../../helpers/constants/design-system';
@@ -57,6 +59,10 @@ import { formatAmount } from '../../confirmations/components/simulation-details/
5759
import { getIntlLocale } from '../../../ducks/locale/locale';
5860
import { TransactionGroup } from '../../../hooks/bridge/useBridgeTxHistoryData';
5961
import TransactionActivityLog from '../../../components/app/transaction-activity-log';
62+
import {
63+
NETWORK_TO_SHORT_NETWORK_NAME_MAP,
64+
AllowedBridgeChainIds,
65+
} from '../../../../shared/constants/bridge';
6066
import TransactionDetailRow from './transaction-detail-row';
6167
import BridgeExplorerLinks from './bridge-explorer-links';
6268
import BridgeStepList from './bridge-step-list';
@@ -207,8 +213,14 @@ const CrossChainSwapTxDetails = () => {
207213
]
208214
: undefined;
209215

210-
const srcNetworkName = srcNetwork?.name;
211-
const destNetworkName = destNetwork?.name;
216+
const srcNetworkName =
217+
NETWORK_TO_SHORT_NETWORK_NAME_MAP[
218+
srcNetwork?.chainId as AllowedBridgeChainIds
219+
];
220+
const destNetworkName =
221+
NETWORK_TO_SHORT_NETWORK_NAME_MAP[
222+
destNetwork?.chainId as AllowedBridgeChainIds
223+
];
212224

213225
const data = srcChainTxMeta
214226
? getTransactionBreakdownData({
@@ -354,6 +366,8 @@ const CrossChainSwapTxDetails = () => {
354366
display={Display.Flex}
355367
gap={1}
356368
alignItems={AlignItems.center}
369+
flexWrap={FlexWrap.Wrap}
370+
justifyContent={JustifyContent.flexEnd}
357371
>
358372
{srcNetworkIconName}
359373
<Icon name={IconName.Arrow2Right} size={IconSize.Sm} />
@@ -385,6 +399,8 @@ const CrossChainSwapTxDetails = () => {
385399
display={Display.Flex}
386400
gap={1}
387401
alignItems={AlignItems.center}
402+
flexWrap={FlexWrap.Wrap}
403+
justifyContent={JustifyContent.flexEnd}
388404
>
389405
{t('bridgeTxDetailsTokenAmountOnChain', [
390406
bridgeAmountSent,
@@ -401,6 +417,8 @@ const CrossChainSwapTxDetails = () => {
401417
display={Display.Flex}
402418
gap={1}
403419
alignItems={AlignItems.center}
420+
flexWrap={FlexWrap.Wrap}
421+
justifyContent={JustifyContent.flexEnd}
404422
>
405423
{t('bridgeTxDetailsTokenAmountOnChain', [
406424
bridgeAmountReceived,

0 commit comments

Comments
 (0)