@metamask-previews/subscription-controller 6.0.2-preview-434bd0c → 6.0.2-preview-e9620906a
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 +13 -0
- package/dist/SubscriptionController-method-action-types.cjs +7 -0
- package/dist/SubscriptionController-method-action-types.cjs.map +1 -0
- package/dist/SubscriptionController-method-action-types.d.cts +209 -0
- package/dist/SubscriptionController-method-action-types.d.cts.map +1 -0
- package/dist/SubscriptionController-method-action-types.d.mts +209 -0
- package/dist/SubscriptionController-method-action-types.d.mts.map +1 -0
- package/dist/SubscriptionController-method-action-types.mjs +6 -0
- package/dist/SubscriptionController-method-action-types.mjs.map +1 -0
- package/dist/SubscriptionController.cjs +27 -18
- package/dist/SubscriptionController.cjs.map +1 -1
- package/dist/SubscriptionController.d.cts +3 -58
- package/dist/SubscriptionController.d.cts.map +1 -1
- package/dist/SubscriptionController.d.mts +3 -58
- package/dist/SubscriptionController.d.mts.map +1 -1
- package/dist/SubscriptionController.mjs +27 -18
- package/dist/SubscriptionController.mjs.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Expose all public `SubscriptionController` methods through its messenger ([#8219](https://github.com/MetaMask/core/pull/8219))
|
|
13
|
+
- `SubscriptionController:getSubscriptionsEligibilities`
|
|
14
|
+
- `SubscriptionController:unCancelSubscription`
|
|
15
|
+
- `SubscriptionController:submitUserEvent`
|
|
16
|
+
- `SubscriptionController:assignUserToCohort`
|
|
17
|
+
- `SubscriptionController:getTokenApproveAmount`
|
|
18
|
+
- `SubscriptionController:getTokenMinimumBalanceAmount`
|
|
19
|
+
- `SubscriptionController:clearState`
|
|
20
|
+
- `SubscriptionController:triggerAccessTokenRefresh`
|
|
21
|
+
- Corresponding action types are now exported (e.g. `SubscriptionControllerGetPricingAction`)
|
|
22
|
+
|
|
10
23
|
## [6.0.2]
|
|
11
24
|
|
|
12
25
|
### Changed
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SubscriptionController-method-action-types.cjs","sourceRoot":"","sources":["../src/SubscriptionController-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated by `scripts/generate-method-action-types.ts`.\n * Do not edit manually.\n */\n\nimport type { SubscriptionController } from './SubscriptionController';\n\n/**\n * Gets the pricing information from the subscription service.\n *\n * @returns The pricing information.\n */\nexport type SubscriptionControllerGetPricingAction = {\n type: `SubscriptionController:getPricing`;\n handler: SubscriptionController['getPricing'];\n};\n\nexport type SubscriptionControllerGetSubscriptionsAction = {\n type: `SubscriptionController:getSubscriptions`;\n handler: SubscriptionController['getSubscriptions'];\n};\n\n/**\n * Get the subscription by product.\n *\n * @param productType - The product type.\n * @returns The subscription.\n */\nexport type SubscriptionControllerGetSubscriptionByProductAction = {\n type: `SubscriptionController:getSubscriptionByProduct`;\n handler: SubscriptionController['getSubscriptionByProduct'];\n};\n\n/**\n * Get the subscriptions eligibilities.\n *\n * @param request - Optional request object containing user balance to check cohort eligibility.\n * @returns The subscriptions eligibilities.\n */\nexport type SubscriptionControllerGetSubscriptionsEligibilitiesAction = {\n type: `SubscriptionController:getSubscriptionsEligibilities`;\n handler: SubscriptionController['getSubscriptionsEligibilities'];\n};\n\nexport type SubscriptionControllerCancelSubscriptionAction = {\n type: `SubscriptionController:cancelSubscription`;\n handler: SubscriptionController['cancelSubscription'];\n};\n\nexport type SubscriptionControllerUnCancelSubscriptionAction = {\n type: `SubscriptionController:unCancelSubscription`;\n handler: SubscriptionController['unCancelSubscription'];\n};\n\nexport type SubscriptionControllerStartShieldSubscriptionWithCardAction = {\n type: `SubscriptionController:startShieldSubscriptionWithCard`;\n handler: SubscriptionController['startShieldSubscriptionWithCard'];\n};\n\nexport type SubscriptionControllerStartSubscriptionWithCryptoAction = {\n type: `SubscriptionController:startSubscriptionWithCrypto`;\n handler: SubscriptionController['startSubscriptionWithCrypto'];\n};\n\n/**\n * Handles shield subscription crypto approval transactions.\n *\n * @param txMeta - The transaction metadata.\n * @param isSponsored - Whether the transaction is sponsored.\n * @param rewardAccountId - The account ID of the reward subscription to link to the shield subscription.\n * @returns void\n */\nexport type SubscriptionControllerSubmitShieldSubscriptionCryptoApprovalAction =\n {\n type: `SubscriptionController:submitShieldSubscriptionCryptoApproval`;\n handler: SubscriptionController['submitShieldSubscriptionCryptoApproval'];\n };\n\n/**\n * Get transaction params to create crypto approve transaction for subscription payment\n *\n * @param request - The request object\n * @param request.chainId - The chain ID\n * @param request.tokenAddress - The address of the token\n * @param request.productType - The product type\n * @param request.interval - The interval\n * @returns The crypto approve transaction params\n */\nexport type SubscriptionControllerGetCryptoApproveTransactionParamsAction = {\n type: `SubscriptionController:getCryptoApproveTransactionParams`;\n handler: SubscriptionController['getCryptoApproveTransactionParams'];\n};\n\nexport type SubscriptionControllerUpdatePaymentMethodAction = {\n type: `SubscriptionController:updatePaymentMethod`;\n handler: SubscriptionController['updatePaymentMethod'];\n};\n\n/**\n * Gets the billing portal URL.\n *\n * @returns The billing portal URL\n */\nexport type SubscriptionControllerGetBillingPortalUrlAction = {\n type: `SubscriptionController:getBillingPortalUrl`;\n handler: SubscriptionController['getBillingPortalUrl'];\n};\n\n/**\n * Cache the last selected payment method for a specific product.\n *\n * @param product - The product to cache the payment method for.\n * @param paymentMethod - The payment method to cache.\n * @param paymentMethod.type - The type of the payment method.\n * @param paymentMethod.paymentTokenAddress - The payment token address.\n * @param paymentMethod.plan - The plan of the payment method.\n * @param paymentMethod.product - The product of the payment method.\n */\nexport type SubscriptionControllerCacheLastSelectedPaymentMethodAction = {\n type: `SubscriptionController:cacheLastSelectedPaymentMethod`;\n handler: SubscriptionController['cacheLastSelectedPaymentMethod'];\n};\n\n/**\n * Clear the last selected payment method for a specific product.\n *\n * @param product - The product to clear the payment method for.\n */\nexport type SubscriptionControllerClearLastSelectedPaymentMethodAction = {\n type: `SubscriptionController:clearLastSelectedPaymentMethod`;\n handler: SubscriptionController['clearLastSelectedPaymentMethod'];\n};\n\n/**\n * Submit sponsorship intents to the Subscription Service backend.\n *\n * This is intended to be used together with the crypto subscription flow.\n * When the user has enabled the smart transaction feature, we will sponsor the gas fees for the subscription approval transaction.\n *\n * @param request - Request object containing the address and products.\n * @example {\n * address: '0x1234567890123456789012345678901234567890',\n * products: [ProductType.Shield],\n * recurringInterval: RecurringInterval.Month,\n * billingCycles: 1,\n * }\n * @returns resolves to true if the sponsorship is supported and intents were submitted successfully, false otherwise\n */\nexport type SubscriptionControllerSubmitSponsorshipIntentsAction = {\n type: `SubscriptionController:submitSponsorshipIntents`;\n handler: SubscriptionController['submitSponsorshipIntents'];\n};\n\n/**\n * Submit a user event from the UI. (e.g. shield modal viewed)\n *\n * @param request - Request object containing the event to submit.\n * @example { event: SubscriptionUserEvent.ShieldEntryModalViewed, cohort: 'post_tx' }\n */\nexport type SubscriptionControllerSubmitUserEventAction = {\n type: `SubscriptionController:submitUserEvent`;\n handler: SubscriptionController['submitUserEvent'];\n};\n\n/**\n * Assign user to a cohort.\n *\n * @param request - Request object containing the cohort to assign the user to.\n * @example { cohort: 'post_tx' }\n */\nexport type SubscriptionControllerAssignUserToCohortAction = {\n type: `SubscriptionController:assignUserToCohort`;\n handler: SubscriptionController['assignUserToCohort'];\n};\n\n/**\n * Link rewards to a subscription.\n *\n * @param request - Request object containing the reward subscription ID.\n * @param request.subscriptionId - The ID of the subscription to link rewards to.\n * @param request.rewardAccountId - The account ID of the reward subscription to link to the subscription.\n * @example { subscriptionId: '1234567890', rewardAccountId: 'eip155:1:0x1234567890123456789012345678901234567890' }\n * @returns Resolves when the rewards are linked successfully.\n */\nexport type SubscriptionControllerLinkRewardsAction = {\n type: `SubscriptionController:linkRewards`;\n handler: SubscriptionController['linkRewards'];\n};\n\n/**\n * Calculate token approve amount from price info\n *\n * @param price - The price info\n * @param tokenPaymentInfo - The token price info\n * @returns The token approve amount\n */\nexport type SubscriptionControllerGetTokenApproveAmountAction = {\n type: `SubscriptionController:getTokenApproveAmount`;\n handler: SubscriptionController['getTokenApproveAmount'];\n};\n\n/**\n * Calculate token minimum balance amount from price info\n *\n * @param price - The price info\n * @param tokenPaymentInfo - The token price info\n * @returns The token balance amount\n */\nexport type SubscriptionControllerGetTokenMinimumBalanceAmountAction = {\n type: `SubscriptionController:getTokenMinimumBalanceAmount`;\n handler: SubscriptionController['getTokenMinimumBalanceAmount'];\n};\n\n/**\n * Clears the subscription state and resets to default values.\n */\nexport type SubscriptionControllerClearStateAction = {\n type: `SubscriptionController:clearState`;\n handler: SubscriptionController['clearState'];\n};\n\n/**\n * Triggers an access token refresh.\n */\nexport type SubscriptionControllerTriggerAccessTokenRefreshAction = {\n type: `SubscriptionController:triggerAccessTokenRefresh`;\n handler: SubscriptionController['triggerAccessTokenRefresh'];\n};\n\n/**\n * Union of all SubscriptionController action types.\n */\nexport type SubscriptionControllerMethodActions =\n | SubscriptionControllerGetPricingAction\n | SubscriptionControllerGetSubscriptionsAction\n | SubscriptionControllerGetSubscriptionByProductAction\n | SubscriptionControllerGetSubscriptionsEligibilitiesAction\n | SubscriptionControllerCancelSubscriptionAction\n | SubscriptionControllerUnCancelSubscriptionAction\n | SubscriptionControllerStartShieldSubscriptionWithCardAction\n | SubscriptionControllerStartSubscriptionWithCryptoAction\n | SubscriptionControllerSubmitShieldSubscriptionCryptoApprovalAction\n | SubscriptionControllerGetCryptoApproveTransactionParamsAction\n | SubscriptionControllerUpdatePaymentMethodAction\n | SubscriptionControllerGetBillingPortalUrlAction\n | SubscriptionControllerCacheLastSelectedPaymentMethodAction\n | SubscriptionControllerClearLastSelectedPaymentMethodAction\n | SubscriptionControllerSubmitSponsorshipIntentsAction\n | SubscriptionControllerSubmitUserEventAction\n | SubscriptionControllerAssignUserToCohortAction\n | SubscriptionControllerLinkRewardsAction\n | SubscriptionControllerGetTokenApproveAmountAction\n | SubscriptionControllerGetTokenMinimumBalanceAmountAction\n | SubscriptionControllerClearStateAction\n | SubscriptionControllerTriggerAccessTokenRefreshAction;\n"]}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is auto generated by `scripts/generate-method-action-types.ts`.
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
*/
|
|
5
|
+
import type { SubscriptionController } from "./SubscriptionController.cjs";
|
|
6
|
+
/**
|
|
7
|
+
* Gets the pricing information from the subscription service.
|
|
8
|
+
*
|
|
9
|
+
* @returns The pricing information.
|
|
10
|
+
*/
|
|
11
|
+
export type SubscriptionControllerGetPricingAction = {
|
|
12
|
+
type: `SubscriptionController:getPricing`;
|
|
13
|
+
handler: SubscriptionController['getPricing'];
|
|
14
|
+
};
|
|
15
|
+
export type SubscriptionControllerGetSubscriptionsAction = {
|
|
16
|
+
type: `SubscriptionController:getSubscriptions`;
|
|
17
|
+
handler: SubscriptionController['getSubscriptions'];
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Get the subscription by product.
|
|
21
|
+
*
|
|
22
|
+
* @param productType - The product type.
|
|
23
|
+
* @returns The subscription.
|
|
24
|
+
*/
|
|
25
|
+
export type SubscriptionControllerGetSubscriptionByProductAction = {
|
|
26
|
+
type: `SubscriptionController:getSubscriptionByProduct`;
|
|
27
|
+
handler: SubscriptionController['getSubscriptionByProduct'];
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Get the subscriptions eligibilities.
|
|
31
|
+
*
|
|
32
|
+
* @param request - Optional request object containing user balance to check cohort eligibility.
|
|
33
|
+
* @returns The subscriptions eligibilities.
|
|
34
|
+
*/
|
|
35
|
+
export type SubscriptionControllerGetSubscriptionsEligibilitiesAction = {
|
|
36
|
+
type: `SubscriptionController:getSubscriptionsEligibilities`;
|
|
37
|
+
handler: SubscriptionController['getSubscriptionsEligibilities'];
|
|
38
|
+
};
|
|
39
|
+
export type SubscriptionControllerCancelSubscriptionAction = {
|
|
40
|
+
type: `SubscriptionController:cancelSubscription`;
|
|
41
|
+
handler: SubscriptionController['cancelSubscription'];
|
|
42
|
+
};
|
|
43
|
+
export type SubscriptionControllerUnCancelSubscriptionAction = {
|
|
44
|
+
type: `SubscriptionController:unCancelSubscription`;
|
|
45
|
+
handler: SubscriptionController['unCancelSubscription'];
|
|
46
|
+
};
|
|
47
|
+
export type SubscriptionControllerStartShieldSubscriptionWithCardAction = {
|
|
48
|
+
type: `SubscriptionController:startShieldSubscriptionWithCard`;
|
|
49
|
+
handler: SubscriptionController['startShieldSubscriptionWithCard'];
|
|
50
|
+
};
|
|
51
|
+
export type SubscriptionControllerStartSubscriptionWithCryptoAction = {
|
|
52
|
+
type: `SubscriptionController:startSubscriptionWithCrypto`;
|
|
53
|
+
handler: SubscriptionController['startSubscriptionWithCrypto'];
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Handles shield subscription crypto approval transactions.
|
|
57
|
+
*
|
|
58
|
+
* @param txMeta - The transaction metadata.
|
|
59
|
+
* @param isSponsored - Whether the transaction is sponsored.
|
|
60
|
+
* @param rewardAccountId - The account ID of the reward subscription to link to the shield subscription.
|
|
61
|
+
* @returns void
|
|
62
|
+
*/
|
|
63
|
+
export type SubscriptionControllerSubmitShieldSubscriptionCryptoApprovalAction = {
|
|
64
|
+
type: `SubscriptionController:submitShieldSubscriptionCryptoApproval`;
|
|
65
|
+
handler: SubscriptionController['submitShieldSubscriptionCryptoApproval'];
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Get transaction params to create crypto approve transaction for subscription payment
|
|
69
|
+
*
|
|
70
|
+
* @param request - The request object
|
|
71
|
+
* @param request.chainId - The chain ID
|
|
72
|
+
* @param request.tokenAddress - The address of the token
|
|
73
|
+
* @param request.productType - The product type
|
|
74
|
+
* @param request.interval - The interval
|
|
75
|
+
* @returns The crypto approve transaction params
|
|
76
|
+
*/
|
|
77
|
+
export type SubscriptionControllerGetCryptoApproveTransactionParamsAction = {
|
|
78
|
+
type: `SubscriptionController:getCryptoApproveTransactionParams`;
|
|
79
|
+
handler: SubscriptionController['getCryptoApproveTransactionParams'];
|
|
80
|
+
};
|
|
81
|
+
export type SubscriptionControllerUpdatePaymentMethodAction = {
|
|
82
|
+
type: `SubscriptionController:updatePaymentMethod`;
|
|
83
|
+
handler: SubscriptionController['updatePaymentMethod'];
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Gets the billing portal URL.
|
|
87
|
+
*
|
|
88
|
+
* @returns The billing portal URL
|
|
89
|
+
*/
|
|
90
|
+
export type SubscriptionControllerGetBillingPortalUrlAction = {
|
|
91
|
+
type: `SubscriptionController:getBillingPortalUrl`;
|
|
92
|
+
handler: SubscriptionController['getBillingPortalUrl'];
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Cache the last selected payment method for a specific product.
|
|
96
|
+
*
|
|
97
|
+
* @param product - The product to cache the payment method for.
|
|
98
|
+
* @param paymentMethod - The payment method to cache.
|
|
99
|
+
* @param paymentMethod.type - The type of the payment method.
|
|
100
|
+
* @param paymentMethod.paymentTokenAddress - The payment token address.
|
|
101
|
+
* @param paymentMethod.plan - The plan of the payment method.
|
|
102
|
+
* @param paymentMethod.product - The product of the payment method.
|
|
103
|
+
*/
|
|
104
|
+
export type SubscriptionControllerCacheLastSelectedPaymentMethodAction = {
|
|
105
|
+
type: `SubscriptionController:cacheLastSelectedPaymentMethod`;
|
|
106
|
+
handler: SubscriptionController['cacheLastSelectedPaymentMethod'];
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Clear the last selected payment method for a specific product.
|
|
110
|
+
*
|
|
111
|
+
* @param product - The product to clear the payment method for.
|
|
112
|
+
*/
|
|
113
|
+
export type SubscriptionControllerClearLastSelectedPaymentMethodAction = {
|
|
114
|
+
type: `SubscriptionController:clearLastSelectedPaymentMethod`;
|
|
115
|
+
handler: SubscriptionController['clearLastSelectedPaymentMethod'];
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Submit sponsorship intents to the Subscription Service backend.
|
|
119
|
+
*
|
|
120
|
+
* This is intended to be used together with the crypto subscription flow.
|
|
121
|
+
* When the user has enabled the smart transaction feature, we will sponsor the gas fees for the subscription approval transaction.
|
|
122
|
+
*
|
|
123
|
+
* @param request - Request object containing the address and products.
|
|
124
|
+
* @example {
|
|
125
|
+
* address: '0x1234567890123456789012345678901234567890',
|
|
126
|
+
* products: [ProductType.Shield],
|
|
127
|
+
* recurringInterval: RecurringInterval.Month,
|
|
128
|
+
* billingCycles: 1,
|
|
129
|
+
* }
|
|
130
|
+
* @returns resolves to true if the sponsorship is supported and intents were submitted successfully, false otherwise
|
|
131
|
+
*/
|
|
132
|
+
export type SubscriptionControllerSubmitSponsorshipIntentsAction = {
|
|
133
|
+
type: `SubscriptionController:submitSponsorshipIntents`;
|
|
134
|
+
handler: SubscriptionController['submitSponsorshipIntents'];
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* Submit a user event from the UI. (e.g. shield modal viewed)
|
|
138
|
+
*
|
|
139
|
+
* @param request - Request object containing the event to submit.
|
|
140
|
+
* @example { event: SubscriptionUserEvent.ShieldEntryModalViewed, cohort: 'post_tx' }
|
|
141
|
+
*/
|
|
142
|
+
export type SubscriptionControllerSubmitUserEventAction = {
|
|
143
|
+
type: `SubscriptionController:submitUserEvent`;
|
|
144
|
+
handler: SubscriptionController['submitUserEvent'];
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Assign user to a cohort.
|
|
148
|
+
*
|
|
149
|
+
* @param request - Request object containing the cohort to assign the user to.
|
|
150
|
+
* @example { cohort: 'post_tx' }
|
|
151
|
+
*/
|
|
152
|
+
export type SubscriptionControllerAssignUserToCohortAction = {
|
|
153
|
+
type: `SubscriptionController:assignUserToCohort`;
|
|
154
|
+
handler: SubscriptionController['assignUserToCohort'];
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* Link rewards to a subscription.
|
|
158
|
+
*
|
|
159
|
+
* @param request - Request object containing the reward subscription ID.
|
|
160
|
+
* @param request.subscriptionId - The ID of the subscription to link rewards to.
|
|
161
|
+
* @param request.rewardAccountId - The account ID of the reward subscription to link to the subscription.
|
|
162
|
+
* @example { subscriptionId: '1234567890', rewardAccountId: 'eip155:1:0x1234567890123456789012345678901234567890' }
|
|
163
|
+
* @returns Resolves when the rewards are linked successfully.
|
|
164
|
+
*/
|
|
165
|
+
export type SubscriptionControllerLinkRewardsAction = {
|
|
166
|
+
type: `SubscriptionController:linkRewards`;
|
|
167
|
+
handler: SubscriptionController['linkRewards'];
|
|
168
|
+
};
|
|
169
|
+
/**
|
|
170
|
+
* Calculate token approve amount from price info
|
|
171
|
+
*
|
|
172
|
+
* @param price - The price info
|
|
173
|
+
* @param tokenPaymentInfo - The token price info
|
|
174
|
+
* @returns The token approve amount
|
|
175
|
+
*/
|
|
176
|
+
export type SubscriptionControllerGetTokenApproveAmountAction = {
|
|
177
|
+
type: `SubscriptionController:getTokenApproveAmount`;
|
|
178
|
+
handler: SubscriptionController['getTokenApproveAmount'];
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* Calculate token minimum balance amount from price info
|
|
182
|
+
*
|
|
183
|
+
* @param price - The price info
|
|
184
|
+
* @param tokenPaymentInfo - The token price info
|
|
185
|
+
* @returns The token balance amount
|
|
186
|
+
*/
|
|
187
|
+
export type SubscriptionControllerGetTokenMinimumBalanceAmountAction = {
|
|
188
|
+
type: `SubscriptionController:getTokenMinimumBalanceAmount`;
|
|
189
|
+
handler: SubscriptionController['getTokenMinimumBalanceAmount'];
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* Clears the subscription state and resets to default values.
|
|
193
|
+
*/
|
|
194
|
+
export type SubscriptionControllerClearStateAction = {
|
|
195
|
+
type: `SubscriptionController:clearState`;
|
|
196
|
+
handler: SubscriptionController['clearState'];
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* Triggers an access token refresh.
|
|
200
|
+
*/
|
|
201
|
+
export type SubscriptionControllerTriggerAccessTokenRefreshAction = {
|
|
202
|
+
type: `SubscriptionController:triggerAccessTokenRefresh`;
|
|
203
|
+
handler: SubscriptionController['triggerAccessTokenRefresh'];
|
|
204
|
+
};
|
|
205
|
+
/**
|
|
206
|
+
* Union of all SubscriptionController action types.
|
|
207
|
+
*/
|
|
208
|
+
export type SubscriptionControllerMethodActions = SubscriptionControllerGetPricingAction | SubscriptionControllerGetSubscriptionsAction | SubscriptionControllerGetSubscriptionByProductAction | SubscriptionControllerGetSubscriptionsEligibilitiesAction | SubscriptionControllerCancelSubscriptionAction | SubscriptionControllerUnCancelSubscriptionAction | SubscriptionControllerStartShieldSubscriptionWithCardAction | SubscriptionControllerStartSubscriptionWithCryptoAction | SubscriptionControllerSubmitShieldSubscriptionCryptoApprovalAction | SubscriptionControllerGetCryptoApproveTransactionParamsAction | SubscriptionControllerUpdatePaymentMethodAction | SubscriptionControllerGetBillingPortalUrlAction | SubscriptionControllerCacheLastSelectedPaymentMethodAction | SubscriptionControllerClearLastSelectedPaymentMethodAction | SubscriptionControllerSubmitSponsorshipIntentsAction | SubscriptionControllerSubmitUserEventAction | SubscriptionControllerAssignUserToCohortAction | SubscriptionControllerLinkRewardsAction | SubscriptionControllerGetTokenApproveAmountAction | SubscriptionControllerGetTokenMinimumBalanceAmountAction | SubscriptionControllerClearStateAction | SubscriptionControllerTriggerAccessTokenRefreshAction;
|
|
209
|
+
//# sourceMappingURL=SubscriptionController-method-action-types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SubscriptionController-method-action-types.d.cts","sourceRoot":"","sources":["../src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ate-method-action-types.ts`.
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
*/
|
|
5
|
+
import type { SubscriptionController } from "./SubscriptionController.mjs";
|
|
6
|
+
/**
|
|
7
|
+
* Gets the pricing information from the subscription service.
|
|
8
|
+
*
|
|
9
|
+
* @returns The pricing information.
|
|
10
|
+
*/
|
|
11
|
+
export type SubscriptionControllerGetPricingAction = {
|
|
12
|
+
type: `SubscriptionController:getPricing`;
|
|
13
|
+
handler: SubscriptionController['getPricing'];
|
|
14
|
+
};
|
|
15
|
+
export type SubscriptionControllerGetSubscriptionsAction = {
|
|
16
|
+
type: `SubscriptionController:getSubscriptions`;
|
|
17
|
+
handler: SubscriptionController['getSubscriptions'];
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Get the subscription by product.
|
|
21
|
+
*
|
|
22
|
+
* @param productType - The product type.
|
|
23
|
+
* @returns The subscription.
|
|
24
|
+
*/
|
|
25
|
+
export type SubscriptionControllerGetSubscriptionByProductAction = {
|
|
26
|
+
type: `SubscriptionController:getSubscriptionByProduct`;
|
|
27
|
+
handler: SubscriptionController['getSubscriptionByProduct'];
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Get the subscriptions eligibilities.
|
|
31
|
+
*
|
|
32
|
+
* @param request - Optional request object containing user balance to check cohort eligibility.
|
|
33
|
+
* @returns The subscriptions eligibilities.
|
|
34
|
+
*/
|
|
35
|
+
export type SubscriptionControllerGetSubscriptionsEligibilitiesAction = {
|
|
36
|
+
type: `SubscriptionController:getSubscriptionsEligibilities`;
|
|
37
|
+
handler: SubscriptionController['getSubscriptionsEligibilities'];
|
|
38
|
+
};
|
|
39
|
+
export type SubscriptionControllerCancelSubscriptionAction = {
|
|
40
|
+
type: `SubscriptionController:cancelSubscription`;
|
|
41
|
+
handler: SubscriptionController['cancelSubscription'];
|
|
42
|
+
};
|
|
43
|
+
export type SubscriptionControllerUnCancelSubscriptionAction = {
|
|
44
|
+
type: `SubscriptionController:unCancelSubscription`;
|
|
45
|
+
handler: SubscriptionController['unCancelSubscription'];
|
|
46
|
+
};
|
|
47
|
+
export type SubscriptionControllerStartShieldSubscriptionWithCardAction = {
|
|
48
|
+
type: `SubscriptionController:startShieldSubscriptionWithCard`;
|
|
49
|
+
handler: SubscriptionController['startShieldSubscriptionWithCard'];
|
|
50
|
+
};
|
|
51
|
+
export type SubscriptionControllerStartSubscriptionWithCryptoAction = {
|
|
52
|
+
type: `SubscriptionController:startSubscriptionWithCrypto`;
|
|
53
|
+
handler: SubscriptionController['startSubscriptionWithCrypto'];
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Handles shield subscription crypto approval transactions.
|
|
57
|
+
*
|
|
58
|
+
* @param txMeta - The transaction metadata.
|
|
59
|
+
* @param isSponsored - Whether the transaction is sponsored.
|
|
60
|
+
* @param rewardAccountId - The account ID of the reward subscription to link to the shield subscription.
|
|
61
|
+
* @returns void
|
|
62
|
+
*/
|
|
63
|
+
export type SubscriptionControllerSubmitShieldSubscriptionCryptoApprovalAction = {
|
|
64
|
+
type: `SubscriptionController:submitShieldSubscriptionCryptoApproval`;
|
|
65
|
+
handler: SubscriptionController['submitShieldSubscriptionCryptoApproval'];
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Get transaction params to create crypto approve transaction for subscription payment
|
|
69
|
+
*
|
|
70
|
+
* @param request - The request object
|
|
71
|
+
* @param request.chainId - The chain ID
|
|
72
|
+
* @param request.tokenAddress - The address of the token
|
|
73
|
+
* @param request.productType - The product type
|
|
74
|
+
* @param request.interval - The interval
|
|
75
|
+
* @returns The crypto approve transaction params
|
|
76
|
+
*/
|
|
77
|
+
export type SubscriptionControllerGetCryptoApproveTransactionParamsAction = {
|
|
78
|
+
type: `SubscriptionController:getCryptoApproveTransactionParams`;
|
|
79
|
+
handler: SubscriptionController['getCryptoApproveTransactionParams'];
|
|
80
|
+
};
|
|
81
|
+
export type SubscriptionControllerUpdatePaymentMethodAction = {
|
|
82
|
+
type: `SubscriptionController:updatePaymentMethod`;
|
|
83
|
+
handler: SubscriptionController['updatePaymentMethod'];
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Gets the billing portal URL.
|
|
87
|
+
*
|
|
88
|
+
* @returns The billing portal URL
|
|
89
|
+
*/
|
|
90
|
+
export type SubscriptionControllerGetBillingPortalUrlAction = {
|
|
91
|
+
type: `SubscriptionController:getBillingPortalUrl`;
|
|
92
|
+
handler: SubscriptionController['getBillingPortalUrl'];
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Cache the last selected payment method for a specific product.
|
|
96
|
+
*
|
|
97
|
+
* @param product - The product to cache the payment method for.
|
|
98
|
+
* @param paymentMethod - The payment method to cache.
|
|
99
|
+
* @param paymentMethod.type - The type of the payment method.
|
|
100
|
+
* @param paymentMethod.paymentTokenAddress - The payment token address.
|
|
101
|
+
* @param paymentMethod.plan - The plan of the payment method.
|
|
102
|
+
* @param paymentMethod.product - The product of the payment method.
|
|
103
|
+
*/
|
|
104
|
+
export type SubscriptionControllerCacheLastSelectedPaymentMethodAction = {
|
|
105
|
+
type: `SubscriptionController:cacheLastSelectedPaymentMethod`;
|
|
106
|
+
handler: SubscriptionController['cacheLastSelectedPaymentMethod'];
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Clear the last selected payment method for a specific product.
|
|
110
|
+
*
|
|
111
|
+
* @param product - The product to clear the payment method for.
|
|
112
|
+
*/
|
|
113
|
+
export type SubscriptionControllerClearLastSelectedPaymentMethodAction = {
|
|
114
|
+
type: `SubscriptionController:clearLastSelectedPaymentMethod`;
|
|
115
|
+
handler: SubscriptionController['clearLastSelectedPaymentMethod'];
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Submit sponsorship intents to the Subscription Service backend.
|
|
119
|
+
*
|
|
120
|
+
* This is intended to be used together with the crypto subscription flow.
|
|
121
|
+
* When the user has enabled the smart transaction feature, we will sponsor the gas fees for the subscription approval transaction.
|
|
122
|
+
*
|
|
123
|
+
* @param request - Request object containing the address and products.
|
|
124
|
+
* @example {
|
|
125
|
+
* address: '0x1234567890123456789012345678901234567890',
|
|
126
|
+
* products: [ProductType.Shield],
|
|
127
|
+
* recurringInterval: RecurringInterval.Month,
|
|
128
|
+
* billingCycles: 1,
|
|
129
|
+
* }
|
|
130
|
+
* @returns resolves to true if the sponsorship is supported and intents were submitted successfully, false otherwise
|
|
131
|
+
*/
|
|
132
|
+
export type SubscriptionControllerSubmitSponsorshipIntentsAction = {
|
|
133
|
+
type: `SubscriptionController:submitSponsorshipIntents`;
|
|
134
|
+
handler: SubscriptionController['submitSponsorshipIntents'];
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* Submit a user event from the UI. (e.g. shield modal viewed)
|
|
138
|
+
*
|
|
139
|
+
* @param request - Request object containing the event to submit.
|
|
140
|
+
* @example { event: SubscriptionUserEvent.ShieldEntryModalViewed, cohort: 'post_tx' }
|
|
141
|
+
*/
|
|
142
|
+
export type SubscriptionControllerSubmitUserEventAction = {
|
|
143
|
+
type: `SubscriptionController:submitUserEvent`;
|
|
144
|
+
handler: SubscriptionController['submitUserEvent'];
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Assign user to a cohort.
|
|
148
|
+
*
|
|
149
|
+
* @param request - Request object containing the cohort to assign the user to.
|
|
150
|
+
* @example { cohort: 'post_tx' }
|
|
151
|
+
*/
|
|
152
|
+
export type SubscriptionControllerAssignUserToCohortAction = {
|
|
153
|
+
type: `SubscriptionController:assignUserToCohort`;
|
|
154
|
+
handler: SubscriptionController['assignUserToCohort'];
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* Link rewards to a subscription.
|
|
158
|
+
*
|
|
159
|
+
* @param request - Request object containing the reward subscription ID.
|
|
160
|
+
* @param request.subscriptionId - The ID of the subscription to link rewards to.
|
|
161
|
+
* @param request.rewardAccountId - The account ID of the reward subscription to link to the subscription.
|
|
162
|
+
* @example { subscriptionId: '1234567890', rewardAccountId: 'eip155:1:0x1234567890123456789012345678901234567890' }
|
|
163
|
+
* @returns Resolves when the rewards are linked successfully.
|
|
164
|
+
*/
|
|
165
|
+
export type SubscriptionControllerLinkRewardsAction = {
|
|
166
|
+
type: `SubscriptionController:linkRewards`;
|
|
167
|
+
handler: SubscriptionController['linkRewards'];
|
|
168
|
+
};
|
|
169
|
+
/**
|
|
170
|
+
* Calculate token approve amount from price info
|
|
171
|
+
*
|
|
172
|
+
* @param price - The price info
|
|
173
|
+
* @param tokenPaymentInfo - The token price info
|
|
174
|
+
* @returns The token approve amount
|
|
175
|
+
*/
|
|
176
|
+
export type SubscriptionControllerGetTokenApproveAmountAction = {
|
|
177
|
+
type: `SubscriptionController:getTokenApproveAmount`;
|
|
178
|
+
handler: SubscriptionController['getTokenApproveAmount'];
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* Calculate token minimum balance amount from price info
|
|
182
|
+
*
|
|
183
|
+
* @param price - The price info
|
|
184
|
+
* @param tokenPaymentInfo - The token price info
|
|
185
|
+
* @returns The token balance amount
|
|
186
|
+
*/
|
|
187
|
+
export type SubscriptionControllerGetTokenMinimumBalanceAmountAction = {
|
|
188
|
+
type: `SubscriptionController:getTokenMinimumBalanceAmount`;
|
|
189
|
+
handler: SubscriptionController['getTokenMinimumBalanceAmount'];
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* Clears the subscription state and resets to default values.
|
|
193
|
+
*/
|
|
194
|
+
export type SubscriptionControllerClearStateAction = {
|
|
195
|
+
type: `SubscriptionController:clearState`;
|
|
196
|
+
handler: SubscriptionController['clearState'];
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* Triggers an access token refresh.
|
|
200
|
+
*/
|
|
201
|
+
export type SubscriptionControllerTriggerAccessTokenRefreshAction = {
|
|
202
|
+
type: `SubscriptionController:triggerAccessTokenRefresh`;
|
|
203
|
+
handler: SubscriptionController['triggerAccessTokenRefresh'];
|
|
204
|
+
};
|
|
205
|
+
/**
|
|
206
|
+
* Union of all SubscriptionController action types.
|
|
207
|
+
*/
|
|
208
|
+
export type SubscriptionControllerMethodActions = SubscriptionControllerGetPricingAction | SubscriptionControllerGetSubscriptionsAction | SubscriptionControllerGetSubscriptionByProductAction | SubscriptionControllerGetSubscriptionsEligibilitiesAction | SubscriptionControllerCancelSubscriptionAction | SubscriptionControllerUnCancelSubscriptionAction | SubscriptionControllerStartShieldSubscriptionWithCardAction | SubscriptionControllerStartSubscriptionWithCryptoAction | SubscriptionControllerSubmitShieldSubscriptionCryptoApprovalAction | SubscriptionControllerGetCryptoApproveTransactionParamsAction | SubscriptionControllerUpdatePaymentMethodAction | SubscriptionControllerGetBillingPortalUrlAction | SubscriptionControllerCacheLastSelectedPaymentMethodAction | SubscriptionControllerClearLastSelectedPaymentMethodAction | SubscriptionControllerSubmitSponsorshipIntentsAction | SubscriptionControllerSubmitUserEventAction | SubscriptionControllerAssignUserToCohortAction | SubscriptionControllerLinkRewardsAction | SubscriptionControllerGetTokenApproveAmountAction | SubscriptionControllerGetTokenMinimumBalanceAmountAction | SubscriptionControllerClearStateAction | SubscriptionControllerTriggerAccessTokenRefreshAction;
|
|
209
|
+
//# sourceMappingURL=SubscriptionController-method-action-types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SubscriptionController-method-action-types.d.mts","sourceRoot":"","sources":["../src/SubscriptionController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,qCAAiC;AAEvE;;;;GAIG;AACH,MAAM,MAAM,sCAAsC,GAAG;IACnD,IAAI,EAAE,mCAAmC,CAAC;IAC1C,OAAO,EAAE,sBAAsB,CAAC,YAAY,CAAC,CAAC;CAC/C,CAAC;AAEF,MAAM,MAAM,4CAA4C,GAAG;IACzD,IAAI,EAAE,yCAAyC,CAAC;IAChD,OAAO,EAAE,sBAAsB,CAAC,kBAAkB,CAAC,CAAC;CAC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MG;AACH,MAAM,MAAM,wDAAwD,GAAG;IACrE,IAAI,EAAE,qDAAqD,CAAC;IAC5D,OAAO,EAAE,sBAAsB,CAAC,8BAA8B,CAAC,CAAC;CACjE,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,sCAAsC,GAAG;IACnD,IAAI,EAAE,mCAAmC,CAAC;IAC1C,OAAO,EAAE,sBAAsB,CAAC,YAAY,CAAC,CAAC;CAC/C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qDAAqD,GAAG;IAClE,IAAI,EAAE,kDAAkD,CAAC;IACzD,OAAO,EAAE,sBAAsB,CAAC,2BAA2B,CAAC,CAAC;CAC9D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,mCAAmC,GAC3C,sCAAsC,GACtC,4CAA4C,GAC5C,oDAAoD,GACpD,yDAAyD,GACzD,8CAA8C,GAC9C,gDAAgD,GAChD,2DAA2D,GAC3D,uDAAuD,GACvD,kEAAkE,GAClE,6DAA6D,GAC7D,+CAA+C,GAC/C,+CAA+C,GAC/C,0DAA0D,GAC1D,0DAA0D,GAC1D,oDAAoD,GACpD,2CAA2C,GAC3C,8CAA8C,GAC9C,uCAAuC,GACvC,iDAAiD,GACjD,wDAAwD,GACxD,sCAAsC,GACtC,qDAAqD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SubscriptionController-method-action-types.mjs","sourceRoot":"","sources":["../src/SubscriptionController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated by `scripts/generate-method-action-types.ts`.\n * Do not edit manually.\n */\n\nimport type { SubscriptionController } from './SubscriptionController';\n\n/**\n * Gets the pricing information from the subscription service.\n *\n * @returns The pricing information.\n */\nexport type SubscriptionControllerGetPricingAction = {\n type: `SubscriptionController:getPricing`;\n handler: SubscriptionController['getPricing'];\n};\n\nexport type SubscriptionControllerGetSubscriptionsAction = {\n type: `SubscriptionController:getSubscriptions`;\n handler: SubscriptionController['getSubscriptions'];\n};\n\n/**\n * Get the subscription by product.\n *\n * @param productType - The product type.\n * @returns The subscription.\n */\nexport type SubscriptionControllerGetSubscriptionByProductAction = {\n type: `SubscriptionController:getSubscriptionByProduct`;\n handler: SubscriptionController['getSubscriptionByProduct'];\n};\n\n/**\n * Get the subscriptions eligibilities.\n *\n * @param request - Optional request object containing user balance to check cohort eligibility.\n * @returns The subscriptions eligibilities.\n */\nexport type SubscriptionControllerGetSubscriptionsEligibilitiesAction = {\n type: `SubscriptionController:getSubscriptionsEligibilities`;\n handler: SubscriptionController['getSubscriptionsEligibilities'];\n};\n\nexport type SubscriptionControllerCancelSubscriptionAction = {\n type: `SubscriptionController:cancelSubscription`;\n handler: SubscriptionController['cancelSubscription'];\n};\n\nexport type SubscriptionControllerUnCancelSubscriptionAction = {\n type: `SubscriptionController:unCancelSubscription`;\n handler: SubscriptionController['unCancelSubscription'];\n};\n\nexport type SubscriptionControllerStartShieldSubscriptionWithCardAction = {\n type: `SubscriptionController:startShieldSubscriptionWithCard`;\n handler: SubscriptionController['startShieldSubscriptionWithCard'];\n};\n\nexport type SubscriptionControllerStartSubscriptionWithCryptoAction = {\n type: `SubscriptionController:startSubscriptionWithCrypto`;\n handler: SubscriptionController['startSubscriptionWithCrypto'];\n};\n\n/**\n * Handles shield subscription crypto approval transactions.\n *\n * @param txMeta - The transaction metadata.\n * @param isSponsored - Whether the transaction is sponsored.\n * @param rewardAccountId - The account ID of the reward subscription to link to the shield subscription.\n * @returns void\n */\nexport type SubscriptionControllerSubmitShieldSubscriptionCryptoApprovalAction =\n {\n type: `SubscriptionController:submitShieldSubscriptionCryptoApproval`;\n handler: SubscriptionController['submitShieldSubscriptionCryptoApproval'];\n };\n\n/**\n * Get transaction params to create crypto approve transaction for subscription payment\n *\n * @param request - The request object\n * @param request.chainId - The chain ID\n * @param request.tokenAddress - The address of the token\n * @param request.productType - The product type\n * @param request.interval - The interval\n * @returns The crypto approve transaction params\n */\nexport type SubscriptionControllerGetCryptoApproveTransactionParamsAction = {\n type: `SubscriptionController:getCryptoApproveTransactionParams`;\n handler: SubscriptionController['getCryptoApproveTransactionParams'];\n};\n\nexport type SubscriptionControllerUpdatePaymentMethodAction = {\n type: `SubscriptionController:updatePaymentMethod`;\n handler: SubscriptionController['updatePaymentMethod'];\n};\n\n/**\n * Gets the billing portal URL.\n *\n * @returns The billing portal URL\n */\nexport type SubscriptionControllerGetBillingPortalUrlAction = {\n type: `SubscriptionController:getBillingPortalUrl`;\n handler: SubscriptionController['getBillingPortalUrl'];\n};\n\n/**\n * Cache the last selected payment method for a specific product.\n *\n * @param product - The product to cache the payment method for.\n * @param paymentMethod - The payment method to cache.\n * @param paymentMethod.type - The type of the payment method.\n * @param paymentMethod.paymentTokenAddress - The payment token address.\n * @param paymentMethod.plan - The plan of the payment method.\n * @param paymentMethod.product - The product of the payment method.\n */\nexport type SubscriptionControllerCacheLastSelectedPaymentMethodAction = {\n type: `SubscriptionController:cacheLastSelectedPaymentMethod`;\n handler: SubscriptionController['cacheLastSelectedPaymentMethod'];\n};\n\n/**\n * Clear the last selected payment method for a specific product.\n *\n * @param product - The product to clear the payment method for.\n */\nexport type SubscriptionControllerClearLastSelectedPaymentMethodAction = {\n type: `SubscriptionController:clearLastSelectedPaymentMethod`;\n handler: SubscriptionController['clearLastSelectedPaymentMethod'];\n};\n\n/**\n * Submit sponsorship intents to the Subscription Service backend.\n *\n * This is intended to be used together with the crypto subscription flow.\n * When the user has enabled the smart transaction feature, we will sponsor the gas fees for the subscription approval transaction.\n *\n * @param request - Request object containing the address and products.\n * @example {\n * address: '0x1234567890123456789012345678901234567890',\n * products: [ProductType.Shield],\n * recurringInterval: RecurringInterval.Month,\n * billingCycles: 1,\n * }\n * @returns resolves to true if the sponsorship is supported and intents were submitted successfully, false otherwise\n */\nexport type SubscriptionControllerSubmitSponsorshipIntentsAction = {\n type: `SubscriptionController:submitSponsorshipIntents`;\n handler: SubscriptionController['submitSponsorshipIntents'];\n};\n\n/**\n * Submit a user event from the UI. (e.g. shield modal viewed)\n *\n * @param request - Request object containing the event to submit.\n * @example { event: SubscriptionUserEvent.ShieldEntryModalViewed, cohort: 'post_tx' }\n */\nexport type SubscriptionControllerSubmitUserEventAction = {\n type: `SubscriptionController:submitUserEvent`;\n handler: SubscriptionController['submitUserEvent'];\n};\n\n/**\n * Assign user to a cohort.\n *\n * @param request - Request object containing the cohort to assign the user to.\n * @example { cohort: 'post_tx' }\n */\nexport type SubscriptionControllerAssignUserToCohortAction = {\n type: `SubscriptionController:assignUserToCohort`;\n handler: SubscriptionController['assignUserToCohort'];\n};\n\n/**\n * Link rewards to a subscription.\n *\n * @param request - Request object containing the reward subscription ID.\n * @param request.subscriptionId - The ID of the subscription to link rewards to.\n * @param request.rewardAccountId - The account ID of the reward subscription to link to the subscription.\n * @example { subscriptionId: '1234567890', rewardAccountId: 'eip155:1:0x1234567890123456789012345678901234567890' }\n * @returns Resolves when the rewards are linked successfully.\n */\nexport type SubscriptionControllerLinkRewardsAction = {\n type: `SubscriptionController:linkRewards`;\n handler: SubscriptionController['linkRewards'];\n};\n\n/**\n * Calculate token approve amount from price info\n *\n * @param price - The price info\n * @param tokenPaymentInfo - The token price info\n * @returns The token approve amount\n */\nexport type SubscriptionControllerGetTokenApproveAmountAction = {\n type: `SubscriptionController:getTokenApproveAmount`;\n handler: SubscriptionController['getTokenApproveAmount'];\n};\n\n/**\n * Calculate token minimum balance amount from price info\n *\n * @param price - The price info\n * @param tokenPaymentInfo - The token price info\n * @returns The token balance amount\n */\nexport type SubscriptionControllerGetTokenMinimumBalanceAmountAction = {\n type: `SubscriptionController:getTokenMinimumBalanceAmount`;\n handler: SubscriptionController['getTokenMinimumBalanceAmount'];\n};\n\n/**\n * Clears the subscription state and resets to default values.\n */\nexport type SubscriptionControllerClearStateAction = {\n type: `SubscriptionController:clearState`;\n handler: SubscriptionController['clearState'];\n};\n\n/**\n * Triggers an access token refresh.\n */\nexport type SubscriptionControllerTriggerAccessTokenRefreshAction = {\n type: `SubscriptionController:triggerAccessTokenRefresh`;\n handler: SubscriptionController['triggerAccessTokenRefresh'];\n};\n\n/**\n * Union of all SubscriptionController action types.\n */\nexport type SubscriptionControllerMethodActions =\n | SubscriptionControllerGetPricingAction\n | SubscriptionControllerGetSubscriptionsAction\n | SubscriptionControllerGetSubscriptionByProductAction\n | SubscriptionControllerGetSubscriptionsEligibilitiesAction\n | SubscriptionControllerCancelSubscriptionAction\n | SubscriptionControllerUnCancelSubscriptionAction\n | SubscriptionControllerStartShieldSubscriptionWithCardAction\n | SubscriptionControllerStartSubscriptionWithCryptoAction\n | SubscriptionControllerSubmitShieldSubscriptionCryptoApprovalAction\n | SubscriptionControllerGetCryptoApproveTransactionParamsAction\n | SubscriptionControllerUpdatePaymentMethodAction\n | SubscriptionControllerGetBillingPortalUrlAction\n | SubscriptionControllerCacheLastSelectedPaymentMethodAction\n | SubscriptionControllerClearLastSelectedPaymentMethodAction\n | SubscriptionControllerSubmitSponsorshipIntentsAction\n | SubscriptionControllerSubmitUserEventAction\n | SubscriptionControllerAssignUserToCohortAction\n | SubscriptionControllerLinkRewardsAction\n | SubscriptionControllerGetTokenApproveAmountAction\n | SubscriptionControllerGetTokenMinimumBalanceAmountAction\n | SubscriptionControllerClearStateAction\n | SubscriptionControllerTriggerAccessTokenRefreshAction;\n"]}
|
|
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
11
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
12
|
};
|
|
13
|
-
var _SubscriptionController_instances, _SubscriptionController_subscriptionService,
|
|
13
|
+
var _SubscriptionController_instances, _SubscriptionController_subscriptionService, _SubscriptionController_getSubscriptionPriceAmount, _SubscriptionController_getSubscriptionBalanceAmount, _SubscriptionController_getProductPriceByProductAndPlan, _SubscriptionController_assertValidSubscriptionStateForCryptoApproval, _SubscriptionController_assertIsUserNotSubscribed, _SubscriptionController_assertIsUserSubscribed, _SubscriptionController_assertIsPaymentMethodCrypto, _SubscriptionController_getIsEligibleForTrialedSponsorship, _SubscriptionController_getChainSupportsSponsorship, _SubscriptionController_areTrialedProductsEqual, _SubscriptionController_areSubscriptionsEqual, _SubscriptionController_isSubscriptionEqual, _SubscriptionController_stringifySubscription;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.SubscriptionController = exports.getDefaultSubscriptionControllerState = void 0;
|
|
16
16
|
const polling_controller_1 = require("@metamask/polling-controller");
|
|
@@ -81,6 +81,30 @@ const subscriptionControllerMetadata = {
|
|
|
81
81
|
usedInUi: true,
|
|
82
82
|
},
|
|
83
83
|
};
|
|
84
|
+
const MESSENGER_EXPOSED_METHODS = [
|
|
85
|
+
'getPricing',
|
|
86
|
+
'getSubscriptions',
|
|
87
|
+
'getSubscriptionByProduct',
|
|
88
|
+
'getSubscriptionsEligibilities',
|
|
89
|
+
'cancelSubscription',
|
|
90
|
+
'unCancelSubscription',
|
|
91
|
+
'startShieldSubscriptionWithCard',
|
|
92
|
+
'startSubscriptionWithCrypto',
|
|
93
|
+
'submitShieldSubscriptionCryptoApproval',
|
|
94
|
+
'getCryptoApproveTransactionParams',
|
|
95
|
+
'updatePaymentMethod',
|
|
96
|
+
'getBillingPortalUrl',
|
|
97
|
+
'cacheLastSelectedPaymentMethod',
|
|
98
|
+
'clearLastSelectedPaymentMethod',
|
|
99
|
+
'submitSponsorshipIntents',
|
|
100
|
+
'submitUserEvent',
|
|
101
|
+
'assignUserToCohort',
|
|
102
|
+
'linkRewards',
|
|
103
|
+
'getTokenApproveAmount',
|
|
104
|
+
'getTokenMinimumBalanceAmount',
|
|
105
|
+
'clearState',
|
|
106
|
+
'triggerAccessTokenRefresh',
|
|
107
|
+
];
|
|
84
108
|
class SubscriptionController extends (0, polling_controller_1.StaticIntervalPollingController)() {
|
|
85
109
|
/**
|
|
86
110
|
* Creates a new SubscriptionController instance.
|
|
@@ -105,7 +129,7 @@ class SubscriptionController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
105
129
|
_SubscriptionController_subscriptionService.set(this, void 0);
|
|
106
130
|
this.setIntervalLength(pollingInterval);
|
|
107
131
|
__classPrivateFieldSet(this, _SubscriptionController_subscriptionService, subscriptionService, "f");
|
|
108
|
-
|
|
132
|
+
this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
|
|
109
133
|
}
|
|
110
134
|
/**
|
|
111
135
|
* Gets the pricing information from the subscription service.
|
|
@@ -508,22 +532,7 @@ class SubscriptionController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
508
532
|
}
|
|
509
533
|
}
|
|
510
534
|
exports.SubscriptionController = SubscriptionController;
|
|
511
|
-
_SubscriptionController_subscriptionService = new WeakMap(), _SubscriptionController_instances = new WeakSet(),
|
|
512
|
-
this.messenger.registerActionHandler('SubscriptionController:getSubscriptions', this.getSubscriptions.bind(this));
|
|
513
|
-
this.messenger.registerActionHandler('SubscriptionController:getSubscriptionByProduct', this.getSubscriptionByProduct.bind(this));
|
|
514
|
-
this.messenger.registerActionHandler('SubscriptionController:cancelSubscription', this.cancelSubscription.bind(this));
|
|
515
|
-
this.messenger.registerActionHandler('SubscriptionController:startShieldSubscriptionWithCard', this.startShieldSubscriptionWithCard.bind(this));
|
|
516
|
-
this.messenger.registerActionHandler('SubscriptionController:getPricing', this.getPricing.bind(this));
|
|
517
|
-
this.messenger.registerActionHandler('SubscriptionController:getCryptoApproveTransactionParams', this.getCryptoApproveTransactionParams.bind(this));
|
|
518
|
-
this.messenger.registerActionHandler('SubscriptionController:startSubscriptionWithCrypto', this.startSubscriptionWithCrypto.bind(this));
|
|
519
|
-
this.messenger.registerActionHandler('SubscriptionController:updatePaymentMethod', this.updatePaymentMethod.bind(this));
|
|
520
|
-
this.messenger.registerActionHandler('SubscriptionController:getBillingPortalUrl', this.getBillingPortalUrl.bind(this));
|
|
521
|
-
this.messenger.registerActionHandler(`${constants_1.controllerName}:submitSponsorshipIntents`, this.submitSponsorshipIntents.bind(this));
|
|
522
|
-
this.messenger.registerActionHandler(`${constants_1.controllerName}:submitShieldSubscriptionCryptoApproval`, this.submitShieldSubscriptionCryptoApproval.bind(this));
|
|
523
|
-
this.messenger.registerActionHandler(`${constants_1.controllerName}:linkRewards`, this.linkRewards.bind(this));
|
|
524
|
-
this.messenger.registerActionHandler(`${constants_1.controllerName}:cacheLastSelectedPaymentMethod`, this.cacheLastSelectedPaymentMethod.bind(this));
|
|
525
|
-
this.messenger.registerActionHandler(`${constants_1.controllerName}:clearLastSelectedPaymentMethod`, this.clearLastSelectedPaymentMethod.bind(this));
|
|
526
|
-
}, _SubscriptionController_getSubscriptionPriceAmount = function _SubscriptionController_getSubscriptionPriceAmount(price) {
|
|
535
|
+
_SubscriptionController_subscriptionService = new WeakMap(), _SubscriptionController_instances = new WeakSet(), _SubscriptionController_getSubscriptionPriceAmount = function _SubscriptionController_getSubscriptionPriceAmount(price) {
|
|
527
536
|
// no need to use BigInt since max unitDecimals are always 2 for price
|
|
528
537
|
const amount = new bignumber_js_1.BigNumber(price.unitAmount)
|
|
529
538
|
.div(10 ** price.unitDecimals)
|