You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Explanation
<!--
Thanks for your contribution! Take a moment to answer these questions so
that reviewers have the information they need to properly understand
your changes:
* What is the current state of things and why does it need to change?
* What is the solution your changes offer and how does it work?
* Are there any changes whose purpose might not obvious to those
unfamiliar with the domain?
* If your primary goal was to update one package but you found you had
to update another one along the way, why did you do so?
* If you had to upgrade a dependency, why did you do so?
-->
Added new method, `submitSponsorshipIntents`, which submits the user's
sponsorship intents for new subscription with crypto.
## References
<!--
Are there any issues that this pull request is tied to?
Are there other links that reviewers should consult to understand these
changes better?
Are there client or consumer pull requests to adopt any breaking
changes?
For example:
* Fixes #12345
* Related to #67890
-->
## Checklist
- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [x] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs),
highlighting breaking changes as necessary
- [x] I've prepared draft pull requests for clients and consumer
packages to resolve any breaking changes
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Introduces submitSponsorshipIntents flow for crypto subscriptions,
adds/validates cached crypto payment method data (including token
symbol), and updates approve amount/pricing handling with new helpers
and errors.
>
> - **Controller (`src/SubscriptionController.ts`)**
> - **New API**: `submitSponsorshipIntents` (registered via messenger)
to submit gas-sponsorship intents using cached crypto payment method and
pricing-derived `billingCycles`/`recurringInterval`.
> - **Validation/Helpers**: Add `#assertIsPaymentMethodCrypto`,
`#getProductPriceByProductAndPlan`, and refine
`#assertIsUserNotSubscribed` using `ACTIVE_SUBSCRIPTION_STATUSES`.
> - **State**: `cacheLastSelectedPaymentMethod` now requires
`paymentTokenSymbol` for crypto; persists `lastSelectedPaymentMethod`
per product.
> - **Approve Params**: `getTokenApproveAmount` uses price
`minBillingCycles`, affecting `approveAmount`.
> - **Service (`src/SubscriptionService.ts`)**
> - **New Endpoint**: `submitSponsorshipIntents` POST to
`transaction-sponsorship/intents`.
> - **Types/Constants (`src/types.ts`, `src/constants.ts`,
`src/index.ts`)**
> - Add
`SubmitSponsorshipIntentsRequest`/`SubmitSponsorshipIntentsMethodParams`.
> - Add `CachedLastSelectedPaymentMethod` (includes optional
`paymentTokenSymbol`).
> - Add errors: `PaymentTokenAddressAndSymbolRequiredForCrypto`,
`PaymentMethodNotCrypto`, `ProductPriceNotFound`; export
`ACTIVE_SUBSCRIPTION_STATUSES`.
> - Extend `StartCryptoSubscriptionRequest` with optional `isSponsored`,
`smartTransactionId`.
> - **Tests**
> - Add coverage for sponsorship intents flow and new validations;
update pricing mocks to include `minBillingCycles` and yearly price;
adjust expected `approveAmount`.
> - **Changelog**
> - Document new `submitSponsorshipIntents` method.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
3387604. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Copy file name to clipboardExpand all lines: packages/subscription-controller/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
12
12
- Added the new controller state, `lastSelectedPaymentMethod`. ([#6946](https://github.com/MetaMask/core/pull/6946))
13
13
- We will use this in the UI state persistence between navigation.
14
14
- We will use this to query user subscription plan details in subscribe methods internally.
15
+
- Added new public method, `submitSponsorshipIntents`, to submit sponsorship intents for the new subscription with crypto. ([#6898](https://github.com/MetaMask/core/pull/6898))
0 commit comments