Skip to content

Commit 53b96ef

Browse files
authored
Merge branch 'main' into price-alerts-price-percent
2 parents bd02f31 + d95691f commit 53b96ef

62 files changed

Lines changed: 2771 additions & 2064 deletions

File tree

Some content is hidden

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

.eslintrc.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,12 @@ const utilNumberImportBurndownFiles = [
9393
'app/components/UI/Stake/hooks/useBalance.ts',
9494
'app/components/UI/Tokens/util/deriveBalanceFromAssetMarketDetails.test.ts',
9595
'app/components/UI/Tokens/util/deriveBalanceFromAssetMarketDetails.ts',
96-
'app/components/UI/TransactionElement/utils-gas.js',
97-
'app/components/UI/TransactionElement/utils.js',
9896
'app/components/UI/UrlAutocomplete/Result.tsx',
9997
'app/components/Views/GasEducationCarousel/index.js',
10098
'app/components/Views/NetworksManagement/NetworkDetailsView/hooks/useNetworkValidation.ts',
10199
'app/components/Views/SocialLeaderboard/TraderPositionView/components/QuickBuyBottomSheet/useQuickBuyBottomSheet.ts',
102100
'app/components/Views/SocialLeaderboard/TraderPositionView/components/QuickBuyBottomSheet/useQuickBuyQuotes.ts',
103101
'app/components/Views/SocialLeaderboard/utils/formatters.ts',
104-
'app/components/Views/UnifiedTransactionsView/useUnifiedTxActions.test.ts',
105102
'app/components/Views/confirmations/components/gas/max-base-fee-input/max-base-fee-input.tsx',
106103
'app/components/Views/confirmations/components/gas/priority-fee-input/priority-fee-input.tsx',
107104
'app/components/Views/confirmations/components/info/typed-sign-v3v4/simulation/components/native-value-display/native-value-display.tsx',
@@ -133,10 +130,9 @@ const utilNumberImportBurndownFiles = [
133130
// `../number/bigint` (or `./number/bigint` from `app/util/`).
134131
'app/util/confirm-tx.js',
135132
'app/util/conversions.js',
136-
'app/util/confirmation/gas.ts',
133+
137134
'app/util/confirmation/transactions.ts',
138135
'app/util/custom-gas/index.js',
139-
'app/util/networks/index.js',
140136
'app/util/transactions/index.js',
141137
'app/util/transactions/index.test.ts',
142138
];

.github/workflows/run-appium-smoke-tests-android.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,3 +219,27 @@ jobs:
219219
metamask_environment: ${{ inputs.metamask_environment }}
220220
runner_provider: ${{ inputs.runner_provider }}
221221
secrets: inherit
222+
223+
appium-money-android-smoke:
224+
if: >-
225+
${{
226+
!cancelled() &&
227+
(contains(fromJson(inputs.selected_tags), 'ALL') ||
228+
contains(fromJson(inputs.selected_tags), 'SmokeMoney'))
229+
}}
230+
strategy:
231+
matrix:
232+
split: [1]
233+
fail-fast: false
234+
uses: ./.github/workflows/run-appium-e2e-workflow.yml
235+
with:
236+
test-suite-name: appium-money-android-smoke-${{ matrix.split }}
237+
platform: android
238+
test_suite_tag: SmokeMoney
239+
split_number: ${{ matrix.split }}
240+
total_splits: 1
241+
test-timeout-minutes: 60
242+
build_type: ${{ inputs.build_type }}
243+
metamask_environment: ${{ inputs.metamask_environment }}
244+
runner_provider: ${{ inputs.runner_provider }}
245+
secrets: inherit

.github/workflows/run-appium-smoke-tests-ios.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,27 @@ jobs:
198198
metamask_environment: ${{ inputs.metamask_environment || 'e2e' }}
199199
runner_provider: ${{ inputs.runner_provider || 'current' }}
200200
secrets: inherit
201+
202+
appium-money-ios-smoke:
203+
if: >-
204+
${{
205+
!cancelled() &&
206+
(contains(fromJson(inputs.selected_tags || '["ALL"]'), 'ALL') ||
207+
contains(fromJson(inputs.selected_tags || '["ALL"]'), 'SmokeMoney'))
208+
}}
209+
strategy:
210+
matrix:
211+
split: [1]
212+
fail-fast: false
213+
uses: ./.github/workflows/run-appium-e2e-workflow.yml
214+
with:
215+
test-suite-name: appium-money-ios-smoke-${{ matrix.split }}
216+
platform: ios
217+
test_suite_tag: SmokeMoney
218+
split_number: ${{ matrix.split }}
219+
total_splits: 1
220+
test-timeout-minutes: 60
221+
build_type: ${{ inputs.build_type || 'main' }}
222+
metamask_environment: ${{ inputs.metamask_environment || 'e2e' }}
223+
runner_provider: ${{ inputs.runner_provider || 'current' }}
224+
secrets: inherit

app/components/UI/ActionModal/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ const styles = StyleSheet.create({
1414
});
1515

1616
/**
17+
* @deprecated Please update your code to use `BottomSheet` from `@metamask/design-system-react-native`.
18+
* The API may have changed — compare props before migrating.
19+
* @see {@link https://github.com/MetaMask/metamask-design-system/blob/main/packages/design-system-react-native/src/components/BottomSheet/README.md}
20+
* @since @metamask/design-system-react-native@0.11.0
21+
*
1722
* View that renders an action modal
1823
*
1924
* @param {object} props

app/components/UI/Bridge/utils/transaction-history.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@ import { TransactionMeta } from '@metamask/transaction-controller';
1616
import { TRANSACTION_TYPES } from '../../../../util/transactions';
1717
import { calculateTotalGas } from '../../TransactionElement/utils-gas';
1818
import {
19-
renderFromWei,
2019
addCurrencySymbol,
2120
balanceToFiatNumber,
22-
weiToFiatNumber,
23-
weiToFiat,
2421
formatAmountWithThreshold,
2522
} from '../../../../util/number';
23+
import {
24+
renderFromWei,
25+
weiToFiatNumber,
26+
weiToFiat,
27+
} from '../../../../util/number/bigint';
2628
import { Hex } from '@metamask/utils';
2729
import { ethers } from 'ethers';
2830
import { toFormattedAddress } from '../../../../util/address';
@@ -229,7 +231,11 @@ export const decodeSwapsTx = (args: {
229231
sourceAmountFiatNumber,
230232
currentCurrency,
231233
),
232-
summaryFee: weiToFiat(totalGas, conversionRate, currentCurrency),
234+
summaryFee: weiToFiat(
235+
totalGas,
236+
conversionRate,
237+
currentCurrency as Parameters<typeof weiToFiat>[2],
238+
),
233239
summaryTotalAmount: summaryTotalAmountNativeTokenFiat,
234240
summarySecondaryTotalAmount: summaryTotalAmountNativeToken,
235241
};

app/components/UI/Money/Views/MoneyHomeView/MoneyHomeView.test.tsx

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2691,8 +2691,6 @@ describe('MoneyHomeView', () => {
26912691
} as unknown as ReturnType<typeof useMoneyAccountCardLinkage>;
26922692

26932693
// EUR/ETH = 900, USD/ETH = 1000 -> fiat->USD factor is 1000/900 = 10/9.
2694-
// 90 EUR raw fiat converts to exactly 100 USD, proving the conversion (not
2695-
// a pass-through of balanceFiat) drives the rendered value.
26962694
const eurCurrencyRatesState = {
26972695
engine: {
26982696
backgroundState: {
@@ -2716,14 +2714,37 @@ describe('MoneyHomeView', () => {
27162714
);
27172715
});
27182716

2719-
it('converts the primary token raw fiat number from the preferred currency to USD', () => {
2717+
it('converts a non-Money primary token raw fiat number to USD', () => {
27202718
mockSelectIsCardholder.mockReturnValue(true);
27212719
mockUseMoneyAccountCardLinkage.mockReturnValue(linkedCardLinkage);
27222720
mockUseCardHomeData.mockReturnValue({
27232721
...baseCardHomeData,
27242722
primaryToken: {
27252723
balanceFiat: '€90.00',
27262724
rawFiatNumber: 90,
2725+
isMoneyAccountEntry: false,
2726+
} as unknown as ReturnType<
2727+
typeof useMoneyAccountCardLinkage
2728+
>['primaryMoneyAccount'],
2729+
});
2730+
2731+
const { getByTestId } = renderWithProvider(<MoneyHomeView />, {
2732+
state: eurCurrencyRatesState,
2733+
});
2734+
2735+
expect(
2736+
getByTestId(MoneyMetaMaskCardTestIds.MANAGE_BALANCE),
2737+
).toHaveTextContent('$100.00');
2738+
});
2739+
2740+
it('renders the Money Account USD raw fiat number without reconverting it', () => {
2741+
mockSelectIsCardholder.mockReturnValue(true);
2742+
mockUseMoneyAccountCardLinkage.mockReturnValue(linkedCardLinkage);
2743+
mockUseCardHomeData.mockReturnValue({
2744+
...baseCardHomeData,
2745+
primaryToken: {
2746+
balanceFiat: '$100.00',
2747+
rawFiatNumber: 100,
27272748
isMoneyAccountEntry: true,
27282749
} as unknown as ReturnType<
27292750
typeof useMoneyAccountCardLinkage
@@ -2754,15 +2775,13 @@ describe('MoneyHomeView', () => {
27542775
).toHaveTextContent('$0.00');
27552776
});
27562777

2757-
it('falls back to formatted zero when the fiat→USD rate is unavailable', () => {
2758-
// rawFiatNumber is present, but currency rates haven't loaded — must not
2759-
// render an unconverted (wrong-currency) balance.
2778+
it('renders the Money Account USD balance when currency rates are unavailable', () => {
27602779
mockSelectIsCardholder.mockReturnValue(true);
27612780
mockUseMoneyAccountCardLinkage.mockReturnValue(linkedCardLinkage);
27622781
mockUseCardHomeData.mockReturnValue({
27632782
...baseCardHomeData,
27642783
primaryToken: {
2765-
balanceFiat: '90.00',
2784+
balanceFiat: '$90.00',
27662785
rawFiatNumber: 90,
27672786
isMoneyAccountEntry: true,
27682787
} as unknown as ReturnType<
@@ -2774,7 +2793,7 @@ describe('MoneyHomeView', () => {
27742793

27752794
expect(
27762795
getByTestId(MoneyMetaMaskCardTestIds.MANAGE_BALANCE),
2777-
).toHaveTextContent('$0.00');
2796+
).toHaveTextContent('$90.00');
27782797
});
27792798

27802799
it('masks the Card manage balance when privacy mode is on', () => {

app/components/UI/Money/Views/MoneyHomeView/MoneyHomeView.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -660,17 +660,22 @@ const MoneyHomeView = () => {
660660

661661
const { primaryToken: cardPrimaryToken } = useCardHomeData();
662662
const currencyRates = useSelector(selectCurrencyRates);
663-
// The Card pipeline reports balanceFiat in the user's selected currency, but
664-
// we want to show USD fiat values in this view.
663+
// Money Account entries are already valued in USD. Other Card tokens report
664+
// their fiat value in the user's selected currency.
665665
const cardBalanceUsd = useMemo(() => {
666-
const usd = convertSelectedFiatToUsd(
667-
cardPrimaryToken?.rawFiatNumber,
668-
currencyRates,
669-
);
666+
const rawFiat = cardPrimaryToken?.rawFiatNumber;
667+
const usd = cardPrimaryToken?.isMoneyAccountEntry
668+
? rawFiat
669+
: convertSelectedFiatToUsd(rawFiat, currencyRates);
670670
return usd === undefined
671671
? formattedZero
672672
: moneyFormatUsd(new BigNumber(usd));
673-
}, [cardPrimaryToken?.rawFiatNumber, currencyRates, formattedZero]);
673+
}, [
674+
cardPrimaryToken?.isMoneyAccountEntry,
675+
cardPrimaryToken?.rawFiatNumber,
676+
currencyRates,
677+
formattedZero,
678+
]);
674679

675680
const cardState = deriveCardState({
676681
isCardholder,

app/components/UI/Predict/constants/feedConfig.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,10 @@ export const PREDICT_FEED_REGISTRY: Record<PredictFeedId, PredictFeedConfig> = {
227227
createAllFilter({
228228
status: 'open',
229229
order: 'volume24hr',
230-
limit: 5,
230+
// Fetch 10 (not the ~5 shown) so the home Trending section still
231+
// fills its display cap after standalone/staleness filtering, and
232+
// so the "See all" feed loads 10 per infinite-scroll page.
233+
limit: 10,
231234
}),
232235
],
233236
dynamic: {
@@ -236,7 +239,7 @@ export const PREDICT_FEED_REGISTRY: Record<PredictFeedId, PredictFeedConfig> = {
236239
baseParams: {
237240
status: 'open',
238241
order: 'volume24hr',
239-
limit: 5,
242+
limit: 10,
240243
},
241244
},
242245
},

app/components/UI/Predict/views/PredictHome/components/PredictTrendingSection/usePredictTrendingSection.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ describe('usePredictTrendingSection', () => {
4949
expect.objectContaining({
5050
order: 'volume24hr',
5151
status: 'open',
52-
limit: TRENDING_DISPLAY_LIMIT,
52+
// Fetch limit is intentionally larger than the display cap so the
53+
// section fills after filtering; keep it decoupled from
54+
// TRENDING_DISPLAY_LIMIT.
55+
limit: 10,
5356
}),
5457
);
5558
});

app/components/UI/Predict/views/PredictHome/components/PredictTrendingSection/usePredictTrendingSection.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ import { usePredictMarketList } from '../../../../hooks/usePredictMarketList';
99
*/
1010
export const TRENDING_DISPLAY_LIMIT = 5;
1111

12+
/**
13+
* How many markets we fetch. Deliberately larger than {@link TRENDING_DISPLAY_LIMIT}
14+
* so that after standalone/staleness filtering the home section still has enough
15+
* survivors to fill its display cap. Mirrors the feed registry's trending limit.
16+
*/
17+
const TRENDING_FETCH_LIMIT = 10;
18+
1219
/**
1320
* Query params derived from the feed registry so the home section and the
1421
* full "See all" feed share the same React Query cache key.
@@ -18,7 +25,7 @@ const TRENDING_PARAMS: PredictMarketListParams =
1825
resolvePredictFeedDefaultFilter('trending')?.params ?? {
1926
order: 'volume24hr',
2027
status: 'open',
21-
limit: TRENDING_DISPLAY_LIMIT,
28+
limit: TRENDING_FETCH_LIMIT,
2229
};
2330

2431
export interface UsePredictTrendingSectionResult {

0 commit comments

Comments
 (0)