Skip to content

Commit 6f19c17

Browse files
authored
Merge branch 'main' into mmpay_recipient_update
2 parents 25e05f4 + 9faf0fb commit 6f19c17

711 files changed

Lines changed: 36970 additions & 19766 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.
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
---
2+
name: perps-core-sync
3+
description: Sync the perps controller from mobile to the core monorepo with change detection, automated validation, failure resolution, and post-sync commit guidance. Use after perps controller changes land in mobile.
4+
---
5+
6+
# Perps Core Sync
7+
8+
## Purpose
9+
10+
Use this skill to sync `app/controllers/perps/` from mobile to `packages/perps-controller/src/` in the core monorepo. The sync is driven by `scripts/perps/validate-core-sync.sh` — a 9-step pipeline (preflight, conflict check, copy, install, verify, eslint fix, build, lint, write sync state).
11+
12+
Use when:
13+
14+
- New commits touch `app/controllers/perps/` since the last sync
15+
- A perps PR is merged and needs to propagate to core
16+
- You need to verify mobile changes are core-compatible before pushing
17+
18+
Do not use when:
19+
20+
- Changes are UI-only (`app/components/UI/Perps/`) — these don't sync
21+
- Changes are test-only (`*.test.ts`) — tests are excluded from sync
22+
- The core repo is not checked out locally
23+
24+
## Pre-Sync: Detect Changes
25+
26+
Read the sync state from core to find what changed since the last sync:
27+
28+
```bash
29+
cat <core-path>/packages/perps-controller/.sync-state.json
30+
```
31+
32+
Extract `lastSyncedMobileCommit` and run:
33+
34+
```bash
35+
# Commits since last sync
36+
git log <lastSyncedMobileCommit>..HEAD --oneline -- app/controllers/perps/
37+
38+
# File-level summary (excluding tests)
39+
git diff <lastSyncedMobileCommit>..HEAD --stat -- app/controllers/perps/ ':!*.test.ts'
40+
```
41+
42+
Pay special attention to:
43+
44+
- **New files** — need exports wired in core's `index.ts`, may need `tsconfig` references or new dependencies
45+
- **Deleted files** — rsync `--delete` handles removal, but verify no stale imports remain in core
46+
- **Changes to `PerpsPlatformDependencies`** — DI interface changes affect extension consumers
47+
- **Public API changes** — state shape, method signatures, event names affect all consumers
48+
49+
## Execute Sync
50+
51+
```bash
52+
bash scripts/perps/validate-core-sync.sh --core-path <core-path>
53+
```
54+
55+
Options:
56+
57+
- `--skip-build` — skip the build step for faster iteration when debugging lint/copy issues
58+
- `--skip-test` — skip the test step for faster iteration
59+
- `--verbose` — show full output for every step (useful for debugging)
60+
61+
The script runs these 12 steps in order:
62+
63+
| Step | What it does |
64+
| ----------------------- | --------------------------------------------------------------------------------------- |
65+
| 1. Pre-flight checks | Confirms mobile source, core destination, required tools |
66+
| 2. Conflict check | Fetches origin/main, checks for upstream perps-controller changes, validates sync state |
67+
| 3. Copy source files | rsync `.ts` files (excluding tests, mocks, fixtures) |
68+
| 4. Install dependencies | `yarn install` in core |
69+
| 5. Verify build fixes | Checks for `__DEV__`, mobile imports, closure fixes |
70+
| 6. ESLint auto-fix | Runs `--fix`, `--suppress-all`, `--prune-suppressions`, checks suppression delta |
71+
| 7. Format fix (oxfmt) | Runs `yarn lint:misc --write` — core uses oxfmt, not prettier |
72+
| 8. Build | `yarn workspace @metamask/perps-controller build` |
73+
| 9. Lint | Final lint pass to confirm zero violations |
74+
| 10. Test | `yarn workspace @metamask/perps-controller test` — catches DI/fixture mismatches |
75+
| 11. Changelog check | Verifies `CHANGELOG.md` has been updated (core CI requirement) |
76+
| 12. Write sync state | Updates `.sync-state.json` with commit hashes and checksum |
77+
78+
## Failure Resolution
79+
80+
| Failure | Cause | Fix |
81+
| -------------------------------------------------------- | -------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
82+
| `__DEV__` found | Mobile code uses `__DEV__` guard | Replace with `false` in the mobile source file, or route through `PerpsPlatformDependencies` for environment-aware behavior. Fix in mobile, then re-sync. |
83+
| Mobile imports (Engine, react-native, Sentry, DevLogger) | Direct platform import in controller | Route through `PerpsPlatformDependencies` (DI). All platform services must come through the `infrastructure` constructor param. Fix in mobile. |
84+
| Suppression delta increase | Sync introduces new ESLint violations | Fix violations in mobile first (e.g., `'x' in y``hasProperty(y, 'x')` from `@metamask/utils`). Re-run sync after fixing. |
85+
| Build failure | Missing tsconfig references, missing dependencies, type errors | Check `packages/perps-controller/tsconfig.json` references. Ensure new imports have corresponding `dependencies` in `package.json`. |
86+
| Lint failure after fix | Auto-fix didn't resolve all issues | Re-run the eslint fix step. If persistent, check for new rule violations that need manual fixes in mobile. |
87+
| Format fix failure | oxfmt can't auto-fix some files | Check for syntax errors that prevent parsing. Core uses `oxfmt` (not prettier) for TS formatting. |
88+
| Test failure | Test fixtures missing new DI dependencies | Add mocks for new `PerpsPlatformDependencies` fields (e.g., `diskCache`) in `tests/defer-eligibility.test.ts`. |
89+
| Changelog check failure | `CHANGELOG.md` not updated | Add entries under `## [Unreleased]` with `### Added`, `### Fixed`, `### Changed` sections linking to the PR. |
90+
| Conflict check: behind origin/main | Someone pushed perps-controller changes to main | `cd <core-path> && git merge origin/main` before re-running sync. |
91+
| Conflict check: checksum mismatch | Core source was hand-edited since last sync | Review the edits. Either port them back to mobile or discard and re-sync. |
92+
93+
## Post-Sync
94+
95+
After all 12 steps pass:
96+
97+
1. **Review the diff in core:**
98+
99+
```bash
100+
cd <core-path> && git diff --stat
101+
```
102+
103+
2. **Update `CHANGELOG.md`** before committing. Core CI requires entries under `## [Unreleased]`. Sections must follow [Keep a Changelog](https://keepachangelog.com/) order:
104+
105+
```
106+
### Added — new features, exports, files
107+
### Changed — refactors, dependency bumps
108+
### Deprecated — soon-to-be-removed features
109+
### Removed — removed features
110+
### Fixed — bug fixes
111+
### Security — vulnerability fixes
112+
```
113+
114+
Each entry must link to the PR: `([#NNNN](https://github.com/MetaMask/core/pull/NNNN))`.
115+
Validate locally: `yarn workspace @metamask/perps-controller changelog:validate`
116+
117+
3. **Commit in core** with conventional format:
118+
119+
```
120+
feat(perps): sync controller from mobile
121+
122+
Syncs app/controllers/perps/ from mobile commit <short-hash>.
123+
124+
Changes:
125+
- <summarize key changes from the pre-sync commit list>
126+
```
127+
128+
4. **Verify `.sync-state.json` was updated** — it should contain the current mobile HEAD commit.
129+
130+
5. **Check suppression count** — if non-zero, note it in the PR description. Target is zero suppressions.
131+
132+
6. **Use `--verbose` when debugging** — without it, step output is captured to temp files and only shown on failure. With `--verbose`, all output streams to the terminal.
133+
134+
## Portability Rules
135+
136+
Reference: `docs/perps/perps-review-antipatterns.md` (Controller Portability section).
137+
138+
- **No `__DEV__`** — must not appear in controller files. Core has no React Native dev mode.
139+
- **No mobile imports** — no `react-native`, `Engine`, `Sentry`, `DevLogger`. Everything through `PerpsPlatformDependencies` DI.
140+
- **No direct controller imports from app code** — app files must import from `@metamask/perps-controller`, not relative paths.
141+
- **Public API = publisher contract** — changing state shape, method signatures, or event names affects extension consumers. Coordinate breaking changes.
142+
- **New dependencies must be in DI interface** — controller code must not reach outside its boundary.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
interface:
2+
display_name: "Core Sync"
3+
short_description: "Sync perps controller from mobile to core monorepo."
4+
default_prompt: "Use $perps-core-sync to detect changes and sync app/controllers/perps/ to core."

.agents/skills/pr-codeowners/SKILL.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ description: Identify code owners for changed files and map them to Slack group
3838
| wallet-api-platform | wallet-integrations-team |
3939
| ramp | ramp-team |
4040
| predict | predict-team |
41+
| social-ai | social-ai-team |
4142
| rewards | rewards-team |
4243
| design-system-engineers | metamask-design-system-team |
4344
| core-platform | core-platform-team |
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
name: perps-core-sync
3+
summary: Sync perps controller from mobile to core monorepo with change detection.
4+
---
5+
6+
Follow `.agents/skills/perps-core-sync/SKILL.md`.

.cursor/rules/ui-development-guidelines.mdc

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,19 @@ Always prioritize @metamask/design-system-react-native components and Tailwind C
1717
**Before writing any new component or choosing what to use, ask: "Does @metamask/design-system-react-native have this?"**
1818

1919
1. **FIRST**: Use `@metamask/design-system-react-native` components
20-
- **Always use for**: Box (layout), Text (typography), Button/ButtonBase/ButtonIcon, Icon, Checkbox
20+
- **Always use for**: Box (layout), Text, SensitiveText, TextButton (inline links only)
21+
- **Always use for**: Button, ButtonBase, ButtonIcon, ButtonSemantic, Icon, Checkbox, RadioButton
2122
- **Always use for**: Avatar variants (Account, Base, Favicon, Group, Icon, Network, Token)
2223
- **Always use for**: Badge variants (Count, Icon, Network, Status, Wrapper)
24+
- **Always use for**: BottomSheet, BottomSheetFooter, BottomSheetHeader, BottomSheetDialog, BottomSheetOverlay
25+
- **Always use for**: HeaderBase, HeaderRoot, HeaderSearch, HeaderStandard
26+
- **Always use for**: BannerAlert, Card, ListItem, Skeleton, Label, Input, TextField
27+
- **Always use for**: KeyValueRow, KeyValueColumn, ActionListItem, MainActionButton, TabEmptyState
28+
2329
- **Rule**: If it exists in the design system, you MUST use it
2430

2531
2. **SECOND**: Use `app/component-library` ONLY if design system lacks it
26-
- **Use for**: BottomSheet, Tabs, Headers, ListItems, Skeleton, Tags, Modal, Overlay, Toast, RadioButton, etc.
32+
- **Use for**: Tabs, Tags, Cells, Modal, Overlay, Toast, Pickers, Select, Sheet/SheetHeader, etc.
2733
- **Rule**: These are MetaMask-specific implementations not (yet) in the design system
2834
- **Important**: component-library components should themselves use design system primitives internally
2935

@@ -40,10 +46,12 @@ Always prioritize @metamask/design-system-react-native components and Tailwind C
4046
### Decision Tree
4147
```
4248
Need a component?
43-
├─ Is it Box, Text, Button, Icon, Avatar, Badge, or Checkbox?
49+
├─ Is it Box, Text, Button, Icon, Avatar, Badge, Checkbox, RadioButton,
50+
│ BottomSheet, Header, BannerAlert, Card, ListItem, Skeleton, Label,
51+
│ TextField, Input, KeyValueRow, SensitiveText, TextButton, or ActionListItem?
4452
│ └─ YES → Use @metamask/design-system-react-native [STOP]
4553
46-
├─ Is it BottomSheet, Tabs, Header, ListItem, Skeleton, Tag, Modal, etc?
54+
├─ Is it Tabs, Tags, Cells, Modal, Overlay, Toast, Pickers, Select, Sheet?
4755
│ └─ YES → Use app/component-library [STOP]
4856
4957
├─ Is it feature-specific UI (e.g., BridgeInputSelector, StakeInputView)?

.depcheckrc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ ignores:
3838
# ESBuild is used for AI E2E script compilation
3939
- 'esbuild'
4040
- 'esbuild-register'
41+
# tsx runs all scripts/tooling/*.ts files directly (CLI wrapper, MCP server, yarn pre/post hooks, report CLI)
42+
- 'tsx'
4143
# xml2js is used in .github/scripts/ for E2E test report processing
4244
- 'xml2js'
4345
# jest-junit is used as a Jest reporter in tests/jest.e2e.detox.config.js

.github/CODEOWNERS

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,25 @@ app/core/AgenticService/ @MetaMask/perps
181181
**/Perps/** @MetaMask/perps
182182
**/perps/** @MetaMask/perps
183183

184+
# Social & AI Team
185+
app/components/Views/SocialLeaderboard/ @MetaMask/social-ai
186+
app/components/UI/MarketInsights/ @MetaMask/social-ai
187+
app/components/Views/Homepage/Sections/WhatsHappening/ @MetaMask/social-ai
188+
app/components/Views/Homepage/Sections/TopTraders/ @MetaMask/social-ai
189+
app/core/Engine/controllers/social-controller-init* @MetaMask/social-ai
190+
app/core/Engine/controllers/social-service-init* @MetaMask/social-ai
191+
app/core/Engine/messengers/social-controller-messenger* @MetaMask/social-ai
192+
app/core/Engine/messengers/social-service-messenger* @MetaMask/social-ai
193+
app/core/Engine/controllers/ai-digest-controller-init* @MetaMask/social-ai
194+
app/core/Engine/messengers/ai-digest-controller-messenger* @MetaMask/social-ai
195+
app/selectors/featureFlagController/socialLeaderboard/ @MetaMask/social-ai
196+
app/selectors/featureFlagController/marketInsights/ @MetaMask/social-ai
197+
app/selectors/featureFlagController/whatsHappening/ @MetaMask/social-ai
198+
**/SocialLeaderboard/** @MetaMask/social-ai
199+
**/MarketInsights/** @MetaMask/social-ai
200+
**/WhatsHappening/** @MetaMask/social-ai
201+
**/TopTraders/** @MetaMask/social-ai
202+
184203
# Predict Team
185204
app/components/UI/Predict/ @MetaMask/predict
186205
app/core/Engine/controllers/predict-controller @MetaMask/predict

.github/actionlint.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ self-hosted-runner:
1515
- "ghcr.io/cirruslabs/ubuntu-runner-amd64:24.04-lg"
1616
- "ghcr.io/cirruslabs/ubuntu-runner-amd64:24.04-xl"
1717
- "low-priority"
18+
- "bitrise_pool_name:DemoFA"
19+
- "bitrise_pool_name:DemoFAXL"
1820

1921
# Configuration variables in array of strings defined in your repository or
2022
# organization. `null` means disabling configuration variables check.

.github/pull-request-template.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,17 @@ Feature: my feature name
6363
- [ ] I've documented my code using [JSDoc](https://jsdoc.app/) format if applicable
6464
- [ ] I've applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors.
6565

66+
#### Performance checks (if applicable)
67+
68+
- [ ] I've tested on Android
69+
- Ideally on a mid-range device; emulator is acceptable
70+
- [ ] I've tested with a power user scenario
71+
- Use these [power-user SRPs](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/edit-v2/401401446401?draftShareId=9d77e1e1-4bdc-4be1-9ebb-ccd916988d93) to import wallets with many accounts and tokens
72+
- [ ] I've instrumented key operations with Sentry traces for production performance metrics
73+
- See [`trace()`](/app/util/trace.ts) for usage and [`addToken`](/app/components/Views/AddAsset/components/AddCustomToken/AddCustomToken.tsx#L274) for an example
74+
75+
For performance guidelines and tooling, see the [Performance Guide](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/400085549067/Performance+Guide+for+Engineers).
76+
6677
## **Pre-merge reviewer checklist**
6778

6879
- [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,21 +63,14 @@ const SCAN_ANALYTICS_EXPECTATIONS_DIR = 'tests/helpers/analytics/expectations';
6363
* Remove paths here when migrated to the expectations folder so the slim parser is enough.
6464
*/
6565
const LEGACY_INLINE_METAMETRICS_PATHS = [
66-
'tests/smoke/card/card-button.spec.ts',
67-
'tests/smoke/card/card-home-add-funds.spec.ts',
68-
'tests/smoke/card/card-home-manage-card.spec.ts',
6966
'tests/smoke/confirmations/send/metricsValidationHelper.ts',
7067
'tests/smoke/confirmations/transactions/dapp-initiated-transfer.spec.ts',
7168
'tests/smoke/predict/predict-cash-out.spec.ts',
7269
'tests/smoke/predict/predict-claim-positions.spec.ts',
7370
'tests/smoke/predict/predict-geo-restriction.spec.ts',
7471
'tests/smoke/predict/predict-open-position.spec.ts',
75-
'tests/smoke/ramps/onramp-unified-buy.spec.ts',
7672
'tests/smoke/snaps/test-snap-preinstalled.spec.ts',
7773
'tests/smoke/swap/bridge-action-smoke.spec.ts',
78-
'tests/smoke/swap/swap-action-smoke.spec.ts',
79-
'tests/smoke/wallet/analytics/import-wallet.spec.ts',
80-
'tests/smoke/wallet/analytics/new-wallet.spec.ts',
8174
'tests/regression/ramps/onramp-parameters.spec.ts',
8275
'tests/regression/wallet/analytics/opt-out.ts',
8376
];

0 commit comments

Comments
 (0)