Skip to content

Commit b750f49

Browse files
authored
fix: add modal type to subscriptionEligibility (#7124)
## 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? --> Add missing modalType field and constant to SubscriptionEligibility ## 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] > Adds optional `modalType` to `SubscriptionEligibility`, introduces `MODAL_TYPE/ModalType`, and updates exports and tests. > > - **Types**: > - Add `MODAL_TYPE` constant and `ModalType` type in `src/types.ts`. > - Extend `SubscriptionEligibility` with optional `modalType` field. > - **Exports**: > - Export `ModalType` and `MODAL_TYPE` from `src/index.ts`. > - **Tests**: > - Update `SubscriptionController.test.ts` to import `MODAL_TYPE` and include `modalType` in eligibility mocks. > - **Changelog**: > - Document addition of `modalType` field and constant in `CHANGELOG.md`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 612be7c. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent e9def0b commit b750f49

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

packages/subscription-controller/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Added `modalType` field and constant to `SubscriptionEligibility` ([#7124](https://github.com/MetaMask/core/pull/7124))
13+
1014
## [4.0.0]
1115

1216
### Added

packages/subscription-controller/src/SubscriptionController.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import type {
4242
RecurringInterval,
4343
} from './types';
4444
import {
45+
MODAL_TYPE,
4546
PAYMENT_TYPES,
4647
PRODUCT_TYPES,
4748
RECURRING_INTERVALS,
@@ -1426,6 +1427,7 @@ describe('SubscriptionController', () => {
14261427
canSubscribe: true,
14271428
minBalanceUSD: 100,
14281429
canViewEntryModal: true,
1430+
modalType: MODAL_TYPE.A,
14291431
cohorts: [],
14301432
assignedCohort: null,
14311433
hasAssignedCohortExpired: false,

packages/subscription-controller/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export type {
6565
BalanceCategory,
6666
AssignCohortRequest,
6767
GetSubscriptionsEligibilitiesRequest,
68+
ModalType,
6869
} from './types';
6970
export {
7071
CRYPTO_PAYMENT_METHOD_ERRORS,
@@ -75,6 +76,7 @@ export {
7576
SubscriptionUserEvent,
7677
COHORT_NAMES,
7778
BALANCE_CATEGORIES,
79+
MODAL_TYPE,
7880
} from './types';
7981
export { SubscriptionServiceError } from './errors';
8082
export { Env, SubscriptionControllerErrorMessage } from './constants';

packages/subscription-controller/src/types.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ export const CRYPTO_PAYMENT_METHOD_ERRORS = {
5353
export type CryptoPaymentMethodError =
5454
(typeof CRYPTO_PAYMENT_METHOD_ERRORS)[keyof typeof CRYPTO_PAYMENT_METHOD_ERRORS];
5555

56+
export const MODAL_TYPE = {
57+
A: 'A',
58+
B: 'B',
59+
} as const;
60+
61+
export type ModalType = (typeof MODAL_TYPE)[keyof typeof MODAL_TYPE];
62+
5663
/** only usd for now */
5764
export type Currency = 'usd';
5865

@@ -266,6 +273,7 @@ export type SubscriptionEligibility = {
266273
canSubscribe: boolean;
267274
minBalanceUSD: number;
268275
canViewEntryModal: boolean;
276+
modalType?: ModalType;
269277
cohorts: Cohort[];
270278
assignedCohort: string | null;
271279
hasAssignedCohortExpired: boolean;

0 commit comments

Comments
 (0)