Skip to content

Commit 0cd6479

Browse files
committed
Merge branch 'main' of github.com:metamask/metamask-mobile into MUSD-660-money-account-activity
2 parents 2a3ce2b + 825cbe0 commit 0cd6479

24 files changed

Lines changed: 1154 additions & 139 deletions

File tree

.github/scripts/collect-qa-stats.mjs

Lines changed: 68 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
*
2323
* MetaMetrics (top-level `metametrics` namespace): static scan of
2424
* `tests/helpers/analytics/expectations/*.ts` plus `LEGACY_INLINE_METAMETRICS_PATHS`
25-
* for specs not yet using declarative expectations.
25+
* for specs not yet using declarative expectations. Event names are picked from
26+
* `name:` fields, `eventNames: [...]`, `onboardingEvents.*`, and event-ish `const` arrays.
2627
*
2728
* Example output:
2829
* {
@@ -348,7 +349,63 @@ function parseConstStringLiterals(source) {
348349
}
349350

350351
/**
351-
* Event names from declarative `*.analytics.ts` modules (onboarding refs, `name:` entries, event arrays).
352+
* Content between "[" and matching "]" at the same nesting depth (naive bracket count).
353+
*
354+
* @param {string} source
355+
* @param {number} openBracketIdx index of '[' opening the array
356+
* @returns {string|null}
357+
*/
358+
function sliceBalancedSquareBracketInner(source, openBracketIdx) {
359+
if (source[openBracketIdx] !== '[') return null;
360+
let depth = 0;
361+
for (let i = openBracketIdx; i < source.length; i += 1) {
362+
const c = source[i];
363+
if (c === '[') depth += 1;
364+
else if (c === ']') {
365+
depth -= 1;
366+
if (depth === 0) return source.slice(openBracketIdx + 1, i);
367+
}
368+
}
369+
return null;
370+
}
371+
372+
/**
373+
* Segment from CSV inside `eventNames:` or event-ish `const` arrays. Spread/rest is skipped —
374+
* duplicated by a sibling `const *Names*` list when present (e.g. `...transactionEventNames`).
375+
*
376+
* @param {string} token
377+
* @param {Record<string, string>} onboardingMap
378+
* @param {Record<string, string>} strConsts
379+
* @returns {string|null}
380+
*/
381+
function resolveDeclarativeExpectationListToken(token, onboardingMap, strConsts) {
382+
const t = token.replace(/^\s+|\s+$/g, '');
383+
if (!t) return null;
384+
const lit = t.match(/^['"]([^'"]+)['"]$/);
385+
if (lit) return lit[1];
386+
const onb = t.match(/^onboardingEvents\.(\w+)$/);
387+
if (onb && onboardingMap[onb[1]]) return onboardingMap[onb[1]];
388+
if (/^\.\.\.\s*\w+$/.test(t)) return null;
389+
if (strConsts[t]) return strConsts[t];
390+
return null;
391+
}
392+
393+
/**
394+
* @param {string} inner
395+
* @param {Record<string, string>} onboardingMap
396+
* @param {Record<string, string>} strConsts
397+
* @param {Set<string>} out
398+
*/
399+
function collectExpectationCsvArrayInner(inner, onboardingMap, strConsts, out) {
400+
for (const part of inner.split(',')) {
401+
const v = resolveDeclarativeExpectationListToken(part, onboardingMap, strConsts);
402+
if (v) out.add(v);
403+
}
404+
}
405+
406+
/**
407+
* Event names from declarative `*.analytics.ts`: `eventNames:` arrays, onboarding refs,
408+
* `name:` entries, string/const lookups, and event-ish `const [...]` declarations.
352409
*
353410
* @param {string} source
354411
* @param {Record<string, string>} onboardingMap
@@ -368,11 +425,18 @@ function collectFromDeclarativeExpectationsSource(source, onboardingMap, out) {
368425
const v = onboardingMap[m[1]];
369426
if (v) out.add(v);
370427
}
371-
for (const m of source.matchAll(/\bname:\s*(\w+)\s*,/g)) {
428+
// Allow `name: IDENT,` (more properties follow) or `name: IDENT }` (single-field expectation object).
429+
for (const m of source.matchAll(/\bname:\s*(\w+)\s*[},]/g)) {
372430
const v = strConsts[m[1]];
373431
if (v) out.add(v);
374432
}
375433

434+
for (const em of source.matchAll(/\beventNames:\s*\[/g)) {
435+
const openIdx = em.index + em[0].length - 1;
436+
const inner = sliceBalancedSquareBracketInner(source, openIdx);
437+
if (inner) collectExpectationCsvArrayInner(inner, onboardingMap, strConsts, out);
438+
}
439+
376440
const reArrays = /\bconst\s+(\w+)\s*=\s*\[([\s\S]*?)\];/g;
377441
let am;
378442
while ((am = reArrays.exec(source)) !== null) {
@@ -382,21 +446,7 @@ function collectFromDeclarativeExpectationsSource(source, onboardingMap, out) {
382446
/(?:event|Event|Expected|expectation|analytics|Names)/.test(varName) ||
383447
/\bonboardingEvents\b|\bexpectedEvents\b/.test(inner);
384448
if (!looksLikeEventList) continue;
385-
for (const part of inner.split(',')) {
386-
const t = part.replace(/^\s+|\s+$/g, '');
387-
if (!t) continue;
388-
const lit = t.match(/^['"]([^'"]+)['"]$/);
389-
if (lit) {
390-
out.add(lit[1]);
391-
continue;
392-
}
393-
const onb = t.match(/^onboardingEvents\.(\w+)$/);
394-
if (onb && onboardingMap[onb[1]]) {
395-
out.add(onboardingMap[onb[1]]);
396-
continue;
397-
}
398-
if (strConsts[t]) out.add(strConsts[t]);
399-
}
449+
collectExpectationCsvArrayInner(inner, onboardingMap, strConsts, out);
400450
}
401451
}
402452

.github/workflows/run-performance-e2e-release.yml

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,10 @@ jobs:
3838
- name: Check release trigger conditions
3939
id: check
4040
run: |
41-
# Always run for manual dispatch
42-
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
41+
# Always run for manual dispatch or release branch pushes
42+
if [[ "${{ github.event_name }}" == "workflow_dispatch" || ("${{ github.event_name }}" == "push" && "${{ github.ref_name }}" =~ ^release/) ]]; then
4343
echo "should-run=true" >> "$GITHUB_OUTPUT"
44-
echo "Performance tests triggered by manual dispatch"
45-
# For push events, only run if the triggering commit is a metamaskbot version bump
46-
elif [[ "${{ github.event_name }}" == "push" ]]; then
47-
COMMIT_MESSAGE=$(git log -1 --format="%s" "${{ github.sha }}")
48-
COMMIT_AUTHOR=$(git log -1 --format="%ae" "${{ github.sha }}")
49-
if [[ "$COMMIT_MESSAGE" =~ "Bump version number" && "$COMMIT_AUTHOR" =~ ^metamaskbot@ ]]; then
50-
echo "should-run=true" >> "$GITHUB_OUTPUT"
51-
echo "Push triggered by metamaskbot version bump: $COMMIT_MESSAGE"
52-
else
53-
echo "should-run=false" >> "$GITHUB_OUTPUT"
54-
echo "Push is not a metamaskbot version bump — skipping. Author: $COMMIT_AUTHOR | Message: $COMMIT_MESSAGE"
55-
fi
44+
echo "Performance tests triggered by ${{ github.event_name }}"
5645
# For scheduled runs, check for recent metamaskbot version bumps
5746
elif [[ "${{ github.event_name }}" == "schedule" ]]; then
5847
git fetch --all
@@ -67,11 +56,13 @@ jobs:
6756
# Check if the commit message contains "Bump version number" (ignore [skip ci])
6857
COMMIT_MESSAGE=$(git log -1 --format="%s" "$COMMIT_HASH")
6958
if [[ "$COMMIT_MESSAGE" =~ "Bump version number" ]]; then
70-
# Only run if the commit is from the last 30 minutes (to avoid re-running the same commit)
59+
# Check if we've already processed this commit by looking for a workflow run with this commit
60+
# We'll use a simple approach: check if the commit is from the last 30 minutes
7161
COMMIT_TIME=$(git log -1 --format="%ct" "$COMMIT_HASH")
7262
CURRENT_TIME=$(date +%s)
7363
TIME_DIFF=$((CURRENT_TIME - COMMIT_TIME))
7464
65+
# Only run if the commit is from the last 30 minutes (to avoid re-running the same commit)
7566
if [[ $TIME_DIFF -lt 1800 ]]; then
7667
echo "should-run=true" >> "$GITHUB_OUTPUT"
7768
echo "Recent metamaskbot version bump found (within last 30 min): $RECENT_VERSION_BUMP"

app/components/UI/Card/hooks/useAssetBalances.test.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ describe('useAssetBalances', () => {
131131
backgroundState: {
132132
TokensController: {
133133
allTokens: {},
134-
allDetectedTokens: {},
135134
},
136135
NetworkController: {
137136
networkConfigurationsByChainId: {
@@ -218,7 +217,6 @@ describe('useAssetBalances', () => {
218217
backgroundState: {
219218
TokensController: {
220219
allTokens: {},
221-
allDetectedTokens: {},
222220
},
223221
NetworkController: {
224222
networkConfigurationsByChainId: {
@@ -449,7 +447,6 @@ describe('useAssetBalances', () => {
449447
'mock-account': [walletAsset],
450448
},
451449
},
452-
allDetectedTokens: {},
453450
},
454451
NetworkController: {
455452
networkConfigurationsByChainId: {
@@ -546,7 +543,6 @@ describe('useAssetBalances', () => {
546543
'mock-account': [walletAsset],
547544
},
548545
},
549-
allDetectedTokens: {},
550546
},
551547
NetworkController: {
552548
networkConfigurationsByChainId: {
@@ -694,7 +690,6 @@ describe('useAssetBalances', () => {
694690
'mock-account': [walletAsset],
695691
},
696692
},
697-
allDetectedTokens: {},
698693
},
699694
NetworkController: {
700695
networkConfigurationsByChainId: {
@@ -754,7 +749,6 @@ describe('useAssetBalances', () => {
754749
backgroundState: {
755750
TokensController: {
756751
allTokens: {},
757-
allDetectedTokens: {},
758752
},
759753
NetworkController: {
760754
networkConfigurationsByChainId: {
@@ -804,7 +798,6 @@ describe('useAssetBalances', () => {
804798
backgroundState: {
805799
TokensController: {
806800
allTokens: {},
807-
allDetectedTokens: {},
808801
},
809802
NetworkController: {
810803
networkConfigurationsByChainId: {
@@ -870,7 +863,6 @@ describe('useAssetBalances', () => {
870863
backgroundState: {
871864
TokensController: {
872865
allTokens: {},
873-
allDetectedTokens: {},
874866
},
875867
NetworkController: {
876868
networkConfigurationsByChainId: {},
@@ -1017,7 +1009,6 @@ describe('useAssetBalances', () => {
10171009
'mock-account': [walletAsset],
10181010
},
10191011
},
1020-
allDetectedTokens: {},
10211012
},
10221013
NetworkController: {
10231014
networkConfigurationsByChainId: {
@@ -1089,7 +1080,6 @@ describe('useAssetBalances', () => {
10891080
'mock-account': [walletAsset],
10901081
},
10911082
},
1092-
allDetectedTokens: {},
10931083
},
10941084
NetworkController: {
10951085
networkConfigurationsByChainId: {
@@ -1161,7 +1151,6 @@ describe('useAssetBalances', () => {
11611151
'mock-account': [walletAsset],
11621152
},
11631153
},
1164-
allDetectedTokens: {},
11651154
},
11661155
NetworkController: {
11671156
networkConfigurationsByChainId: {
@@ -1233,7 +1222,6 @@ describe('useAssetBalances', () => {
12331222
'mock-account': [walletAsset],
12341223
},
12351224
},
1236-
allDetectedTokens: {},
12371225
},
12381226
NetworkController: {
12391227
networkConfigurationsByChainId: {
@@ -1291,7 +1279,6 @@ describe('useAssetBalances', () => {
12911279
backgroundState: {
12921280
TokensController: {
12931281
allTokens: {},
1294-
allDetectedTokens: {},
12951282
},
12961283
NetworkController: {
12971284
networkConfigurationsByChainId: {
@@ -1356,7 +1343,6 @@ describe('useAssetBalances', () => {
13561343
backgroundState: {
13571344
TokensController: {
13581345
allTokens: {},
1359-
allDetectedTokens: {},
13601346
},
13611347
NetworkController: {
13621348
networkConfigurationsByChainId: {
@@ -1426,7 +1412,6 @@ describe('useAssetBalances', () => {
14261412
'mock-account': [walletAsset],
14271413
},
14281414
},
1429-
allDetectedTokens: {},
14301415
},
14311416
NetworkController: {
14321417
networkConfigurationsByChainId: {
@@ -1496,7 +1481,6 @@ describe('useAssetBalances', () => {
14961481
'mock-account': [walletAsset],
14971482
},
14981483
},
1499-
allDetectedTokens: {},
15001484
},
15011485
NetworkController: {
15021486
networkConfigurationsByChainId: {
@@ -1877,7 +1861,6 @@ describe('useAssetBalances', () => {
18771861
'mock-account': [walletAsset],
18781862
},
18791863
},
1880-
allDetectedTokens: {},
18811864
},
18821865
NetworkController: {
18831866
networkConfigurationsByChainId: {
@@ -1944,7 +1927,6 @@ describe('useAssetBalances', () => {
19441927
'mock-account': [walletAsset],
19451928
},
19461929
},
1947-
allDetectedTokens: {},
19481930
},
19491931
NetworkController: {
19501932
networkConfigurationsByChainId: {
@@ -2012,7 +1994,6 @@ describe('useAssetBalances', () => {
20121994
'mock-account': [walletAsset],
20131995
},
20141996
},
2015-
allDetectedTokens: {},
20161997
},
20171998
NetworkController: {
20181999
networkConfigurationsByChainId: {
@@ -2079,7 +2060,6 @@ describe('useAssetBalances', () => {
20792060
'mock-account': [walletAsset],
20802061
},
20812062
},
2082-
allDetectedTokens: {},
20832063
},
20842064
NetworkController: {
20852065
networkConfigurationsByChainId: {

app/components/UI/Card/hooks/useAssetBalances.tsx

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,6 @@ export const useAssetBalances = (
9595

9696
// Get raw state needed for asset lookups - these are stable references from Redux
9797
const allAssets = useSelector(getTokensControllerAllTokens);
98-
const allDetectedTokens = useSelector(
99-
(state: RootState) =>
100-
state.engine.backgroundState.TokensController.allDetectedTokens,
101-
);
10298
const networkConfigs = useSelector(
10399
(state: RootState) =>
104100
state.engine.backgroundState.NetworkController
@@ -124,7 +120,6 @@ export const useAssetBalances = (
124120

125121
// Manually lookup asset from raw state (similar to selectAsset)
126122
const allTokensForChain = allAssets?.[chainId as Hex];
127-
const detectedTokensForChain = allDetectedTokens?.[chainId as Hex];
128123

129124
let asset: TokenI | undefined;
130125
if (allTokensForChain) {
@@ -139,18 +134,6 @@ export const useAssetBalances = (
139134
}
140135
}
141136
}
142-
if (!asset && detectedTokensForChain) {
143-
for (const accountTokens of Object.values(detectedTokensForChain)) {
144-
const found = (accountTokens as TokenI[])?.find(
145-
(t) =>
146-
t.address?.toLowerCase() === token.address?.toLowerCase(),
147-
);
148-
if (found) {
149-
asset = found;
150-
break;
151-
}
152-
}
153-
}
154137

155138
if (asset) {
156139
const key = `${token.address.toLowerCase()}-${token.caipChainId}`;
@@ -159,7 +142,7 @@ export const useAssetBalances = (
159142
}
160143
});
161144
return map;
162-
}, [tokens, allAssets, allDetectedTokens]);
145+
}, [tokens, allAssets]);
163146

164147
// Build the exchangeRatesMap in useMemo using raw state
165148
const exchangeRatesMap = useMemo(() => {

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { PredictCategory } from '../types';
2+
import { PREDICT_WORLD_CUP_FEED_PARAM } from './worldCupTabs';
23

34
export type PredictTabKey = PredictCategory;
45

@@ -21,9 +22,15 @@ export const PREDICT_HOT_TAB: PredictTabConfig = {
2122
labelKey: 'predict.category.hot',
2223
};
2324

25+
export const PREDICT_WORLD_CUP_TAB: PredictTabConfig = {
26+
key: PREDICT_WORLD_CUP_FEED_PARAM,
27+
labelKey: 'predict.world_cup.title',
28+
};
29+
2430
export const PREDICT_ALL_TABS: readonly PredictTabConfig[] = [
2531
...PREDICT_BASE_TABS,
2632
PREDICT_HOT_TAB,
33+
PREDICT_WORLD_CUP_TAB,
2734
];
2835

2936
const PREDICT_TAB_KEYS = PREDICT_ALL_TABS.map((tab) => tab.key);

0 commit comments

Comments
 (0)