Commit f25b4ba
authored
feat: allow add account in swap flow (MetaMask#22718)
## **Description**
This PR allows users to add an account to their rewards program, logic
is like this:
- GIVEN I have an active subscription but the current address is not
opted in
- AND the current address is eligible to be added (not a Bitcoin / Tron
/ hardware wallet / Snap account)
- I can add the current address in one click / tap and then see the
estimated points
then users will see the rewards row but with a cta that allows them to
add the active account address to the active subscription.
## **Changelog**
CHANGELOG entry: allow add account in swap flow
## **Related issues**
Fixes: https://consensyssoftware.atlassian.net/browse/RWDS-799
## **Screenshots/Recordings**
### **After**
<img width="461" height="45" alt="Screenshot-79"
src="https://github.com/user-attachments/assets/973c8bb9-e2da-4aca-a880-405a04fed5d1"
/>
---
<img width="476" height="100" alt="Screenshot-82"
src="https://github.com/user-attachments/assets/413aa101-6514-4d5e-b2fb-348dfcf7afd6"
/>
## **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**
- [x] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [x] 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]
> Adds a Rewards “Add account” CTA to the Bridge quote details,
introduces a linking hook/component, updates rewards logic, and adds
comprehensive tests, assets, and strings.
>
> - **Bridge | UI**:
> - `QuoteDetailsCard`: Shows Rewards row; when not opted-in displays
`AddRewardsAccount` CTA, otherwise renders `RewardPointsAnimation`. Adds
`bridge-rewards-row` test ID and uses fade-in image mock.
> - **Rewards**:
> - New `useLinkAccountAddress` hook (metrics, toasts) and
`AddRewardsAccount` component to link current account to Rewards.
> - `useRewards`: gates by `getFirstSubscriptionId`, exposes
`accountOptedIn`, shows row if opt-in is supported, subscribes to
`RewardsController:accountLinked`, refines deps.
> - **Tests**:
> - New/expanded tests for `QuoteDetailsCard`, `useRewards`,
`AddRewardsAccount`, and `useLinkAccountAddress`; updates BridgeView
tests/mocks (adds `controllerMessenger.subscribe/unsubscribe`, image
mocks).
> - **Assets/Locales**:
> - Adds rewards points SVG icon and
`rewards.link_account_group.link_account_address_error` string.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
bfa1421. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 5c22aa6 commit f25b4ba
12 files changed
Lines changed: 1801 additions & 115 deletions
File tree
- app
- components/UI
- Bridge
- Views/BridgeView
- __snapshots__
- components/QuoteDetailsCard
- hooks/useRewards
- Rewards
- components/AddRewardsAccount
- hooks
- images/rewards
- locales/languages
Lines changed: 20 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
92 | 97 | | |
93 | 98 | | |
94 | 99 | | |
| |||
272 | 277 | | |
273 | 278 | | |
274 | 279 | | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
275 | 295 | | |
276 | 296 | | |
277 | 297 | | |
| |||
Lines changed: 2 additions & 64 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
476 | 476 | | |
477 | 477 | | |
478 | 478 | | |
479 | | - | |
480 | | - | |
481 | | - | |
| 479 | + | |
482 | 480 | | |
483 | 481 | | |
484 | 482 | | |
| |||
504 | 502 | | |
505 | 503 | | |
506 | 504 | | |
507 | | - | |
508 | | - | |
509 | | - | |
510 | | - | |
511 | | - | |
512 | | - | |
513 | | - | |
514 | | - | |
515 | | - | |
516 | | - | |
517 | | - | |
518 | | - | |
519 | | - | |
520 | | - | |
521 | | - | |
522 | | - | |
523 | | - | |
524 | | - | |
525 | | - | |
526 | | - | |
527 | | - | |
528 | | - | |
529 | | - | |
530 | | - | |
531 | | - | |
532 | | - | |
533 | | - | |
534 | | - | |
535 | | - | |
536 | 505 | | |
537 | 506 | | |
538 | 507 | | |
| |||
2138 | 2107 | | |
2139 | 2108 | | |
2140 | 2109 | | |
2141 | | - | |
2142 | | - | |
2143 | | - | |
| 2110 | + | |
2144 | 2111 | | |
2145 | 2112 | | |
2146 | 2113 | | |
| |||
2166 | 2133 | | |
2167 | 2134 | | |
2168 | 2135 | | |
2169 | | - | |
2170 | | - | |
2171 | | - | |
2172 | | - | |
2173 | | - | |
2174 | | - | |
2175 | | - | |
2176 | | - | |
2177 | | - | |
2178 | | - | |
2179 | | - | |
2180 | | - | |
2181 | | - | |
2182 | | - | |
2183 | | - | |
2184 | | - | |
2185 | | - | |
2186 | | - | |
2187 | | - | |
2188 | | - | |
2189 | | - | |
2190 | | - | |
2191 | | - | |
2192 | | - | |
2193 | | - | |
2194 | | - | |
2195 | | - | |
2196 | | - | |
2197 | | - | |
2198 | 2136 | | |
2199 | 2137 | | |
2200 | 2138 | | |
| |||
Lines changed: 84 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
30 | 45 | | |
31 | 46 | | |
32 | 47 | | |
| |||
67 | 82 | | |
68 | 83 | | |
69 | 84 | | |
| 85 | + | |
| 86 | + | |
70 | 87 | | |
71 | 88 | | |
72 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
73 | 112 | | |
74 | 113 | | |
75 | 114 | | |
| |||
486 | 525 | | |
487 | 526 | | |
488 | 527 | | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
489 | 531 | | |
490 | 532 | | |
491 | 533 | | |
| |||
516 | 558 | | |
517 | 559 | | |
518 | 560 | | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
519 | 564 | | |
520 | 565 | | |
521 | 566 | | |
| |||
568 | 613 | | |
569 | 614 | | |
570 | 615 | | |
571 | | - | |
| 616 | + | |
572 | 617 | | |
573 | 618 | | |
574 | 619 | | |
575 | 620 | | |
576 | 621 | | |
577 | 622 | | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
578 | 626 | | |
579 | 627 | | |
580 | 628 | | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
581 | 632 | | |
582 | 633 | | |
583 | 634 | | |
584 | 635 | | |
585 | 636 | | |
586 | | - | |
| 637 | + | |
587 | 638 | | |
588 | 639 | | |
589 | 640 | | |
590 | 641 | | |
591 | 642 | | |
592 | | - | |
| 643 | + | |
593 | 644 | | |
594 | | - | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
595 | 652 | | |
596 | 653 | | |
597 | 654 | | |
| |||
602 | 659 | | |
603 | 660 | | |
604 | 661 | | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
605 | 665 | | |
606 | 666 | | |
607 | 667 | | |
| |||
632 | 692 | | |
633 | 693 | | |
634 | 694 | | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
635 | 698 | | |
636 | 699 | | |
637 | 700 | | |
| |||
668 | 731 | | |
669 | 732 | | |
670 | 733 | | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
671 | 737 | | |
672 | 738 | | |
673 | 739 | | |
| |||
702 | 768 | | |
703 | 769 | | |
704 | 770 | | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
705 | 774 | | |
706 | 775 | | |
707 | 776 | | |
| |||
733 | 802 | | |
734 | 803 | | |
735 | 804 | | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
736 | 808 | | |
737 | 809 | | |
738 | 810 | | |
| |||
764 | 836 | | |
765 | 837 | | |
766 | 838 | | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
767 | 842 | | |
768 | 843 | | |
769 | 844 | | |
| |||
812 | 887 | | |
813 | 888 | | |
814 | 889 | | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
815 | 893 | | |
816 | 894 | | |
817 | 895 | | |
| |||
826 | 904 | | |
827 | 905 | | |
828 | 906 | | |
829 | | - | |
| 907 | + | |
830 | 908 | | |
831 | 909 | | |
832 | 910 | | |
833 | 911 | | |
834 | 912 | | |
835 | 913 | | |
836 | 914 | | |
| 915 | + | |
837 | 916 | | |
838 | 917 | | |
839 | 918 | | |
| |||
0 commit comments