@subscrypts/subscrypts-sdk-react 1.6.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/LICENSE +21 -0
- package/README.md +2140 -0
- package/dist/components/buttons/SubscryptsButton.d.ts +19 -0
- package/dist/components/buttons/SubscryptsButton.d.ts.map +1 -0
- package/dist/components/buttons/index.d.ts +5 -0
- package/dist/components/buttons/index.d.ts.map +1 -0
- package/dist/components/checkout/CheckoutWizard.d.ts +22 -0
- package/dist/components/checkout/CheckoutWizard.d.ts.map +1 -0
- package/dist/components/checkout/ConfigurationStep.d.ts +15 -0
- package/dist/components/checkout/ConfigurationStep.d.ts.map +1 -0
- package/dist/components/checkout/TransactionStep.d.ts +15 -0
- package/dist/components/checkout/TransactionStep.d.ts.map +1 -0
- package/dist/components/checkout/index.d.ts +7 -0
- package/dist/components/checkout/index.d.ts.map +1 -0
- package/dist/components/guards/SubscriptionGuard.d.ts +25 -0
- package/dist/components/guards/SubscriptionGuard.d.ts.map +1 -0
- package/dist/components/guards/index.d.ts +5 -0
- package/dist/components/guards/index.d.ts.map +1 -0
- package/dist/components/index.d.ts +20 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/merchant/MerchantDashboard.d.ts +24 -0
- package/dist/components/merchant/MerchantDashboard.d.ts.map +1 -0
- package/dist/components/merchant/index.d.ts +6 -0
- package/dist/components/merchant/index.d.ts.map +1 -0
- package/dist/components/pricing/PlanCard.d.ts +45 -0
- package/dist/components/pricing/PlanCard.d.ts.map +1 -0
- package/dist/components/pricing/PricingTable.d.ts +68 -0
- package/dist/components/pricing/PricingTable.d.ts.map +1 -0
- package/dist/components/pricing/index.d.ts +10 -0
- package/dist/components/pricing/index.d.ts.map +1 -0
- package/dist/components/shared/ErrorDisplay.d.ts +34 -0
- package/dist/components/shared/ErrorDisplay.d.ts.map +1 -0
- package/dist/components/shared/LoadingSpinner.d.ts +5 -0
- package/dist/components/shared/LoadingSpinner.d.ts.map +1 -0
- package/dist/components/shared/Modal.d.ts +12 -0
- package/dist/components/shared/Modal.d.ts.map +1 -0
- package/dist/components/shared/NetworkSwitchPrompt.d.ts +33 -0
- package/dist/components/shared/NetworkSwitchPrompt.d.ts.map +1 -0
- package/dist/components/shared/SubscryptsErrorBoundary.d.ts +41 -0
- package/dist/components/shared/SubscryptsErrorBoundary.d.ts.map +1 -0
- package/dist/components/subscription/ConfirmDialog.d.ts +44 -0
- package/dist/components/subscription/ConfirmDialog.d.ts.map +1 -0
- package/dist/components/subscription/ManageSubscriptionModal.d.ts +35 -0
- package/dist/components/subscription/ManageSubscriptionModal.d.ts.map +1 -0
- package/dist/components/subscription/SubscriptionCard.d.ts +35 -0
- package/dist/components/subscription/SubscriptionCard.d.ts.map +1 -0
- package/dist/components/subscription/SubscriptionDashboard.d.ts +40 -0
- package/dist/components/subscription/SubscriptionDashboard.d.ts.map +1 -0
- package/dist/components/subscription/index.d.ts +12 -0
- package/dist/components/subscription/index.d.ts.map +1 -0
- package/dist/components/wallet/ConnectWalletModal.d.ts +29 -0
- package/dist/components/wallet/ConnectWalletModal.d.ts.map +1 -0
- package/dist/components/wallet/index.d.ts +6 -0
- package/dist/components/wallet/index.d.ts.map +1 -0
- package/dist/constants/index.d.ts +16 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/context/SubscryptsContext.d.ts +36 -0
- package/dist/context/SubscryptsContext.d.ts.map +1 -0
- package/dist/context/SubscryptsProvider.d.ts +28 -0
- package/dist/context/SubscryptsProvider.d.ts.map +1 -0
- package/dist/context/index.d.ts +7 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/contract/abis/Subscrypts.d.ts +2917 -0
- package/dist/contract/abis/Subscrypts.d.ts.map +1 -0
- package/dist/contract/abis/dexFactoryABI.d.ts +184 -0
- package/dist/contract/abis/dexFactoryABI.d.ts.map +1 -0
- package/dist/contract/abis/dexPairABI.d.ts +775 -0
- package/dist/contract/abis/dexPairABI.d.ts.map +1 -0
- package/dist/contract/abis/dexPositionManagerABI.d.ts +948 -0
- package/dist/contract/abis/dexPositionManagerABI.d.ts.map +1 -0
- package/dist/contract/abis/dexQuoterABI.d.ts +206 -0
- package/dist/contract/abis/dexQuoterABI.d.ts.map +1 -0
- package/dist/contract/abis/dexRouterABI.d.ts +439 -0
- package/dist/contract/abis/dexRouterABI.d.ts.map +1 -0
- package/dist/contract/abis/dexUSDCABI.d.ts +132 -0
- package/dist/contract/abis/dexUSDCABI.d.ts.map +1 -0
- package/dist/contract/abis/index.d.ts +15 -0
- package/dist/contract/abis/index.d.ts.map +1 -0
- package/dist/contract/config.d.ts +40 -0
- package/dist/contract/config.d.ts.map +1 -0
- package/dist/contract/index.d.ts +12 -0
- package/dist/contract/index.d.ts.map +1 -0
- package/dist/contract/methods.d.ts +305 -0
- package/dist/contract/methods.d.ts.map +1 -0
- package/dist/hooks/events/index.d.ts +6 -0
- package/dist/hooks/events/index.d.ts.map +1 -0
- package/dist/hooks/events/useSubscryptsEvents.d.ts +63 -0
- package/dist/hooks/events/useSubscryptsEvents.d.ts.map +1 -0
- package/dist/hooks/index.d.ts +12 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/merchant/index.d.ts +10 -0
- package/dist/hooks/merchant/index.d.ts.map +1 -0
- package/dist/hooks/merchant/useMerchantPlans.d.ts +30 -0
- package/dist/hooks/merchant/useMerchantPlans.d.ts.map +1 -0
- package/dist/hooks/merchant/useMerchantRevenue.d.ts +59 -0
- package/dist/hooks/merchant/useMerchantRevenue.d.ts.map +1 -0
- package/dist/hooks/merchant/useMerchantSubscribers.d.ts +54 -0
- package/dist/hooks/merchant/useMerchantSubscribers.d.ts.map +1 -0
- package/dist/hooks/plans/index.d.ts +12 -0
- package/dist/hooks/plans/index.d.ts.map +1 -0
- package/dist/hooks/plans/usePlan.d.ts +33 -0
- package/dist/hooks/plans/usePlan.d.ts.map +1 -0
- package/dist/hooks/plans/usePlans.d.ts +36 -0
- package/dist/hooks/plans/usePlans.d.ts.map +1 -0
- package/dist/hooks/plans/usePlansByMerchant.d.ts +35 -0
- package/dist/hooks/plans/usePlansByMerchant.d.ts.map +1 -0
- package/dist/hooks/pricing/index.d.ts +10 -0
- package/dist/hooks/pricing/index.d.ts.map +1 -0
- package/dist/hooks/pricing/usePlanPrice.d.ts +59 -0
- package/dist/hooks/pricing/usePlanPrice.d.ts.map +1 -0
- package/dist/hooks/pricing/useSUBSPrice.d.ts +39 -0
- package/dist/hooks/pricing/useSUBSPrice.d.ts.map +1 -0
- package/dist/hooks/subscriptions/index.d.ts +12 -0
- package/dist/hooks/subscriptions/index.d.ts.map +1 -0
- package/dist/hooks/subscriptions/useManageSubscription.d.ts +39 -0
- package/dist/hooks/subscriptions/useManageSubscription.d.ts.map +1 -0
- package/dist/hooks/subscriptions/useMySubscriptions.d.ts +53 -0
- package/dist/hooks/subscriptions/useMySubscriptions.d.ts.map +1 -0
- package/dist/hooks/subscriptions/useSubscribe.d.ts +58 -0
- package/dist/hooks/subscriptions/useSubscribe.d.ts.map +1 -0
- package/dist/hooks/subscriptions/useSubscriptionStatus.d.ts +34 -0
- package/dist/hooks/subscriptions/useSubscriptionStatus.d.ts.map +1 -0
- package/dist/hooks/tokens/index.d.ts +6 -0
- package/dist/hooks/tokens/index.d.ts.map +1 -0
- package/dist/hooks/tokens/useTokenBalance.d.ts +36 -0
- package/dist/hooks/tokens/useTokenBalance.d.ts.map +1 -0
- package/dist/hooks/wallet/index.d.ts +6 -0
- package/dist/hooks/wallet/index.d.ts.map +1 -0
- package/dist/hooks/wallet/useWallet.d.ts +40 -0
- package/dist/hooks/wallet/useWallet.d.ts.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7850 -0
- package/dist/index.js.map +1 -0
- package/dist/services/cache.service.d.ts +89 -0
- package/dist/services/cache.service.d.ts.map +1 -0
- package/dist/services/index.d.ts +7 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/token.service.d.ts +43 -0
- package/dist/services/token.service.d.ts.map +1 -0
- package/dist/services/wallet.service.d.ts +46 -0
- package/dist/services/wallet.service.d.ts.map +1 -0
- package/dist/style.css +3 -0
- package/dist/styles.d.ts +2 -0
- package/dist/styles.d.ts.map +1 -0
- package/dist/types/component.types.d.ts +192 -0
- package/dist/types/component.types.d.ts.map +1 -0
- package/dist/types/contract.types.d.ts +81 -0
- package/dist/types/contract.types.d.ts.map +1 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/subscription.types.d.ts +65 -0
- package/dist/types/subscription.types.d.ts.map +1 -0
- package/dist/types/wallet.types.d.ts +53 -0
- package/dist/types/wallet.types.d.ts.map +1 -0
- package/dist/utils/errorMessages.d.ts +44 -0
- package/dist/utils/errorMessages.d.ts.map +1 -0
- package/dist/utils/errors.d.ts +60 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/formatters.d.ts +44 -0
- package/dist/utils/formatters.d.ts.map +1 -0
- package/dist/utils/index.d.ts +10 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/logger.d.ts +80 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/permit.utils.d.ts +52 -0
- package/dist/utils/permit.utils.d.ts.map +1 -0
- package/dist/utils/subscriptionHelpers.d.ts +67 -0
- package/dist/utils/subscriptionHelpers.d.ts.map +1 -0
- package/dist/utils/subscriptionStatus.d.ts +48 -0
- package/dist/utils/subscriptionStatus.d.ts.map +1 -0
- package/dist/utils/validators.d.ts +76 -0
- package/dist/utils/validators.d.ts.map +1 -0
- package/dist/wallet/ExternalConnector.d.ts +32 -0
- package/dist/wallet/ExternalConnector.d.ts.map +1 -0
- package/dist/wallet/InjectedConnector.d.ts +55 -0
- package/dist/wallet/InjectedConnector.d.ts.map +1 -0
- package/dist/wallet/index.d.ts +9 -0
- package/dist/wallet/index.d.ts.map +1 -0
- package/dist/wallet/sessionStore.d.ts +28 -0
- package/dist/wallet/sessionStore.d.ts.map +1 -0
- package/dist/wallet/types.d.ts +66 -0
- package/dist/wallet/types.d.ts.map +1 -0
- package/package.json +99 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { UsePlansByMerchantReturn } from '../plans/usePlansByMerchant';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Hook return type (re-exported from usePlansByMerchant)
|
|
5
|
+
*/
|
|
6
|
+
export type UseMerchantPlansReturn = UsePlansByMerchantReturn;
|
|
7
|
+
/**
|
|
8
|
+
* Fetch all plans owned by the connected wallet.
|
|
9
|
+
*
|
|
10
|
+
* This is a convenience wrapper around usePlansByMerchant that uses
|
|
11
|
+
* the connected wallet address automatically.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* const { plans, total, isLoading } = useMerchantPlans();
|
|
16
|
+
*
|
|
17
|
+
* return (
|
|
18
|
+
* <div>
|
|
19
|
+
* <h2>My Plans ({total})</h2>
|
|
20
|
+
* {plans.map(plan => (
|
|
21
|
+
* <div key={plan.id.toString()}>
|
|
22
|
+
* {plan.description} - {plan.subscriberCount.toString()} subscribers
|
|
23
|
+
* </div>
|
|
24
|
+
* ))}
|
|
25
|
+
* </div>
|
|
26
|
+
* );
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function useMerchantPlans(): UseMerchantPlansReturn;
|
|
30
|
+
//# sourceMappingURL=useMerchantPlans.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMerchantPlans.d.ts","sourceRoot":"","sources":["../../../src/hooks/merchant/useMerchantPlans.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAsB,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAE3F;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,wBAAwB,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,gBAAgB,IAAI,sBAAsB,CAOzD"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useMerchantRevenue Hook
|
|
3
|
+
*
|
|
4
|
+
* Calculate Monthly Recurring Revenue (MRR) from active subscriptions.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Merchant revenue data
|
|
8
|
+
*/
|
|
9
|
+
export interface MerchantRevenueData {
|
|
10
|
+
/** Total number of subscribers across all plans */
|
|
11
|
+
totalSubscribers: number;
|
|
12
|
+
/** Number of active subscribers */
|
|
13
|
+
activeSubscribers: number;
|
|
14
|
+
/** Monthly Recurring Revenue in SUBS (18 decimals) */
|
|
15
|
+
monthlyRecurringRevenue: bigint;
|
|
16
|
+
/** MRR formatted as SUBS string */
|
|
17
|
+
mrrFormatted: string;
|
|
18
|
+
/** MRR in USD (estimated using current SUBS price) */
|
|
19
|
+
mrrUsdEstimate: number | null;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Hook return type
|
|
23
|
+
*/
|
|
24
|
+
export interface UseMerchantRevenueReturn {
|
|
25
|
+
/** Revenue data (null if loading or error) */
|
|
26
|
+
revenue: MerchantRevenueData | null;
|
|
27
|
+
/** Loading state */
|
|
28
|
+
isLoading: boolean;
|
|
29
|
+
/** Error if any */
|
|
30
|
+
error: Error | null;
|
|
31
|
+
/** Manually refresh revenue */
|
|
32
|
+
refetch: () => Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Calculate Monthly Recurring Revenue from active subscriptions.
|
|
36
|
+
*
|
|
37
|
+
* Fetches all subscriptions for the merchant's plans, filters for active ones,
|
|
38
|
+
* and calculates MRR by normalizing all subscriptions to monthly amounts.
|
|
39
|
+
*
|
|
40
|
+
* @param planIds - Optional array of plan IDs to calculate revenue for (defaults to all merchant plans)
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```tsx
|
|
44
|
+
* const { revenue, isLoading } = useMerchantRevenue();
|
|
45
|
+
*
|
|
46
|
+
* if (revenue) {
|
|
47
|
+
* return (
|
|
48
|
+
* <div>
|
|
49
|
+
* <h2>Revenue Dashboard</h2>
|
|
50
|
+
* <p>MRR: {revenue.mrrFormatted} SUBS</p>
|
|
51
|
+
* <p>≈ ${revenue.mrrUsdEstimate?.toFixed(2)}</p>
|
|
52
|
+
* <p>{revenue.activeSubscribers} / {revenue.totalSubscribers} active</p>
|
|
53
|
+
* </div>
|
|
54
|
+
* );
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export declare function useMerchantRevenue(planIds?: string[]): UseMerchantRevenueReturn;
|
|
59
|
+
//# sourceMappingURL=useMerchantRevenue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMerchantRevenue.d.ts","sourceRoot":"","sources":["../../../src/hooks/merchant/useMerchantRevenue.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAWH;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,mDAAmD;IACnD,gBAAgB,EAAE,MAAM,CAAC;IACzB,mCAAmC;IACnC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,sDAAsD;IACtD,uBAAuB,EAAE,MAAM,CAAC;IAChC,mCAAmC;IACnC,YAAY,EAAE,MAAM,CAAC;IACrB,sDAAsD;IACtD,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,8CAA8C;IAC9C,OAAO,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACpC,oBAAoB;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,mBAAmB;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,+BAA+B;IAC/B,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,wBAAwB,CAgI/E"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Subscription } from '../../types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Hook return type
|
|
5
|
+
*/
|
|
6
|
+
export interface UseMerchantSubscribersReturn {
|
|
7
|
+
/** Array of subscriptions for current page */
|
|
8
|
+
subscribers: Subscription[];
|
|
9
|
+
/** Total number of subscriptions */
|
|
10
|
+
total: number;
|
|
11
|
+
/** Number of active subscriptions */
|
|
12
|
+
activeCount: number;
|
|
13
|
+
/** Current page (1-indexed) */
|
|
14
|
+
page: number;
|
|
15
|
+
/** Number of subscriptions per page */
|
|
16
|
+
pageSize: number;
|
|
17
|
+
/** Whether there are more pages */
|
|
18
|
+
hasMore: boolean;
|
|
19
|
+
/** Loading state */
|
|
20
|
+
isLoading: boolean;
|
|
21
|
+
/** Error if any */
|
|
22
|
+
error: Error | null;
|
|
23
|
+
/** Go to next page */
|
|
24
|
+
nextPage: () => void;
|
|
25
|
+
/** Go to previous page */
|
|
26
|
+
prevPage: () => void;
|
|
27
|
+
/** Manually refresh subscriptions */
|
|
28
|
+
refetch: () => Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Fetch paginated subscribers for a specific plan
|
|
32
|
+
*
|
|
33
|
+
* @param planId - Plan ID to fetch subscribers for
|
|
34
|
+
* @param pageSize - Number of subscriptions per page (default: 10)
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```tsx
|
|
38
|
+
* const { subscribers, activeCount, total, page, hasMore, nextPage, prevPage, isLoading }
|
|
39
|
+
* = useMerchantSubscribers('1');
|
|
40
|
+
*
|
|
41
|
+
* return (
|
|
42
|
+
* <div>
|
|
43
|
+
* <h3>{activeCount} active out of {total} total subscribers</h3>
|
|
44
|
+
* {subscribers.map(sub => (
|
|
45
|
+
* <SubscriptionCard key={sub.id} subscription={sub} />
|
|
46
|
+
* ))}
|
|
47
|
+
* <button onClick={prevPage} disabled={page === 1}>Previous</button>
|
|
48
|
+
* <button onClick={nextPage} disabled={!hasMore}>Next</button>
|
|
49
|
+
* </div>
|
|
50
|
+
* );
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare function useMerchantSubscribers(planId: string, pageSize?: number): UseMerchantSubscribersReturn;
|
|
54
|
+
//# sourceMappingURL=useMerchantSubscribers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMerchantSubscribers.d.ts","sourceRoot":"","sources":["../../../src/hooks/merchant/useMerchantSubscribers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAI3C;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C,8CAA8C;IAC9C,WAAW,EAAE,YAAY,EAAE,CAAC;IAC5B,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,qCAAqC;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,uCAAuC;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,mCAAmC;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,oBAAoB;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,mBAAmB;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,sBAAsB;IACtB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,0BAA0B;IAC1B,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,qCAAqC;IACrC,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,QAAQ,GAAE,MAAW,GACpB,4BAA4B,CA8G9B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plan Hooks
|
|
3
|
+
*
|
|
4
|
+
* React hooks for fetching subscription plan data from the smart contract.
|
|
5
|
+
*/
|
|
6
|
+
export { usePlan } from './usePlan';
|
|
7
|
+
export type { UsePlanReturn } from './usePlan';
|
|
8
|
+
export { usePlans } from './usePlans';
|
|
9
|
+
export type { UsePlansReturn } from './usePlans';
|
|
10
|
+
export { usePlansByMerchant } from './usePlansByMerchant';
|
|
11
|
+
export type { UsePlansByMerchantReturn } from './usePlansByMerchant';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/plans/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,YAAY,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Plan } from '../../types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Hook return type
|
|
5
|
+
*/
|
|
6
|
+
export interface UsePlanReturn {
|
|
7
|
+
/** Plan data (null if not found or loading) */
|
|
8
|
+
plan: Plan | null;
|
|
9
|
+
/** Loading state */
|
|
10
|
+
isLoading: boolean;
|
|
11
|
+
/** Error if any */
|
|
12
|
+
error: Error | null;
|
|
13
|
+
/** Manually refresh plan data */
|
|
14
|
+
refetch: () => Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Fetch a single plan by ID
|
|
18
|
+
*
|
|
19
|
+
* @param planId - Plan ID to fetch
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* const { plan, isLoading, error } = usePlan('1');
|
|
24
|
+
*
|
|
25
|
+
* if (isLoading) return <Spinner />;
|
|
26
|
+
* if (error) return <Error message={error.message} />;
|
|
27
|
+
* if (!plan) return <NotFound />;
|
|
28
|
+
*
|
|
29
|
+
* return <PlanDetails plan={plan} />;
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function usePlan(planId: string): UsePlanReturn;
|
|
33
|
+
//# sourceMappingURL=usePlan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePlan.d.ts","sourceRoot":"","sources":["../../../src/hooks/plans/usePlan.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAInC;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,+CAA+C;IAC/C,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,oBAAoB;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,mBAAmB;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,iCAAiC;IACjC,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,CAmErD"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Plan } from '../../types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Hook return type
|
|
5
|
+
*/
|
|
6
|
+
export interface UsePlansReturn {
|
|
7
|
+
/** Array of plans (empty if loading or error) */
|
|
8
|
+
plans: Plan[];
|
|
9
|
+
/** Loading state */
|
|
10
|
+
isLoading: boolean;
|
|
11
|
+
/** Error if any */
|
|
12
|
+
error: Error | null;
|
|
13
|
+
/** Manually refresh all plans */
|
|
14
|
+
refetch: () => Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Fetch multiple plans by IDs
|
|
18
|
+
*
|
|
19
|
+
* @param planIds - Array of plan IDs to fetch
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* const { plans, isLoading, error } = usePlans(['1', '2', '3']);
|
|
24
|
+
*
|
|
25
|
+
* if (isLoading) return <Spinner />;
|
|
26
|
+
* if (error) return <Error message={error.message} />;
|
|
27
|
+
*
|
|
28
|
+
* return (
|
|
29
|
+
* <div className="grid">
|
|
30
|
+
* {plans.map(plan => <PlanCard key={plan.id.toString()} plan={plan} />)}
|
|
31
|
+
* </div>
|
|
32
|
+
* );
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function usePlans(planIds: string[]): UsePlansReturn;
|
|
36
|
+
//# sourceMappingURL=usePlans.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePlans.d.ts","sourceRoot":"","sources":["../../../src/hooks/plans/usePlans.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAInC;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,iDAAiD;IACjD,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,oBAAoB;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,mBAAmB;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,iCAAiC;IACjC,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,cAAc,CA0E1D"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Plan } from '../../types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Hook return type
|
|
5
|
+
*/
|
|
6
|
+
export interface UsePlansByMerchantReturn {
|
|
7
|
+
/** Plans created by the merchant */
|
|
8
|
+
plans: Plan[];
|
|
9
|
+
/** Total matching plans */
|
|
10
|
+
total: number;
|
|
11
|
+
/** Loading state */
|
|
12
|
+
isLoading: boolean;
|
|
13
|
+
/** Error if any */
|
|
14
|
+
error: Error | null;
|
|
15
|
+
/** Manually refresh data */
|
|
16
|
+
refetch: () => Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Fetch all plans created by a specific merchant address.
|
|
20
|
+
*
|
|
21
|
+
* Fetches all plans from the contract and filters client-side by merchantAddress.
|
|
22
|
+
*
|
|
23
|
+
* @param merchantAddress - Ethereum address of the merchant
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```tsx
|
|
27
|
+
* const { plans, total, isLoading } = usePlansByMerchant('0x1234...');
|
|
28
|
+
*
|
|
29
|
+
* plans.forEach(plan => {
|
|
30
|
+
* console.log(plan.description, plan.subscriberCount);
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare function usePlansByMerchant(merchantAddress: string): UsePlansByMerchantReturn;
|
|
35
|
+
//# sourceMappingURL=usePlansByMerchant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePlansByMerchant.d.ts","sourceRoot":"","sources":["../../../src/hooks/plans/usePlansByMerchant.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAExC;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,oCAAoC;IACpC,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,2BAA2B;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,oBAAoB;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,mBAAmB;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,4BAA4B;IAC5B,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,kBAAkB,CAAC,eAAe,EAAE,MAAM,GAAG,wBAAwB,CAyEpF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pricing Hooks
|
|
3
|
+
*
|
|
4
|
+
* React hooks for fetching price data from on-chain oracles.
|
|
5
|
+
*/
|
|
6
|
+
export { useSUBSPrice } from './useSUBSPrice';
|
|
7
|
+
export type { UseSUBSPriceReturn } from './useSUBSPrice';
|
|
8
|
+
export { usePlanPrice } from './usePlanPrice';
|
|
9
|
+
export type { UsePlanPriceReturn, PlanPriceInfo } from './usePlanPrice';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/pricing/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,YAAY,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,YAAY,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* usePlanPrice Hook
|
|
3
|
+
*
|
|
4
|
+
* Comprehensive price information for a subscription plan,
|
|
5
|
+
* including SUBS, USDC, and USD-equivalent prices.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Comprehensive price information for a plan
|
|
9
|
+
*/
|
|
10
|
+
export interface PlanPriceInfo {
|
|
11
|
+
/** Price in SUBS (18 decimals) */
|
|
12
|
+
subsAmount: bigint;
|
|
13
|
+
/** Formatted SUBS amount */
|
|
14
|
+
subsFormatted: string;
|
|
15
|
+
/** USDC equivalent (6 decimals), null if quote unavailable */
|
|
16
|
+
usdcAmount: bigint | null;
|
|
17
|
+
/** Formatted USDC amount, null if quote unavailable */
|
|
18
|
+
usdcFormatted: string | null;
|
|
19
|
+
/** USD display value, null if price unavailable */
|
|
20
|
+
usdValue: number | null;
|
|
21
|
+
/** Payment frequency label */
|
|
22
|
+
frequency: string;
|
|
23
|
+
/** Whether the plan is USD-denominated (currencyCode=1) */
|
|
24
|
+
isUsdDenominated: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Hook return type
|
|
28
|
+
*/
|
|
29
|
+
export interface UsePlanPriceReturn {
|
|
30
|
+
/** Price information (null if not loaded) */
|
|
31
|
+
price: PlanPriceInfo | null;
|
|
32
|
+
/** Loading state */
|
|
33
|
+
isLoading: boolean;
|
|
34
|
+
/** Error if any */
|
|
35
|
+
error: Error | null;
|
|
36
|
+
/** Manually refresh price */
|
|
37
|
+
refetch: () => Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Fetch comprehensive price information for a subscription plan.
|
|
41
|
+
*
|
|
42
|
+
* Resolves SUBS amount, USDC equivalent (via Uniswap), and USD value
|
|
43
|
+
* for both SUBS-denominated and USD-denominated plans.
|
|
44
|
+
*
|
|
45
|
+
* @param planId - Plan ID to fetch pricing for
|
|
46
|
+
* @param refreshInterval - Refresh interval in ms (default: 60000)
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```tsx
|
|
50
|
+
* const { price, isLoading } = usePlanPrice('1');
|
|
51
|
+
*
|
|
52
|
+
* if (price) {
|
|
53
|
+
* console.log(`${price.subsFormatted} SUBS / ${price.frequency}`);
|
|
54
|
+
* if (price.usdValue) console.log(`≈ $${price.usdValue.toFixed(2)}`);
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export declare function usePlanPrice(planId: string, refreshInterval?: number): UsePlanPriceReturn;
|
|
59
|
+
//# sourceMappingURL=usePlanPrice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePlanPrice.d.ts","sourceRoot":"","sources":["../../../src/hooks/pricing/usePlanPrice.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAYH;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,kCAAkC;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,4BAA4B;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,8DAA8D;IAC9D,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,uDAAuD;IACvD,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,mDAAmD;IACnD,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,8BAA8B;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,2DAA2D;IAC3D,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,6CAA6C;IAC7C,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;IAC5B,oBAAoB;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,mBAAmB;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,6BAA6B;IAC7B,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAwBD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,eAAe,GAAE,MAAiC,GACjD,kBAAkB,CAwHpB"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useSUBSPrice Hook
|
|
3
|
+
*
|
|
4
|
+
* Fetch the current SUBS token price in USD from the on-chain oracle.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Hook return type
|
|
8
|
+
*/
|
|
9
|
+
export interface UseSUBSPriceReturn {
|
|
10
|
+
/** Price of 1 SUBS in USD (null if not loaded) */
|
|
11
|
+
priceUsd: number | null;
|
|
12
|
+
/** Raw price from contract (null if not loaded) */
|
|
13
|
+
rawPrice: bigint | null;
|
|
14
|
+
/** Loading state */
|
|
15
|
+
isLoading: boolean;
|
|
16
|
+
/** Error if any */
|
|
17
|
+
error: Error | null;
|
|
18
|
+
/** Manually refresh price */
|
|
19
|
+
refetch: () => Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Fetch the current SUBS/USD price from the on-chain oracle.
|
|
23
|
+
*
|
|
24
|
+
* Uses `convertTokenToOtherCurrency(1e18)` to get the USD value of 1 SUBS.
|
|
25
|
+
* Auto-refreshes every 60 seconds.
|
|
26
|
+
*
|
|
27
|
+
* @param refreshInterval - Refresh interval in ms (default: 60000)
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```tsx
|
|
31
|
+
* const { priceUsd, isLoading } = useSUBSPrice();
|
|
32
|
+
*
|
|
33
|
+
* if (priceUsd) {
|
|
34
|
+
* console.log(`1 SUBS = $${priceUsd.toFixed(4)}`);
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function useSUBSPrice(refreshInterval?: number): UseSUBSPriceReturn;
|
|
39
|
+
//# sourceMappingURL=useSUBSPrice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSUBSPrice.d.ts","sourceRoot":"","sources":["../../../src/hooks/pricing/useSUBSPrice.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,kDAAkD;IAClD,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,mDAAmD;IACnD,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,oBAAoB;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,mBAAmB;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,6BAA6B;IAC7B,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAQD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,CAAC,eAAe,GAAE,MAAiC,GAAG,kBAAkB,CA8DnG"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Subscription hooks exports
|
|
3
|
+
*/
|
|
4
|
+
export { useSubscriptionStatus } from './useSubscriptionStatus';
|
|
5
|
+
export type { UseSubscriptionStatusReturn } from './useSubscriptionStatus';
|
|
6
|
+
export { useSubscribe } from './useSubscribe';
|
|
7
|
+
export type { UseSubscribeReturn, SubscribeParams } from './useSubscribe';
|
|
8
|
+
export { useManageSubscription } from './useManageSubscription';
|
|
9
|
+
export type { UseManageSubscriptionReturn } from './useManageSubscription';
|
|
10
|
+
export { useMySubscriptions } from './useMySubscriptions';
|
|
11
|
+
export type { UseMySubscriptionsReturn } from './useMySubscriptions';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/subscriptions/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,YAAY,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AAE3E,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,YAAY,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAE1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,YAAY,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AAE3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,YAAY,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { TransactionState } from '../../types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Hook return type
|
|
5
|
+
*/
|
|
6
|
+
export interface UseManageSubscriptionReturn {
|
|
7
|
+
/** Cancel subscription (disables auto-renew and sets 0 remaining cycles) */
|
|
8
|
+
cancelSubscription: () => Promise<void>;
|
|
9
|
+
/** Toggle auto-renewal on/off */
|
|
10
|
+
toggleAutoRenew: (enabled: boolean) => Promise<void>;
|
|
11
|
+
/** Update remaining payment cycles */
|
|
12
|
+
updateCycles: (cycles: number) => Promise<void>;
|
|
13
|
+
/** Update subscription custom attributes */
|
|
14
|
+
updateAttributes: (attributes: string) => Promise<void>;
|
|
15
|
+
/** Current transaction state */
|
|
16
|
+
txState: TransactionState;
|
|
17
|
+
/** Error if any */
|
|
18
|
+
error: Error | null;
|
|
19
|
+
/** Whether a transaction is in progress */
|
|
20
|
+
isProcessing: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Manage an existing subscription.
|
|
24
|
+
*
|
|
25
|
+
* @param subscriptionId - The subscription ID to manage
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```tsx
|
|
29
|
+
* const { cancelSubscription, toggleAutoRenew, isProcessing } = useManageSubscription('42');
|
|
30
|
+
*
|
|
31
|
+
* // Cancel subscription
|
|
32
|
+
* await cancelSubscription();
|
|
33
|
+
*
|
|
34
|
+
* // Toggle auto-renewal
|
|
35
|
+
* await toggleAutoRenew(false);
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function useManageSubscription(subscriptionId: string): UseManageSubscriptionReturn;
|
|
39
|
+
//# sourceMappingURL=useManageSubscription.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useManageSubscription.d.ts","sourceRoot":"","sources":["../../../src/hooks/subscriptions/useManageSubscription.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,4EAA4E;IAC5E,kBAAkB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,iCAAiC;IACjC,eAAe,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,sCAAsC;IACtC,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,4CAA4C;IAC5C,gBAAgB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,gCAAgC;IAChC,OAAO,EAAE,gBAAgB,CAAC;IAC1B,mBAAmB;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,2CAA2C;IAC3C,YAAY,EAAE,OAAO,CAAC;CACvB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CAAC,cAAc,EAAE,MAAM,GAAG,2BAA2B,CAuIzF"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Subscription } from '../../types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Hook return type
|
|
5
|
+
*/
|
|
6
|
+
export interface UseMySubscriptionsReturn {
|
|
7
|
+
/** Array of subscriptions for current page */
|
|
8
|
+
subscriptions: Subscription[];
|
|
9
|
+
/** Total number of subscriptions */
|
|
10
|
+
total: number;
|
|
11
|
+
/** Current page (1-indexed) */
|
|
12
|
+
page: number;
|
|
13
|
+
/** Number of subscriptions per page */
|
|
14
|
+
pageSize: number;
|
|
15
|
+
/** Whether there are more pages */
|
|
16
|
+
hasMore: boolean;
|
|
17
|
+
/** Loading state */
|
|
18
|
+
isLoading: boolean;
|
|
19
|
+
/** Error if any */
|
|
20
|
+
error: Error | null;
|
|
21
|
+
/** Go to next page */
|
|
22
|
+
nextPage: () => void;
|
|
23
|
+
/** Go to previous page */
|
|
24
|
+
prevPage: () => void;
|
|
25
|
+
/** Manually refresh subscriptions */
|
|
26
|
+
refetch: () => Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Fetch paginated subscriptions for a wallet address
|
|
30
|
+
*
|
|
31
|
+
* @param address - Optional address to fetch subscriptions for (defaults to connected wallet)
|
|
32
|
+
* @param pageSize - Number of subscriptions per page (default: 10)
|
|
33
|
+
* @param planIds - Optional array of plan IDs to check (recommended for reliability)
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```tsx
|
|
37
|
+
* // Get all subscriptions (tries getSubscriptionsByAddress, up to 100 subs)
|
|
38
|
+
* const { subscriptions, isLoading } = useMySubscriptions();
|
|
39
|
+
*
|
|
40
|
+
* // Filter to specific plans + fallback if getSubscriptionsByAddress fails
|
|
41
|
+
* const { subscriptions, isLoading } = useMySubscriptions(undefined, 10, ['1', '2', '3']);
|
|
42
|
+
*
|
|
43
|
+
* if (isLoading) return <Spinner />;
|
|
44
|
+
*
|
|
45
|
+
* return (
|
|
46
|
+
* <div>
|
|
47
|
+
* {subscriptions.map(sub => <SubscriptionCard key={sub.id} subscription={sub} />)}
|
|
48
|
+
* </div>
|
|
49
|
+
* );
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare function useMySubscriptions(address?: string, pageSize?: number, planIds?: string[]): UseMySubscriptionsReturn;
|
|
53
|
+
//# sourceMappingURL=useMySubscriptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMySubscriptions.d.ts","sourceRoot":"","sources":["../../../src/hooks/subscriptions/useMySubscriptions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,EAAE,YAAY,EAAwB,MAAM,aAAa,CAAC;AAuBjE;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,8CAA8C;IAC9C,aAAa,EAAE,YAAY,EAAE,CAAC;IAC9B,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,uCAAuC;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,mCAAmC;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,oBAAoB;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,mBAAmB;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,sBAAsB;IACtB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,0BAA0B;IAC1B,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,qCAAqC;IACrC,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,CAAC,EAAE,MAAM,EAChB,QAAQ,GAAE,MAAW,EACrB,OAAO,CAAC,EAAE,MAAM,EAAE,GACjB,wBAAwB,CA6I1B"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { PaymentMethod } from '../../types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Subscription parameters
|
|
5
|
+
*/
|
|
6
|
+
export interface SubscribeParams {
|
|
7
|
+
/** Plan ID to subscribe to */
|
|
8
|
+
planId: string;
|
|
9
|
+
/** Number of payment cycles */
|
|
10
|
+
cycleLimit: number;
|
|
11
|
+
/** Enable auto-renewal */
|
|
12
|
+
autoRenew: boolean;
|
|
13
|
+
/** Payment method: SUBS or USDC */
|
|
14
|
+
paymentMethod: PaymentMethod;
|
|
15
|
+
/** Referral address (optional) */
|
|
16
|
+
referralAddress?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Hook return type
|
|
20
|
+
*/
|
|
21
|
+
export interface UseSubscribeReturn {
|
|
22
|
+
/** Execute subscription */
|
|
23
|
+
subscribe: (params: SubscribeParams) => Promise<string>;
|
|
24
|
+
/** Transaction is in progress */
|
|
25
|
+
isSubscribing: boolean;
|
|
26
|
+
/** Current transaction state */
|
|
27
|
+
txState: 'idle' | 'approving' | 'waiting_approval' | 'subscribing' | 'waiting_subscribe' | 'success' | 'error';
|
|
28
|
+
/** Error if any */
|
|
29
|
+
error: Error | null;
|
|
30
|
+
/** Transaction hash */
|
|
31
|
+
txHash: string | null;
|
|
32
|
+
/** Subscription ID (available after success) */
|
|
33
|
+
subscriptionId: string | null;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Hook to execute subscription transactions
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```tsx
|
|
40
|
+
* const { subscribe, isSubscribing, txState, error } = useSubscribe();
|
|
41
|
+
*
|
|
42
|
+
* const handleSubscribe = async () => {
|
|
43
|
+
* try {
|
|
44
|
+
* const subId = await subscribe({
|
|
45
|
+
* planId: '1',
|
|
46
|
+
* cycleLimit: 12,
|
|
47
|
+
* autoRenew: true,
|
|
48
|
+
* paymentMethod: 'SUBS'
|
|
49
|
+
* });
|
|
50
|
+
* console.log('Subscription ID:', subId);
|
|
51
|
+
* } catch (error) {
|
|
52
|
+
* console.error('Failed:', error);
|
|
53
|
+
* }
|
|
54
|
+
* };
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function useSubscribe(): UseSubscribeReturn;
|
|
58
|
+
//# sourceMappingURL=useSubscribe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSubscribe.d.ts","sourceRoot":"","sources":["../../../src/hooks/subscriptions/useSubscribe.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAU5C;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,8BAA8B;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,+BAA+B;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,0BAA0B;IAC1B,SAAS,EAAE,OAAO,CAAC;IACnB,mCAAmC;IACnC,aAAa,EAAE,aAAa,CAAC;IAC7B,kCAAkC;IAClC,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,2BAA2B;IAC3B,SAAS,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACxD,iCAAiC;IACjC,aAAa,EAAE,OAAO,CAAC;IACvB,gCAAgC;IAChC,OAAO,EAAE,MAAM,GAAG,WAAW,GAAG,kBAAkB,GAAG,aAAa,GAAG,mBAAmB,GAAG,SAAS,GAAG,OAAO,CAAC;IAC/G,mBAAmB;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,uBAAuB;IACvB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,gDAAgD;IAChD,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,YAAY,IAAI,kBAAkB,CAiXjD"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { SubscriptionStatus } from '../../types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Hook return type
|
|
5
|
+
*/
|
|
6
|
+
export interface UseSubscriptionStatusReturn {
|
|
7
|
+
/** Subscription status (null if not found) */
|
|
8
|
+
status: SubscriptionStatus | null;
|
|
9
|
+
/** Loading state */
|
|
10
|
+
isLoading: boolean;
|
|
11
|
+
/** Error if any */
|
|
12
|
+
error: Error | null;
|
|
13
|
+
/** Manually refresh subscription status */
|
|
14
|
+
refetch: () => Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Check subscription status for a specific plan
|
|
18
|
+
*
|
|
19
|
+
* @param planId - Plan ID to check
|
|
20
|
+
* @param subscriber - Optional subscriber address (defaults to connected wallet)
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* const { status, isLoading, error } = useSubscriptionStatus('1');
|
|
25
|
+
*
|
|
26
|
+
* if (isLoading) return <Spinner />;
|
|
27
|
+
* if (error) return <Error message={error.message} />;
|
|
28
|
+
* if (!status?.isActive) return <Subscribe />;
|
|
29
|
+
*
|
|
30
|
+
* return <PremiumContent />;
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function useSubscriptionStatus(planId: string, subscriber?: string): UseSubscriptionStatusReturn;
|
|
34
|
+
//# sourceMappingURL=useSubscriptionStatus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSubscriptionStatus.d.ts","sourceRoot":"","sources":["../../../src/hooks/subscriptions/useSubscriptionStatus.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,kBAAkB,EAAwB,MAAM,aAAa,CAAC;AAIvE;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,8CAA8C;IAC9C,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAClC,oBAAoB;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,mBAAmB;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,2CAA2C;IAC3C,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,UAAU,CAAC,EAAE,MAAM,GAClB,2BAA2B,CA8I7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/tokens/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,YAAY,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC"}
|