@varity-labs/ui-kit 2.0.0-beta.6 → 2.0.0-beta.8
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/README.md +14 -16
- package/dist/components/PaymentWidget/PaymentWidget.d.ts +7 -19
- package/dist/components/PaymentWidget/PaymentWidget.d.ts.map +1 -1
- package/dist/components/PaymentWidget/PaymentWidget.js +10 -176
- package/dist/components/PaymentWidget/PaymentWidget.js.map +1 -1
- package/dist/components/PaymentWidget/useSeamlessPayment.d.ts +8 -34
- package/dist/components/PaymentWidget/useSeamlessPayment.d.ts.map +1 -1
- package/dist/components/PaymentWidget/useSeamlessPayment.js +12 -158
- package/dist/components/PaymentWidget/useSeamlessPayment.js.map +1 -1
- package/dist/components/PaymentWidget/useVarityPayment.d.ts +5 -6
- package/dist/components/PaymentWidget/useVarityPayment.d.ts.map +1 -1
- package/dist/components/PaymentWidget/useVarityPayment.js +11 -147
- package/dist/components/PaymentWidget/useVarityPayment.js.map +1 -1
- package/dist/providers/PrivyStack.d.ts +14 -9
- package/dist/providers/PrivyStack.d.ts.map +1 -1
- package/dist/providers/PrivyStack.js +2 -4
- package/dist/providers/PrivyStack.js.map +1 -1
- package/dist/providers/VarityDashboardProvider.d.ts +2 -2
- package/dist/providers/VarityDashboardProvider.d.ts.map +1 -1
- package/dist/providers/VarityDashboardProvider.js +3 -26
- package/dist/providers/VarityDashboardProvider.js.map +1 -1
- package/dist/providers/WalletSyncProvider.d.ts +3 -7
- package/dist/providers/WalletSyncProvider.d.ts.map +1 -1
- package/dist/providers/WalletSyncProvider.js +6 -14
- package/dist/providers/WalletSyncProvider.js.map +1 -1
- package/package.json +5 -6
- package/dist/components/Analytics/__tests__/DataTable.test.d.ts +0 -2
- package/dist/components/Analytics/__tests__/DataTable.test.d.ts.map +0 -1
- package/dist/components/Analytics/__tests__/DataTable.test.js +0 -113
- package/dist/components/Analytics/__tests__/DataTable.test.js.map +0 -1
- package/dist/components/Dashboard/__tests__/EmptyState.test.d.ts +0 -2
- package/dist/components/Dashboard/__tests__/EmptyState.test.d.ts.map +0 -1
- package/dist/components/Dashboard/__tests__/EmptyState.test.js +0 -81
- package/dist/components/Dashboard/__tests__/EmptyState.test.js.map +0 -1
- package/dist/components/Dashboard/__tests__/KPICard.test.d.ts +0 -2
- package/dist/components/Dashboard/__tests__/KPICard.test.d.ts.map +0 -1
- package/dist/components/Dashboard/__tests__/KPICard.test.js +0 -78
- package/dist/components/Dashboard/__tests__/KPICard.test.js.map +0 -1
- package/dist/components/InAppWallet/EmailLoginButton.d.ts +0 -27
- package/dist/components/InAppWallet/EmailLoginButton.d.ts.map +0 -1
- package/dist/components/InAppWallet/EmailLoginButton.js +0 -84
- package/dist/components/InAppWallet/EmailLoginButton.js.map +0 -1
- package/dist/components/InAppWallet/InAppWalletProvider.d.ts +0 -54
- package/dist/components/InAppWallet/InAppWalletProvider.d.ts.map +0 -1
- package/dist/components/InAppWallet/InAppWalletProvider.js +0 -225
- package/dist/components/InAppWallet/InAppWalletProvider.js.map +0 -1
- package/dist/components/InAppWallet/OnboardingFlow.d.ts +0 -25
- package/dist/components/InAppWallet/OnboardingFlow.d.ts.map +0 -1
- package/dist/components/InAppWallet/OnboardingFlow.js +0 -159
- package/dist/components/InAppWallet/OnboardingFlow.js.map +0 -1
- package/dist/components/InAppWallet/SocialLoginButtons.d.ts +0 -28
- package/dist/components/InAppWallet/SocialLoginButtons.d.ts.map +0 -1
- package/dist/components/InAppWallet/SocialLoginButtons.js +0 -128
- package/dist/components/InAppWallet/SocialLoginButtons.js.map +0 -1
- package/dist/components/InAppWallet/index.d.ts +0 -15
- package/dist/components/InAppWallet/index.d.ts.map +0 -1
- package/dist/components/InAppWallet/index.js +0 -14
- package/dist/components/InAppWallet/index.js.map +0 -1
- package/dist/components/Payments/CheckoutModal.d.ts +0 -19
- package/dist/components/Payments/CheckoutModal.d.ts.map +0 -1
- package/dist/components/Payments/CheckoutModal.js +0 -194
- package/dist/components/Payments/CheckoutModal.js.map +0 -1
- package/dist/components/Payments/SubscriptionWidget.d.ts +0 -17
- package/dist/components/Payments/SubscriptionWidget.d.ts.map +0 -1
- package/dist/components/Payments/SubscriptionWidget.js +0 -89
- package/dist/components/Payments/SubscriptionWidget.js.map +0 -1
- package/dist/components/Payments/constants.d.ts +0 -59
- package/dist/components/Payments/constants.d.ts.map +0 -1
- package/dist/components/Payments/constants.js +0 -145
- package/dist/components/Payments/constants.js.map +0 -1
- package/dist/components/Payments/index.d.ts +0 -10
- package/dist/components/Payments/index.d.ts.map +0 -1
- package/dist/components/Payments/index.js +0 -12
- package/dist/components/Payments/index.js.map +0 -1
- package/dist/components/Payments/types.d.ts +0 -119
- package/dist/components/Payments/types.d.ts.map +0 -1
- package/dist/components/Payments/types.js +0 -27
- package/dist/components/Payments/types.js.map +0 -1
- package/dist/components/Payments/usePayments.d.ts +0 -33
- package/dist/components/Payments/usePayments.d.ts.map +0 -1
- package/dist/components/Payments/usePayments.js +0 -249
- package/dist/components/Payments/usePayments.js.map +0 -1
- package/dist/components/Privy/__tests__/InitScreens.test.d.ts +0 -2
- package/dist/components/Privy/__tests__/InitScreens.test.d.ts.map +0 -1
- package/dist/components/Privy/__tests__/InitScreens.test.js +0 -74
- package/dist/components/Privy/__tests__/InitScreens.test.js.map +0 -1
- package/dist/components/SIWE/AuthStatus.d.ts +0 -15
- package/dist/components/SIWE/AuthStatus.d.ts.map +0 -1
- package/dist/components/SIWE/AuthStatus.js +0 -47
- package/dist/components/SIWE/AuthStatus.js.map +0 -1
- package/dist/components/SIWE/ProtectedRoute.d.ts +0 -17
- package/dist/components/SIWE/ProtectedRoute.d.ts.map +0 -1
- package/dist/components/SIWE/ProtectedRoute.js +0 -52
- package/dist/components/SIWE/ProtectedRoute.js.map +0 -1
- package/dist/components/SIWE/SIWEButton.d.ts +0 -22
- package/dist/components/SIWE/SIWEButton.d.ts.map +0 -1
- package/dist/components/SIWE/SIWEButton.js +0 -106
- package/dist/components/SIWE/SIWEButton.js.map +0 -1
- package/dist/components/SIWE/SIWEModal.d.ts +0 -19
- package/dist/components/SIWE/SIWEModal.d.ts.map +0 -1
- package/dist/components/SIWE/SIWEModal.js +0 -75
- package/dist/components/SIWE/SIWEModal.js.map +0 -1
- package/dist/components/SIWE/SIWEProvider.d.ts +0 -38
- package/dist/components/SIWE/SIWEProvider.d.ts.map +0 -1
- package/dist/components/SIWE/SIWEProvider.js +0 -227
- package/dist/components/SIWE/SIWEProvider.js.map +0 -1
- package/dist/components/SIWE/index.d.ts +0 -15
- package/dist/components/SIWE/index.d.ts.map +0 -1
- package/dist/components/SIWE/index.js +0 -10
- package/dist/components/SIWE/index.js.map +0 -1
- package/dist/core/VarityClient.d.ts +0 -76
- package/dist/core/VarityClient.d.ts.map +0 -1
- package/dist/core/VarityClient.js +0 -99
- package/dist/core/VarityClient.js.map +0 -1
- package/dist/core/config.d.ts +0 -136
- package/dist/core/config.d.ts.map +0 -1
- package/dist/core/config.js +0 -156
- package/dist/core/config.js.map +0 -1
- package/dist/hooks/useAnalytics.d.ts +0 -94
- package/dist/hooks/useAnalytics.d.ts.map +0 -1
- package/dist/hooks/useAnalytics.js +0 -116
- package/dist/hooks/useAnalytics.js.map +0 -1
- package/dist/hooks/useAuth.d.ts +0 -71
- package/dist/hooks/useAuth.d.ts.map +0 -1
- package/dist/hooks/useAuth.js +0 -198
- package/dist/hooks/useAuth.js.map +0 -1
- package/dist/hooks/useDashboard.d.ts +0 -110
- package/dist/hooks/useDashboard.d.ts.map +0 -1
- package/dist/hooks/useDashboard.js +0 -201
- package/dist/hooks/useDashboard.js.map +0 -1
- package/dist/hooks/useVarityAPI.d.ts +0 -88
- package/dist/hooks/useVarityAPI.d.ts.map +0 -1
- package/dist/hooks/useVarityAPI.js +0 -138
- package/dist/hooks/useVarityAPI.js.map +0 -1
- package/dist/hooks/useWalletAuth.d.ts +0 -108
- package/dist/hooks/useWalletAuth.d.ts.map +0 -1
- package/dist/hooks/useWalletAuth.js +0 -415
- package/dist/hooks/useWalletAuth.js.map +0 -1
- package/dist/hooks/web3/index.d.ts +0 -5
- package/dist/hooks/web3/index.d.ts.map +0 -1
- package/dist/hooks/web3/index.js +0 -6
- package/dist/hooks/web3/index.js.map +0 -1
- package/dist/hooks/web3/useAddressValidation.d.ts +0 -37
- package/dist/hooks/web3/useAddressValidation.d.ts.map +0 -1
- package/dist/hooks/web3/useAddressValidation.js +0 -59
- package/dist/hooks/web3/useAddressValidation.js.map +0 -1
- package/dist/hooks/web3/useBlockExplorer.d.ts +0 -37
- package/dist/hooks/web3/useBlockExplorer.d.ts.map +0 -1
- package/dist/hooks/web3/useBlockExplorer.js +0 -59
- package/dist/hooks/web3/useBlockExplorer.js.map +0 -1
- package/dist/hooks/web3/useUSDCFormat.d.ts +0 -34
- package/dist/hooks/web3/useUSDCFormat.d.ts.map +0 -1
- package/dist/hooks/web3/useUSDCFormat.js +0 -43
- package/dist/hooks/web3/useUSDCFormat.js.map +0 -1
- package/dist/hooks/web3/useVarityWallet.d.ts +0 -48
- package/dist/hooks/web3/useVarityWallet.d.ts.map +0 -1
- package/dist/hooks/web3/useVarityWallet.js +0 -70
- package/dist/hooks/web3/useVarityWallet.js.map +0 -1
- package/dist/modules/cache/index.d.ts +0 -12
- package/dist/modules/cache/index.d.ts.map +0 -1
- package/dist/modules/cache/index.js +0 -13
- package/dist/modules/cache/index.js.map +0 -1
- package/dist/providers/ChainContext.d.ts +0 -65
- package/dist/providers/ChainContext.d.ts.map +0 -1
- package/dist/providers/ChainContext.js +0 -92
- package/dist/providers/ChainContext.js.map +0 -1
- package/dist/providers/VarityProvider.d.ts +0 -32
- package/dist/providers/VarityProvider.d.ts.map +0 -1
- package/dist/providers/VarityProvider.js +0 -56
- package/dist/providers/VarityProvider.js.map +0 -1
- package/dist/providers/WalletContext.d.ts +0 -68
- package/dist/providers/WalletContext.d.ts.map +0 -1
- package/dist/providers/WalletContext.js +0 -98
- package/dist/providers/WalletContext.js.map +0 -1
- package/dist/providers/index.d.ts +0 -48
- package/dist/providers/index.d.ts.map +0 -1
- package/dist/providers/index.js +0 -53
- package/dist/providers/index.js.map +0 -1
- package/dist/types/api-extensions.d.ts +0 -92
- package/dist/types/api-extensions.d.ts.map +0 -1
- package/dist/types/api-extensions.js +0 -7
- package/dist/types/api-extensions.js.map +0 -1
- package/dist/wallets/SimpleSmartWallet.d.ts +0 -68
- package/dist/wallets/SimpleSmartWallet.d.ts.map +0 -1
- package/dist/wallets/SimpleSmartWallet.js +0 -74
- package/dist/wallets/SimpleSmartWallet.js.map +0 -1
- package/dist/wallets/SmartWalletProvider.d.ts +0 -217
- package/dist/wallets/SmartWalletProvider.d.ts.map +0 -1
- package/dist/wallets/SmartWalletProvider.js +0 -366
- package/dist/wallets/SmartWalletProvider.js.map +0 -1
- package/dist/wallets/config.d.ts +0 -222
- package/dist/wallets/config.d.ts.map +0 -1
- package/dist/wallets/config.js +0 -206
- package/dist/wallets/config.js.map +0 -1
- package/dist/wallets/index.d.ts +0 -9
- package/dist/wallets/index.d.ts.map +0 -1
- package/dist/wallets/index.js +0 -9
- package/dist/wallets/index.js.map +0 -1
- package/dist/web3/AddressDisplay/AddressDisplay.d.ts +0 -33
- package/dist/web3/AddressDisplay/AddressDisplay.d.ts.map +0 -1
- package/dist/web3/AddressDisplay/AddressDisplay.js +0 -42
- package/dist/web3/AddressDisplay/AddressDisplay.js.map +0 -1
- package/dist/web3/AddressInput/AddressInput.d.ts +0 -36
- package/dist/web3/AddressInput/AddressInput.d.ts.map +0 -1
- package/dist/web3/AddressInput/AddressInput.js +0 -54
- package/dist/web3/AddressInput/AddressInput.js.map +0 -1
- package/dist/web3/AmountInput/AmountInput.d.ts +0 -41
- package/dist/web3/AmountInput/AmountInput.d.ts.map +0 -1
- package/dist/web3/AmountInput/AmountInput.js +0 -74
- package/dist/web3/AmountInput/AmountInput.js.map +0 -1
- package/dist/web3/BalanceDisplay/BalanceDisplay.d.ts +0 -30
- package/dist/web3/BalanceDisplay/BalanceDisplay.d.ts.map +0 -1
- package/dist/web3/BalanceDisplay/BalanceDisplay.js +0 -35
- package/dist/web3/BalanceDisplay/BalanceDisplay.js.map +0 -1
- package/dist/web3/BlockExplorerLink/BlockExplorerLink.d.ts +0 -41
- package/dist/web3/BlockExplorerLink/BlockExplorerLink.d.ts.map +0 -1
- package/dist/web3/BlockExplorerLink/BlockExplorerLink.js +0 -46
- package/dist/web3/BlockExplorerLink/BlockExplorerLink.js.map +0 -1
- package/dist/web3/ConnectWallet/ConnectWallet.d.ts +0 -35
- package/dist/web3/ConnectWallet/ConnectWallet.d.ts.map +0 -1
- package/dist/web3/ConnectWallet/ConnectWallet.js +0 -58
- package/dist/web3/ConnectWallet/ConnectWallet.js.map +0 -1
- package/dist/web3/DisconnectButton/DisconnectButton.d.ts +0 -30
- package/dist/web3/DisconnectButton/DisconnectButton.d.ts.map +0 -1
- package/dist/web3/DisconnectButton/DisconnectButton.js +0 -48
- package/dist/web3/DisconnectButton/DisconnectButton.js.map +0 -1
- package/dist/web3/WalletBalance/WalletBalance.d.ts +0 -27
- package/dist/web3/WalletBalance/WalletBalance.d.ts.map +0 -1
- package/dist/web3/WalletBalance/WalletBalance.js +0 -49
- package/dist/web3/WalletBalance/WalletBalance.js.map +0 -1
- package/dist/web3/WalletDropdown/WalletDropdown.d.ts +0 -29
- package/dist/web3/WalletDropdown/WalletDropdown.d.ts.map +0 -1
- package/dist/web3/WalletDropdown/WalletDropdown.js +0 -93
- package/dist/web3/WalletDropdown/WalletDropdown.js.map +0 -1
- package/dist/web3/WalletInfo/WalletInfo.d.ts +0 -31
- package/dist/web3/WalletInfo/WalletInfo.d.ts.map +0 -1
- package/dist/web3/WalletInfo/WalletInfo.js +0 -41
- package/dist/web3/WalletInfo/WalletInfo.js.map +0 -1
- package/dist/web3/index.d.ts +0 -11
- package/dist/web3/index.d.ts.map +0 -1
- package/dist/web3/index.js +0 -14
- package/dist/web3/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -16,13 +16,13 @@ Peer dependencies: `react` and `react-dom` 18+.
|
|
|
16
16
|
## Quick Start
|
|
17
17
|
|
|
18
18
|
```tsx
|
|
19
|
-
import {
|
|
19
|
+
import { AuthProvider } from '@varity-labs/ui-kit'
|
|
20
20
|
|
|
21
21
|
function App() {
|
|
22
22
|
return (
|
|
23
|
-
<
|
|
23
|
+
<AuthProvider>
|
|
24
24
|
<YourApp />
|
|
25
|
-
</
|
|
25
|
+
</AuthProvider>
|
|
26
26
|
)
|
|
27
27
|
}
|
|
28
28
|
```
|
|
@@ -110,14 +110,14 @@ Authentication, theming, and providers are all configured automatically with zer
|
|
|
110
110
|
Built-in authentication -- email, Google, and social login with zero configuration:
|
|
111
111
|
|
|
112
112
|
```tsx
|
|
113
|
-
import {
|
|
113
|
+
import { AuthProvider, LoginButton } from '@varity-labs/ui-kit'
|
|
114
114
|
import { useAuth } from '@varity-labs/ui-kit'
|
|
115
115
|
|
|
116
116
|
function App() {
|
|
117
117
|
return (
|
|
118
|
-
<
|
|
118
|
+
<AuthProvider>
|
|
119
119
|
<Dashboard />
|
|
120
|
-
</
|
|
120
|
+
</AuthProvider>
|
|
121
121
|
)
|
|
122
122
|
}
|
|
123
123
|
|
|
@@ -141,10 +141,10 @@ function Dashboard() {
|
|
|
141
141
|
|
|
142
142
|
| Component | Description |
|
|
143
143
|
|-----------|-------------|
|
|
144
|
-
| `
|
|
145
|
-
| `
|
|
146
|
-
| `
|
|
147
|
-
| `
|
|
144
|
+
| `LoginButton` | Drop-in login button |
|
|
145
|
+
| `UserProfile` | User profile display |
|
|
146
|
+
| `ProtectedRoute` | Route protection wrapper |
|
|
147
|
+
| `ReadyGate` | Loading gate during initialization |
|
|
148
148
|
|
|
149
149
|
### Auth Hooks
|
|
150
150
|
|
|
@@ -166,7 +166,7 @@ import { PaymentWidget, PaymentGate, useVarityPayment } from '@varity-labs/ui-ki
|
|
|
166
166
|
// Wrap a trigger element -- opens checkout on click
|
|
167
167
|
// appId is a number (from Varity App Registry)
|
|
168
168
|
// price is in cents (e.g., 9900 = $99.00)
|
|
169
|
-
<PaymentWidget appId={123} price={9900} onSuccess={(
|
|
169
|
+
<PaymentWidget appId={123} price={9900} onSuccess={(receipt) => console.log('Paid!', receipt)}>
|
|
170
170
|
<button>Buy Premium - $99</button>
|
|
171
171
|
</PaymentWidget>
|
|
172
172
|
|
|
@@ -219,7 +219,7 @@ import {
|
|
|
219
219
|
|
|
220
220
|
function App() {
|
|
221
221
|
return (
|
|
222
|
-
<
|
|
222
|
+
<AuthProvider>
|
|
223
223
|
<ToastProvider>
|
|
224
224
|
<DashboardLayout>
|
|
225
225
|
<DashboardSidebar items={sidebarItems} />
|
|
@@ -231,7 +231,7 @@ function App() {
|
|
|
231
231
|
</main>
|
|
232
232
|
</DashboardLayout>
|
|
233
233
|
</ToastProvider>
|
|
234
|
-
</
|
|
234
|
+
</AuthProvider>
|
|
235
235
|
)
|
|
236
236
|
}
|
|
237
237
|
```
|
|
@@ -240,9 +240,7 @@ function App() {
|
|
|
240
240
|
|
|
241
241
|
| Provider | Description |
|
|
242
242
|
|----------|-------------|
|
|
243
|
-
| `
|
|
244
|
-
| `VarityPrivyProvider` | Auth provider (lower-level) |
|
|
245
|
-
| `ZeroDevProvider` | Gas sponsorship provider (automatic in PrivyStack) |
|
|
243
|
+
| `AuthProvider` | All-in-one provider (auth + theme + query client) |
|
|
246
244
|
| `ThemeProvider` | Theme management |
|
|
247
245
|
| `ToastProvider` | Toast notifications |
|
|
248
246
|
| `VarityDashboardProvider` | Dashboard state management |
|
|
@@ -1,21 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* PaymentWidget Component
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* - 10% to Varity treasury
|
|
8
|
-
*
|
|
9
|
-
* Zero-crypto checkout: Users pay with credit card via thirdweb Pay.
|
|
10
|
-
* No wallets, no tokens, no blockchain terminology visible.
|
|
11
|
-
* The experience is identical to Stripe checkout.
|
|
12
|
-
*
|
|
13
|
-
* Flow:
|
|
14
|
-
* 1. User clicks purchase button
|
|
15
|
-
* 2. Credit card form appears (thirdweb Pay modal)
|
|
16
|
-
* 3. thirdweb converts USD → USDC on Arbitrum One
|
|
17
|
-
* 4. USDC approve + purchaseApp() execute automatically
|
|
18
|
-
* 5. User sees "Purchase complete" — never sees crypto
|
|
4
|
+
* Payments are coming soon. This component currently passes children through
|
|
5
|
+
* unchanged. Full payment processing (credit card checkout, 90/10 revenue
|
|
6
|
+
* split) will be enabled in a future release.
|
|
19
7
|
*
|
|
20
8
|
* @example
|
|
21
9
|
* ```tsx
|
|
@@ -29,11 +17,11 @@
|
|
|
29
17
|
import React from 'react';
|
|
30
18
|
import { PaymentWidgetProps } from './types';
|
|
31
19
|
/**
|
|
32
|
-
* PaymentWidget -
|
|
20
|
+
* PaymentWidget - Coming soon
|
|
33
21
|
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
22
|
+
* Renders children as-is until payment processing is enabled in a future
|
|
23
|
+
* release. Wrap your purchase button with this component so you can enable
|
|
24
|
+
* payments without any code changes when they launch.
|
|
37
25
|
*/
|
|
38
26
|
export declare const PaymentWidget: React.FC<PaymentWidgetProps>;
|
|
39
27
|
export default PaymentWidget;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PaymentWidget.d.ts","sourceRoot":"","sources":["../../../src/components/PaymentWidget/PaymentWidget.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"PaymentWidget.d.ts","sourceRoot":"","sources":["../../../src/components/PaymentWidget/PaymentWidget.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE7C;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAKtD,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1,21 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* PaymentWidget Component
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* - 10% to Varity treasury
|
|
8
|
-
*
|
|
9
|
-
* Zero-crypto checkout: Users pay with credit card via thirdweb Pay.
|
|
10
|
-
* No wallets, no tokens, no blockchain terminology visible.
|
|
11
|
-
* The experience is identical to Stripe checkout.
|
|
12
|
-
*
|
|
13
|
-
* Flow:
|
|
14
|
-
* 1. User clicks purchase button
|
|
15
|
-
* 2. Credit card form appears (thirdweb Pay modal)
|
|
16
|
-
* 3. thirdweb converts USD → USDC on Arbitrum One
|
|
17
|
-
* 4. USDC approve + purchaseApp() execute automatically
|
|
18
|
-
* 5. User sees "Purchase complete" — never sees crypto
|
|
4
|
+
* Payments are coming soon. This component currently passes children through
|
|
5
|
+
* unchanged. Full payment processing (credit card checkout, 90/10 revenue
|
|
6
|
+
* split) will be enabled in a future release.
|
|
19
7
|
*
|
|
20
8
|
* @example
|
|
21
9
|
* ```tsx
|
|
@@ -26,170 +14,16 @@
|
|
|
26
14
|
* </PaymentWidget>
|
|
27
15
|
* ```
|
|
28
16
|
*/
|
|
29
|
-
import React
|
|
30
|
-
import { TransactionButton, useActiveAccount } from 'thirdweb/react';
|
|
31
|
-
import { prepareContractCall, getContract, readContract, defineChain } from 'thirdweb';
|
|
32
|
-
import { approve } from 'thirdweb/extensions/erc20';
|
|
33
|
-
import { useVarityPayment } from './useVarityPayment';
|
|
34
|
-
/** Arbitrum One USDC contract address */
|
|
35
|
-
const USDC_ADDRESS = '0xaf88d065e77c8cC2239327C5EDb3A432268e5831';
|
|
36
|
-
/** Arbitrum One chain config for thirdweb */
|
|
37
|
-
const ARBITRUM_ONE = defineChain(42161);
|
|
38
|
-
/**
|
|
39
|
-
* Build the payModal config that hides all crypto complexity.
|
|
40
|
-
* Users see a clean credit card checkout — no wallets, tokens, or chains.
|
|
41
|
-
*
|
|
42
|
-
* The payModal auto-detects that the transaction needs USDC on Arbitrum One
|
|
43
|
-
* and shows the credit card on-ramp when the user has insufficient balance.
|
|
44
|
-
*/
|
|
45
|
-
function buildPayModalConfig(opts) {
|
|
46
|
-
return {
|
|
47
|
-
theme: opts.theme,
|
|
48
|
-
metadata: {
|
|
49
|
-
name: opts.title,
|
|
50
|
-
image: '/logo/varity-logo-color.svg',
|
|
51
|
-
},
|
|
52
|
-
// Credit card only — hide crypto swap/transfer options
|
|
53
|
-
buyWithCrypto: false,
|
|
54
|
-
// Prefer Stripe for the cleanest credit card experience
|
|
55
|
-
buyWithFiat: {
|
|
56
|
-
preferredProvider: 'stripe',
|
|
57
|
-
},
|
|
58
|
-
// Only show USDC on Arbitrum One, labeled as "USD" to hide crypto
|
|
59
|
-
supportedTokens: {
|
|
60
|
-
42161: [{
|
|
61
|
-
address: USDC_ADDRESS,
|
|
62
|
-
name: 'USD',
|
|
63
|
-
symbol: 'USD',
|
|
64
|
-
icon: 'https://assets.coingecko.com/coins/images/6319/standard/usdc.png',
|
|
65
|
-
}],
|
|
66
|
-
},
|
|
67
|
-
showThirdwebBranding: false,
|
|
68
|
-
};
|
|
69
|
-
}
|
|
17
|
+
import React from 'react';
|
|
70
18
|
/**
|
|
71
|
-
* PaymentWidget -
|
|
19
|
+
* PaymentWidget - Coming soon
|
|
72
20
|
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
21
|
+
* Renders children as-is until payment processing is enabled in a future
|
|
22
|
+
* release. Wrap your purchase button with this component so you can enable
|
|
23
|
+
* payments without any code changes when they launch.
|
|
76
24
|
*/
|
|
77
|
-
export const PaymentWidget = ({
|
|
78
|
-
|
|
79
|
-
const account = useActiveAccount();
|
|
80
|
-
const [isAuthorized, setIsAuthorized] = useState(false);
|
|
81
|
-
const [hasAllowance, setHasAllowance] = useState(null);
|
|
82
|
-
// Get payment contract address
|
|
83
|
-
const paymentsAddress = (typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_VARITY_PAYMENTS_ADDRESS
|
|
84
|
-
? process.env.NEXT_PUBLIC_VARITY_PAYMENTS_ADDRESS
|
|
85
|
-
: '0x0568cf3b5b9c94542aa8d32eb51ffa38912fc48c');
|
|
86
|
-
// Amount needed in raw USDC units
|
|
87
|
-
const amountNeeded = pricing?.priceUsdc
|
|
88
|
-
? pricing.priceUsdc
|
|
89
|
-
: price
|
|
90
|
-
? BigInt(price * 10000) // cents * 10000 = USDC units (6 decimals)
|
|
91
|
-
: BigInt(0);
|
|
92
|
-
// Check USDC allowance on mount — skip authorize step if sufficient
|
|
93
|
-
useEffect(() => {
|
|
94
|
-
if (!account?.address || amountNeeded === BigInt(0)) {
|
|
95
|
-
setHasAllowance(false);
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
const checkAllowance = async () => {
|
|
99
|
-
try {
|
|
100
|
-
const { createThirdwebClient } = await import('thirdweb');
|
|
101
|
-
const client = createThirdwebClient({
|
|
102
|
-
clientId: process.env.NEXT_PUBLIC_THIRDWEB_CLIENT_ID || '',
|
|
103
|
-
});
|
|
104
|
-
const usdcContract = getContract({ client, chain: ARBITRUM_ONE, address: USDC_ADDRESS });
|
|
105
|
-
const currentAllowance = await readContract({
|
|
106
|
-
contract: usdcContract,
|
|
107
|
-
method: 'function allowance(address owner, address spender) view returns (uint256)',
|
|
108
|
-
params: [account.address, paymentsAddress],
|
|
109
|
-
});
|
|
110
|
-
setHasAllowance(BigInt(currentAllowance.toString()) >= amountNeeded);
|
|
111
|
-
}
|
|
112
|
-
catch {
|
|
113
|
-
setHasAllowance(false);
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
checkAllowance();
|
|
117
|
-
}, [account?.address, amountNeeded, paymentsAddress]);
|
|
118
|
-
// Calculate price in USD for display and payModal
|
|
119
|
-
const priceUsd = pricing?.priceUsdc
|
|
120
|
-
? Number(pricing.priceUsdc) / 1_000_000
|
|
121
|
-
: price
|
|
122
|
-
? price / 100
|
|
123
|
-
: 0;
|
|
124
|
-
const displayPrice = priceUsd > 0 ? `$${priceUsd.toFixed(2)}` : null;
|
|
125
|
-
// Already purchased
|
|
126
|
-
if (hasPurchased && !isLoading) {
|
|
127
|
-
return (React.createElement("div", { className: `inline-flex items-center gap-2 text-green-500 ${className}` },
|
|
128
|
-
React.createElement("svg", { className: "w-5 h-5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24" },
|
|
129
|
-
React.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M5 13l4 4L19 7" })),
|
|
130
|
-
React.createElement("span", null, "Purchased")));
|
|
131
|
-
}
|
|
132
|
-
// Loading
|
|
133
|
-
if (isLoading) {
|
|
134
|
-
return React.createElement("div", { className: className }, children);
|
|
135
|
-
}
|
|
136
|
-
// No pricing set
|
|
137
|
-
if (!pricing?.isActive) {
|
|
138
|
-
return null;
|
|
139
|
-
}
|
|
140
|
-
// Helper to get thirdweb client
|
|
141
|
-
const getClient = async () => {
|
|
142
|
-
const { createThirdwebClient } = await import('thirdweb');
|
|
143
|
-
return createThirdwebClient({
|
|
144
|
-
clientId: process.env.NEXT_PUBLIC_THIRDWEB_CLIENT_ID || '',
|
|
145
|
-
});
|
|
146
|
-
};
|
|
147
|
-
const needsAuthorization = hasAllowance === false && !isAuthorized;
|
|
148
|
-
if (needsAuthorization) {
|
|
149
|
-
// Step 1: Authorize payment (sets USDC allowance)
|
|
150
|
-
// payModal handles credit card on-ramp if user has no USDC
|
|
151
|
-
return (React.createElement(TransactionButton, { transaction: async () => {
|
|
152
|
-
const client = await getClient();
|
|
153
|
-
const usdcContract = getContract({ client, chain: ARBITRUM_ONE, address: USDC_ADDRESS });
|
|
154
|
-
return approve({
|
|
155
|
-
contract: usdcContract,
|
|
156
|
-
spender: paymentsAddress,
|
|
157
|
-
amount: priceUsd,
|
|
158
|
-
});
|
|
159
|
-
}, onTransactionConfirmed: () => {
|
|
160
|
-
setIsAuthorized(true);
|
|
161
|
-
}, onError: (error) => {
|
|
162
|
-
onError?.(error);
|
|
163
|
-
}, payModal: buildPayModalConfig({
|
|
164
|
-
theme,
|
|
165
|
-
title: `Payment — ${displayPrice}`,
|
|
166
|
-
}), className: className, disabled: disabled }, children));
|
|
167
|
-
}
|
|
168
|
-
// Step 2 (or only step if allowance exists): Complete purchase
|
|
169
|
-
return (React.createElement(TransactionButton, { transaction: async () => {
|
|
170
|
-
const client = await getClient();
|
|
171
|
-
const contract = getContract({ client, chain: ARBITRUM_ONE, address: paymentsAddress });
|
|
172
|
-
return prepareContractCall({
|
|
173
|
-
contract,
|
|
174
|
-
method: {
|
|
175
|
-
name: 'purchaseApp',
|
|
176
|
-
type: 'function',
|
|
177
|
-
stateMutability: 'nonpayable',
|
|
178
|
-
inputs: [{ name: 'appId', type: 'uint64' }],
|
|
179
|
-
outputs: [],
|
|
180
|
-
},
|
|
181
|
-
params: [BigInt(appId)],
|
|
182
|
-
});
|
|
183
|
-
}, onTransactionConfirmed: (receipt) => {
|
|
184
|
-
onSuccess?.(receipt.transactionHash);
|
|
185
|
-
}, onError: (error) => {
|
|
186
|
-
onError?.(error);
|
|
187
|
-
}, payModal: buildPayModalConfig({
|
|
188
|
-
theme,
|
|
189
|
-
title: type === 'subscription'
|
|
190
|
-
? `Subscribe — ${displayPrice}/mo`
|
|
191
|
-
: `Purchase — ${displayPrice}`,
|
|
192
|
-
}), className: className, disabled: disabled }, children));
|
|
25
|
+
export const PaymentWidget = ({ children, className = '', }) => {
|
|
26
|
+
return React.createElement("span", { className: className || undefined }, children);
|
|
193
27
|
};
|
|
194
28
|
export default PaymentWidget;
|
|
195
29
|
//# sourceMappingURL=PaymentWidget.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PaymentWidget.js","sourceRoot":"","sources":["../../../src/components/PaymentWidget/PaymentWidget.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"PaymentWidget.js","sourceRoot":"","sources":["../../../src/components/PaymentWidget/PaymentWidget.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAiC,CAAC,EAC1D,QAAQ,EACR,SAAS,GAAG,EAAE,GACf,EAAE,EAAE;IACH,OAAO,8BAAM,SAAS,EAAE,SAAS,IAAI,SAAS,IAAG,QAAQ,CAAQ,CAAC;AACpE,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1,45 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* useSeamlessPayment
|
|
2
|
+
* useSeamlessPayment Hook
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* Flow:
|
|
8
|
-
* 1. Check USDC balance
|
|
9
|
-
* 2. If insufficient → Auto-trigger Privy on-ramp (Bridge/MoonPay/Coinbase modal)
|
|
10
|
-
* 3. Auto-approve USDC allowance if needed
|
|
11
|
-
* 4. Execute purchase (90/10 split)
|
|
12
|
-
*
|
|
13
|
-
* Integration with Bridge:
|
|
14
|
-
* - Once Bridge is configured in PrivyProvider's fundingMethodConfig
|
|
15
|
-
* - useFundWallet automatically uses Bridge (Stripe UX)
|
|
16
|
-
* - Falls back to MoonPay/Coinbase if Bridge unavailable
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```tsx
|
|
20
|
-
* const { seamlessPurchase } = useSeamlessPayment({ appId: 123 });
|
|
21
|
-
*
|
|
22
|
-
* <button onClick={() => seamlessPurchase()}>
|
|
23
|
-
* Pay $99
|
|
24
|
-
* </button>
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
/**
|
|
28
|
-
* Enhanced payment hook with seamless on-ramp integration
|
|
4
|
+
* Payments are coming soon. Returns safe defaults until payment processing
|
|
5
|
+
* is enabled in a future release.
|
|
29
6
|
*/
|
|
30
7
|
export declare function useSeamlessPayment({ appId }: {
|
|
31
8
|
appId: number;
|
|
32
9
|
}): {
|
|
33
10
|
seamlessPurchase: () => Promise<{
|
|
34
|
-
success:
|
|
35
|
-
|
|
36
|
-
error?: string;
|
|
37
|
-
needsApproval?: boolean;
|
|
38
|
-
needsFunding?: boolean;
|
|
11
|
+
success: false;
|
|
12
|
+
error: string;
|
|
39
13
|
}>;
|
|
40
|
-
onrampStatus: "idle"
|
|
41
|
-
checkBalance: (
|
|
42
|
-
checkAllowance: (
|
|
14
|
+
onrampStatus: "idle";
|
|
15
|
+
checkBalance: (_address: string) => Promise<bigint>;
|
|
16
|
+
checkAllowance: (_address: string) => Promise<bigint>;
|
|
43
17
|
hasPurchased: boolean;
|
|
44
18
|
isLoading: boolean;
|
|
45
19
|
isPurchasing: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSeamlessPayment.d.ts","sourceRoot":"","sources":["../../../src/components/PaymentWidget/useSeamlessPayment.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"useSeamlessPayment.d.ts","sourceRoot":"","sources":["../../../src/components/PaymentWidget/useSeamlessPayment.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,wBAAgB,kBAAkB,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE;;;;;;6BAU5B,MAAM,KAAG,OAAO,CAAC,MAAM,CAAC;+BACtB,MAAM,KAAG,OAAO,CAAC,MAAM,CAAC;;;;;;;;EAE5D"}
|
|
@@ -1,167 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* useSeamlessPayment
|
|
2
|
+
* useSeamlessPayment Hook
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* Flow:
|
|
8
|
-
* 1. Check USDC balance
|
|
9
|
-
* 2. If insufficient → Auto-trigger Privy on-ramp (Bridge/MoonPay/Coinbase modal)
|
|
10
|
-
* 3. Auto-approve USDC allowance if needed
|
|
11
|
-
* 4. Execute purchase (90/10 split)
|
|
12
|
-
*
|
|
13
|
-
* Integration with Bridge:
|
|
14
|
-
* - Once Bridge is configured in PrivyProvider's fundingMethodConfig
|
|
15
|
-
* - useFundWallet automatically uses Bridge (Stripe UX)
|
|
16
|
-
* - Falls back to MoonPay/Coinbase if Bridge unavailable
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```tsx
|
|
20
|
-
* const { seamlessPurchase } = useSeamlessPayment({ appId: 123 });
|
|
21
|
-
*
|
|
22
|
-
* <button onClick={() => seamlessPurchase()}>
|
|
23
|
-
* Pay $99
|
|
24
|
-
* </button>
|
|
25
|
-
* ```
|
|
4
|
+
* Payments are coming soon. Returns safe defaults until payment processing
|
|
5
|
+
* is enabled in a future release.
|
|
26
6
|
*/
|
|
27
|
-
import { useCallback, useState } from 'react';
|
|
28
|
-
import { useFundWallet } from '@privy-io/react-auth';
|
|
29
|
-
import { useActiveAccount } from 'thirdweb/react';
|
|
30
|
-
import { readContract, getContract } from 'thirdweb';
|
|
31
|
-
import { createThirdwebClient, defineChain } from 'thirdweb';
|
|
32
7
|
import { useVarityPayment } from './useVarityPayment';
|
|
33
|
-
import { THIRDWEB_CLIENT_ID } from '../../config/chains';
|
|
34
|
-
const USDC_ADDRESS = '0xaf88d065e77c8cC2239327C5EDb3A432268e5831'; // Arbitrum One USDC
|
|
35
|
-
const VARITY_PAYMENTS_ADDRESS = '0x0568cf3b5b9c94542aa8d32eb51ffa38912fc48c';
|
|
36
|
-
/**
|
|
37
|
-
* Enhanced payment hook with seamless on-ramp integration
|
|
38
|
-
*/
|
|
39
8
|
export function useSeamlessPayment({ appId }) {
|
|
40
|
-
const
|
|
41
|
-
const { fundWallet } = useFundWallet();
|
|
42
|
-
const account = useActiveAccount();
|
|
43
|
-
const [onrampStatus, setOnrampStatus] = useState('idle');
|
|
44
|
-
const client = createThirdwebClient({ clientId: THIRDWEB_CLIENT_ID });
|
|
45
|
-
/**
|
|
46
|
-
* Check USDC balance on Arbitrum One
|
|
47
|
-
*/
|
|
48
|
-
const checkBalance = useCallback(async (address) => {
|
|
49
|
-
const usdcContract = getContract({
|
|
50
|
-
client,
|
|
51
|
-
chain: defineChain(42161), // Arbitrum One
|
|
52
|
-
address: USDC_ADDRESS,
|
|
53
|
-
});
|
|
54
|
-
const balance = await readContract({
|
|
55
|
-
contract: usdcContract,
|
|
56
|
-
method: 'function balanceOf(address) view returns (uint256)',
|
|
57
|
-
params: [address],
|
|
58
|
-
});
|
|
59
|
-
return BigInt(balance.toString());
|
|
60
|
-
}, [client]);
|
|
61
|
-
/**
|
|
62
|
-
* Check USDC allowance for VarityPayments contract
|
|
63
|
-
*/
|
|
64
|
-
const checkAllowance = useCallback(async (address) => {
|
|
65
|
-
const usdcContract = getContract({
|
|
66
|
-
client,
|
|
67
|
-
chain: defineChain(42161), // Arbitrum One
|
|
68
|
-
address: USDC_ADDRESS,
|
|
69
|
-
});
|
|
70
|
-
const allowance = await readContract({
|
|
71
|
-
contract: usdcContract,
|
|
72
|
-
method: 'function allowance(address owner, address spender) view returns (uint256)',
|
|
73
|
-
params: [address, VARITY_PAYMENTS_ADDRESS],
|
|
74
|
-
});
|
|
75
|
-
return BigInt(allowance.toString());
|
|
76
|
-
}, [client]);
|
|
77
|
-
/**
|
|
78
|
-
* Seamless purchase flow - ONE CLICK handles everything
|
|
79
|
-
*
|
|
80
|
-
* Steps:
|
|
81
|
-
* 1. Check USDC balance
|
|
82
|
-
* 2. If insufficient → Open Bridge/MoonPay/Coinbase modal (via Privy)
|
|
83
|
-
* 3. Check USDC allowance
|
|
84
|
-
* 4. If insufficient → PaymentWidget's TransactionButton handles approval
|
|
85
|
-
* 5. Execute purchase
|
|
86
|
-
*
|
|
87
|
-
* User Experience:
|
|
88
|
-
* - Click "Pay $99"
|
|
89
|
-
* - If no USDC → Credit card modal opens (Bridge = Stripe UX)
|
|
90
|
-
* - Enter card details
|
|
91
|
-
* - "Processing..." (approval + purchase happen automatically)
|
|
92
|
-
* - "Payment successful!"
|
|
93
|
-
*
|
|
94
|
-
* User NEVER sees: USDC, blockchain, transactions, approvals
|
|
95
|
-
*/
|
|
96
|
-
const seamlessPurchase = useCallback(async () => {
|
|
97
|
-
if (!account?.address) {
|
|
98
|
-
return { success: false, error: 'Please connect your wallet first' };
|
|
99
|
-
}
|
|
100
|
-
if (!basePayment.pricing || !basePayment.pricing.isActive) {
|
|
101
|
-
return { success: false, error: 'This app is not available for purchase' };
|
|
102
|
-
}
|
|
103
|
-
if (basePayment.hasPurchased) {
|
|
104
|
-
return { success: false, error: 'You have already purchased this app' };
|
|
105
|
-
}
|
|
106
|
-
const needed = basePayment.pricing.priceUsdc;
|
|
107
|
-
try {
|
|
108
|
-
// Step 1: Check USDC balance
|
|
109
|
-
setOnrampStatus('checking');
|
|
110
|
-
const balance = await checkBalance(account.address);
|
|
111
|
-
console.log(`[SeamlessPayment] Balance: ${balance}, Needed: ${needed}`);
|
|
112
|
-
// Step 2: If insufficient balance, trigger on-ramp
|
|
113
|
-
if (balance < needed) {
|
|
114
|
-
const amountToFund = Number(needed - balance) / 1_000_000; // USDC has 6 decimals
|
|
115
|
-
const amountRounded = Math.ceil(amountToFund); // Round up to nearest dollar
|
|
116
|
-
console.log(`[SeamlessPayment] Insufficient USDC. Funding $${amountRounded}...`);
|
|
117
|
-
setOnrampStatus('funding');
|
|
118
|
-
// This opens Privy's funding modal
|
|
119
|
-
// If Bridge is configured → Bridge (Stripe) modal
|
|
120
|
-
// Otherwise → MoonPay/Coinbase modal
|
|
121
|
-
await fundWallet(account.address, {
|
|
122
|
-
chain: defineChain(42161), // Arbitrum One
|
|
123
|
-
asset: 'USDC',
|
|
124
|
-
amount: amountRounded.toString(),
|
|
125
|
-
});
|
|
126
|
-
console.log('[SeamlessPayment] Funding complete!');
|
|
127
|
-
// Return status so PaymentWidget can show "Please click again to complete purchase"
|
|
128
|
-
return {
|
|
129
|
-
success: false,
|
|
130
|
-
needsFunding: true,
|
|
131
|
-
error: 'Funding complete! Please click the purchase button again to complete your purchase.'
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
// Step 3: Check allowance
|
|
135
|
-
const allowance = await checkAllowance(account.address);
|
|
136
|
-
if (allowance < needed) {
|
|
137
|
-
// Let PaymentWidget's TransactionButton handle approval
|
|
138
|
-
console.log('[SeamlessPayment] Allowance insufficient, needs approval');
|
|
139
|
-
return { success: false, needsApproval: true };
|
|
140
|
-
}
|
|
141
|
-
// Step 4: Execute purchase (handled by basePayment.purchase)
|
|
142
|
-
setOnrampStatus('purchasing');
|
|
143
|
-
const txHash = await basePayment.purchase();
|
|
144
|
-
if (txHash) {
|
|
145
|
-
setOnrampStatus('idle');
|
|
146
|
-
return { success: true, txHash };
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
return { success: false, error: 'Purchase failed - no transaction hash' };
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
catch (error) {
|
|
153
|
-
console.error('[SeamlessPayment] Error:', error);
|
|
154
|
-
setOnrampStatus('idle');
|
|
155
|
-
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
156
|
-
return { success: false, error: errorMessage };
|
|
157
|
-
}
|
|
158
|
-
}, [account, basePayment, checkBalance, checkAllowance, fundWallet]);
|
|
9
|
+
const base = useVarityPayment({ appId });
|
|
159
10
|
return {
|
|
160
|
-
...
|
|
161
|
-
seamlessPurchase
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
11
|
+
...base,
|
|
12
|
+
seamlessPurchase: async () => ({
|
|
13
|
+
success: false,
|
|
14
|
+
error: 'Payments coming soon',
|
|
15
|
+
}),
|
|
16
|
+
onrampStatus: 'idle',
|
|
17
|
+
checkBalance: async (_address) => BigInt(0),
|
|
18
|
+
checkAllowance: async (_address) => BigInt(0),
|
|
165
19
|
};
|
|
166
20
|
}
|
|
167
21
|
//# sourceMappingURL=useSeamlessPayment.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSeamlessPayment.js","sourceRoot":"","sources":["../../../src/components/PaymentWidget/useSeamlessPayment.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"useSeamlessPayment.js","sourceRoot":"","sources":["../../../src/components/PaymentWidget/useSeamlessPayment.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,UAAU,kBAAkB,CAAC,EAAE,KAAK,EAAqB;IAC7D,MAAM,IAAI,GAAG,gBAAgB,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IAEzC,OAAO;QACL,GAAG,IAAI;QACP,gBAAgB,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;YAC7B,OAAO,EAAE,KAAc;YACvB,KAAK,EAAE,sBAAsB;SAC9B,CAAC;QACF,YAAY,EAAE,MAAe;QAC7B,YAAY,EAAE,KAAK,EAAE,QAAgB,EAAmB,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;QACpE,cAAc,EAAE,KAAK,EAAE,QAAgB,EAAmB,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;KACvE,CAAC;AACJ,CAAC"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* useVarityPayment Hook
|
|
3
|
-
*
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Hook for managing app purchase state
|
|
3
|
+
*
|
|
4
|
+
* Payments are coming soon. Returns safe defaults until payment processing
|
|
5
|
+
* is enabled in a future release.
|
|
8
6
|
*
|
|
9
7
|
* @example
|
|
10
8
|
* ```tsx
|
|
@@ -15,6 +13,7 @@ import { UseVarityPaymentReturn, UseVarityPaymentOptions } from './types';
|
|
|
15
13
|
* return <PremiumContent />;
|
|
16
14
|
* ```
|
|
17
15
|
*/
|
|
18
|
-
|
|
16
|
+
import type { UseVarityPaymentOptions, UseVarityPaymentReturn } from './types';
|
|
17
|
+
export declare function useVarityPayment(_options: UseVarityPaymentOptions): UseVarityPaymentReturn;
|
|
19
18
|
export default useVarityPayment;
|
|
20
19
|
//# sourceMappingURL=useVarityPayment.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useVarityPayment.d.ts","sourceRoot":"","sources":["../../../src/components/PaymentWidget/useVarityPayment.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"useVarityPayment.d.ts","sourceRoot":"","sources":["../../../src/components/PaymentWidget/useVarityPayment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAE/E,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,uBAAuB,GAChC,sBAAsB,CAUxB;AAED,eAAe,gBAAgB,CAAC"}
|