@varity-labs/ui-kit 2.0.0-beta.8 → 2.0.0-beta.9

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.
Files changed (194) hide show
  1. package/dist/components/Dashboard/DashboardHeader.js +4 -4
  2. package/dist/components/Dashboard/DashboardHeader.js.map +1 -1
  3. package/dist/components/Dashboard/DashboardLayout.d.ts +3 -3
  4. package/dist/components/Dashboard/DashboardLayout.d.ts.map +1 -1
  5. package/dist/components/Dashboard/DashboardLayout.js +1 -1
  6. package/dist/components/InAppWallet/EmailLoginButton.d.ts +27 -0
  7. package/dist/components/InAppWallet/EmailLoginButton.d.ts.map +1 -0
  8. package/dist/components/InAppWallet/EmailLoginButton.js +84 -0
  9. package/dist/components/InAppWallet/EmailLoginButton.js.map +1 -0
  10. package/dist/components/InAppWallet/InAppWalletProvider.d.ts +54 -0
  11. package/dist/components/InAppWallet/InAppWalletProvider.d.ts.map +1 -0
  12. package/dist/components/InAppWallet/InAppWalletProvider.js +225 -0
  13. package/dist/components/InAppWallet/InAppWalletProvider.js.map +1 -0
  14. package/dist/components/InAppWallet/OnboardingFlow.d.ts +25 -0
  15. package/dist/components/InAppWallet/OnboardingFlow.d.ts.map +1 -0
  16. package/dist/components/InAppWallet/OnboardingFlow.js +159 -0
  17. package/dist/components/InAppWallet/OnboardingFlow.js.map +1 -0
  18. package/dist/components/InAppWallet/SocialLoginButtons.d.ts +28 -0
  19. package/dist/components/InAppWallet/SocialLoginButtons.d.ts.map +1 -0
  20. package/dist/components/InAppWallet/SocialLoginButtons.js +128 -0
  21. package/dist/components/InAppWallet/SocialLoginButtons.js.map +1 -0
  22. package/dist/components/InAppWallet/index.d.ts +15 -0
  23. package/dist/components/InAppWallet/index.d.ts.map +1 -0
  24. package/dist/components/InAppWallet/index.js +14 -0
  25. package/dist/components/InAppWallet/index.js.map +1 -0
  26. package/dist/components/PaymentWidget/PaymentWidget.d.ts +19 -7
  27. package/dist/components/PaymentWidget/PaymentWidget.d.ts.map +1 -1
  28. package/dist/components/PaymentWidget/PaymentWidget.js +176 -10
  29. package/dist/components/PaymentWidget/PaymentWidget.js.map +1 -1
  30. package/dist/components/PaymentWidget/useSeamlessPayment.d.ts +34 -8
  31. package/dist/components/PaymentWidget/useSeamlessPayment.d.ts.map +1 -1
  32. package/dist/components/PaymentWidget/useSeamlessPayment.js +158 -12
  33. package/dist/components/PaymentWidget/useSeamlessPayment.js.map +1 -1
  34. package/dist/components/PaymentWidget/useVarityPayment.d.ts +6 -5
  35. package/dist/components/PaymentWidget/useVarityPayment.d.ts.map +1 -1
  36. package/dist/components/PaymentWidget/useVarityPayment.js +147 -11
  37. package/dist/components/PaymentWidget/useVarityPayment.js.map +1 -1
  38. package/dist/components/Payments/CheckoutModal.d.ts +19 -0
  39. package/dist/components/Payments/CheckoutModal.d.ts.map +1 -0
  40. package/dist/components/Payments/CheckoutModal.js +194 -0
  41. package/dist/components/Payments/CheckoutModal.js.map +1 -0
  42. package/dist/components/Payments/SubscriptionWidget.d.ts +17 -0
  43. package/dist/components/Payments/SubscriptionWidget.d.ts.map +1 -0
  44. package/dist/components/Payments/SubscriptionWidget.js +89 -0
  45. package/dist/components/Payments/SubscriptionWidget.js.map +1 -0
  46. package/dist/components/Payments/constants.d.ts +59 -0
  47. package/dist/components/Payments/constants.d.ts.map +1 -0
  48. package/dist/components/Payments/constants.js +145 -0
  49. package/dist/components/Payments/constants.js.map +1 -0
  50. package/dist/components/Payments/index.d.ts +10 -0
  51. package/dist/components/Payments/index.d.ts.map +1 -0
  52. package/dist/components/Payments/index.js +12 -0
  53. package/dist/components/Payments/index.js.map +1 -0
  54. package/dist/components/Payments/types.d.ts +119 -0
  55. package/dist/components/Payments/types.d.ts.map +1 -0
  56. package/dist/components/Payments/types.js +27 -0
  57. package/dist/components/Payments/types.js.map +1 -0
  58. package/dist/components/Payments/usePayments.d.ts +33 -0
  59. package/dist/components/Payments/usePayments.d.ts.map +1 -0
  60. package/dist/components/Payments/usePayments.js +249 -0
  61. package/dist/components/Payments/usePayments.js.map +1 -0
  62. package/dist/components/SIWE/AuthStatus.d.ts +15 -0
  63. package/dist/components/SIWE/AuthStatus.d.ts.map +1 -0
  64. package/dist/components/SIWE/AuthStatus.js +47 -0
  65. package/dist/components/SIWE/AuthStatus.js.map +1 -0
  66. package/dist/components/SIWE/ProtectedRoute.d.ts +17 -0
  67. package/dist/components/SIWE/ProtectedRoute.d.ts.map +1 -0
  68. package/dist/components/SIWE/ProtectedRoute.js +52 -0
  69. package/dist/components/SIWE/ProtectedRoute.js.map +1 -0
  70. package/dist/components/SIWE/SIWEButton.d.ts +22 -0
  71. package/dist/components/SIWE/SIWEButton.d.ts.map +1 -0
  72. package/dist/components/SIWE/SIWEButton.js +106 -0
  73. package/dist/components/SIWE/SIWEButton.js.map +1 -0
  74. package/dist/components/SIWE/SIWEModal.d.ts +19 -0
  75. package/dist/components/SIWE/SIWEModal.d.ts.map +1 -0
  76. package/dist/components/SIWE/SIWEModal.js +75 -0
  77. package/dist/components/SIWE/SIWEModal.js.map +1 -0
  78. package/dist/components/SIWE/SIWEProvider.d.ts +38 -0
  79. package/dist/components/SIWE/SIWEProvider.d.ts.map +1 -0
  80. package/dist/components/SIWE/SIWEProvider.js +227 -0
  81. package/dist/components/SIWE/SIWEProvider.js.map +1 -0
  82. package/dist/components/SIWE/index.d.ts +15 -0
  83. package/dist/components/SIWE/index.d.ts.map +1 -0
  84. package/dist/components/SIWE/index.js +10 -0
  85. package/dist/components/SIWE/index.js.map +1 -0
  86. package/dist/hooks/web3/index.d.ts +5 -0
  87. package/dist/hooks/web3/index.d.ts.map +1 -0
  88. package/dist/hooks/web3/index.js +6 -0
  89. package/dist/hooks/web3/index.js.map +1 -0
  90. package/dist/hooks/web3/useAddressValidation.d.ts +37 -0
  91. package/dist/hooks/web3/useAddressValidation.d.ts.map +1 -0
  92. package/dist/hooks/web3/useAddressValidation.js +59 -0
  93. package/dist/hooks/web3/useAddressValidation.js.map +1 -0
  94. package/dist/hooks/web3/useBlockExplorer.d.ts +37 -0
  95. package/dist/hooks/web3/useBlockExplorer.d.ts.map +1 -0
  96. package/dist/hooks/web3/useBlockExplorer.js +59 -0
  97. package/dist/hooks/web3/useBlockExplorer.js.map +1 -0
  98. package/dist/hooks/web3/useUSDCFormat.d.ts +34 -0
  99. package/dist/hooks/web3/useUSDCFormat.d.ts.map +1 -0
  100. package/dist/hooks/web3/useUSDCFormat.js +43 -0
  101. package/dist/hooks/web3/useUSDCFormat.js.map +1 -0
  102. package/dist/hooks/web3/useVarityWallet.d.ts +48 -0
  103. package/dist/hooks/web3/useVarityWallet.d.ts.map +1 -0
  104. package/dist/hooks/web3/useVarityWallet.js +70 -0
  105. package/dist/hooks/web3/useVarityWallet.js.map +1 -0
  106. package/dist/providers/ChainContext.d.ts +65 -0
  107. package/dist/providers/ChainContext.d.ts.map +1 -0
  108. package/dist/providers/ChainContext.js +92 -0
  109. package/dist/providers/ChainContext.js.map +1 -0
  110. package/dist/providers/PrivyStack.d.ts +17 -50
  111. package/dist/providers/PrivyStack.d.ts.map +1 -1
  112. package/dist/providers/PrivyStack.js +15 -43
  113. package/dist/providers/PrivyStack.js.map +1 -1
  114. package/dist/providers/VarityDashboardProvider.d.ts +2 -2
  115. package/dist/providers/VarityDashboardProvider.d.ts.map +1 -1
  116. package/dist/providers/VarityDashboardProvider.js +26 -3
  117. package/dist/providers/VarityDashboardProvider.js.map +1 -1
  118. package/dist/providers/VarityProvider.d.ts +32 -0
  119. package/dist/providers/VarityProvider.d.ts.map +1 -0
  120. package/dist/providers/VarityProvider.js +56 -0
  121. package/dist/providers/VarityProvider.js.map +1 -0
  122. package/dist/providers/WalletContext.d.ts +68 -0
  123. package/dist/providers/WalletContext.d.ts.map +1 -0
  124. package/dist/providers/WalletContext.js +98 -0
  125. package/dist/providers/WalletContext.js.map +1 -0
  126. package/dist/providers/WalletSyncProvider.d.ts +15 -18
  127. package/dist/providers/WalletSyncProvider.d.ts.map +1 -1
  128. package/dist/providers/WalletSyncProvider.js +12 -15
  129. package/dist/providers/WalletSyncProvider.js.map +1 -1
  130. package/dist/providers/index.d.ts +48 -0
  131. package/dist/providers/index.d.ts.map +1 -0
  132. package/dist/providers/index.js +53 -0
  133. package/dist/providers/index.js.map +1 -0
  134. package/dist/wallets/SimpleSmartWallet.d.ts +68 -0
  135. package/dist/wallets/SimpleSmartWallet.d.ts.map +1 -0
  136. package/dist/wallets/SimpleSmartWallet.js +74 -0
  137. package/dist/wallets/SimpleSmartWallet.js.map +1 -0
  138. package/dist/wallets/SmartWalletProvider.d.ts +217 -0
  139. package/dist/wallets/SmartWalletProvider.d.ts.map +1 -0
  140. package/dist/wallets/SmartWalletProvider.js +366 -0
  141. package/dist/wallets/SmartWalletProvider.js.map +1 -0
  142. package/dist/wallets/config.d.ts +222 -0
  143. package/dist/wallets/config.d.ts.map +1 -0
  144. package/dist/wallets/config.js +206 -0
  145. package/dist/wallets/config.js.map +1 -0
  146. package/dist/wallets/index.d.ts +9 -0
  147. package/dist/wallets/index.d.ts.map +1 -0
  148. package/dist/wallets/index.js +9 -0
  149. package/dist/wallets/index.js.map +1 -0
  150. package/dist/web3/AddressDisplay/AddressDisplay.d.ts +33 -0
  151. package/dist/web3/AddressDisplay/AddressDisplay.d.ts.map +1 -0
  152. package/dist/web3/AddressDisplay/AddressDisplay.js +42 -0
  153. package/dist/web3/AddressDisplay/AddressDisplay.js.map +1 -0
  154. package/dist/web3/AddressInput/AddressInput.d.ts +36 -0
  155. package/dist/web3/AddressInput/AddressInput.d.ts.map +1 -0
  156. package/dist/web3/AddressInput/AddressInput.js +54 -0
  157. package/dist/web3/AddressInput/AddressInput.js.map +1 -0
  158. package/dist/web3/AmountInput/AmountInput.d.ts +41 -0
  159. package/dist/web3/AmountInput/AmountInput.d.ts.map +1 -0
  160. package/dist/web3/AmountInput/AmountInput.js +74 -0
  161. package/dist/web3/AmountInput/AmountInput.js.map +1 -0
  162. package/dist/web3/BalanceDisplay/BalanceDisplay.d.ts +30 -0
  163. package/dist/web3/BalanceDisplay/BalanceDisplay.d.ts.map +1 -0
  164. package/dist/web3/BalanceDisplay/BalanceDisplay.js +35 -0
  165. package/dist/web3/BalanceDisplay/BalanceDisplay.js.map +1 -0
  166. package/dist/web3/BlockExplorerLink/BlockExplorerLink.d.ts +41 -0
  167. package/dist/web3/BlockExplorerLink/BlockExplorerLink.d.ts.map +1 -0
  168. package/dist/web3/BlockExplorerLink/BlockExplorerLink.js +46 -0
  169. package/dist/web3/BlockExplorerLink/BlockExplorerLink.js.map +1 -0
  170. package/dist/web3/ConnectWallet/ConnectWallet.d.ts +35 -0
  171. package/dist/web3/ConnectWallet/ConnectWallet.d.ts.map +1 -0
  172. package/dist/web3/ConnectWallet/ConnectWallet.js +58 -0
  173. package/dist/web3/ConnectWallet/ConnectWallet.js.map +1 -0
  174. package/dist/web3/DisconnectButton/DisconnectButton.d.ts +30 -0
  175. package/dist/web3/DisconnectButton/DisconnectButton.d.ts.map +1 -0
  176. package/dist/web3/DisconnectButton/DisconnectButton.js +48 -0
  177. package/dist/web3/DisconnectButton/DisconnectButton.js.map +1 -0
  178. package/dist/web3/WalletBalance/WalletBalance.d.ts +27 -0
  179. package/dist/web3/WalletBalance/WalletBalance.d.ts.map +1 -0
  180. package/dist/web3/WalletBalance/WalletBalance.js +49 -0
  181. package/dist/web3/WalletBalance/WalletBalance.js.map +1 -0
  182. package/dist/web3/WalletDropdown/WalletDropdown.d.ts +29 -0
  183. package/dist/web3/WalletDropdown/WalletDropdown.d.ts.map +1 -0
  184. package/dist/web3/WalletDropdown/WalletDropdown.js +93 -0
  185. package/dist/web3/WalletDropdown/WalletDropdown.js.map +1 -0
  186. package/dist/web3/WalletInfo/WalletInfo.d.ts +31 -0
  187. package/dist/web3/WalletInfo/WalletInfo.d.ts.map +1 -0
  188. package/dist/web3/WalletInfo/WalletInfo.js +41 -0
  189. package/dist/web3/WalletInfo/WalletInfo.js.map +1 -0
  190. package/dist/web3/index.d.ts +11 -0
  191. package/dist/web3/index.d.ts.map +1 -0
  192. package/dist/web3/index.js +14 -0
  193. package/dist/web3/index.js.map +1 -0
  194. package/package.json +4 -3
