Skip to content

Commit 1a41d46

Browse files
Merge branch 'main' into fix/perps/tpsl-optimistic-update
2 parents cc778a1 + adcb2c2 commit 1a41d46

338 files changed

Lines changed: 21913 additions & 14131 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: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Create Deeplink Handler
2+
3+
Generate a new deeplink handler with all required boilerplate code, tests, and integration instructions.
4+
5+
## Required Information
6+
7+
Before generating, I need the following details:
8+
9+
1. **Action Name** (kebab-case): The URL path segment (e.g., `my-feature` for `https://link.metamask.io/my-feature`)
10+
2. **URL Parameters**: List of query parameters to support (e.g., `id`, `type`, `source`)
11+
3. **Navigation Route**: The destination route constant (e.g., `Routes.MY_FEATURE.HOME`)
12+
4. **Whitelisting**: Should this action bypass the security interstitial? (default: no)
13+
14+
---
15+
16+
## Generation Tasks
17+
18+
Using the guidelines from `.cursor/rules/deeplink-handler-guidelines.mdc`, generate the following:
19+
20+
### 1. Handler File
21+
22+
Create `app/core/DeeplinkManager/handlers/legacy/handle{PascalCaseName}Url.ts` with:
23+
24+
- Proper TypeScript interfaces for params
25+
- URL parameter parsing function
26+
- Main handler function with try/catch and fallback
27+
- DevLogger usage for debugging
28+
- TSDoc documentation with supported URL formats
29+
30+
### 2. Test File
31+
32+
Create `app/core/DeeplinkManager/handlers/legacy/__tests__/handle{PascalCaseName}Url.test.ts` with:
33+
34+
- Jest mocks for NavigationService and DevLogger
35+
- Test cases for:
36+
- Navigation with no parameters
37+
- Navigation with each individual parameter
38+
- Navigation with all parameters combined
39+
- Fallback to WALLET.HOME on error
40+
41+
### 3. Integration Instructions
42+
43+
After generating the files, provide exact code snippets for the manual integration steps:
44+
45+
#### Step A: Add to ACTIONS enum
46+
47+
Show the exact line to add to `app/constants/deeplinks.ts`
48+
49+
#### Step B: Add to PREFIXES
50+
51+
Show the exact line to add to the PREFIXES object
52+
53+
#### Step C: Import handler
54+
55+
Show the import statement for `handleUniversalLink.ts`
56+
57+
#### Step D: Add to SUPPORTED_ACTIONS enum
58+
59+
Show the exact line to add
60+
61+
#### Step E: Add switch case (CRITICAL)
62+
63+
Show the complete switch case block to add
64+
65+
#### Step F: (Optional) Add to whitelist
66+
67+
If whitelisting requested, show the line to add to WHITELISTED_ACTIONS
68+
69+
### 4. Test Commands
70+
71+
Provide ready-to-run commands:
72+
73+
- Unit test command
74+
- iOS Simulator deeplink test
75+
- Android Emulator deeplink test
76+
77+
### 5. Documentation Updates
78+
79+
Remind to update:
80+
81+
- `docs/readme/deeplinking.md` (add to Supported Actions table)
82+
- `docs/deeplink-test-urls.md` (add test URLs)
83+
84+
---
85+
86+
## Example Usage
87+
88+
**User prompt**: "Create a deeplink handler for `stake` with parameters `validator` and `amount`, navigating to `Routes.STAKING.STAKE_INPUT`"
89+
90+
**Expected output**:
91+
92+
1. Generated `handleStakeUrl.ts` with validator and amount params
93+
2. Generated `handleStakeUrl.test.ts` with full test coverage
94+
3. Copy-paste integration snippets for all manual steps
95+
4. Test commands ready to run
96+
97+
---
98+
99+
## File References
100+
101+
@.cursor/rules/deeplink-handler-guidelines.mdc
102+
@app/constants/deeplinks.ts
103+
@app/core/DeeplinkManager/handlers/legacy/handleUniversalLink.ts
104+
@app/core/DeeplinkManager/handlers/legacy/handlePerpsUrl.ts
105+
@app/core/DeeplinkManager/handlers/legacy/handleRewardsUrl.ts
106+
@app/core/DeeplinkManager/handlers/legacy/handlePredictUrl.ts

0 commit comments

Comments
 (0)