Commit 4371caf
authored
feat(card): Solana Delegation (MetaMask#25276)
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->
## **Description**
<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->
This PR adds Solana delegation support for MetaMask Card spending limits
and updates the UI to reflect multi-network support.
**Key changes:**
1. **Solana Delegation Support**: Implements the complete delegation
flow for Solana tokens, enabling users to set spending limits on Solana
assets (e.g., SOL, USDC on Solana).
- Added `completeSolanaDelegation` method in CardSDK for the
Solana-specific backend endpoint
- Integrated Solana Wallet Snap for message signing (`signCardMessage`)
and SPL Token approval transactions (`approveCardAmount`)
- Updated `useCardDelegation` hook to handle both EVM and Solana chains
2. **UI Updates**:
- Updated the "Other" button in the Spending Limit screen to display
Base and Solana network icons alongside the three dots icon
- Removed "Solana not supported" warnings and filters from
AssetSelectionBottomSheet and SpendingLimit components
- Enabled the "Manage Spending Limit" option for all supported networks
including Solana
## **Changelog**
<!--
If this PR is not End-User-Facing and should not show up in the
CHANGELOG, you can choose to either:
1. Write `CHANGELOG entry: null`
2. Label with `no-changelog`
If this PR is End-User-Facing, please write a short User-Facing
description in the past tense like:
`CHANGELOG entry: Added a new tab for users to see their NFTs`
`CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker`
(This helps the Release Engineer do their job more quickly and
accurately)
-->
CHANGELOG entry: Added Solana delegation support for MetaMask Card
spending limits
## **Related issues**
Fixes:
## **Manual testing steps**
```gherkin
Feature: Solana Delegation for Card Spending Limits
Scenario: User sets spending limit on Solana token
Given user is authenticated with MetaMask Card
And user has a Solana account with SOL or USDC balance
When user navigates to Spending Limit screen
And user selects a Solana token (SOL or USDC)
And user chooses "Full access" or sets a custom spending limit
And user confirms the spending limit
Then user is prompted to sign a message via Solana Wallet Snap
And user approves the SPL Token approval transaction
And spending limit is successfully set for the Solana token
Scenario: User views "Other" networks button
Given user is on the Spending Limit screen
When user views the asset selection cards
Then the "Other" button displays Base and Solana network icons with a three dots icon
```
## **Screenshots/Recordings**
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
<!-- [screenshots/recordings] -->
### **After**
<!-- [screenshots/recordings] -->
## **Pre-merge author checklist**
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable
- [x] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] 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.
## **Pre-merge reviewer checklist**
- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **High Risk**
> Adds a new Solana signing + SPL approval flow via the Solana Wallet
Snap and changes delegation completion API routing/validation, touching
transaction execution and auth-sensitive logic. Bugs here could break
spending-limit updates or cause incorrect on-chain approvals across
networks.
>
> **Overview**
> Adds **Solana support for card spending-limit delegation** end-to-end:
`useCardDelegation` can now sign SIWE-style messages via the Solana
Wallet Snap, submit an SPL token approval (`approveCardAmount`), wait
for non-EVM confirmation via
`MultichainTransactionsController:stateChange`, then complete delegation
via the backend.
>
> Updates the SDK to replace `completeEVMDelegation` with network-aware
`completeDelegation` (EVM vs Solana endpoints + format validation), and
removes prior Solana gating across the UI (spending-limit screen
validation/warnings, asset-selection filtering/footer, and Card Home
manage-limit availability). Also refreshes the “Other” asset card to
show Base+Solana network icons and bumps `@metamask/solana-wallet-snap`
to `^2.7.4`.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
11f71a5. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent ab4c4b7 commit 4371caf
23 files changed
Lines changed: 1239 additions & 479 deletions
File tree
- app/components/UI/Card
- Views
- CardHome
- SpendingLimit
- components
- components/AssetSelectionBottomSheet
- hooks
- sdk
- util
- locales/languages
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2278 | 2278 | | |
2279 | 2279 | | |
2280 | 2280 | | |
2281 | | - | |
2282 | | - | |
2283 | | - | |
2284 | | - | |
2285 | | - | |
2286 | | - | |
2287 | | - | |
2288 | | - | |
2289 | | - | |
2290 | | - | |
2291 | | - | |
2292 | | - | |
2293 | | - | |
2294 | | - | |
2295 | | - | |
2296 | | - | |
2297 | | - | |
2298 | | - | |
2299 | | - | |
2300 | | - | |
2301 | | - | |
2302 | | - | |
2303 | | - | |
2304 | | - | |
2305 | | - | |
2306 | 2281 | | |
2307 | 2282 | | |
2308 | 2283 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1571 | 1571 | | |
1572 | 1572 | | |
1573 | 1573 | | |
1574 | | - | |
1575 | | - | |
1576 | | - | |
1577 | | - | |
1578 | | - | |
1579 | | - | |
1580 | | - | |
1581 | | - | |
1582 | | - | |
1583 | | - | |
1584 | | - | |
1585 | | - | |
1586 | | - | |
1587 | | - | |
1588 | | - | |
1589 | | - | |
1590 | | - | |
| 1574 | + | |
| 1575 | + | |
| 1576 | + | |
| 1577 | + | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
1591 | 1589 | | |
1592 | 1590 | | |
1593 | 1591 | | |
| |||
Lines changed: 0 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
317 | 317 | | |
318 | 318 | | |
319 | 319 | | |
320 | | - | |
321 | 320 | | |
322 | 321 | | |
323 | 322 | | |
| |||
576 | 575 | | |
577 | 576 | | |
578 | 577 | | |
579 | | - | |
580 | 578 | | |
581 | 579 | | |
582 | 580 | | |
| |||
692 | 690 | | |
693 | 691 | | |
694 | 692 | | |
695 | | - | |
696 | 693 | | |
697 | 694 | | |
698 | 695 | | |
| |||
736 | 733 | | |
737 | 734 | | |
738 | 735 | | |
739 | | - | |
740 | 736 | | |
741 | 737 | | |
742 | 738 | | |
| |||
858 | 854 | | |
859 | 855 | | |
860 | 856 | | |
861 | | - | |
862 | 857 | | |
863 | 858 | | |
864 | 859 | | |
| |||
1071 | 1066 | | |
1072 | 1067 | | |
1073 | 1068 | | |
1074 | | - | |
1075 | 1069 | | |
1076 | 1070 | | |
1077 | 1071 | | |
| |||
Lines changed: 0 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
122 | | - | |
123 | 122 | | |
124 | 123 | | |
125 | 124 | | |
| |||
328 | 327 | | |
329 | 328 | | |
330 | 329 | | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | 330 | | |
352 | 331 | | |
353 | 332 | | |
| |||
Lines changed: 38 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| 17 | + | |
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
| |||
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| 29 | + | |
| 30 | + | |
27 | 31 | | |
28 | 32 | | |
29 | 33 | | |
| |||
102 | 106 | | |
103 | 107 | | |
104 | 108 | | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
110 | 143 | | |
111 | 144 | | |
112 | 145 | | |
| |||
Lines changed: 3 additions & 68 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
212 | | - | |
213 | 212 | | |
214 | 213 | | |
215 | 214 | | |
| |||
267 | 266 | | |
268 | 267 | | |
269 | 268 | | |
270 | | - | |
271 | 269 | | |
272 | 270 | | |
273 | 271 | | |
| |||
372 | 370 | | |
373 | 371 | | |
374 | 372 | | |
375 | | - | |
| 373 | + | |
376 | 374 | | |
377 | 375 | | |
378 | 376 | | |
| |||
383 | 381 | | |
384 | 382 | | |
385 | 383 | | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
403 | 384 | | |
404 | | - | |
| 385 | + | |
405 | 386 | | |
406 | | - | |
407 | 387 | | |
408 | 388 | | |
409 | 389 | | |
| 390 | + | |
410 | 391 | | |
411 | 392 | | |
412 | 393 | | |
| |||
891 | 872 | | |
892 | 873 | | |
893 | 874 | | |
894 | | - | |
895 | | - | |
896 | | - | |
897 | | - | |
898 | | - | |
899 | | - | |
900 | | - | |
901 | | - | |
902 | | - | |
903 | | - | |
904 | | - | |
905 | | - | |
906 | | - | |
907 | | - | |
908 | | - | |
909 | | - | |
910 | | - | |
911 | | - | |
912 | | - | |
913 | | - | |
914 | | - | |
915 | | - | |
916 | | - | |
917 | | - | |
918 | | - | |
919 | | - | |
920 | | - | |
921 | | - | |
922 | | - | |
923 | | - | |
924 | | - | |
925 | | - | |
926 | | - | |
927 | | - | |
928 | | - | |
929 | | - | |
930 | | - | |
931 | | - | |
932 | | - | |
933 | | - | |
934 | | - | |
935 | | - | |
936 | | - | |
937 | | - | |
938 | | - | |
939 | | - | |
940 | 875 | | |
941 | 876 | | |
942 | 877 | | |
| |||
0 commit comments