Skip to content

Commit 2308a0f

Browse files
authored
Merge branch 'main' into chore/update-core-assets-87.1.1
2 parents 7ba7bb3 + 6f1c0f2 commit 2308a0f

File tree

96 files changed

+1445
-5450
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+1445
-5450
lines changed

app/components/Views/confirmations/components/activity/transaction-details-bridge-fee-row/transaction-details-bridge-fee-row.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { TransactionDetailsBridgeFeeRow } from './transaction-details-bridge-fee
66

77
jest.mock('../../../hooks/activity/useTransactionDetails');
88

9-
const BRIDGE_FEE_FIAT_MOCK = '$123.45';
9+
const BRIDGE_FEE_FIAT_MOCK = '123.45';
1010

1111
function render() {
1212
return renderWithProvider(<TransactionDetailsBridgeFeeRow />, {});
@@ -29,7 +29,7 @@ describe('TransactionDetailsBridgeFeeRow', () => {
2929

3030
it('renders bridge fee fiat', () => {
3131
const { getByText } = render();
32-
expect(getByText(BRIDGE_FEE_FIAT_MOCK)).toBeDefined();
32+
expect(getByText(`$${BRIDGE_FEE_FIAT_MOCK}`)).toBeDefined();
3333
});
3434

3535
it('renders nothing if no bridge fee fiat', () => {
@@ -41,6 +41,6 @@ describe('TransactionDetailsBridgeFeeRow', () => {
4141

4242
const { queryByText } = render();
4343

44-
expect(queryByText(BRIDGE_FEE_FIAT_MOCK)).toBeNull();
44+
expect(queryByText(`$${BRIDGE_FEE_FIAT_MOCK}`)).toBeNull();
4545
});
4646
});
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
1-
import React from 'react';
1+
import React, { useMemo } from 'react';
22
import { TransactionDetailsRow } from '../transaction-details-row/transaction-details-row';
33
import Text from '../../../../../../component-library/components/Texts/Text';
44
import { useTransactionDetails } from '../../../hooks/activity/useTransactionDetails';
55
import { strings } from '../../../../../../../locales/i18n';
6+
import useFiatFormatter from '../../../../../UI/SimulationDetails/FiatDisplay/useFiatFormatter';
7+
import { BigNumber } from 'bignumber.js';
68

79
export function TransactionDetailsBridgeFeeRow() {
10+
const formatFiat = useFiatFormatter({ currency: 'usd' });
811
const { transactionMeta } = useTransactionDetails();
912
const { metamaskPay } = transactionMeta;
1013
const { bridgeFeeFiat } = metamaskPay || {};
1114

15+
const bridgeFeeFiatFormatted = useMemo(
16+
() => formatFiat(new BigNumber(bridgeFeeFiat ?? 0)),
17+
[bridgeFeeFiat, formatFiat],
18+
);
19+
1220
if (!bridgeFeeFiat) {
1321
return null;
1422
}
@@ -17,7 +25,7 @@ export function TransactionDetailsBridgeFeeRow() {
1725
<TransactionDetailsRow
1826
label={strings('transaction_details.label.bridge_fee')}
1927
>
20-
<Text>{bridgeFeeFiat}</Text>
28+
<Text>{bridgeFeeFiatFormatted}</Text>
2129
</TransactionDetailsRow>
2230
);
2331
}

app/components/Views/confirmations/components/activity/transaction-details-hero/transaction-details-hero.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe('TransactionDetailsHero', () => {
5757

5858
it('renders human amount', () => {
5959
const { getByText } = render();
60-
expect(getByText('$123.456')).toBeDefined();
60+
expect(getByText('$123.46')).toBeDefined();
6161
});
6262

6363
it('renders human amount if token transfer is nested call', () => {
@@ -80,7 +80,7 @@ describe('TransactionDetailsHero', () => {
8080

8181
const { getByText } = render();
8282

83-
expect(getByText('$123.456')).toBeDefined();
83+
expect(getByText('$123.46')).toBeDefined();
8484
});
8585

8686
it('renders nothing if no to', () => {

app/components/Views/confirmations/components/activity/transaction-details-hero/transaction-details-hero.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,16 @@ import { calcTokenAmount } from '../../../../../../util/transactions';
1616
import { useStyles } from '../../../../../../component-library/hooks';
1717
import styleSheet from './transaction-details-hero.styles';
1818
import { getTokenTransferData } from '../../../utils/transaction-pay';
19+
import useFiatFormatter from '../../../../../UI/SimulationDetails/FiatDisplay/useFiatFormatter';
20+
import { PERPS_CURRENCY } from '../../../constants/perps';
1921

2022
const SUPPORTED_TYPES = [
2123
TransactionType.perpsDeposit,
2224
TransactionType.predictDeposit,
2325
];
2426

2527
export function TransactionDetailsHero() {
28+
const formatFiat = useFiatFormatter({ currency: PERPS_CURRENCY });
2629
const { styles } = useStyles(styleSheet, {});
2730
const { transactionMeta } = useTransactionDetails();
2831
const { chainId } = transactionMeta;
@@ -52,7 +55,7 @@ export function TransactionDetailsHero() {
5255
return null;
5356
}
5457

55-
const amountHuman = calcTokenAmount(amount, decimals).toString(10);
58+
const formattedAmount = formatFiat(calcTokenAmount(amount, decimals));
5659

5760
return (
5861
<Box
@@ -61,7 +64,7 @@ export function TransactionDetailsHero() {
6164
gap={12}
6265
style={styles.container}
6366
>
64-
<Text variant={TextVariant.DisplayLG}>${amountHuman}</Text>
67+
<Text variant={TextVariant.DisplayLG}>{formattedAmount}</Text>
6568
</Box>
6669
);
6770
}

app/components/Views/confirmations/components/activity/transaction-details-network-fee-row/transaction-details-network-fee-row.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { TransactionDetailsNetworkFeeRow } from './transaction-details-network-f
66

77
jest.mock('../../../hooks/activity/useTransactionDetails');
88

9-
const NETWORK_FEE_FIAT_MOCK = '$123.45';
9+
const NETWORK_FEE_FIAT_MOCK = '123.45';
1010

1111
function render() {
1212
return renderWithProvider(<TransactionDetailsNetworkFeeRow />, {});
@@ -29,7 +29,7 @@ describe('TransactionDetailsNetworkFeeRow', () => {
2929

3030
it('renders network fee fiat', () => {
3131
const { getByText } = render();
32-
expect(getByText(NETWORK_FEE_FIAT_MOCK)).toBeDefined();
32+
expect(getByText(`$${NETWORK_FEE_FIAT_MOCK}`)).toBeDefined();
3333
});
3434

3535
it('renders nothing if no network fee fiat', () => {
@@ -41,6 +41,6 @@ describe('TransactionDetailsNetworkFeeRow', () => {
4141

4242
const { queryByText } = render();
4343

44-
expect(queryByText(NETWORK_FEE_FIAT_MOCK)).toBeNull();
44+
expect(queryByText(`$${NETWORK_FEE_FIAT_MOCK}`)).toBeNull();
4545
});
4646
});
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
1-
import React from 'react';
1+
import React, { useMemo } from 'react';
22
import { TransactionDetailsRow } from '../transaction-details-row/transaction-details-row';
33
import Text from '../../../../../../component-library/components/Texts/Text';
44
import { useTransactionDetails } from '../../../hooks/activity/useTransactionDetails';
55
import { strings } from '../../../../../../../locales/i18n';
6+
import useFiatFormatter from '../../../../../UI/SimulationDetails/FiatDisplay/useFiatFormatter';
7+
import { BigNumber } from 'bignumber.js';
68

79
export function TransactionDetailsNetworkFeeRow() {
10+
const formatFiat = useFiatFormatter({ currency: 'usd' });
811
const { transactionMeta } = useTransactionDetails();
912
const { metamaskPay } = transactionMeta;
1013
const { networkFeeFiat } = metamaskPay || {};
1114

15+
const networkFeeFiatFormatted = useMemo(
16+
() => formatFiat(new BigNumber(networkFeeFiat ?? 0)),
17+
[formatFiat, networkFeeFiat],
18+
);
19+
1220
if (!networkFeeFiat) {
1321
return null;
1422
}
@@ -17,7 +25,7 @@ export function TransactionDetailsNetworkFeeRow() {
1725
<TransactionDetailsRow
1826
label={strings('transaction_details.label.network_fee')}
1927
>
20-
<Text>{networkFeeFiat}</Text>
28+
<Text>{networkFeeFiatFormatted}</Text>
2129
</TransactionDetailsRow>
2230
);
2331
}

app/components/Views/confirmations/components/activity/transaction-details-summary/transaction-details-summary.test.tsx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { BridgeHistoryItem } from '@metamask/bridge-status-controller';
1818
import { useNetworkName } from '../../../hooks/useNetworkName';
1919
import { Hex } from '@metamask/utils';
2020
import { useTokenAmount } from '../../../hooks/useTokenAmount';
21+
import { useTokenWithBalance } from '../../../hooks/tokens/useTokenWithBalance';
2122

2223
const mockNavigate = jest.fn();
2324

@@ -27,6 +28,7 @@ jest.mock('../../../../../UI/Bridge/hooks/useMultichainBlockExplorerTxUrl');
2728
jest.mock('../../../../../../selectors/bridgeStatusController');
2829
jest.mock('../../../hooks/useNetworkName');
2930
jest.mock('../../../hooks/useTokenAmount');
31+
jest.mock('../../../hooks/tokens/useTokenWithBalance');
3032

3133
jest.mock('@react-navigation/native', () => ({
3234
...jest.requireActual('@react-navigation/native'),
@@ -79,6 +81,7 @@ describe('TransactionDetailsSummary', () => {
7981
const useBridgeTxHistoryDataMock = jest.mocked(useBridgeTxHistoryData);
8082
const useNetworkNameMock = jest.mocked(useNetworkName);
8183
const useTokenAmountMock = jest.mocked(useTokenAmount);
84+
const useTokenWithBalanceMock = jest.mocked(useTokenWithBalance);
8285

8386
const useMultichainBlockExplorerTxUrlMock = jest.mocked(
8487
useMultichainBlockExplorerTxUrl,
@@ -147,6 +150,10 @@ describe('TransactionDetailsSummary', () => {
147150
});
148151

149152
useTokenAmountMock.mockReturnValue({} as ReturnType<typeof useTokenAmount>);
153+
154+
useTokenWithBalanceMock.mockReturnValue(
155+
{} as ReturnType<typeof useTokenWithBalance>,
156+
);
150157
});
151158

152159
it('renders perps deposit line title', () => {
@@ -157,7 +164,12 @@ describe('TransactionDetailsSummary', () => {
157164
});
158165

159166
expect(
160-
getByText(strings('transaction_details.summary_title.perps_deposit')),
167+
getByText(
168+
strings('transaction_details.summary_title.bridge_receive', {
169+
targetSymbol: 'USDC',
170+
targetChain: 'Hyperliquid',
171+
}),
172+
),
161173
).toBeDefined();
162174
});
163175

@@ -390,7 +402,7 @@ describe('TransactionDetailsSummary', () => {
390402
{
391403
...TRANSACTION_META_MOCK,
392404
id: REQUIRED_TRANSACTION_ID_MOCK,
393-
type: TransactionType.perpsDeposit,
405+
type: TransactionType.predictDeposit,
394406
},
395407
{
396408
...TRANSACTION_META_MOCK,
@@ -401,7 +413,7 @@ describe('TransactionDetailsSummary', () => {
401413
});
402414

403415
expect(
404-
getByText(strings('transaction_details.summary_title.perps_deposit')),
416+
getByText(strings('transaction_details.summary_title.predict_deposit')),
405417
).toBeDefined();
406418

407419
expect(
@@ -423,7 +435,7 @@ describe('TransactionDetailsSummary', () => {
423435
...TRANSACTION_META_MOCK,
424436
id: REQUIRED_TRANSACTION_ID_MOCK,
425437
batchId: BATCH_ID_MOCK,
426-
type: TransactionType.perpsDeposit,
438+
type: TransactionType.predictDeposit,
427439
},
428440
{
429441
...TRANSACTION_META_MOCK,
@@ -435,7 +447,7 @@ describe('TransactionDetailsSummary', () => {
435447
});
436448

437449
expect(
438-
getByText(strings('transaction_details.summary_title.perps_deposit')),
450+
getByText(strings('transaction_details.summary_title.predict_deposit')),
439451
).toBeDefined();
440452

441453
expect(

0 commit comments

Comments
 (0)