@@ -1,8 +1,15 @@
1
1
  /**
2
2
  * useVarityPayment Hook
3
- *
4
- * Payments are coming soon. Returns safe defaults until payment processing
5
- * is enabled in a future release.
3
+ * Manages purchase state for developer apps with 90/10 revenue split
4
+ */
5
+ import { useState, useEffect, useCallback } from 'react';
6
+ import { useActiveAccount, useSendTransaction } from 'thirdweb/react';
7
+ import { prepareContractCall, readContract, getContract } from 'thirdweb';
8
+ import { createThirdwebClient } from 'thirdweb';
9
+ import { arbitrumOne, THIRDWEB_CLIENT_ID } from '../../config/chains';
10
+ import { VARITY_PAYMENTS_ADDRESS, VARITY_PAYMENTS_ABI, } from './types';
11
+ /**
12
+ * Hook for managing app purchase state
6
13
  *
7
14
  * @example
8
15
  * ```tsx
@@ -13,15 +20,144 @@
13
20
  * return <PremiumContent />;
14
21
  * ```
15
22
  */
16
- export function useVarityPayment(_options) {
23
+ export function useVarityPayment({ appId, autoFetch = true, }) {
24
+ const [hasPurchased, setHasPurchased] = useState(false);
25
+ const [isLoading, setIsLoading] = useState(true);
26
+ const [isPurchasing, setIsPurchasing] = useState(false);
27
+ const [error, setError] = useState(null);
28
+ const [pricing, setPricing] = useState(null);
29
+ const account = useActiveAccount();
30
+ const { mutateAsync: sendTx } = useSendTransaction();
31
+ // Create thirdweb client
32
+ const client = createThirdwebClient({ clientId: THIRDWEB_CLIENT_ID });
33
+ // Get contract instance
34
+ const getPaymentsContract = useCallback(() => {
35
+ return getContract({
36
+ client,
37
+ chain: arbitrumOne, // Payments on Arb One (mainnet, real USDC)
38
+ address: VARITY_PAYMENTS_ADDRESS,
39
+ });
40
+ }, [client]);
41
+ /**
42
+ * Fetch pricing and purchase status
43
+ */
44
+ const fetchData = useCallback(async () => {
45
+ if (!appId) {
46
+ setIsLoading(false);
47
+ return;
48
+ }
49
+ try {
50
+ setIsLoading(true);
51
+ setError(null);
52
+ const contract = getPaymentsContract();
53
+ // Get app pricing
54
+ const pricingMethod = VARITY_PAYMENTS_ABI.find(m => m.name === 'getAppPricing');
55
+ if (pricingMethod) {
56
+ const pricingData = await readContract({
57
+ contract,
58
+ method: pricingMethod,
59
+ params: [BigInt(appId)],
60
+ });
61
+ setPricing({
62
+ priceUsdc: pricingData[0],
63
+ developer: pricingData[1],
64
+ isSubscription: pricingData[2],
65
+ intervalDays: Number(pricingData[3]),
66
+ isActive: pricingData[4],
67
+ });
68
+ }
69
+ // Check if user has purchased (if connected)
70
+ if (account?.address) {
71
+ const purchasedMethod = VARITY_PAYMENTS_ABI.find(m => m.name === 'hasUserPurchased');
72
+ if (purchasedMethod) {
73
+ const purchased = await readContract({
74
+ contract,
75
+ method: purchasedMethod,
76
+ params: [BigInt(appId), account.address],
77
+ });
78
+ setHasPurchased(purchased);
79
+ }
80
+ }
81
+ else {
82
+ setHasPurchased(false);
83
+ }
84
+ }
85
+ catch (err) {
86
+ console.error('Failed to fetch payment data:', err);
87
+ // Don't show error for apps without pricing - just set pricing to null
88
+ setPricing(null);
89
+ setHasPurchased(false);
90
+ }
91
+ finally {
92
+ setIsLoading(false);
93
+ }
94
+ }, [appId, account?.address, getPaymentsContract]);
95
+ /**
96
+ * Purchase the app
97
+ */
98
+ const purchase = useCallback(async () => {
99
+ if (!account) {
100
+ setError('Please sign in first');
101
+ return null;
102
+ }
103
+ if (!pricing || !pricing.isActive) {
104
+ setError('This app is not available for purchase');
105
+ return null;
106
+ }
107
+ if (hasPurchased) {
108
+ setError('You have already purchased this app');
109
+ return null;
110
+ }
111
+ try {
112
+ setIsPurchasing(true);
113
+ setError(null);
114
+ const contract = getPaymentsContract();
115
+ const purchaseMethod = VARITY_PAYMENTS_ABI.find(m => m.name === 'purchaseApp');
116
+ if (!purchaseMethod) {
117
+ throw new Error('Purchase method not found in ABI');
118
+ }
119
+ const transaction = prepareContractCall({
120
+ contract,
121
+ method: purchaseMethod,
122
+ params: [BigInt(appId)],
123
+ // No value — purchaseApp is nonpayable, pulls USDC via ERC-20 transferFrom
124
+ });
125
+ const result = await sendTx(transaction);
126
+ const txHash = result.transactionHash;
127
+ // Update purchase status
128
+ setHasPurchased(true);
129
+ return txHash;
130
+ }
131
+ catch (err) {
132
+ const errorMessage = err instanceof Error ? err.message : 'Purchase failed';
133
+ setError(errorMessage);
134
+ console.error('Purchase error:', err);
135
+ return null;
136
+ }
137
+ finally {
138
+ setIsPurchasing(false);
139
+ }
140
+ }, [account, pricing, hasPurchased, appId, getPaymentsContract, sendTx]);
141
+ /**
142
+ * Refresh purchase status
143
+ */
144
+ const refresh = useCallback(async () => {
145
+ await fetchData();
146
+ }, [fetchData]);
147
+ // Auto-fetch on mount and when dependencies change
148
+ useEffect(() => {
149
+ if (autoFetch) {
150
+ fetchData();
151
+ }
152
+ }, [autoFetch, fetchData]);
17
153
  return {
18
- hasPurchased: false,
19
- isLoading: false,
20
- isPurchasing: false,
21
- error: null,
22
- pricing: null,
23
- purchase: async () => null,
24
- refresh: async () => { },
154
+ hasPurchased,
155
+ isLoading,
156
+ isPurchasing,
157
+ error,
158
+ pricing,
159
+ purchase,
160
+ refresh,
25
161
  };
26
162
  }
27
163
  export default useVarityPayment;
@@ -1 +1 @@
1
- {"version":3,"file":"useVarityPayment.js","sourceRoot":"","sources":["../../../src/components/PaymentWidget/useVarityPayment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,MAAM,UAAU,gBAAgB,CAC9B,QAAiC;IAEjC,OAAO;QACL,YAAY,EAAE,KAAK;QACnB,SAAS,EAAE,KAAK;QAChB,YAAY,EAAE,KAAK;QACnB,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI;QAC1B,OAAO,EAAE,KAAK,IAAI,EAAE,GAAE,CAAC;KACxB,CAAC;AACJ,CAAC;AAED,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":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,mDAAmD;IACnD,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,SAAS,EAAE,CAAC;YACd,SAAS,EAAE,CAAC;QACd,CAAC;IACH,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;IAE3B,OAAO;QACL,YAAY;QACZ,SAAS;QACT,YAAY;QACZ,KAAK;QACL,OAAO;QACP,QAAQ;QACR,OAAO;KACR,CAAC;AACJ,CAAC;AAED,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import { SubscriptionPlan } from './types';
3
+ /**
4
+ * Checkout Modal Component
5
+ * Handles USDC payment processing for subscriptions
6
+ */
7
+ interface CheckoutModalProps {
8
+ isOpen: boolean;
9
+ onClose: () => void;
10
+ plan: SubscriptionPlan;
11
+ clientId: string;
12
+ paymentRecipient: string;
13
+ onSuccess?: (txHash: string) => void;
14
+ onError?: (error: Error) => void;
15
+ theme?: 'light' | 'dark';
16
+ }
17
+ export declare const CheckoutModal: React.FC<CheckoutModalProps>;
18
+ export default CheckoutModal;
19
+ //# sourceMappingURL=CheckoutModal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CheckoutModal.d.ts","sourceRoot":"","sources":["../../../src/components/Payments/CheckoutModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAKnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAK3C;;;GAGG;AAEH,UAAU,kBAAkB;IAC1B,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,IAAI,EAAE,gBAAgB,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CAC1B;AAWD,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAuLtD,CAAC;AA0NF,eAAe,aAAa,CAAC"}
@@ -0,0 +1,194 @@
1
+ import React, { useState, useEffect } from 'react';
2
+ import { useActiveAccount, useSendTransaction } from 'thirdweb/react';
3
+ import { prepareContractCall, waitForReceipt } from 'thirdweb';
4
+ import { getContract } from 'thirdweb';
5
+ import { createThirdwebClient } from 'thirdweb';
6
+ import { formatUSDC, USDC_CONTRACT_ADDRESS } from './constants';
7
+ import { useSIWE } from '../SIWE/SIWEProvider';
8
+ import { varityL3Testnet } from '../../config/chains';
9
+ var CheckoutStep;
10
+ (function (CheckoutStep) {
11
+ CheckoutStep["REVIEW"] = "review";
12
+ CheckoutStep["APPROVE"] = "approve";
13
+ CheckoutStep["PAYMENT"] = "payment";
14
+ CheckoutStep["CONFIRMING"] = "confirming";
15
+ CheckoutStep["SUCCESS"] = "success";
16
+ CheckoutStep["ERROR"] = "error";
17
+ })(CheckoutStep || (CheckoutStep = {}));
18
+ export const CheckoutModal = ({ isOpen, onClose, plan, clientId, paymentRecipient, onSuccess, onError, theme = 'dark', }) => {
19
+ const [currentStep, setCurrentStep] = useState(CheckoutStep.REVIEW);
20
+ const [error, setError] = useState(null);
21
+ const [txHash, setTxHash] = useState(null);
22
+ const { isAuthenticated } = useSIWE();
23
+ const account = useActiveAccount();
24
+ const { mutate: sendTransaction, isPending } = useSendTransaction();
25
+ const client = createThirdwebClient({ clientId });
26
+ // Reset state when modal opens
27
+ useEffect(() => {
28
+ if (isOpen) {
29
+ setCurrentStep(CheckoutStep.REVIEW);
30
+ setError(null);
31
+ setTxHash(null);
32
+ }
33
+ }, [isOpen]);
34
+ if (!isOpen)
35
+ return null;
36
+ const bgColor = theme === 'dark' ? 'bg-gray-900' : 'bg-white';
37
+ const textColor = theme === 'dark' ? 'text-white' : 'text-gray-900';
38
+ const mutedTextColor = theme === 'dark' ? 'text-gray-400' : 'text-gray-600';
39
+ const borderColor = theme === 'dark' ? 'border-gray-700' : 'border-gray-200';
40
+ const handlePayment = async () => {
41
+ if (!account || !isAuthenticated) {
42
+ setError('Please connect wallet and authenticate first');
43
+ setCurrentStep(CheckoutStep.ERROR);
44
+ return;
45
+ }
46
+ try {
47
+ setCurrentStep(CheckoutStep.PAYMENT);
48
+ setError(null);
49
+ // Get USDC contract
50
+ const usdcContract = getContract({
51
+ client,
52
+ chain: varityL3Testnet,
53
+ address: USDC_CONTRACT_ADDRESS,
54
+ });
55
+ // Prepare USDC transfer transaction
56
+ const transaction = prepareContractCall({
57
+ contract: usdcContract,
58
+ method: 'function transfer(address to, uint256 amount) returns (bool)',
59
+ params: [paymentRecipient, BigInt(plan.price)],
60
+ });
61
+ // Send transaction
62
+ sendTransaction(transaction, {
63
+ onSuccess: async (result) => {
64
+ setTxHash(result.transactionHash);
65
+ setCurrentStep(CheckoutStep.CONFIRMING);
66
+ try {
67
+ // Wait for on-chain confirmation instead of a fixed timeout
68
+ await waitForReceipt({
69
+ client,
70
+ chain: varityL3Testnet,
71
+ transactionHash: result.transactionHash,
72
+ });
73
+ setCurrentStep(CheckoutStep.SUCCESS);
74
+ onSuccess?.(result.transactionHash);
75
+ }
76
+ catch (receiptErr) {
77
+ const msg = receiptErr?.message || 'Transaction failed on-chain';
78
+ setError(msg);
79
+ setCurrentStep(CheckoutStep.ERROR);
80
+ onError?.(receiptErr);
81
+ }
82
+ },
83
+ onError: (err) => {
84
+ const errorMessage = err.message || 'Payment failed';
85
+ setError(errorMessage);
86
+ setCurrentStep(CheckoutStep.ERROR);
87
+ onError?.(err);
88
+ },
89
+ });
90
+ }
91
+ catch (err) {
92
+ const errorMessage = err.message || 'Payment failed';
93
+ setError(errorMessage);
94
+ setCurrentStep(CheckoutStep.ERROR);
95
+ onError?.(err);
96
+ }
97
+ };
98
+ const handleClose = () => {
99
+ if (currentStep !== CheckoutStep.PAYMENT && currentStep !== CheckoutStep.CONFIRMING) {
100
+ onClose();
101
+ }
102
+ };
103
+ return (React.createElement("div", { className: "fixed inset-0 z-50 flex items-center justify-center" },
104
+ React.createElement("div", { className: "absolute inset-0 bg-black bg-opacity-50", onClick: handleClose }),
105
+ React.createElement("div", { className: `relative w-full max-w-2xl mx-4 rounded-2xl shadow-2xl ${bgColor} ${textColor} border ${borderColor}` },
106
+ currentStep !== CheckoutStep.PAYMENT && currentStep !== CheckoutStep.CONFIRMING && (React.createElement("button", { onClick: handleClose, className: "absolute top-4 right-4 text-gray-400 hover:text-gray-600 transition-colors" },
107
+ React.createElement("svg", { className: "w-6 h-6", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24" },
108
+ React.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" })))),
109
+ React.createElement("div", { className: "p-8" },
110
+ React.createElement("h2", { className: "text-3xl font-bold mb-6" }, "Complete Your Subscription"),
111
+ currentStep === CheckoutStep.REVIEW && (React.createElement(ReviewStep, { plan: plan, onProceed: handlePayment, theme: theme, textColor: textColor, mutedTextColor: mutedTextColor, borderColor: borderColor, isPending: isPending })),
112
+ currentStep === CheckoutStep.PAYMENT && (React.createElement(ProcessingStep, { message: "Processing payment...", theme: theme, textColor: textColor })),
113
+ currentStep === CheckoutStep.CONFIRMING && (React.createElement(ProcessingStep, { message: "Confirming transaction...", txHash: txHash, theme: theme, textColor: textColor, mutedTextColor: mutedTextColor })),
114
+ currentStep === CheckoutStep.SUCCESS && (React.createElement(SuccessStep, { plan: plan, txHash: txHash, onClose: onClose, theme: theme, textColor: textColor, mutedTextColor: mutedTextColor })),
115
+ currentStep === CheckoutStep.ERROR && (React.createElement(ErrorStep, { error: error, onRetry: handlePayment, onClose: onClose, theme: theme, textColor: textColor }))))));
116
+ };
117
+ const ReviewStep = ({ plan, onProceed, theme, textColor, mutedTextColor, borderColor, isPending, }) => (React.createElement(React.Fragment, null,
118
+ React.createElement("div", { className: `border ${borderColor} rounded-lg p-6 mb-6` },
119
+ React.createElement("div", { className: "flex justify-between items-start mb-4" },
120
+ React.createElement("div", null,
121
+ React.createElement("h3", { className: `text-xl font-bold ${textColor}` },
122
+ plan.name,
123
+ " Plan"),
124
+ React.createElement("p", { className: mutedTextColor }, plan.description)),
125
+ React.createElement("div", { className: "text-right" },
126
+ React.createElement("p", { className: `text-2xl font-bold ${textColor}` }, formatUSDC(plan.price)),
127
+ React.createElement("p", { className: `text-sm ${mutedTextColor}` }, "per month"))),
128
+ React.createElement("div", { className: "space-y-2" },
129
+ React.createElement("p", { className: `font-semibold ${textColor} mb-2` }, "Included features:"),
130
+ plan.features.slice(0, 5).map((feature, index) => (React.createElement("div", { key: index, className: "flex items-center gap-2" },
131
+ React.createElement("svg", { className: "w-4 h-4 text-green-500", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24" },
132
+ React.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M5 13l4 4L19 7" })),
133
+ React.createElement("span", { className: `text-sm ${mutedTextColor}` }, feature)))))),
134
+ React.createElement("div", { className: `bg-${theme === 'dark' ? 'gray-800' : 'gray-50'} rounded-lg p-6 mb-6` },
135
+ React.createElement("h4", { className: `font-semibold mb-4 ${textColor}` }, "Payment Details"),
136
+ React.createElement("div", { className: "space-y-2" },
137
+ React.createElement("div", { className: "flex justify-between" },
138
+ React.createElement("span", { className: mutedTextColor }, "Subtotal"),
139
+ React.createElement("span", { className: textColor }, formatUSDC(plan.price))),
140
+ React.createElement("div", { className: "flex justify-between" },
141
+ React.createElement("span", { className: mutedTextColor }, "Currency"),
142
+ React.createElement("span", { className: textColor }, "USDC (Varity L3)")),
143
+ React.createElement("div", { className: `border-t ${borderColor} pt-2 mt-2` }),
144
+ React.createElement("div", { className: "flex justify-between font-bold" },
145
+ React.createElement("span", { className: textColor }, "Total Due Today"),
146
+ React.createElement("span", { className: `text-xl ${textColor}` }, formatUSDC(plan.price))))),
147
+ React.createElement("button", { onClick: onProceed, disabled: isPending, className: "w-full py-4 bg-blue-600 hover:bg-blue-700 text-white font-bold rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2" }, isPending ? (React.createElement(React.Fragment, null,
148
+ React.createElement(LoadingSpinner, null),
149
+ "Processing...")) : (React.createElement(React.Fragment, null,
150
+ "Pay ",
151
+ formatUSDC(plan.price),
152
+ " USDC"))),
153
+ React.createElement("p", { className: `text-xs text-center mt-4 ${mutedTextColor}` }, "Your payment is secure and encrypted. Powered by Thirdweb on Varity L3.")));
154
+ const ProcessingStep = ({ message, txHash, theme, textColor, mutedTextColor }) => (React.createElement("div", { className: "text-center py-12" },
155
+ React.createElement("div", { className: "inline-flex items-center justify-center w-20 h-20 rounded-full bg-blue-500 text-white mb-6 animate-pulse" },
156
+ React.createElement(LoadingSpinner, null)),
157
+ React.createElement("h3", { className: `text-2xl font-bold mb-2 ${textColor}` }, message),
158
+ React.createElement("p", { className: mutedTextColor }, "Please wait while we process your transaction"),
159
+ txHash && (React.createElement("div", { className: "mt-6" },
160
+ React.createElement("p", { className: `text-sm ${mutedTextColor} mb-2` }, "Transaction Hash:"),
161
+ React.createElement("code", { className: `text-xs ${theme === 'dark' ? 'bg-gray-800 text-gray-300' : 'bg-gray-100 text-gray-700'} px-3 py-1 rounded` },
162
+ txHash.substring(0, 10),
163
+ "...",
164
+ txHash.substring(txHash.length - 10))))));
165
+ const SuccessStep = ({ plan, txHash, onClose, theme, textColor, mutedTextColor }) => (React.createElement("div", { className: "text-center py-12" },
166
+ React.createElement("div", { className: "inline-flex items-center justify-center w-20 h-20 rounded-full bg-green-500 text-white mb-6" },
167
+ React.createElement("svg", { className: "w-12 h-12", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24" },
168
+ React.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M5 13l4 4L19 7" }))),
169
+ React.createElement("h3", { className: `text-2xl font-bold mb-2 ${textColor}` }, "Payment Successful!"),
170
+ React.createElement("p", { className: mutedTextColor },
171
+ "You're now subscribed to the ",
172
+ plan.name,
173
+ " plan"),
174
+ txHash && (React.createElement("div", { className: "mt-6" },
175
+ React.createElement("p", { className: `text-sm ${mutedTextColor} mb-2` }, "Transaction Hash:"),
176
+ React.createElement("code", { className: `text-xs ${theme === 'dark' ? 'bg-gray-800 text-gray-300' : 'bg-gray-100 text-gray-700'} px-3 py-1 rounded` }, txHash))),
177
+ React.createElement("button", { onClick: onClose, className: "mt-8 px-8 py-3 bg-blue-600 hover:bg-blue-700 text-white font-semibold rounded-lg transition-colors" }, "Go to Dashboard")));
178
+ const ErrorStep = ({ error, onRetry, onClose, theme, textColor }) => (React.createElement("div", { className: "text-center py-12" },
179
+ React.createElement("div", { className: "inline-flex items-center justify-center w-20 h-20 rounded-full bg-red-500 text-white mb-6" },
180
+ React.createElement("svg", { className: "w-12 h-12", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24" },
181
+ React.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }))),
182
+ React.createElement("h3", { className: `text-2xl font-bold mb-2 ${textColor}` }, "Payment Failed"),
183
+ React.createElement("p", { className: "text-red-500 mb-8" }, error || 'An error occurred during payment'),
184
+ React.createElement("div", { className: "flex gap-4 justify-center" },
185
+ React.createElement("button", { onClick: onRetry, className: "px-6 py-3 bg-blue-600 hover:bg-blue-700 text-white font-semibold rounded-lg transition-colors" }, "Try Again"),
186
+ React.createElement("button", { onClick: onClose, className: `px-6 py-3 ${theme === 'dark' ? 'bg-gray-700 hover:bg-gray-600' : 'bg-gray-200 hover:bg-gray-300'} ${textColor} font-semibold rounded-lg transition-colors` }, "Cancel"))));
187
+ /**
188
+ * Loading Spinner Component
189
+ */
190
+ const LoadingSpinner = () => (React.createElement("svg", { className: "animate-spin h-6 w-6", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24" },
191
+ React.createElement("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
192
+ React.createElement("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })));
193
+ export default CheckoutModal;
194
+ //# sourceMappingURL=CheckoutModal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CheckoutModal.js","sourceRoot":"","sources":["../../../src/components/Payments/CheckoutModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAsB,MAAM,aAAa,CAAC;AACpF,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAkBtD,IAAK,YAOJ;AAPD,WAAK,YAAY;IACf,iCAAiB,CAAA;IACjB,mCAAmB,CAAA;IACnB,mCAAmB,CAAA;IACnB,yCAAyB,CAAA;IACzB,mCAAmB,CAAA;IACnB,+BAAe,CAAA;AACjB,CAAC,EAPI,YAAY,KAAZ,YAAY,QAOhB;AAED,MAAM,CAAC,MAAM,aAAa,GAAiC,CAAC,EAC1D,MAAM,EACN,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,gBAAgB,EAChB,SAAS,EACT,OAAO,EACP,KAAK,GAAG,MAAM,GACf,EAAE,EAAE;IACH,MAAM,CAAC,WAAW,EAAE,cA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,aAAa,CAAC"}
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { SubscriptionTier } from './types';
3
+ /**
4
+ * Subscription Widget Component
5
+ * Displays subscription plans with feature comparison
6
+ */
7
+ interface SubscriptionWidgetProps {
8
+ currentPlan?: SubscriptionTier;
9
+ onSelectPlan: (planId: string) => void;
10
+ theme?: 'light' | 'dark';
11
+ showAnnualToggle?: boolean;
12
+ className?: string;
13
+ isLoading?: boolean;
14
+ }
15
+ export declare const SubscriptionWidget: React.FC<SubscriptionWidgetProps>;
16
+ export default SubscriptionWidget;
17
+ //# sourceMappingURL=SubscriptionWidget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SubscriptionWidget.d.ts","sourceRoot":"","sources":["../../../src/components/Payments/SubscriptionWidget.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AACxC,OAAO,EAAoB,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAG7D;;;GAGG;AAEH,UAAU,uBAAuB;IAC/B,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CA6FhE,CAAC;AA6KF,eAAe,kBAAkB,CAAC"}
@@ -0,0 +1,89 @@
1
+ import React, { useState } from 'react';
2
+ import { SUBSCRIPTION_PLANS, formatUSDC } from './constants';
3
+ export const SubscriptionWidget = ({ currentPlan, onSelectPlan, theme = 'dark', showAnnualToggle = false, className = '', isLoading = false, }) => {
4
+ const [billingPeriod, setBillingPeriod] = useState('monthly');
5
+ const bgColor = theme === 'dark' ? 'bg-gray-900' : 'bg-white';
6
+ const textColor = theme === 'dark' ? 'text-white' : 'text-gray-900';
7
+ const mutedTextColor = theme === 'dark' ? 'text-gray-400' : 'text-gray-600';
8
+ const borderColor = theme === 'dark' ? 'border-gray-700' : 'border-gray-200';
9
+ const calculateAnnualPrice = (monthlyPrice) => {
10
+ // 20% discount for annual billing
11
+ return Math.floor(monthlyPrice * 12 * 0.8);
12
+ };
13
+ return (React.createElement("div", { className: `${className}` },
14
+ React.createElement("div", { className: "text-center mb-12" },
15
+ React.createElement("h2", { className: `text-4xl font-bold mb-4 ${textColor}` }, "Choose Your Plan"),
16
+ React.createElement("p", { className: `text-lg ${mutedTextColor}` }, "Select the perfect plan for your business needs")),
17
+ showAnnualToggle && (React.createElement("div", { className: "flex justify-center items-center gap-4 mb-8" },
18
+ React.createElement("button", { onClick: () => setBillingPeriod('monthly'), className: `px-4 py-2 rounded-lg font-semibold transition-colors ${billingPeriod === 'monthly'
19
+ ? 'bg-blue-600 text-white'
20
+ : theme === 'dark'
21
+ ? 'bg-gray-800 text-gray-400 hover:bg-gray-700'
22
+ : 'bg-gray-200 text-gray-600 hover:bg-gray-300'}` }, "Monthly"),
23
+ React.createElement("button", { onClick: () => setBillingPeriod('annual'), className: `px-4 py-2 rounded-lg font-semibold transition-colors relative ${billingPeriod === 'annual'
24
+ ? 'bg-blue-600 text-white'
25
+ : theme === 'dark'
26
+ ? 'bg-gray-800 text-gray-400 hover:bg-gray-700'
27
+ : 'bg-gray-200 text-gray-600 hover:bg-gray-300'}` },
28
+ "Annual",
29
+ React.createElement("span", { className: "absolute -top-2 -right-2 bg-green-500 text-white text-xs px-2 py-0.5 rounded-full" }, "Save 20%")))),
30
+ React.createElement("div", { className: "grid grid-cols-1 md:grid-cols-3 gap-8 max-w-7xl mx-auto" }, SUBSCRIPTION_PLANS.map((plan) => (React.createElement(PlanCard, { key: plan.id, plan: plan, isCurrentPlan: currentPlan === plan.tier, onSelect: () => onSelectPlan(plan.id), billingPeriod: billingPeriod, calculateAnnualPrice: calculateAnnualPrice, theme: theme, bgColor: bgColor, textColor: textColor, mutedTextColor: mutedTextColor, borderColor: borderColor, isLoading: isLoading })))),
31
+ React.createElement("div", { className: "text-center mt-12" },
32
+ React.createElement("button", { className: `${mutedTextColor} hover:text-blue-500 underline transition-colors` }, "View detailed feature comparison"))));
33
+ };
34
+ const PlanCard = ({ plan, isCurrentPlan, onSelect, billingPeriod, calculateAnnualPrice, theme, bgColor, textColor, mutedTextColor, borderColor, isLoading, }) => {
35
+ const displayPrice = billingPeriod === 'annual'
36
+ ? calculateAnnualPrice(plan.price)
37
+ : plan.price;
38
+ const pricePerMonth = billingPeriod === 'annual'
39
+ ? formatUSDC(displayPrice / 12)
40
+ : formatUSDC(displayPrice);
41
+ const totalPrice = formatUSDC(displayPrice);
42
+ const cardBg = plan.isRecommended
43
+ ? theme === 'dark'
44
+ ? 'bg-gradient-to-br from-blue-900 to-gray-900'
45
+ : 'bg-gradient-to-br from-blue-50 to-white'
46
+ : theme === 'dark'
47
+ ? 'bg-gray-800'
48
+ : 'bg-white';
49
+ const cardBorder = plan.isRecommended
50
+ ? 'border-blue-500'
51
+ : borderColor;
52
+ return (React.createElement("div", { className: `relative rounded-2xl border-2 ${cardBorder} ${cardBg} p-8 shadow-xl transition-transform hover:scale-105` },
53
+ plan.isRecommended && (React.createElement("div", { className: "absolute -top-4 left-1/2 transform -translate-x-1/2" },
54
+ React.createElement("span", { className: "bg-blue-500 text-white px-4 py-1 rounded-full text-sm font-semibold" }, "Recommended"))),
55
+ plan.isPopular && !plan.isRecommended && (React.createElement("div", { className: "absolute top-4 right-4" },
56
+ React.createElement("span", { className: "bg-green-500 text-white px-3 py-1 rounded-full text-xs font-semibold" }, "Popular"))),
57
+ React.createElement("h3", { className: `text-2xl font-bold mb-2 ${textColor}` }, plan.name),
58
+ React.createElement("p", { className: `mb-6 ${mutedTextColor}` }, plan.description),
59
+ React.createElement("div", { className: "mb-6" },
60
+ React.createElement("div", { className: "flex items-baseline gap-2" },
61
+ React.createElement("span", { className: `text-4xl font-bold ${textColor}` }, pricePerMonth),
62
+ React.createElement("span", { className: mutedTextColor }, "/month")),
63
+ billingPeriod === 'annual' && (React.createElement("p", { className: `text-sm mt-1 ${mutedTextColor}` },
64
+ totalPrice,
65
+ " billed annually"))),
66
+ React.createElement("button", { onClick: onSelect, disabled: isCurrentPlan || isLoading, className: `w-full py-3 rounded-lg font-semibold transition-colors mb-6 ${isCurrentPlan
67
+ ? theme === 'dark'
68
+ ? 'bg-gray-700 text-gray-400 cursor-not-allowed'
69
+ : 'bg-gray-200 text-gray-500 cursor-not-allowed'
70
+ : plan.isRecommended
71
+ ? 'bg-blue-600 hover:bg-blue-700 text-white'
72
+ : theme === 'dark'
73
+ ? 'bg-gray-700 hover:bg-gray-600 text-white'
74
+ : 'bg-gray-900 hover:bg-gray-800 text-white'}` }, isLoading ? (React.createElement("span", { className: "flex items-center justify-center gap-2" },
75
+ React.createElement(LoadingSpinner, null),
76
+ "Processing...")) : isCurrentPlan ? ('Current Plan') : ('Select Plan')),
77
+ React.createElement("div", { className: "space-y-3" }, plan.features.map((feature, index) => (React.createElement("div", { key: index, className: "flex items-start gap-3" },
78
+ React.createElement("svg", { className: `w-5 h-5 mt-0.5 flex-shrink-0 ${plan.isRecommended ? 'text-blue-500' : 'text-green-500'}`, fill: "none", stroke: "currentColor", viewBox: "0 0 24 24" },
79
+ React.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M5 13l4 4L19 7" })),
80
+ React.createElement("span", { className: `text-sm ${mutedTextColor}` }, feature)))))));
81
+ };
82
+ /**
83
+ * Loading Spinner Component
84
+ */
85
+ const LoadingSpinner = () => (React.createElement("svg", { className: "animate-spin h-5 w-5", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24" },
86
+ React.createElement("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
87
+ React.createElement("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })));
88
+ export default SubscriptionWidget;
89
+ //# sourceMappingURL=SubscriptionWidget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SubscriptionWidget.js","sourceRoot":"","sources":["../../../src/components/Payments/SubscriptionWidget.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAgB7D,MAAM,CAAC,MAAM,kBAAkB,GAAsC,CAAC,EACpE,WAAW,EACX,YAAY,EACZ,KAAK,GAAG,MAAM,EACd,gBAAgB,GAAG,KAAK,EACxB,SAAS,GAAG,EAAE,EACd,SAAS,GAAG,KAAK,GAClB,EAAE,EAAE;IACH,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAuB,SAAS,CAAC,CAAC;IAEpF,MAAM,OAAO,GAAG,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,UAAU,CAAC;IAC9D,MAAM,SAAS,GAAG,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,eAAe,CAAC;IACpE,MAAM,cAAc,GAAG,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,eAAe,CAAC;IAC5E,MAAM,WAAW,GAAG,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,iBAAiB,CAAC;IAE7E,MAAM,oBAAoB,GAAG,CAAC,YAAoB,EAAU,EAAE;QAC5D,kCAAkC;QAClC,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC;IAC7C,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AO,EAAE,KAAK,EAAE,EAAE,CAAC,CACrC,6BAAK,GAAG,EAAE,KAAK,EAAE,SAAS,EAAC,wBAAwB;YACjD,6BACE,SAAS,EAAE,gCACT,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,gBACzC,EAAE,EACF,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,cAAc,EACrB,OAAO,EAAC,WAAW;gBAEnB,8BAAM,aAAa,EAAC,OAAO,EAAC,cAAc,EAAC,OAAO,EAAC,WAAW,EAAE,CAAC,EAAE,CAAC,EAAC,gBAAgB,GAAG,CACpF;YACN,8BAAM,SAAS,EAAE,WAAW,cAAc,EAAE,IAAG,OAAO,CAAQ,CAC1D,CACP,CAAC,CACE,CACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,cAAc,GAAa,GAAG,EAAE,CAAC,CACrC,6BACE,SAAS,EAAC,sBAAsB,EAChC,KAAK,EAAC,4BAA4B,EAClC,IAAI,EAAC,MAAM,EACX,OAAO,EAAC,WAAW;IAEnB,gCACE,SAAS,EAAC,YAAY,EACtB,EAAE,EAAC,IAAI,EACP,EAAE,EAAC,IAAI,EACP,CAAC,EAAC,IAAI,EACN,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,GAAG,GACf;IACF,8BACE,SAAS,EAAC,YAAY,EACtB,IAAI,EAAC,cAAc,EACnB,CAAC,EAAC,iHAAiH,GACnH,CACE,CACP,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Payment Constants
3
+ * Subscription plans, pricing, and USDC configuration
4
+ */
5
+ import { SubscriptionPlan, SubscriptionTier } from './types';
6
+ /**
7
+ * Varity L3 Chain Configuration
8
+ */
9
+ export declare const VARITY_L3_CHAIN_ID = 33529;
10
+ export declare const USDC_CONTRACT_ADDRESS = "0x6Fd8ee6B4C2193e9E2e0E2EC5D295689B607c0cE";
11
+ export declare const USDC_DECIMALS = 6;
12
+ /**
13
+ * Subscription Plans
14
+ * Prices in USDC (with 6 decimals)
15
+ */
16
+ export declare const SUBSCRIPTION_PLANS: SubscriptionPlan[];
17
+ /**
18
+ * Get subscription plan by ID
19
+ */
20
+ export declare function getSubscriptionPlan(planId: string): SubscriptionPlan | undefined;
21
+ /**
22
+ * Get subscription plan by tier
23
+ */
24
+ export declare function getSubscriptionPlanByTier(tier: SubscriptionTier): SubscriptionPlan | undefined;
25
+ /**
26
+ * Format USDC amount for display
27
+ * Converts from 6 decimal representation to human-readable
28
+ */
29
+ export declare function formatUSDC(amount: number): string;
30
+ /**
31
+ * Convert human amount to USDC contract amount
32
+ * e.g., 99 -> 99_000000 (6 decimals)
33
+ */
34
+ export declare function toUSDCAmount(humanAmount: number): number;
35
+ /**
36
+ * Convert USDC contract amount to human amount
37
+ * e.g., 99_000000 -> 99
38
+ */
39
+ export declare function fromUSDCAmount(contractAmount: number): number;
40
+ /**
41
+ * Payment API Endpoints
42
+ */
43
+ export declare const PAYMENT_ENDPOINTS: {
44
+ CREATE_CHECKOUT: string;
45
+ GET_SUBSCRIPTION: string;
46
+ CANCEL_SUBSCRIPTION: string;
47
+ RESUME_SUBSCRIPTION: string;
48
+ UPGRADE_SUBSCRIPTION: string;
49
+ DOWNGRADE_SUBSCRIPTION: string;
50
+ GET_INVOICES: string;
51
+ GET_USAGE: string;
52
+ WEBHOOK: string;
53
+ };
54
+ /**
55
+ * Trial Period Configuration
56
+ */
57
+ export declare const TRIAL_PERIOD_DAYS = 14;
58
+ export declare const TRIAL_ENABLED = true;
59
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/components/Payments/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE7D;;GAEG;AACH,eAAO,MAAM,kBAAkB,QAAQ,CAAC;AACxC,eAAO,MAAM,qBAAqB,+CAA+C,CAAC;AAClF,eAAO,MAAM,aAAa,IAAI,CAAC;AAE/B;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,gBAAgB,EAyEhD,CAAC;AAEF;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAEhF;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,gBAAgB,GAAG,gBAAgB,GAAG,SAAS,CAE9F;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAKjD;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAExD;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;CAU7B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,aAAa,OAAO,CAAC"}