@metamask/subscription-controller 9.1.0 → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -1
- package/dist/SubscriptionService-structs.d.ts +150 -36
- package/dist/SubscriptionService-structs.d.ts.map +1 -1
- package/dist/SubscriptionService-structs.js +46 -12
- package/dist/SubscriptionService-structs.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/selectors.d.ts +41 -1
- package/dist/selectors.d.ts.map +1 -1
- package/dist/selectors.js +65 -0
- package/dist/selectors.js.map +1 -1
- package/dist/subscription-delegation/SubscriptionDelegationService-method-action-types.d.ts +5 -0
- package/dist/subscription-delegation/SubscriptionDelegationService-method-action-types.d.ts.map +1 -1
- package/dist/subscription-delegation/SubscriptionDelegationService-method-action-types.js.map +1 -1
- package/dist/subscription-delegation/SubscriptionDelegationService.d.ts +6 -1
- package/dist/subscription-delegation/SubscriptionDelegationService.d.ts.map +1 -1
- package/dist/subscription-delegation/SubscriptionDelegationService.js +35 -15
- package/dist/subscription-delegation/SubscriptionDelegationService.js.map +1 -1
- package/dist/subscription-delegation/fingerprint.d.ts +11 -0
- package/dist/subscription-delegation/fingerprint.d.ts.map +1 -1
- package/dist/subscription-delegation/fingerprint.js +40 -0
- package/dist/subscription-delegation/fingerprint.js.map +1 -1
- package/dist/types.d.ts +107 -17
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +39 -0
- package/dist/types.js.map +1 -1
- package/package.json +10 -10
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,31 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [10.0.0]
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Add `INVOICE_PAYMENT_STATUSES` / `InvoicePaymentStatus` for typed invoice
|
|
15
|
+
payment status values. ([#10305](https://github.com/MetaMask/core/pull/10305))
|
|
16
|
+
- Add `CRYPTO_PAYMENT_ERRORS` / `CryptoPaymentError` and optional `Subscription.lastInvoice` (`SubscriptionInvoice`) for Subscription API crypto payment-execution failures. ([#10305](https://github.com/MetaMask/core/pull/10305))
|
|
17
|
+
- Add `selectIsPaymentFailed`, `selectPaymentFailureReason`, `selectIsRenewalNeeded`, and `selectIsDelegationExhausted` selectors keyed by subscription product. ([#10305](https://github.com/MetaMask/core/pull/10305))
|
|
18
|
+
- Add `UpdateDelegationPaymentMethodCryptoRequest` so `updatePaymentMethod` can rotate an active crypto subscription with `cryptoAuthMethod` and `delegationHash`. ([#10305](https://github.com/MetaMask/core/pull/10305))
|
|
19
|
+
- Add optional `forceNew` to `SubscriptionDelegationService:prepareDelegation` to create a replacement delegation instead of reusing a matching stored one. ([#10305](https://github.com/MetaMask/core/pull/10305))
|
|
20
|
+
- Add optional `TokenPaymentInfo.vault` and the `VaultName` type plus `VAULT_NAMES` constants, for the named vault a vault-share settlement token belongs to. `VaultName` is an open `string` because the set of vaults is server-driven. ([#10416](https://github.com/MetaMask/core/pull/10416))
|
|
21
|
+
- Add `isVaultShareToken` to identify a yield-bearing vault-share settlement token, replacing the removed `isVaultShare` flag. ([#10416](https://github.com/MetaMask/core/pull/10416))
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
|
|
25
|
+
- **BREAKING:** Remove `TokenPaymentInfo.isVaultShare`, which the Subscription API no longer sends. A vault share is now identified by the presence of `accountantAddress` — use `isVaultShareToken`. Leaving the field in place made `getPricing` reject every vault-share token and fail the whole pricing response. ([#10416](https://github.com/MetaMask/core/pull/10416))
|
|
26
|
+
- **BREAKING:** Make `Subscription.currentPeriodStart`, `currentPeriodEnd`, `cancelType`, and `isEligibleForSupport` optional so paused or failed crypto subscriptions can validate. ([#10305](https://github.com/MetaMask/core/pull/10305))
|
|
27
|
+
- Refresh the access token when Money Account Plus subscription snapshots change, including payment-failure state while status remains active. ([#10305](https://github.com/MetaMask/core/pull/10305))
|
|
28
|
+
- Prefer the latest period `startDate` when `prepareDelegation` reuses a matching stored cash-subscription delegation, so a `forceNew` replacement is chosen over an older equivalent record. ([#10305](https://github.com/MetaMask/core/pull/10305))
|
|
29
|
+
- Bump `@metamask/profile-sync-controller` from `^32.1.1` to `^32.3.1` ([#10348](https://github.com/MetaMask/core/pull/10348), [#10409](https://github.com/MetaMask/core/pull/10409), [#10418](https://github.com/MetaMask/core/pull/10418))
|
|
30
|
+
- Bump `@metamask/transaction-controller` from `^70.1.0` to `^72.0.0` ([#10386](https://github.com/MetaMask/core/pull/10386), [#10423](https://github.com/MetaMask/core/pull/10423))
|
|
31
|
+
- Bump `@metamask/authenticated-user-storage` from `^4.0.0` to `^4.1.0` ([#10400](https://github.com/MetaMask/core/pull/10400))
|
|
32
|
+
- Bump `@tanstack/query-core` from `^5.62.16` to `^5.89.0` ([#9324](https://github.com/MetaMask/core/pull/9324))
|
|
33
|
+
- Bump `@metamask/money-account-utils` from `^2.0.0` to `^2.0.1` ([#10423](https://github.com/MetaMask/core/pull/10423))
|
|
34
|
+
|
|
10
35
|
## [9.1.0]
|
|
11
36
|
|
|
12
37
|
### Added
|
|
@@ -513,7 +538,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
513
538
|
- Bump `@metamask/controller-utils` from `^11.12.0` to `^11.14.0` ([#6620](https://github.com/MetaMask/core/pull/6620), [#6629](https://github.com/MetaMask/core/pull/6629))
|
|
514
539
|
- Bump `@metamask/utils` from `^11.4.2` to `^11.8.0` ([#6588](https://github.com/MetaMask/core/pull/6588))
|
|
515
540
|
|
|
516
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/subscription-controller@
|
|
541
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/subscription-controller@10.0.0...HEAD
|
|
542
|
+
[10.0.0]: https://github.com/MetaMask/core/compare/@metamask/subscription-controller@9.1.0...@metamask/subscription-controller@10.0.0
|
|
517
543
|
[9.1.0]: https://github.com/MetaMask/core/compare/@metamask/subscription-controller@9.0.1...@metamask/subscription-controller@9.1.0
|
|
518
544
|
[9.0.1]: https://github.com/MetaMask/core/compare/@metamask/subscription-controller@9.0.0...@metamask/subscription-controller@9.0.1
|
|
519
545
|
[9.0.0]: https://github.com/MetaMask/core/compare/@metamask/subscription-controller@8.1.0...@metamask/subscription-controller@9.0.0
|
|
@@ -8,8 +8,8 @@ export declare const SubscriptionStruct: Struct<{
|
|
|
8
8
|
unitAmount: number;
|
|
9
9
|
unitDecimals: number;
|
|
10
10
|
}[];
|
|
11
|
-
currentPeriodStart
|
|
12
|
-
currentPeriodEnd
|
|
11
|
+
currentPeriodStart?: string | undefined;
|
|
12
|
+
currentPeriodEnd?: string | undefined;
|
|
13
13
|
cancelAtPeriodEnd?: boolean | undefined;
|
|
14
14
|
status: "active" | "canceled" | "incomplete" | "incomplete_expired" | "past_due" | "paused" | "provisional" | "trialing" | "unpaid";
|
|
15
15
|
interval: "month" | "year";
|
|
@@ -34,10 +34,16 @@ export declare const SubscriptionStruct: Struct<{
|
|
|
34
34
|
trialEnd?: string | undefined;
|
|
35
35
|
endDate?: string | undefined;
|
|
36
36
|
canceledAt?: string | undefined;
|
|
37
|
-
cancelType
|
|
37
|
+
cancelType?: "allowed_at_period_end" | "allowed_immediate" | "not_allowed" | "not_allowed_pending_verification" | undefined;
|
|
38
38
|
inactiveAt?: string | undefined;
|
|
39
|
-
isEligibleForSupport
|
|
39
|
+
isEligibleForSupport?: boolean | undefined;
|
|
40
40
|
billingCycles?: number | undefined;
|
|
41
|
+
lastInvoice?: {
|
|
42
|
+
id: string;
|
|
43
|
+
status: "FAILED" | "PROCESSING" | "SUCCEEDED" | "UNKNOWN";
|
|
44
|
+
errorCode?: "delegation_not_found" | "delegation_revoked" | "exceeds_delegation_allowance" | "insufficient_allowance" | "insufficient_balance" | "internal_server_error" | "recipient_not_allowlisted" | undefined;
|
|
45
|
+
updatedAt: string;
|
|
46
|
+
} | undefined;
|
|
41
47
|
}, {
|
|
42
48
|
id: Struct<string, null>;
|
|
43
49
|
products: Struct<{
|
|
@@ -61,8 +67,8 @@ export declare const SubscriptionStruct: Struct<{
|
|
|
61
67
|
unitAmount: Struct<number, null>;
|
|
62
68
|
unitDecimals: Struct<number, null>;
|
|
63
69
|
}>>;
|
|
64
|
-
currentPeriodStart: Struct<string, null>;
|
|
65
|
-
currentPeriodEnd: Struct<string, null>;
|
|
70
|
+
currentPeriodStart: Struct<string | undefined, null>;
|
|
71
|
+
currentPeriodEnd: Struct<string | undefined, null>;
|
|
66
72
|
cancelAtPeriodEnd: Struct<boolean | undefined, null>;
|
|
67
73
|
status: Struct<"active" | "canceled" | "incomplete" | "incomplete_expired" | "past_due" | "paused" | "provisional" | "trialing" | "unpaid", {
|
|
68
74
|
active: "active";
|
|
@@ -100,15 +106,39 @@ export declare const SubscriptionStruct: Struct<{
|
|
|
100
106
|
trialEnd: Struct<string | undefined, null>;
|
|
101
107
|
endDate: Struct<string | undefined, null>;
|
|
102
108
|
canceledAt: Struct<string | undefined, null>;
|
|
103
|
-
cancelType: Struct<"allowed_at_period_end" | "allowed_immediate" | "not_allowed" | "not_allowed_pending_verification", {
|
|
109
|
+
cancelType: Struct<"allowed_at_period_end" | "allowed_immediate" | "not_allowed" | "not_allowed_pending_verification" | undefined, {
|
|
104
110
|
allowed_at_period_end: "allowed_at_period_end";
|
|
105
111
|
allowed_immediate: "allowed_immediate";
|
|
106
112
|
not_allowed: "not_allowed";
|
|
107
113
|
not_allowed_pending_verification: "not_allowed_pending_verification";
|
|
108
114
|
}>;
|
|
109
115
|
inactiveAt: Struct<string | undefined, null>;
|
|
110
|
-
isEligibleForSupport: Struct<boolean, null>;
|
|
116
|
+
isEligibleForSupport: Struct<boolean | undefined, null>;
|
|
111
117
|
billingCycles: Struct<number | undefined, null>;
|
|
118
|
+
lastInvoice: Struct<{
|
|
119
|
+
id: string;
|
|
120
|
+
status: "FAILED" | "PROCESSING" | "SUCCEEDED" | "UNKNOWN";
|
|
121
|
+
errorCode?: "delegation_not_found" | "delegation_revoked" | "exceeds_delegation_allowance" | "insufficient_allowance" | "insufficient_balance" | "internal_server_error" | "recipient_not_allowlisted" | undefined;
|
|
122
|
+
updatedAt: string;
|
|
123
|
+
} | undefined, {
|
|
124
|
+
id: Struct<string, null>;
|
|
125
|
+
status: Struct<"FAILED" | "PROCESSING" | "SUCCEEDED" | "UNKNOWN", {
|
|
126
|
+
FAILED: "FAILED";
|
|
127
|
+
PROCESSING: "PROCESSING";
|
|
128
|
+
SUCCEEDED: "SUCCEEDED";
|
|
129
|
+
UNKNOWN: "UNKNOWN";
|
|
130
|
+
}>;
|
|
131
|
+
errorCode: Struct<"delegation_not_found" | "delegation_revoked" | "exceeds_delegation_allowance" | "insufficient_allowance" | "insufficient_balance" | "internal_server_error" | "recipient_not_allowlisted" | undefined, {
|
|
132
|
+
delegation_not_found: "delegation_not_found";
|
|
133
|
+
delegation_revoked: "delegation_revoked";
|
|
134
|
+
exceeds_delegation_allowance: "exceeds_delegation_allowance";
|
|
135
|
+
insufficient_allowance: "insufficient_allowance";
|
|
136
|
+
insufficient_balance: "insufficient_balance";
|
|
137
|
+
internal_server_error: "internal_server_error";
|
|
138
|
+
recipient_not_allowlisted: "recipient_not_allowlisted";
|
|
139
|
+
}>;
|
|
140
|
+
updatedAt: Struct<string, null>;
|
|
141
|
+
}>;
|
|
112
142
|
}>;
|
|
113
143
|
export declare const GetSubscriptionsResponseStruct: Struct<{
|
|
114
144
|
customerId?: string | undefined;
|
|
@@ -120,8 +150,8 @@ export declare const GetSubscriptionsResponseStruct: Struct<{
|
|
|
120
150
|
unitAmount: number;
|
|
121
151
|
unitDecimals: number;
|
|
122
152
|
}[];
|
|
123
|
-
currentPeriodStart
|
|
124
|
-
currentPeriodEnd
|
|
153
|
+
currentPeriodStart?: string | undefined;
|
|
154
|
+
currentPeriodEnd?: string | undefined;
|
|
125
155
|
cancelAtPeriodEnd?: boolean | undefined;
|
|
126
156
|
status: "active" | "canceled" | "incomplete" | "incomplete_expired" | "past_due" | "paused" | "provisional" | "trialing" | "unpaid";
|
|
127
157
|
interval: "month" | "year";
|
|
@@ -146,10 +176,16 @@ export declare const GetSubscriptionsResponseStruct: Struct<{
|
|
|
146
176
|
trialEnd?: string | undefined;
|
|
147
177
|
endDate?: string | undefined;
|
|
148
178
|
canceledAt?: string | undefined;
|
|
149
|
-
cancelType
|
|
179
|
+
cancelType?: "allowed_at_period_end" | "allowed_immediate" | "not_allowed" | "not_allowed_pending_verification" | undefined;
|
|
150
180
|
inactiveAt?: string | undefined;
|
|
151
|
-
isEligibleForSupport
|
|
181
|
+
isEligibleForSupport?: boolean | undefined;
|
|
152
182
|
billingCycles?: number | undefined;
|
|
183
|
+
lastInvoice?: {
|
|
184
|
+
id: string;
|
|
185
|
+
status: "FAILED" | "PROCESSING" | "SUCCEEDED" | "UNKNOWN";
|
|
186
|
+
errorCode?: "delegation_not_found" | "delegation_revoked" | "exceeds_delegation_allowance" | "insufficient_allowance" | "insufficient_balance" | "internal_server_error" | "recipient_not_allowlisted" | undefined;
|
|
187
|
+
updatedAt: string;
|
|
188
|
+
} | undefined;
|
|
153
189
|
}[];
|
|
154
190
|
trialedProducts: ("money_account_plus" | "shield")[];
|
|
155
191
|
productEntitlements?: {
|
|
@@ -177,8 +213,8 @@ export declare const GetSubscriptionsResponseStruct: Struct<{
|
|
|
177
213
|
unitAmount: number;
|
|
178
214
|
unitDecimals: number;
|
|
179
215
|
}[];
|
|
180
|
-
currentPeriodStart
|
|
181
|
-
currentPeriodEnd
|
|
216
|
+
currentPeriodStart?: string | undefined;
|
|
217
|
+
currentPeriodEnd?: string | undefined;
|
|
182
218
|
cancelAtPeriodEnd?: boolean | undefined;
|
|
183
219
|
status: "active" | "canceled" | "incomplete" | "incomplete_expired" | "past_due" | "paused" | "provisional" | "trialing" | "unpaid";
|
|
184
220
|
interval: "month" | "year";
|
|
@@ -203,10 +239,16 @@ export declare const GetSubscriptionsResponseStruct: Struct<{
|
|
|
203
239
|
trialEnd?: string | undefined;
|
|
204
240
|
endDate?: string | undefined;
|
|
205
241
|
canceledAt?: string | undefined;
|
|
206
|
-
cancelType
|
|
242
|
+
cancelType?: "allowed_at_period_end" | "allowed_immediate" | "not_allowed" | "not_allowed_pending_verification" | undefined;
|
|
207
243
|
inactiveAt?: string | undefined;
|
|
208
|
-
isEligibleForSupport
|
|
244
|
+
isEligibleForSupport?: boolean | undefined;
|
|
209
245
|
billingCycles?: number | undefined;
|
|
246
|
+
lastInvoice?: {
|
|
247
|
+
id: string;
|
|
248
|
+
status: "FAILED" | "PROCESSING" | "SUCCEEDED" | "UNKNOWN";
|
|
249
|
+
errorCode?: "delegation_not_found" | "delegation_revoked" | "exceeds_delegation_allowance" | "insufficient_allowance" | "insufficient_balance" | "internal_server_error" | "recipient_not_allowlisted" | undefined;
|
|
250
|
+
updatedAt: string;
|
|
251
|
+
} | undefined;
|
|
210
252
|
} | undefined;
|
|
211
253
|
rewardAccountId?: `${string}:${string}:${string}` | undefined;
|
|
212
254
|
}, {
|
|
@@ -219,8 +261,8 @@ export declare const GetSubscriptionsResponseStruct: Struct<{
|
|
|
219
261
|
unitAmount: number;
|
|
220
262
|
unitDecimals: number;
|
|
221
263
|
}[];
|
|
222
|
-
currentPeriodStart
|
|
223
|
-
currentPeriodEnd
|
|
264
|
+
currentPeriodStart?: string | undefined;
|
|
265
|
+
currentPeriodEnd?: string | undefined;
|
|
224
266
|
cancelAtPeriodEnd?: boolean | undefined;
|
|
225
267
|
status: "active" | "canceled" | "incomplete" | "incomplete_expired" | "past_due" | "paused" | "provisional" | "trialing" | "unpaid";
|
|
226
268
|
interval: "month" | "year";
|
|
@@ -245,10 +287,16 @@ export declare const GetSubscriptionsResponseStruct: Struct<{
|
|
|
245
287
|
trialEnd?: string | undefined;
|
|
246
288
|
endDate?: string | undefined;
|
|
247
289
|
canceledAt?: string | undefined;
|
|
248
|
-
cancelType
|
|
290
|
+
cancelType?: "allowed_at_period_end" | "allowed_immediate" | "not_allowed" | "not_allowed_pending_verification" | undefined;
|
|
249
291
|
inactiveAt?: string | undefined;
|
|
250
|
-
isEligibleForSupport
|
|
292
|
+
isEligibleForSupport?: boolean | undefined;
|
|
251
293
|
billingCycles?: number | undefined;
|
|
294
|
+
lastInvoice?: {
|
|
295
|
+
id: string;
|
|
296
|
+
status: "FAILED" | "PROCESSING" | "SUCCEEDED" | "UNKNOWN";
|
|
297
|
+
errorCode?: "delegation_not_found" | "delegation_revoked" | "exceeds_delegation_allowance" | "insufficient_allowance" | "insufficient_balance" | "internal_server_error" | "recipient_not_allowlisted" | undefined;
|
|
298
|
+
updatedAt: string;
|
|
299
|
+
} | undefined;
|
|
252
300
|
}[], Struct<{
|
|
253
301
|
id: string;
|
|
254
302
|
products: {
|
|
@@ -257,8 +305,8 @@ export declare const GetSubscriptionsResponseStruct: Struct<{
|
|
|
257
305
|
unitAmount: number;
|
|
258
306
|
unitDecimals: number;
|
|
259
307
|
}[];
|
|
260
|
-
currentPeriodStart
|
|
261
|
-
currentPeriodEnd
|
|
308
|
+
currentPeriodStart?: string | undefined;
|
|
309
|
+
currentPeriodEnd?: string | undefined;
|
|
262
310
|
cancelAtPeriodEnd?: boolean | undefined;
|
|
263
311
|
status: "active" | "canceled" | "incomplete" | "incomplete_expired" | "past_due" | "paused" | "provisional" | "trialing" | "unpaid";
|
|
264
312
|
interval: "month" | "year";
|
|
@@ -283,10 +331,16 @@ export declare const GetSubscriptionsResponseStruct: Struct<{
|
|
|
283
331
|
trialEnd?: string | undefined;
|
|
284
332
|
endDate?: string | undefined;
|
|
285
333
|
canceledAt?: string | undefined;
|
|
286
|
-
cancelType
|
|
334
|
+
cancelType?: "allowed_at_period_end" | "allowed_immediate" | "not_allowed" | "not_allowed_pending_verification" | undefined;
|
|
287
335
|
inactiveAt?: string | undefined;
|
|
288
|
-
isEligibleForSupport
|
|
336
|
+
isEligibleForSupport?: boolean | undefined;
|
|
289
337
|
billingCycles?: number | undefined;
|
|
338
|
+
lastInvoice?: {
|
|
339
|
+
id: string;
|
|
340
|
+
status: "FAILED" | "PROCESSING" | "SUCCEEDED" | "UNKNOWN";
|
|
341
|
+
errorCode?: "delegation_not_found" | "delegation_revoked" | "exceeds_delegation_allowance" | "insufficient_allowance" | "insufficient_balance" | "internal_server_error" | "recipient_not_allowlisted" | undefined;
|
|
342
|
+
updatedAt: string;
|
|
343
|
+
} | undefined;
|
|
290
344
|
}, {
|
|
291
345
|
id: Struct<string, null>;
|
|
292
346
|
products: Struct<{
|
|
@@ -310,8 +364,8 @@ export declare const GetSubscriptionsResponseStruct: Struct<{
|
|
|
310
364
|
unitAmount: Struct<number, null>;
|
|
311
365
|
unitDecimals: Struct<number, null>;
|
|
312
366
|
}>>;
|
|
313
|
-
currentPeriodStart: Struct<string, null>;
|
|
314
|
-
currentPeriodEnd: Struct<string, null>;
|
|
367
|
+
currentPeriodStart: Struct<string | undefined, null>;
|
|
368
|
+
currentPeriodEnd: Struct<string | undefined, null>;
|
|
315
369
|
cancelAtPeriodEnd: Struct<boolean | undefined, null>;
|
|
316
370
|
status: Struct<"active" | "canceled" | "incomplete" | "incomplete_expired" | "past_due" | "paused" | "provisional" | "trialing" | "unpaid", {
|
|
317
371
|
active: "active";
|
|
@@ -349,15 +403,39 @@ export declare const GetSubscriptionsResponseStruct: Struct<{
|
|
|
349
403
|
trialEnd: Struct<string | undefined, null>;
|
|
350
404
|
endDate: Struct<string | undefined, null>;
|
|
351
405
|
canceledAt: Struct<string | undefined, null>;
|
|
352
|
-
cancelType: Struct<"allowed_at_period_end" | "allowed_immediate" | "not_allowed" | "not_allowed_pending_verification", {
|
|
406
|
+
cancelType: Struct<"allowed_at_period_end" | "allowed_immediate" | "not_allowed" | "not_allowed_pending_verification" | undefined, {
|
|
353
407
|
allowed_at_period_end: "allowed_at_period_end";
|
|
354
408
|
allowed_immediate: "allowed_immediate";
|
|
355
409
|
not_allowed: "not_allowed";
|
|
356
410
|
not_allowed_pending_verification: "not_allowed_pending_verification";
|
|
357
411
|
}>;
|
|
358
412
|
inactiveAt: Struct<string | undefined, null>;
|
|
359
|
-
isEligibleForSupport: Struct<boolean, null>;
|
|
413
|
+
isEligibleForSupport: Struct<boolean | undefined, null>;
|
|
360
414
|
billingCycles: Struct<number | undefined, null>;
|
|
415
|
+
lastInvoice: Struct<{
|
|
416
|
+
id: string;
|
|
417
|
+
status: "FAILED" | "PROCESSING" | "SUCCEEDED" | "UNKNOWN";
|
|
418
|
+
errorCode?: "delegation_not_found" | "delegation_revoked" | "exceeds_delegation_allowance" | "insufficient_allowance" | "insufficient_balance" | "internal_server_error" | "recipient_not_allowlisted" | undefined;
|
|
419
|
+
updatedAt: string;
|
|
420
|
+
} | undefined, {
|
|
421
|
+
id: Struct<string, null>;
|
|
422
|
+
status: Struct<"FAILED" | "PROCESSING" | "SUCCEEDED" | "UNKNOWN", {
|
|
423
|
+
FAILED: "FAILED";
|
|
424
|
+
PROCESSING: "PROCESSING";
|
|
425
|
+
SUCCEEDED: "SUCCEEDED";
|
|
426
|
+
UNKNOWN: "UNKNOWN";
|
|
427
|
+
}>;
|
|
428
|
+
errorCode: Struct<"delegation_not_found" | "delegation_revoked" | "exceeds_delegation_allowance" | "insufficient_allowance" | "insufficient_balance" | "internal_server_error" | "recipient_not_allowlisted" | undefined, {
|
|
429
|
+
delegation_not_found: "delegation_not_found";
|
|
430
|
+
delegation_revoked: "delegation_revoked";
|
|
431
|
+
exceeds_delegation_allowance: "exceeds_delegation_allowance";
|
|
432
|
+
insufficient_allowance: "insufficient_allowance";
|
|
433
|
+
insufficient_balance: "insufficient_balance";
|
|
434
|
+
internal_server_error: "internal_server_error";
|
|
435
|
+
recipient_not_allowlisted: "recipient_not_allowlisted";
|
|
436
|
+
}>;
|
|
437
|
+
updatedAt: Struct<string, null>;
|
|
438
|
+
}>;
|
|
361
439
|
}>>;
|
|
362
440
|
trialedProducts: Struct<("money_account_plus" | "shield")[], Struct<"money_account_plus" | "shield", {
|
|
363
441
|
money_account_plus: "money_account_plus";
|
|
@@ -425,8 +503,8 @@ export declare const GetSubscriptionsResponseStruct: Struct<{
|
|
|
425
503
|
unitAmount: number;
|
|
426
504
|
unitDecimals: number;
|
|
427
505
|
}[];
|
|
428
|
-
currentPeriodStart
|
|
429
|
-
currentPeriodEnd
|
|
506
|
+
currentPeriodStart?: string | undefined;
|
|
507
|
+
currentPeriodEnd?: string | undefined;
|
|
430
508
|
cancelAtPeriodEnd?: boolean | undefined;
|
|
431
509
|
status: "active" | "canceled" | "incomplete" | "incomplete_expired" | "past_due" | "paused" | "provisional" | "trialing" | "unpaid";
|
|
432
510
|
interval: "month" | "year";
|
|
@@ -451,10 +529,16 @@ export declare const GetSubscriptionsResponseStruct: Struct<{
|
|
|
451
529
|
trialEnd?: string | undefined;
|
|
452
530
|
endDate?: string | undefined;
|
|
453
531
|
canceledAt?: string | undefined;
|
|
454
|
-
cancelType
|
|
532
|
+
cancelType?: "allowed_at_period_end" | "allowed_immediate" | "not_allowed" | "not_allowed_pending_verification" | undefined;
|
|
455
533
|
inactiveAt?: string | undefined;
|
|
456
|
-
isEligibleForSupport
|
|
534
|
+
isEligibleForSupport?: boolean | undefined;
|
|
457
535
|
billingCycles?: number | undefined;
|
|
536
|
+
lastInvoice?: {
|
|
537
|
+
id: string;
|
|
538
|
+
status: "FAILED" | "PROCESSING" | "SUCCEEDED" | "UNKNOWN";
|
|
539
|
+
errorCode?: "delegation_not_found" | "delegation_revoked" | "exceeds_delegation_allowance" | "insufficient_allowance" | "insufficient_balance" | "internal_server_error" | "recipient_not_allowlisted" | undefined;
|
|
540
|
+
updatedAt: string;
|
|
541
|
+
} | undefined;
|
|
458
542
|
} | undefined, {
|
|
459
543
|
id: Struct<string, null>;
|
|
460
544
|
products: Struct<{
|
|
@@ -478,8 +562,8 @@ export declare const GetSubscriptionsResponseStruct: Struct<{
|
|
|
478
562
|
unitAmount: Struct<number, null>;
|
|
479
563
|
unitDecimals: Struct<number, null>;
|
|
480
564
|
}>>;
|
|
481
|
-
currentPeriodStart: Struct<string, null>;
|
|
482
|
-
currentPeriodEnd: Struct<string, null>;
|
|
565
|
+
currentPeriodStart: Struct<string | undefined, null>;
|
|
566
|
+
currentPeriodEnd: Struct<string | undefined, null>;
|
|
483
567
|
cancelAtPeriodEnd: Struct<boolean | undefined, null>;
|
|
484
568
|
status: Struct<"active" | "canceled" | "incomplete" | "incomplete_expired" | "past_due" | "paused" | "provisional" | "trialing" | "unpaid", {
|
|
485
569
|
active: "active";
|
|
@@ -517,15 +601,39 @@ export declare const GetSubscriptionsResponseStruct: Struct<{
|
|
|
517
601
|
trialEnd: Struct<string | undefined, null>;
|
|
518
602
|
endDate: Struct<string | undefined, null>;
|
|
519
603
|
canceledAt: Struct<string | undefined, null>;
|
|
520
|
-
cancelType: Struct<"allowed_at_period_end" | "allowed_immediate" | "not_allowed" | "not_allowed_pending_verification", {
|
|
604
|
+
cancelType: Struct<"allowed_at_period_end" | "allowed_immediate" | "not_allowed" | "not_allowed_pending_verification" | undefined, {
|
|
521
605
|
allowed_at_period_end: "allowed_at_period_end";
|
|
522
606
|
allowed_immediate: "allowed_immediate";
|
|
523
607
|
not_allowed: "not_allowed";
|
|
524
608
|
not_allowed_pending_verification: "not_allowed_pending_verification";
|
|
525
609
|
}>;
|
|
526
610
|
inactiveAt: Struct<string | undefined, null>;
|
|
527
|
-
isEligibleForSupport: Struct<boolean, null>;
|
|
611
|
+
isEligibleForSupport: Struct<boolean | undefined, null>;
|
|
528
612
|
billingCycles: Struct<number | undefined, null>;
|
|
613
|
+
lastInvoice: Struct<{
|
|
614
|
+
id: string;
|
|
615
|
+
status: "FAILED" | "PROCESSING" | "SUCCEEDED" | "UNKNOWN";
|
|
616
|
+
errorCode?: "delegation_not_found" | "delegation_revoked" | "exceeds_delegation_allowance" | "insufficient_allowance" | "insufficient_balance" | "internal_server_error" | "recipient_not_allowlisted" | undefined;
|
|
617
|
+
updatedAt: string;
|
|
618
|
+
} | undefined, {
|
|
619
|
+
id: Struct<string, null>;
|
|
620
|
+
status: Struct<"FAILED" | "PROCESSING" | "SUCCEEDED" | "UNKNOWN", {
|
|
621
|
+
FAILED: "FAILED";
|
|
622
|
+
PROCESSING: "PROCESSING";
|
|
623
|
+
SUCCEEDED: "SUCCEEDED";
|
|
624
|
+
UNKNOWN: "UNKNOWN";
|
|
625
|
+
}>;
|
|
626
|
+
errorCode: Struct<"delegation_not_found" | "delegation_revoked" | "exceeds_delegation_allowance" | "insufficient_allowance" | "insufficient_balance" | "internal_server_error" | "recipient_not_allowlisted" | undefined, {
|
|
627
|
+
delegation_not_found: "delegation_not_found";
|
|
628
|
+
delegation_revoked: "delegation_revoked";
|
|
629
|
+
exceeds_delegation_allowance: "exceeds_delegation_allowance";
|
|
630
|
+
insufficient_allowance: "insufficient_allowance";
|
|
631
|
+
insufficient_balance: "insufficient_balance";
|
|
632
|
+
internal_server_error: "internal_server_error";
|
|
633
|
+
recipient_not_allowlisted: "recipient_not_allowlisted";
|
|
634
|
+
}>;
|
|
635
|
+
updatedAt: Struct<string, null>;
|
|
636
|
+
}>;
|
|
529
637
|
}>;
|
|
530
638
|
rewardAccountId: Struct<`${string}:${string}:${string}` | undefined, null>;
|
|
531
639
|
}>;
|
|
@@ -681,6 +789,8 @@ export declare const PricingResponseStruct: Struct<{
|
|
|
681
789
|
paymentMethods: ({
|
|
682
790
|
type: "card";
|
|
683
791
|
products?: ("money_account_plus" | "shield")[] | undefined;
|
|
792
|
+
cryptoAuthMethod?: undefined;
|
|
793
|
+
chains?: undefined;
|
|
684
794
|
} | {
|
|
685
795
|
type: "crypto";
|
|
686
796
|
cryptoAuthMethod?: "delegation" | "erc20_approval" | undefined;
|
|
@@ -755,6 +865,8 @@ export declare const PricingResponseStruct: Struct<{
|
|
|
755
865
|
paymentMethods: Struct<({
|
|
756
866
|
type: "card";
|
|
757
867
|
products?: ("money_account_plus" | "shield")[] | undefined;
|
|
868
|
+
cryptoAuthMethod?: undefined;
|
|
869
|
+
chains?: undefined;
|
|
758
870
|
} | {
|
|
759
871
|
type: "crypto";
|
|
760
872
|
cryptoAuthMethod?: "delegation" | "erc20_approval" | undefined;
|
|
@@ -769,6 +881,8 @@ export declare const PricingResponseStruct: Struct<{
|
|
|
769
881
|
})[], Struct<{
|
|
770
882
|
type: "card";
|
|
771
883
|
products?: ("money_account_plus" | "shield")[] | undefined;
|
|
884
|
+
cryptoAuthMethod?: undefined;
|
|
885
|
+
chains?: undefined;
|
|
772
886
|
} | {
|
|
773
887
|
type: "crypto";
|
|
774
888
|
cryptoAuthMethod?: "delegation" | "erc20_approval" | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubscriptionService-structs.d.ts","sourceRoot":"","sources":["../src/SubscriptionService-structs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SubscriptionService-structs.d.ts","sourceRoot":"","sources":["../src/SubscriptionService-structs.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAgBpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAqEnD,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0B7B,CAAC;AAEH,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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, nullable, number, optional, string, type, union, } from '@metamask/superstruct';
|
|
2
2
|
import { StrictHexStruct, CaipAccountIdStruct } from '@metamask/utils';
|
|
3
|
-
import { CANCEL_TYPES, CRYPTO_AUTH_METHODS, CRYPTO_PAYMENT_METHOD_ERRORS, PAYMENT_TYPES, PRODUCT_TYPES, RECURRING_INTERVALS, MoneyAccountFeature, ShieldFeature, SUBSCRIPTION_STATUSES, } from './types.js';
|
|
3
|
+
import { CANCEL_TYPES, CRYPTO_AUTH_METHODS, CRYPTO_PAYMENT_ERRORS, CRYPTO_PAYMENT_METHOD_ERRORS, INVOICE_PAYMENT_STATUSES, PAYMENT_TYPES, PRODUCT_TYPES, RECURRING_INTERVALS, MoneyAccountFeature, ShieldFeature, SUBSCRIPTION_STATUSES, } from './types.js';
|
|
4
4
|
const ProductTypeStruct = enums(Object.values(PRODUCT_TYPES));
|
|
5
5
|
const CryptoAuthMethodStruct = enums(Object.values(CRYPTO_AUTH_METHODS));
|
|
6
6
|
const ShieldEntitlementsStruct = type({
|
|
@@ -24,8 +24,10 @@ const ProductEntitlementsStruct = type({
|
|
|
24
24
|
});
|
|
25
25
|
const RecurringIntervalStruct = enums(Object.values(RECURRING_INTERVALS));
|
|
26
26
|
const SubscriptionStatusStruct = enums(Object.values(SUBSCRIPTION_STATUSES));
|
|
27
|
+
const InvoicePaymentStatusStruct = enums(Object.values(INVOICE_PAYMENT_STATUSES));
|
|
27
28
|
const CancelTypeStruct = enums(Object.values(CANCEL_TYPES));
|
|
28
29
|
const CryptoPaymentMethodErrorStruct = enums(Object.values(CRYPTO_PAYMENT_METHOD_ERRORS));
|
|
30
|
+
const CryptoPaymentErrorStruct = enums(Object.values(CRYPTO_PAYMENT_ERRORS));
|
|
29
31
|
const ProductStruct = type({
|
|
30
32
|
name: ProductTypeStruct,
|
|
31
33
|
currency: enums(['usd']),
|
|
@@ -56,8 +58,8 @@ const SubscriptionPaymentMethodStruct = union([
|
|
|
56
58
|
export const SubscriptionStruct = type({
|
|
57
59
|
id: string(),
|
|
58
60
|
products: array(ProductStruct),
|
|
59
|
-
currentPeriodStart: string(),
|
|
60
|
-
currentPeriodEnd: string(),
|
|
61
|
+
currentPeriodStart: optional(string()),
|
|
62
|
+
currentPeriodEnd: optional(string()),
|
|
61
63
|
cancelAtPeriodEnd: optional(boolean()),
|
|
62
64
|
status: SubscriptionStatusStruct,
|
|
63
65
|
interval: RecurringIntervalStruct,
|
|
@@ -67,10 +69,16 @@ export const SubscriptionStruct = type({
|
|
|
67
69
|
trialEnd: optional(string()),
|
|
68
70
|
endDate: optional(string()),
|
|
69
71
|
canceledAt: optional(string()),
|
|
70
|
-
cancelType: CancelTypeStruct,
|
|
72
|
+
cancelType: optional(CancelTypeStruct),
|
|
71
73
|
inactiveAt: optional(string()),
|
|
72
|
-
isEligibleForSupport: boolean(),
|
|
74
|
+
isEligibleForSupport: optional(boolean()),
|
|
73
75
|
billingCycles: optional(number()),
|
|
76
|
+
lastInvoice: optional(type({
|
|
77
|
+
id: string(),
|
|
78
|
+
status: InvoicePaymentStatusStruct,
|
|
79
|
+
errorCode: optional(CryptoPaymentErrorStruct),
|
|
80
|
+
updatedAt: string(),
|
|
81
|
+
})),
|
|
74
82
|
});
|
|
75
83
|
export const GetSubscriptionsResponseStruct = type({
|
|
76
84
|
customerId: optional(string()),
|
|
@@ -144,22 +152,38 @@ const ProductPricingStruct = type({
|
|
|
144
152
|
const TokenPaymentInfoConversionRateStruct = type({
|
|
145
153
|
usd: string(),
|
|
146
154
|
});
|
|
155
|
+
/**
|
|
156
|
+
* A settlement token, discriminated by the presence of `accountantAddress`.
|
|
157
|
+
*
|
|
158
|
+
* Both variants use `type` rather than `object` so that fields the API adds
|
|
159
|
+
* later pass through instead of failing the whole union — an exact struct here
|
|
160
|
+
* turns any additive pricing change into a hard `getPricing` failure. The
|
|
161
|
+
* mutually exclusive fields are still pinned with `optional(never())` on the
|
|
162
|
+
* spot variant, so a vault share cannot silently validate as a spot token and
|
|
163
|
+
* get valued at face value.
|
|
164
|
+
*
|
|
165
|
+
* `type` infers an index signature rather than a concrete shape, so the
|
|
166
|
+
* inferred struct type has to be widened through `unknown` before it can be
|
|
167
|
+
* pinned to `TokenPaymentInfo`. The declared type is the contract; the runtime
|
|
168
|
+
* checks above are what enforce it.
|
|
169
|
+
*/
|
|
147
170
|
const TokenPaymentInfoStruct = lazy(() => union([
|
|
148
|
-
|
|
171
|
+
type({
|
|
149
172
|
symbol: string(),
|
|
150
173
|
address: StrictHexStruct,
|
|
151
174
|
decimals: number(),
|
|
152
175
|
conversionRate: optional(TokenPaymentInfoConversionRateStruct),
|
|
153
|
-
isVaultShare: literal(true),
|
|
154
176
|
accountantAddress: StrictHexStruct,
|
|
177
|
+
vault: optional(string()),
|
|
155
178
|
sources: optional(array(TokenPaymentInfoStruct)),
|
|
156
179
|
}),
|
|
157
|
-
|
|
180
|
+
type({
|
|
158
181
|
symbol: string(),
|
|
159
182
|
address: StrictHexStruct,
|
|
160
183
|
decimals: number(),
|
|
161
184
|
conversionRate: optional(TokenPaymentInfoConversionRateStruct),
|
|
162
|
-
|
|
185
|
+
accountantAddress: optional(never()),
|
|
186
|
+
vault: optional(never()),
|
|
163
187
|
sources: optional(array(TokenPaymentInfoStruct)),
|
|
164
188
|
}),
|
|
165
189
|
]));
|
|
@@ -170,12 +194,22 @@ const ChainPaymentInfoStruct = type({
|
|
|
170
194
|
tokens: array(TokenPaymentInfoStruct),
|
|
171
195
|
isSponsorshipSupported: optional(boolean()),
|
|
172
196
|
});
|
|
197
|
+
/**
|
|
198
|
+
* A pricing payment-method row, discriminated by `type`.
|
|
199
|
+
*
|
|
200
|
+
* `type` rather than `object` for the same reason as
|
|
201
|
+
* {@link TokenPaymentInfoStruct}: new fields on a row must not fail the union.
|
|
202
|
+
* The crypto-only fields stay pinned with `optional(never())` on the card
|
|
203
|
+
* variant so a card row carrying `chains` is still rejected.
|
|
204
|
+
*/
|
|
173
205
|
const PricingPaymentMethodStruct = union([
|
|
174
|
-
|
|
206
|
+
type({
|
|
175
207
|
type: enums([PAYMENT_TYPES.byCard]),
|
|
176
208
|
products: optional(array(ProductTypeStruct)),
|
|
209
|
+
cryptoAuthMethod: optional(never()),
|
|
210
|
+
chains: optional(never()),
|
|
177
211
|
}),
|
|
178
|
-
|
|
212
|
+
type({
|
|
179
213
|
type: enums([PAYMENT_TYPES.byCrypto]),
|
|
180
214
|
cryptoAuthMethod: optional(CryptoAuthMethodStruct),
|
|
181
215
|
products: optional(array(ProductTypeStruct)),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubscriptionService-structs.js","sourceRoot":"","sources":["../src/SubscriptionService-structs.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,OAAO,EACP,KAAK,EACL,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,MAAM,EACN,MAAM,EACN,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,KAAK,GACN,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEvE,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,4BAA4B,EAC5B,aAAa,EACb,aAAa,EACb,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,EACb,qBAAqB,GACtB,MAAM,YAAY,CAAC;AAGpB,MAAM,iBAAiB,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC;AAC9D,MAAM,sBAAsB,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC,CAAC;AACzE,MAAM,wBAAwB,GAAG,IAAI,CAAC;IACpC,CAAC,aAAa,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE;IACtC,CAAC,aAAa,CAAC,eAAe,CAAC,EAAE,OAAO,EAAE;CAC3C,CAAC,CAAC;AACH,MAAM,8BAA8B,GAAG,IAAI,CAAC;IAC1C,CAAC,mBAAmB,CAAC,aAAa,CAA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KAAK,CACrD,6BAA6B,CAC9B,CAAC","sourcesContent":["import {\n array,\n boolean,\n enums,\n lazy,\n literal,\n nullable,\n number,\n object,\n optional,\n string,\n type,\n union,\n} from '@metamask/superstruct';\nimport type { Struct } from '@metamask/superstruct';\nimport { StrictHexStruct, CaipAccountIdStruct } from '@metamask/utils';\n\nimport {\n CANCEL_TYPES,\n CRYPTO_AUTH_METHODS,\n CRYPTO_PAYMENT_METHOD_ERRORS,\n PAYMENT_TYPES,\n PRODUCT_TYPES,\n RECURRING_INTERVALS,\n MoneyAccountFeature,\n ShieldFeature,\n SUBSCRIPTION_STATUSES,\n} from './types.js';\nimport type { TokenPaymentInfo } from './types.js';\n\nconst ProductTypeStruct = enums(Object.values(PRODUCT_TYPES));\nconst CryptoAuthMethodStruct = enums(Object.values(CRYPTO_AUTH_METHODS));\nconst ShieldEntitlementsStruct = type({\n [ShieldFeature.ShieldClaim]: boolean(),\n [ShieldFeature.PrioritySupport]: boolean(),\n});\nconst MoneyAccountEntitlementsStruct = type({\n [MoneyAccountFeature.SwapFeeWaiver]: boolean(),\n [MoneyAccountFeature.PerpsFeeWaiver]: boolean(),\n [MoneyAccountFeature.PredictFreeTx]: boolean(),\n [MoneyAccountFeature.PremiumApy]: boolean(),\n});\nconst ProductEntitlementsStruct = type({\n [PRODUCT_TYPES.SHIELD]: optional(\n type({\n entitlements: ShieldEntitlementsStruct,\n }),\n ),\n [PRODUCT_TYPES.MONEY_ACCOUNT_PLUS]: optional(\n type({\n plan: string(),\n entitlements: MoneyAccountEntitlementsStruct,\n }),\n ),\n});\nconst RecurringIntervalStruct = enums(Object.values(RECURRING_INTERVALS));\nconst SubscriptionStatusStruct = enums(Object.values(SUBSCRIPTION_STATUSES));\nconst CancelTypeStruct = enums(Object.values(CANCEL_TYPES));\nconst CryptoPaymentMethodErrorStruct = enums(\n Object.values(CRYPTO_PAYMENT_METHOD_ERRORS),\n);\n\nconst ProductStruct = type({\n name: ProductTypeStruct,\n currency: enums(['usd']),\n unitAmount: number(),\n unitDecimals: number(),\n});\n\nconst SubscriptionCardPaymentMethodStruct = type({\n type: enums([PAYMENT_TYPES.byCard]),\n card: type({\n brand: string(),\n displayBrand: string(),\n last4: string(),\n }),\n});\n\nconst SubscriptionCryptoPaymentMethodStruct = type({\n type: enums([PAYMENT_TYPES.byCrypto]),\n crypto: type({\n payerAddress: StrictHexStruct,\n chainId: StrictHexStruct,\n tokenSymbol: string(),\n error: optional(CryptoPaymentMethodErrorStruct),\n }),\n});\n\nconst SubscriptionPaymentMethodStruct = union([\n SubscriptionCardPaymentMethodStruct,\n SubscriptionCryptoPaymentMethodStruct,\n]);\n\nexport const SubscriptionStruct = type({\n id: string(),\n products: array(ProductStruct),\n currentPeriodStart: string(),\n currentPeriodEnd: string(),\n cancelAtPeriodEnd: optional(boolean()),\n status: SubscriptionStatusStruct,\n interval: RecurringIntervalStruct,\n paymentMethod: SubscriptionPaymentMethodStruct,\n trialPeriodDays: optional(number()),\n trialStart: optional(string()),\n trialEnd: optional(string()),\n endDate: optional(string()),\n canceledAt: optional(string()),\n cancelType: CancelTypeStruct,\n inactiveAt: optional(string()),\n isEligibleForSupport: boolean(),\n billingCycles: optional(number()),\n});\n\nexport const GetSubscriptionsResponseStruct = type({\n customerId: optional(string()),\n subscriptions: array(SubscriptionStruct),\n trialedProducts: array(ProductTypeStruct),\n productEntitlements: optional(ProductEntitlementsStruct),\n lastSubscription: optional(SubscriptionStruct),\n rewardAccountId: optional(CaipAccountIdStruct),\n});\n\nconst SwapsBenefitUsageStruct = type({\n feeBips: nullable(string()),\n capMicroUsd: optional(number()),\n consumedMicroUsd: optional(number()),\n remainingMicroUsd: nullable(number()),\n exhausted: boolean(),\n});\n\nconst PerpsBenefitUsageStruct = type({\n builderFeeBips: nullable(string()),\n builderCode: nullable(string()),\n capMicroUsd: optional(number()),\n consumedMicroUsd: optional(number()),\n remainingMicroUsd: nullable(number()),\n exhausted: boolean(),\n});\n\nconst PredictBenefitUsageStruct = type({\n builderCode: nullable(string()),\n capTxCount: optional(number()),\n consumedTxCount: optional(number()),\n remainingTxCount: nullable(number()),\n exhausted: boolean(),\n});\n\nexport const SubscriptionBenefitsResponseStruct = type({\n eligible: boolean(),\n billingPeriodId: nullable(string()),\n products: type({\n swaps: SwapsBenefitUsageStruct,\n perps: PerpsBenefitUsageStruct,\n predict: PredictBenefitUsageStruct,\n }),\n});\n\nexport const StartSubscriptionResponseStruct = type({\n checkoutSessionUrl: string(),\n});\n\nexport const StartCryptoSubscriptionResponseStruct = type({\n subscriptionId: string(),\n status: SubscriptionStatusStruct,\n});\n\nexport const UpdatePaymentMethodCardResponseStruct = type({\n redirectUrl: string(),\n});\n\nexport const BillingPortalResponseStruct = type({\n url: string(),\n});\n\nexport const SubscriptionApiGeneralResponseStruct = type({\n success: boolean(),\n message: optional(string()),\n});\n\nconst ProductPriceStruct = type({\n interval: RecurringIntervalStruct,\n unitAmount: number(),\n unitDecimals: number(),\n currency: enums(['usd']),\n trialPeriodDays: number(),\n minBillingCycles: number(),\n minBillingCyclesForBalance: number(),\n});\n\nconst ProductPricingStruct = type({\n name: ProductTypeStruct,\n prices: array(ProductPriceStruct),\n});\n\nconst TokenPaymentInfoConversionRateStruct = type({\n usd: string(),\n});\n\nconst TokenPaymentInfoStruct: Struct<TokenPaymentInfo> = lazy(() =>\n union([\n object({\n symbol: string(),\n address: StrictHexStruct,\n decimals: number(),\n conversionRate: optional(TokenPaymentInfoConversionRateStruct),\n isVaultShare: literal(true),\n accountantAddress: StrictHexStruct,\n sources: optional(array(TokenPaymentInfoStruct)),\n }),\n object({\n symbol: string(),\n address: StrictHexStruct,\n decimals: number(),\n conversionRate: optional(TokenPaymentInfoConversionRateStruct),\n isVaultShare: optional(literal(false)),\n sources: optional(array(TokenPaymentInfoStruct)),\n }),\n ]),\n) as Struct<TokenPaymentInfo>;\n\nconst ChainPaymentInfoStruct = type({\n chainId: StrictHexStruct,\n paymentAddress: StrictHexStruct,\n delegateAddress: optional(StrictHexStruct),\n tokens: array(TokenPaymentInfoStruct),\n isSponsorshipSupported: optional(boolean()),\n});\n\nconst PricingPaymentMethodStruct = union([\n object({\n type: enums([PAYMENT_TYPES.byCard]),\n products: optional(array(ProductTypeStruct)),\n }),\n object({\n type: enums([PAYMENT_TYPES.byCrypto]),\n cryptoAuthMethod: optional(CryptoAuthMethodStruct),\n products: optional(array(ProductTypeStruct)),\n chains: optional(array(ChainPaymentInfoStruct)),\n }),\n]);\n\nexport const PricingResponseStruct = type({\n products: array(ProductPricingStruct),\n paymentMethods: array(PricingPaymentMethodStruct),\n});\n\nconst CohortStruct = type({\n cohort: string(),\n eligibilityRate: number(),\n priority: number(),\n eligible: boolean(),\n});\n\nexport const SubscriptionEligibilityStruct = type({\n product: ProductTypeStruct,\n canSubscribe: optional(boolean()),\n canViewEntryModal: optional(boolean()),\n modalType: optional(enums(['A', 'B'])),\n cohorts: optional(array(CohortStruct)),\n assignedCohort: optional(nullable(string())),\n assignedAt: optional(string()),\n hasAssignedCohortExpired: optional(boolean()),\n});\n\nexport const SubscriptionEligibilityArrayStruct = array(\n SubscriptionEligibilityStruct,\n);\n"]}
|
|
1
|
+
{"version":3,"file":"SubscriptionService-structs.js","sourceRoot":"","sources":["../src/SubscriptionService-structs.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,OAAO,EACP,KAAK,EACL,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,KAAK,GACN,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEvE,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,qBAAqB,EACrB,4BAA4B,EAC5B,wBAAwB,EACxB,aAAa,EACb,aAAa,EACb,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,EACb,qBAAqB,GACtB,MAAM,YAAY,CAAC;AAGpB,MAAM,iBAAiB,GAAG,KAAK,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KAAK,CAAC,iBAAiB,CAAC,CAAC;QAC5C,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC;KAChD,CAAC;CACH,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC;IACxC,QAAQ,EAAE,KAAK,CAAC,oBAAoB,CAAC;IACrC,cAAc,EAAE,KAAK,CAAC,0BAA0B,CAAC;CAClD,CAAC,CAAC;AAEH,MAAM,YAAY,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,MAAM,EAAE;IAChB,eAAe,EAAE,MAAM,EAAE;IACzB,QAAQ,EAAE,MAAM,EAAE;IAClB,QAAQ,EAAE,OAAO,EAAE;CACpB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,6BAA6B,GAAG,IAAI,CAAC;IAChD,OAAO,EAAE,iBAAiB;IAC1B,YAAY,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;IACjC,iBAAiB,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;IACtC,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IACtC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IACtC,cAAc,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAC5C,UAAU,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC9B,wBAAwB,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;CAC9C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,kCAAkC,GAAG,KAAK,CACrD,6BAA6B,CAC9B,CAAC","sourcesContent":["import {\n array,\n boolean,\n enums,\n lazy,\n never,\n nullable,\n number,\n optional,\n string,\n type,\n union,\n} from '@metamask/superstruct';\nimport type { Struct } from '@metamask/superstruct';\nimport { StrictHexStruct, CaipAccountIdStruct } from '@metamask/utils';\n\nimport {\n CANCEL_TYPES,\n CRYPTO_AUTH_METHODS,\n CRYPTO_PAYMENT_ERRORS,\n CRYPTO_PAYMENT_METHOD_ERRORS,\n INVOICE_PAYMENT_STATUSES,\n PAYMENT_TYPES,\n PRODUCT_TYPES,\n RECURRING_INTERVALS,\n MoneyAccountFeature,\n ShieldFeature,\n SUBSCRIPTION_STATUSES,\n} from './types.js';\nimport type { TokenPaymentInfo } from './types.js';\n\nconst ProductTypeStruct = enums(Object.values(PRODUCT_TYPES));\nconst CryptoAuthMethodStruct = enums(Object.values(CRYPTO_AUTH_METHODS));\nconst ShieldEntitlementsStruct = type({\n [ShieldFeature.ShieldClaim]: boolean(),\n [ShieldFeature.PrioritySupport]: boolean(),\n});\nconst MoneyAccountEntitlementsStruct = type({\n [MoneyAccountFeature.SwapFeeWaiver]: boolean(),\n [MoneyAccountFeature.PerpsFeeWaiver]: boolean(),\n [MoneyAccountFeature.PredictFreeTx]: boolean(),\n [MoneyAccountFeature.PremiumApy]: boolean(),\n});\nconst ProductEntitlementsStruct = type({\n [PRODUCT_TYPES.SHIELD]: optional(\n type({\n entitlements: ShieldEntitlementsStruct,\n }),\n ),\n [PRODUCT_TYPES.MONEY_ACCOUNT_PLUS]: optional(\n type({\n plan: string(),\n entitlements: MoneyAccountEntitlementsStruct,\n }),\n ),\n});\nconst RecurringIntervalStruct = enums(Object.values(RECURRING_INTERVALS));\nconst SubscriptionStatusStruct = enums(Object.values(SUBSCRIPTION_STATUSES));\nconst InvoicePaymentStatusStruct = enums(\n Object.values(INVOICE_PAYMENT_STATUSES),\n);\nconst CancelTypeStruct = enums(Object.values(CANCEL_TYPES));\nconst CryptoPaymentMethodErrorStruct = enums(\n Object.values(CRYPTO_PAYMENT_METHOD_ERRORS),\n);\nconst CryptoPaymentErrorStruct = enums(Object.values(CRYPTO_PAYMENT_ERRORS));\n\nconst ProductStruct = type({\n name: ProductTypeStruct,\n currency: enums(['usd']),\n unitAmount: number(),\n unitDecimals: number(),\n});\n\nconst SubscriptionCardPaymentMethodStruct = type({\n type: enums([PAYMENT_TYPES.byCard]),\n card: type({\n brand: string(),\n displayBrand: string(),\n last4: string(),\n }),\n});\n\nconst SubscriptionCryptoPaymentMethodStruct = type({\n type: enums([PAYMENT_TYPES.byCrypto]),\n crypto: type({\n payerAddress: StrictHexStruct,\n chainId: StrictHexStruct,\n tokenSymbol: string(),\n error: optional(CryptoPaymentMethodErrorStruct),\n }),\n});\n\nconst SubscriptionPaymentMethodStruct = union([\n SubscriptionCardPaymentMethodStruct,\n SubscriptionCryptoPaymentMethodStruct,\n]);\n\nexport const SubscriptionStruct = type({\n id: string(),\n products: array(ProductStruct),\n currentPeriodStart: optional(string()),\n currentPeriodEnd: optional(string()),\n cancelAtPeriodEnd: optional(boolean()),\n status: SubscriptionStatusStruct,\n interval: RecurringIntervalStruct,\n paymentMethod: SubscriptionPaymentMethodStruct,\n trialPeriodDays: optional(number()),\n trialStart: optional(string()),\n trialEnd: optional(string()),\n endDate: optional(string()),\n canceledAt: optional(string()),\n cancelType: optional(CancelTypeStruct),\n inactiveAt: optional(string()),\n isEligibleForSupport: optional(boolean()),\n billingCycles: optional(number()),\n lastInvoice: optional(\n type({\n id: string(),\n status: InvoicePaymentStatusStruct,\n errorCode: optional(CryptoPaymentErrorStruct),\n updatedAt: string(),\n }),\n ),\n});\n\nexport const GetSubscriptionsResponseStruct = type({\n customerId: optional(string()),\n subscriptions: array(SubscriptionStruct),\n trialedProducts: array(ProductTypeStruct),\n productEntitlements: optional(ProductEntitlementsStruct),\n lastSubscription: optional(SubscriptionStruct),\n rewardAccountId: optional(CaipAccountIdStruct),\n});\n\nconst SwapsBenefitUsageStruct = type({\n feeBips: nullable(string()),\n capMicroUsd: optional(number()),\n consumedMicroUsd: optional(number()),\n remainingMicroUsd: nullable(number()),\n exhausted: boolean(),\n});\n\nconst PerpsBenefitUsageStruct = type({\n builderFeeBips: nullable(string()),\n builderCode: nullable(string()),\n capMicroUsd: optional(number()),\n consumedMicroUsd: optional(number()),\n remainingMicroUsd: nullable(number()),\n exhausted: boolean(),\n});\n\nconst PredictBenefitUsageStruct = type({\n builderCode: nullable(string()),\n capTxCount: optional(number()),\n consumedTxCount: optional(number()),\n remainingTxCount: nullable(number()),\n exhausted: boolean(),\n});\n\nexport const SubscriptionBenefitsResponseStruct = type({\n eligible: boolean(),\n billingPeriodId: nullable(string()),\n products: type({\n swaps: SwapsBenefitUsageStruct,\n perps: PerpsBenefitUsageStruct,\n predict: PredictBenefitUsageStruct,\n }),\n});\n\nexport const StartSubscriptionResponseStruct = type({\n checkoutSessionUrl: string(),\n});\n\nexport const StartCryptoSubscriptionResponseStruct = type({\n subscriptionId: string(),\n status: SubscriptionStatusStruct,\n});\n\nexport const UpdatePaymentMethodCardResponseStruct = type({\n redirectUrl: string(),\n});\n\nexport const BillingPortalResponseStruct = type({\n url: string(),\n});\n\nexport const SubscriptionApiGeneralResponseStruct = type({\n success: boolean(),\n message: optional(string()),\n});\n\nconst ProductPriceStruct = type({\n interval: RecurringIntervalStruct,\n unitAmount: number(),\n unitDecimals: number(),\n currency: enums(['usd']),\n trialPeriodDays: number(),\n minBillingCycles: number(),\n minBillingCyclesForBalance: number(),\n});\n\nconst ProductPricingStruct = type({\n name: ProductTypeStruct,\n prices: array(ProductPriceStruct),\n});\n\nconst TokenPaymentInfoConversionRateStruct = type({\n usd: string(),\n});\n\n/**\n * A settlement token, discriminated by the presence of `accountantAddress`.\n *\n * Both variants use `type` rather than `object` so that fields the API adds\n * later pass through instead of failing the whole union — an exact struct here\n * turns any additive pricing change into a hard `getPricing` failure. The\n * mutually exclusive fields are still pinned with `optional(never())` on the\n * spot variant, so a vault share cannot silently validate as a spot token and\n * get valued at face value.\n *\n * `type` infers an index signature rather than a concrete shape, so the\n * inferred struct type has to be widened through `unknown` before it can be\n * pinned to `TokenPaymentInfo`. The declared type is the contract; the runtime\n * checks above are what enforce it.\n */\nconst TokenPaymentInfoStruct: Struct<TokenPaymentInfo> = lazy(() =>\n union([\n type({\n symbol: string(),\n address: StrictHexStruct,\n decimals: number(),\n conversionRate: optional(TokenPaymentInfoConversionRateStruct),\n accountantAddress: StrictHexStruct,\n vault: optional(string()),\n sources: optional(array(TokenPaymentInfoStruct)),\n }),\n type({\n symbol: string(),\n address: StrictHexStruct,\n decimals: number(),\n conversionRate: optional(TokenPaymentInfoConversionRateStruct),\n accountantAddress: optional(never()),\n vault: optional(never()),\n sources: optional(array(TokenPaymentInfoStruct)),\n }),\n ]),\n) as Struct<TokenPaymentInfo>;\n\nconst ChainPaymentInfoStruct = type({\n chainId: StrictHexStruct,\n paymentAddress: StrictHexStruct,\n delegateAddress: optional(StrictHexStruct),\n tokens: array(TokenPaymentInfoStruct),\n isSponsorshipSupported: optional(boolean()),\n});\n\n/**\n * A pricing payment-method row, discriminated by `type`.\n *\n * `type` rather than `object` for the same reason as\n * {@link TokenPaymentInfoStruct}: new fields on a row must not fail the union.\n * The crypto-only fields stay pinned with `optional(never())` on the card\n * variant so a card row carrying `chains` is still rejected.\n */\nconst PricingPaymentMethodStruct = union([\n type({\n type: enums([PAYMENT_TYPES.byCard]),\n products: optional(array(ProductTypeStruct)),\n cryptoAuthMethod: optional(never()),\n chains: optional(never()),\n }),\n type({\n type: enums([PAYMENT_TYPES.byCrypto]),\n cryptoAuthMethod: optional(CryptoAuthMethodStruct),\n products: optional(array(ProductTypeStruct)),\n chains: optional(array(ChainPaymentInfoStruct)),\n }),\n]);\n\nexport const PricingResponseStruct = type({\n products: array(ProductPricingStruct),\n paymentMethods: array(PricingPaymentMethodStruct),\n});\n\nconst CohortStruct = type({\n cohort: string(),\n eligibilityRate: number(),\n priority: number(),\n eligible: boolean(),\n});\n\nexport const SubscriptionEligibilityStruct = type({\n product: ProductTypeStruct,\n canSubscribe: optional(boolean()),\n canViewEntryModal: optional(boolean()),\n modalType: optional(enums(['A', 'B'])),\n cohorts: optional(array(CohortStruct)),\n assignedCohort: optional(nullable(string())),\n assignedAt: optional(string()),\n hasAssignedCohortExpired: optional(boolean()),\n});\n\nexport const SubscriptionEligibilityArrayStruct = array(\n SubscriptionEligibilityStruct,\n);\n"]}
|