Commit f2fa96c
feat: link rewards to shield subscription (#38489)
<!--
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 allows rewards opted in users to claim points from shield
subscription.
[](https://codespaces.new/MetaMask/metamask-extension/pull/38489?quickstart=1)
## **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: link/claims rewards points from shield subscription
## **Related issues**
Fixes: #38038
## **Manual testing steps**
1. Go to this page...
2.
3.
## **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
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/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-extension/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]
> Integrates rewards with Shield subscriptions and shifts
crypto-approval post-transaction handling into `SubscriptionService`,
adding post-tx cohort assignment, UI hooks, and tests.
>
> - **Subscription Service**:
> - Adds rewards integration: resolves primary `rewardAccountId` (CAIP),
links rewards to existing Shield (`linkRewardToExistingSubscription`).
> - Handles Shield crypto approval post-tx in `handlePostTransaction`
(incl. gas sponsorship check) and tracks events.
> - Assigns post-tx Shield cohort via
`AppStateController:setPendingShieldCohort` and emits metrics.
> - New helpers: primary CAIP account lookup, season/opt-in checks.
> - **Controllers/Messaging**:
> - `metamask-controller`: delegate
`TransactionController:transactionSubmitted` to
`subscriptionService.handlePostTransaction`; remove legacy internal
approval handler; expose `linkRewardToShieldSubscription`.
> - `AppStateController`: add `setPendingShieldCohort` action and
handler.
> - Subscription service messenger/types: add actions
`submitShieldSubscriptionCryptoApproval`, `linkRewards`, rewards
getters, and new AppState action.
> - **UI**:
> - Remove `startSubscriptionWithCrypto` thunk.
> - Add `linkRewardToShieldSubscription` thunk.
> - **Tests**:
> - Unit tests for reward ID inclusion on card flow, post-tx handling,
and reward linking conditions.
> - **Dependencies/Config**:
> - Bump `@metamask/subscription-controller` to `^5.3.1` (and related
lockfile updates).
> - Privacy: allow `rewards.uat-api.cx.metamask.io`.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
5b9bc4e. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: MetaMask Bot <[email protected]>
Co-authored-by: Chaitanya Potti <[email protected]>1 parent 6fdfd8a commit f2fa96c
File tree
10 files changed
+619
-102
lines changed- app/scripts
- controller-init/messengers/subscription
- controllers
- services/subscription
- ui/store
10 files changed
+619
-102
lines changedLines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
43 | 45 | | |
| 46 | + | |
44 | 47 | | |
45 | 48 | | |
46 | 49 | | |
| |||
50 | 53 | | |
51 | 54 | | |
52 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
53 | 60 | | |
54 | 61 | | |
55 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
192 | 192 | | |
193 | 193 | | |
194 | 194 | | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
195 | 200 | | |
196 | 201 | | |
197 | 202 | | |
198 | 203 | | |
199 | 204 | | |
200 | 205 | | |
201 | 206 | | |
202 | | - | |
| 207 | + | |
| 208 | + | |
203 | 209 | | |
204 | 210 | | |
205 | 211 | | |
| |||
778 | 784 | | |
779 | 785 | | |
780 | 786 | | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
781 | 792 | | |
782 | 793 | | |
783 | 794 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
| 132 | + | |
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| |||
916 | 916 | | |
917 | 917 | | |
918 | 918 | | |
919 | | - | |
920 | | - | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
921 | 922 | | |
922 | | - | |
923 | | - | |
| 923 | + | |
924 | 924 | | |
925 | 925 | | |
926 | 926 | | |
| |||
2618 | 2618 | | |
2619 | 2619 | | |
2620 | 2620 | | |
2621 | | - | |
2622 | | - | |
2623 | | - | |
2624 | | - | |
2625 | 2621 | | |
2626 | 2622 | | |
2627 | 2623 | | |
| |||
2630 | 2626 | | |
2631 | 2627 | | |
2632 | 2628 | | |
| 2629 | + | |
| 2630 | + | |
| 2631 | + | |
| 2632 | + | |
2633 | 2633 | | |
2634 | 2634 | | |
2635 | 2635 | | |
| |||
8658 | 8658 | | |
8659 | 8659 | | |
8660 | 8660 | | |
8661 | | - | |
8662 | | - | |
8663 | | - | |
8664 | | - | |
8665 | | - | |
8666 | | - | |
8667 | | - | |
8668 | | - | |
8669 | | - | |
8670 | | - | |
8671 | | - | |
8672 | | - | |
8673 | | - | |
8674 | | - | |
8675 | | - | |
8676 | | - | |
8677 | | - | |
8678 | | - | |
8679 | | - | |
8680 | | - | |
8681 | | - | |
8682 | | - | |
8683 | | - | |
8684 | | - | |
8685 | | - | |
8686 | | - | |
8687 | | - | |
8688 | | - | |
8689 | | - | |
8690 | | - | |
8691 | | - | |
8692 | | - | |
8693 | | - | |
8694 | | - | |
8695 | | - | |
8696 | | - | |
8697 | | - | |
8698 | | - | |
8699 | | - | |
8700 | | - | |
8701 | | - | |
8702 | | - | |
8703 | | - | |
8704 | | - | |
8705 | | - | |
8706 | | - | |
8707 | | - | |
8708 | | - | |
8709 | | - | |
8710 | | - | |
8711 | | - | |
8712 | | - | |
8713 | | - | |
8714 | | - | |
8715 | | - | |
8716 | | - | |
8717 | | - | |
8718 | | - | |
8719 | | - | |
8720 | | - | |
8721 | 8661 | | |
8722 | 8662 | | |
8723 | 8663 | | |
| |||
0 commit comments