@varity-labs/ui-kit 2.0.0-alpha.1 → 2.0.0-beta.10
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 +1 -1
- package/README.md +227 -203
- package/dist/components/Analytics/DataTable.js +1 -1
- package/dist/components/Analytics/DataTable.js.map +1 -1
- package/dist/components/Analytics/EnhancedKPICard.d.ts +21 -0
- package/dist/components/Analytics/EnhancedKPICard.d.ts.map +1 -0
- package/dist/components/Analytics/EnhancedKPICard.js +135 -0
- package/dist/components/Analytics/EnhancedKPICard.js.map +1 -0
- package/dist/components/Analytics/Sparkline.d.ts +44 -0
- package/dist/components/Analytics/Sparkline.d.ts.map +1 -0
- package/dist/components/Analytics/Sparkline.js +90 -0
- package/dist/components/Analytics/Sparkline.js.map +1 -0
- package/dist/components/Analytics/index.d.ts +2 -0
- package/dist/components/Analytics/index.d.ts.map +1 -1
- package/dist/components/Analytics/index.js +2 -0
- package/dist/components/Analytics/index.js.map +1 -1
- package/dist/components/Dashboard/DashboardFooter.d.ts.map +1 -1
- package/dist/components/Dashboard/DashboardFooter.js +22 -6
- package/dist/components/Dashboard/DashboardFooter.js.map +1 -1
- package/dist/components/Dashboard/DashboardHeader.d.ts +10 -0
- package/dist/components/Dashboard/DashboardHeader.d.ts.map +1 -1
- package/dist/components/Dashboard/DashboardHeader.js +191 -58
- package/dist/components/Dashboard/DashboardHeader.js.map +1 -1
- package/dist/components/Dashboard/DashboardLayout.d.ts +13 -3
- package/dist/components/Dashboard/DashboardLayout.d.ts.map +1 -1
- package/dist/components/Dashboard/DashboardLayout.js +9 -4
- package/dist/components/Dashboard/DashboardLayout.js.map +1 -1
- package/dist/components/Dashboard/DashboardSidebar.d.ts.map +1 -1
- package/dist/components/Dashboard/DashboardSidebar.js +41 -12
- package/dist/components/Dashboard/DashboardSidebar.js.map +1 -1
- package/dist/components/Dashboard/EmptyState.js +5 -5
- package/dist/components/Dashboard/EmptyState.js.map +1 -1
- package/dist/components/Dashboard/KPICard.js +5 -5
- package/dist/components/Dashboard/KPICard.js.map +1 -1
- package/dist/components/Display/Avatar.d.ts +21 -0
- package/dist/components/Display/Avatar.d.ts.map +1 -0
- package/dist/components/Display/Avatar.js +71 -0
- package/dist/components/Display/Avatar.js.map +1 -0
- package/dist/components/Display/Badge.d.ts +22 -0
- package/dist/components/Display/Badge.d.ts.map +1 -0
- package/dist/components/Display/Badge.js +60 -0
- package/dist/components/Display/Badge.js.map +1 -0
- package/dist/components/Display/ProgressBar.d.ts +12 -0
- package/dist/components/Display/ProgressBar.d.ts.map +1 -0
- package/dist/components/Display/ProgressBar.js +33 -0
- package/dist/components/Display/ProgressBar.js.map +1 -0
- package/dist/components/Display/index.d.ts +9 -0
- package/dist/components/Display/index.d.ts.map +1 -0
- package/dist/components/Display/index.js +9 -0
- package/dist/components/Display/index.js.map +1 -0
- package/dist/components/Feedback/Skeleton.d.ts +10 -0
- package/dist/components/Feedback/Skeleton.d.ts.map +1 -0
- package/dist/components/Feedback/Skeleton.js +25 -0
- package/dist/components/Feedback/Skeleton.js.map +1 -0
- package/dist/components/Feedback/Toast.d.ts +18 -0
- package/dist/components/Feedback/Toast.d.ts.map +1 -0
- package/dist/components/Feedback/Toast.js +38 -0
- package/dist/components/Feedback/Toast.js.map +1 -0
- package/dist/components/Feedback/ToastProvider.d.ts +11 -0
- package/dist/components/Feedback/ToastProvider.d.ts.map +1 -0
- package/dist/components/Feedback/ToastProvider.js +36 -0
- package/dist/components/Feedback/ToastProvider.js.map +1 -0
- package/dist/components/Feedback/index.d.ts +11 -0
- package/dist/components/Feedback/index.d.ts.map +1 -0
- package/dist/components/Feedback/index.js +9 -0
- package/dist/components/Feedback/index.js.map +1 -0
- package/dist/components/Feedback/useToast.d.ts +3 -0
- package/dist/components/Feedback/useToast.d.ts.map +1 -0
- package/dist/components/Feedback/useToast.js +10 -0
- package/dist/components/Feedback/useToast.js.map +1 -0
- package/dist/components/Form/Button.d.ts +12 -0
- package/dist/components/Form/Button.d.ts.map +1 -0
- package/dist/components/Form/Button.js +22 -0
- package/dist/components/Form/Button.js.map +1 -0
- package/dist/components/Form/Checkbox.d.ts +13 -0
- package/dist/components/Form/Checkbox.d.ts.map +1 -0
- package/dist/components/Form/Checkbox.js +36 -0
- package/dist/components/Form/Checkbox.js.map +1 -0
- package/dist/components/Form/Input.d.ts +9 -0
- package/dist/components/Form/Input.d.ts.map +1 -0
- package/dist/components/Form/Input.js +16 -0
- package/dist/components/Form/Input.js.map +1 -0
- package/dist/components/Form/RadioGroup.d.ts +20 -0
- package/dist/components/Form/RadioGroup.d.ts.map +1 -0
- package/dist/components/Form/RadioGroup.js +43 -0
- package/dist/components/Form/RadioGroup.js.map +1 -0
- package/dist/components/Form/Select.d.ts +12 -0
- package/dist/components/Form/Select.d.ts.map +1 -0
- package/dist/components/Form/Select.js +13 -0
- package/dist/components/Form/Select.js.map +1 -0
- package/dist/components/Form/Textarea.d.ts +8 -0
- package/dist/components/Form/Textarea.d.ts.map +1 -0
- package/dist/components/Form/Textarea.js +13 -0
- package/dist/components/Form/Textarea.js.map +1 -0
- package/dist/components/Form/Toggle.d.ts +12 -0
- package/dist/components/Form/Toggle.d.ts.map +1 -0
- package/dist/components/Form/Toggle.js +48 -0
- package/dist/components/Form/Toggle.js.map +1 -0
- package/dist/components/Form/index.d.ts +13 -0
- package/dist/components/Form/index.d.ts.map +1 -0
- package/dist/components/Form/index.js +13 -0
- package/dist/components/Form/index.js.map +1 -0
- package/dist/components/InAppWallet/InAppWalletProvider.d.ts +4 -4
- package/dist/components/InAppWallet/InAppWalletProvider.d.ts.map +1 -1
- package/dist/components/InAppWallet/InAppWalletProvider.js +15 -28
- package/dist/components/InAppWallet/InAppWalletProvider.js.map +1 -1
- package/dist/components/Navigation/Breadcrumb.d.ts +15 -0
- package/dist/components/Navigation/Breadcrumb.d.ts.map +1 -0
- package/dist/components/Navigation/Breadcrumb.js +28 -0
- package/dist/components/Navigation/Breadcrumb.js.map +1 -0
- package/dist/components/Navigation/CommandPalette.d.ts +26 -0
- package/dist/components/Navigation/CommandPalette.d.ts.map +1 -0
- package/dist/components/Navigation/CommandPalette.js +172 -0
- package/dist/components/Navigation/CommandPalette.js.map +1 -0
- package/dist/components/Navigation/index.d.ts +8 -0
- package/dist/components/Navigation/index.d.ts.map +1 -0
- package/dist/components/Navigation/index.js +8 -0
- package/dist/components/Navigation/index.js.map +1 -0
- package/dist/components/Onramp/BuyUSDCButton.d.ts +9 -7
- package/dist/components/Onramp/BuyUSDCButton.d.ts.map +1 -1
- package/dist/components/Onramp/BuyUSDCButton.js +37 -47
- package/dist/components/Onramp/BuyUSDCButton.js.map +1 -1
- package/dist/components/Onramp/OnrampWidget.d.ts +7 -6
- package/dist/components/Onramp/OnrampWidget.d.ts.map +1 -1
- package/dist/components/Onramp/OnrampWidget.js +58 -37
- package/dist/components/Onramp/OnrampWidget.js.map +1 -1
- package/dist/components/Onramp/index.d.ts +3 -5
- package/dist/components/Onramp/index.d.ts.map +1 -1
- package/dist/components/Onramp/index.js +3 -5
- package/dist/components/Onramp/index.js.map +1 -1
- package/dist/components/Overlay/ConfirmDialog.d.ts +14 -0
- package/dist/components/Overlay/ConfirmDialog.d.ts.map +1 -0
- package/dist/components/Overlay/ConfirmDialog.js +11 -0
- package/dist/components/Overlay/ConfirmDialog.js.map +1 -0
- package/dist/components/Overlay/Dialog.d.ts +11 -0
- package/dist/components/Overlay/Dialog.d.ts.map +1 -0
- package/dist/components/Overlay/Dialog.js +69 -0
- package/dist/components/Overlay/Dialog.js.map +1 -0
- package/dist/components/Overlay/DropdownMenu.d.ts +17 -0
- package/dist/components/Overlay/DropdownMenu.d.ts.map +1 -0
- package/dist/components/Overlay/DropdownMenu.js +123 -0
- package/dist/components/Overlay/DropdownMenu.js.map +1 -0
- package/dist/components/Overlay/index.d.ts +9 -0
- package/dist/components/Overlay/index.d.ts.map +1 -0
- package/dist/components/Overlay/index.js +9 -0
- package/dist/components/Overlay/index.js.map +1 -0
- package/dist/components/PaymentWidget/PaymentGate.d.ts +30 -0
- package/dist/components/PaymentWidget/PaymentGate.d.ts.map +1 -0
- package/dist/components/PaymentWidget/PaymentGate.js +54 -0
- package/dist/components/PaymentWidget/PaymentGate.js.map +1 -0
- package/dist/components/PaymentWidget/PaymentWidget.d.ts +40 -0
- package/dist/components/PaymentWidget/PaymentWidget.d.ts.map +1 -0
- package/dist/components/PaymentWidget/PaymentWidget.js +195 -0
- package/dist/components/PaymentWidget/PaymentWidget.js.map +1 -0
- package/dist/components/PaymentWidget/index.d.ts +30 -0
- package/dist/components/PaymentWidget/index.d.ts.map +1 -0
- package/dist/components/PaymentWidget/index.js +32 -0
- package/dist/components/PaymentWidget/index.js.map +1 -0
- package/dist/components/PaymentWidget/types.d.ts +200 -0
- package/dist/components/PaymentWidget/types.d.ts.map +1 -0
- package/dist/components/PaymentWidget/types.js +84 -0
- package/dist/components/PaymentWidget/types.js.map +1 -0
- package/dist/components/PaymentWidget/useSeamlessPayment.d.ts +51 -0
- package/dist/components/PaymentWidget/useSeamlessPayment.d.ts.map +1 -0
- package/dist/components/PaymentWidget/useSeamlessPayment.js +167 -0
- package/dist/components/PaymentWidget/useSeamlessPayment.js.map +1 -0
- package/dist/components/PaymentWidget/useVarityPayment.d.ts +20 -0
- package/dist/components/PaymentWidget/useVarityPayment.d.ts.map +1 -0
- package/dist/components/PaymentWidget/useVarityPayment.js +164 -0
- package/dist/components/PaymentWidget/useVarityPayment.js.map +1 -0
- package/dist/components/Payments/CheckoutModal.d.ts.map +1 -1
- package/dist/components/Payments/CheckoutModal.js +16 -5
- package/dist/components/Payments/CheckoutModal.js.map +1 -1
- package/dist/components/Payments/constants.js +1 -1
- package/dist/components/Payments/constants.js.map +1 -1
- package/dist/components/Privy/InitTimeoutScreen.d.ts.map +1 -1
- package/dist/components/Privy/InitTimeoutScreen.js +1 -1
- package/dist/components/Privy/InitTimeoutScreen.js.map +1 -1
- package/dist/components/Privy/InitializingScreen.d.ts +3 -3
- package/dist/components/Privy/InitializingScreen.d.ts.map +1 -1
- package/dist/components/Privy/InitializingScreen.js +6 -6
- package/dist/components/Privy/InitializingScreen.js.map +1 -1
- package/dist/components/index.d.ts +5 -2
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +20 -4
- package/dist/components/index.js.map +1 -1
- package/dist/config/chains.d.ts +5 -5
- package/dist/config/chains.d.ts.map +1 -1
- package/dist/config/chains.js +8 -8
- package/dist/config/chains.js.map +1 -1
- package/dist/hooks/index.d.ts +1 -11
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +54 -11
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.d.ts +24 -42
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +180 -43
- package/dist/index.js.map +1 -1
- package/dist/providers/PrivyProvider.js +1 -1
- package/dist/providers/PrivyProvider.js.map +1 -1
- package/dist/providers/PrivyStack.d.ts +31 -73
- package/dist/providers/PrivyStack.d.ts.map +1 -1
- package/dist/providers/PrivyStack.js +32 -160
- package/dist/providers/PrivyStack.js.map +1 -1
- package/dist/providers/VarityDashboardProvider.d.ts +7 -10
- package/dist/providers/VarityDashboardProvider.d.ts.map +1 -1
- package/dist/providers/VarityDashboardProvider.js +12 -15
- package/dist/providers/VarityDashboardProvider.js.map +1 -1
- package/dist/providers/WalletSyncProvider.d.ts +17 -24
- package/dist/providers/WalletSyncProvider.d.ts.map +1 -1
- package/dist/providers/WalletSyncProvider.js +16 -27
- package/dist/providers/WalletSyncProvider.js.map +1 -1
- package/dist/providers/ZeroDevProvider.d.ts +69 -0
- package/dist/providers/ZeroDevProvider.d.ts.map +1 -0
- package/dist/providers/ZeroDevProvider.js +208 -0
- package/dist/providers/ZeroDevProvider.js.map +1 -0
- package/dist/providers/index.d.ts +1 -0
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +2 -0
- package/dist/providers/index.js.map +1 -1
- package/dist/wallets/SimpleSmartWallet.js +1 -1
- package/dist/wallets/SimpleSmartWallet.js.map +1 -1
- package/dist/wallets/SmartWalletProvider.js +1 -1
- package/dist/wallets/SmartWalletProvider.js.map +1 -1
- package/dist/wallets/config.d.ts +31 -8
- package/dist/wallets/config.d.ts.map +1 -1
- package/dist/wallets/config.js +33 -10
- package/dist/wallets/config.js.map +1 -1
- package/dist/wallets/index.d.ts +1 -1
- package/dist/wallets/index.d.ts.map +1 -1
- package/dist/wallets/index.js +1 -1
- package/dist/wallets/index.js.map +1 -1
- package/package.json +34 -26
- 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/modules/cache/index.d.ts +0 -2
- package/dist/modules/cache/index.d.ts.map +0 -1
- package/dist/modules/cache/index.js +0 -2
- package/dist/modules/cache/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
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PaymentWidget Component
|
|
3
|
+
*
|
|
4
|
+
* REQUIRED in every Varity app that charges users.
|
|
5
|
+
* All payments go through the VarityPayments contract with 90/10 revenue split:
|
|
6
|
+
* - 90% to developer
|
|
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
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* import { PaymentWidget } from '@varity-labs/ui-kit';
|
|
23
|
+
*
|
|
24
|
+
* <PaymentWidget appId={123} price={9900}>
|
|
25
|
+
* <button>Buy Premium - $99</button>
|
|
26
|
+
* </PaymentWidget>
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
import React, { useState, useEffect } from '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
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* PaymentWidget - Required component for app monetization
|
|
72
|
+
*
|
|
73
|
+
* Wraps a trigger element and handles the full purchase flow.
|
|
74
|
+
* Automatically checks USDC allowance — skips authorize step if sufficient.
|
|
75
|
+
* Credit card payments handled seamlessly via thirdweb Pay.
|
|
76
|
+
*/
|
|
77
|
+
export const PaymentWidget = ({ appId, price, type = 'one-time', intervalDays = 30, onSuccess, onCancel, onError, theme = 'dark', className = '', children, disabled = false, }) => {
|
|
78
|
+
const { hasPurchased, isLoading, pricing, } = useVarityPayment({ appId });
|
|
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));
|
|
193
|
+
};
|
|
194
|
+
export default PaymentWidget;
|
|
195
|
+
//# sourceMappingURL=PaymentWidget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PaymentWidget.js","sourceRoot":"","sources":["../../../src/components/PaymentWidget/PaymentWidget.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvF,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,yCAAyC;AACzC,MAAM,YAAY,GAAG,4CAA4C,CAAC;AAElE,6CAA6C;AAC7C,MAAM,YAAY,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;AAExC;;;;;;GAMG;AACH,SAAS,mBAAmB,CAAC,IAG5B;IACC,OAAO;QACL,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,QAAQ,EAAE;YACR,IAAI,EAAE,IAAI,CAAC,KAAK;YAChB,KAAK,EAAE,6BAA6B;SACrC;QACD,uDAAuD;QACvD,aAAa,EAAE,KAAc;QAC7B,wDAAwD;QACxD,WAAW,EAAE;YACX,iBAAiB,EAAE,QAAiB;SACrC;QACD,kEAAkE;QAClE,eAAe,EAAE;YACf,KAAK,EAAE,CAAC;oBACN,OAAO,EAAE,YAAY;oBACrB,IAAI,EAAE,KAAK;oBACX,MAAM,EAAE,KAAK;oBACb,IAAI,EAAE,kEAAkE;iBACzE,CAAC;SACH;QACD,oBAAoB,EAAE,KAAK;KAC5B,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAiC,CAAC,EAC1D,KAAK,EACL,KAAK,EACL,IAAI,GAAG,UAAU,EACjB,YAAY,GAAG,E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YAAY,EAAE;SACjC,CAAC,EACF,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,IAEjB,QAAQ,CACS,CACrB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PaymentWidget Components
|
|
3
|
+
*
|
|
4
|
+
* Mandatory components for developer apps to charge end-users.
|
|
5
|
+
* All payments go through the VarityPayments contract with 90/10 revenue split.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* import { PaymentWidget, PaymentGate, useVarityPayment } from '@varity/ui-kit';
|
|
10
|
+
*
|
|
11
|
+
* // Simple button wrapper
|
|
12
|
+
* <PaymentWidget appId={123} price={9900}>
|
|
13
|
+
* <button>Buy Premium</button>
|
|
14
|
+
* </PaymentWidget>
|
|
15
|
+
*
|
|
16
|
+
* // Paywall for content
|
|
17
|
+
* <PaymentGate appId={123} fallback={<LockedUI />}>
|
|
18
|
+
* <PremiumContent />
|
|
19
|
+
* </PaymentGate>
|
|
20
|
+
*
|
|
21
|
+
* // Custom implementation with hook
|
|
22
|
+
* const { hasPurchased, purchase } = useVarityPayment({ appId: 123 });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export { PaymentWidget } from './PaymentWidget';
|
|
26
|
+
export { PaymentGate } from './PaymentGate';
|
|
27
|
+
export { useVarityPayment } from './useVarityPayment';
|
|
28
|
+
export type { PaymentWidgetProps, PaymentGateProps, UseVarityPaymentReturn, UseVarityPaymentOptions, AppPricing, PaymentType, } from './types';
|
|
29
|
+
export { VARITY_PAYMENTS_ADDRESS, VARITY_TREASURY_ADDRESS, PLATFORM_FEE_BPS, VARITY_PAYMENTS_ABI, } from './types';
|
|
30
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/PaymentWidget/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD,YAAY,EACV,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,EACtB,uBAAuB,EACvB,UAAU,EACV,WAAW,GACZ,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,uBAAuB,EACvB,uBAAuB,EACvB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PaymentWidget Components
|
|
3
|
+
*
|
|
4
|
+
* Mandatory components for developer apps to charge end-users.
|
|
5
|
+
* All payments go through the VarityPayments contract with 90/10 revenue split.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* import { PaymentWidget, PaymentGate, useVarityPayment } from '@varity/ui-kit';
|
|
10
|
+
*
|
|
11
|
+
* // Simple button wrapper
|
|
12
|
+
* <PaymentWidget appId={123} price={9900}>
|
|
13
|
+
* <button>Buy Premium</button>
|
|
14
|
+
* </PaymentWidget>
|
|
15
|
+
*
|
|
16
|
+
* // Paywall for content
|
|
17
|
+
* <PaymentGate appId={123} fallback={<LockedUI />}>
|
|
18
|
+
* <PremiumContent />
|
|
19
|
+
* </PaymentGate>
|
|
20
|
+
*
|
|
21
|
+
* // Custom implementation with hook
|
|
22
|
+
* const { hasPurchased, purchase } = useVarityPayment({ appId: 123 });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
// Components
|
|
26
|
+
export { PaymentWidget } from './PaymentWidget';
|
|
27
|
+
export { PaymentGate } from './PaymentGate';
|
|
28
|
+
// Hooks
|
|
29
|
+
export { useVarityPayment } from './useVarityPayment';
|
|
30
|
+
// Constants
|
|
31
|
+
export { VARITY_PAYMENTS_ADDRESS, VARITY_TREASURY_ADDRESS, PLATFORM_FEE_BPS, VARITY_PAYMENTS_ABI, } from './types';
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/PaymentWidget/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,aAAa;AACb,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,QAAQ;AACR,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAYtD,YAAY;AACZ,OAAO,EACL,uBAAuB,EACvB,uBAAuB,EACvB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PaymentWidget Types
|
|
3
|
+
* For developer apps to charge end-users with 90/10 revenue split
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Payment type for app purchases
|
|
7
|
+
*/
|
|
8
|
+
export type PaymentType = 'one-time' | 'subscription';
|
|
9
|
+
/**
|
|
10
|
+
* App pricing information from VarityPayments contract
|
|
11
|
+
*/
|
|
12
|
+
export interface AppPricing {
|
|
13
|
+
/** Price in USDC (6 decimals, e.g., 99_000000 = $99) */
|
|
14
|
+
priceUsdc: bigint;
|
|
15
|
+
/** Developer wallet address */
|
|
16
|
+
developer: string;
|
|
17
|
+
/** Whether this is a subscription */
|
|
18
|
+
isSubscription: boolean;
|
|
19
|
+
/** Billing interval in days (for subscriptions) */
|
|
20
|
+
intervalDays: number;
|
|
21
|
+
/** Whether pricing is active */
|
|
22
|
+
isActive: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* PaymentWidget component props
|
|
26
|
+
*/
|
|
27
|
+
export interface PaymentWidgetProps {
|
|
28
|
+
/** App ID from Varity App Registry (required) */
|
|
29
|
+
appId: number;
|
|
30
|
+
/**
|
|
31
|
+
* Price in cents for display (e.g., 9900 = $99.00)
|
|
32
|
+
* If not provided, will fetch from contract
|
|
33
|
+
*/
|
|
34
|
+
price?: number;
|
|
35
|
+
/** Payment type: one-time or subscription */
|
|
36
|
+
type?: PaymentType;
|
|
37
|
+
/** Billing interval in days (for subscriptions, default: 30) */
|
|
38
|
+
intervalDays?: number;
|
|
39
|
+
/** Callback after successful payment */
|
|
40
|
+
onSuccess?: (txHash: string) => void;
|
|
41
|
+
/** Callback when payment is cancelled */
|
|
42
|
+
onCancel?: () => void;
|
|
43
|
+
/** Callback on payment error */
|
|
44
|
+
onError?: (error: Error) => void;
|
|
45
|
+
/** Theme variant */
|
|
46
|
+
theme?: 'light' | 'dark';
|
|
47
|
+
/** Custom class name */
|
|
48
|
+
className?: string;
|
|
49
|
+
/** Trigger element (button, link, etc.) */
|
|
50
|
+
children: React.ReactNode;
|
|
51
|
+
/** Disable the widget */
|
|
52
|
+
disabled?: boolean;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* PaymentGate component props
|
|
56
|
+
*/
|
|
57
|
+
export interface PaymentGateProps {
|
|
58
|
+
/** App ID from Varity App Registry */
|
|
59
|
+
appId: number;
|
|
60
|
+
/** Price in cents for the unlock button */
|
|
61
|
+
price?: number;
|
|
62
|
+
/** Content to show when not purchased (paywall) */
|
|
63
|
+
fallback: React.ReactNode;
|
|
64
|
+
/** Premium content to show when purchased */
|
|
65
|
+
children: React.ReactNode;
|
|
66
|
+
/** Theme variant */
|
|
67
|
+
theme?: 'light' | 'dark';
|
|
68
|
+
/** Custom class name */
|
|
69
|
+
className?: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* useVarityPayment hook return type
|
|
73
|
+
*/
|
|
74
|
+
export interface UseVarityPaymentReturn {
|
|
75
|
+
/** Whether the current user has purchased this app */
|
|
76
|
+
hasPurchased: boolean;
|
|
77
|
+
/** Loading state for purchase check */
|
|
78
|
+
isLoading: boolean;
|
|
79
|
+
/** Whether a purchase is in progress */
|
|
80
|
+
isPurchasing: boolean;
|
|
81
|
+
/** Error message if any */
|
|
82
|
+
error: string | null;
|
|
83
|
+
/** App pricing information */
|
|
84
|
+
pricing: AppPricing | null;
|
|
85
|
+
/** Trigger a purchase */
|
|
86
|
+
purchase: () => Promise<string | null>;
|
|
87
|
+
/** Refresh purchase status */
|
|
88
|
+
refresh: () => Promise<void>;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* useVarityPayment hook options
|
|
92
|
+
*/
|
|
93
|
+
export interface UseVarityPaymentOptions {
|
|
94
|
+
/** App ID to check purchase status for */
|
|
95
|
+
appId: number;
|
|
96
|
+
/** Auto-fetch pricing on mount */
|
|
97
|
+
autoFetch?: boolean;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* VarityPayments contract address on Arbitrum One (mainnet)
|
|
101
|
+
* Set NEXT_PUBLIC_VARITY_PAYMENTS_ADDRESS env var after deploying to Arb One.
|
|
102
|
+
*/
|
|
103
|
+
export declare const VARITY_PAYMENTS_ADDRESS: `0x${string}`;
|
|
104
|
+
/**
|
|
105
|
+
* Varity Treasury address (receives 10% platform fee)
|
|
106
|
+
*/
|
|
107
|
+
export declare const VARITY_TREASURY_ADDRESS: "0xA0b83bBeF45FeE8c8E158b25b736E05eBd51b793";
|
|
108
|
+
/**
|
|
109
|
+
* Platform fee in basis points (10% = 1000 bps)
|
|
110
|
+
*/
|
|
111
|
+
export declare const PLATFORM_FEE_BPS = 1000;
|
|
112
|
+
/**
|
|
113
|
+
* VarityPayments contract ABI (camelCase - Stylus SDK conversion)
|
|
114
|
+
*/
|
|
115
|
+
export declare const VARITY_PAYMENTS_ABI: readonly [{
|
|
116
|
+
readonly name: "getAppPricing";
|
|
117
|
+
readonly type: "function";
|
|
118
|
+
readonly stateMutability: "view";
|
|
119
|
+
readonly inputs: readonly [{
|
|
120
|
+
readonly name: "appId";
|
|
121
|
+
readonly type: "uint64";
|
|
122
|
+
}];
|
|
123
|
+
readonly outputs: readonly [{
|
|
124
|
+
readonly name: "priceUsdc";
|
|
125
|
+
readonly type: "uint64";
|
|
126
|
+
}, {
|
|
127
|
+
readonly name: "developer";
|
|
128
|
+
readonly type: "address";
|
|
129
|
+
}, {
|
|
130
|
+
readonly name: "isSubscription";
|
|
131
|
+
readonly type: "bool";
|
|
132
|
+
}, {
|
|
133
|
+
readonly name: "intervalDays";
|
|
134
|
+
readonly type: "uint64";
|
|
135
|
+
}, {
|
|
136
|
+
readonly name: "isActive";
|
|
137
|
+
readonly type: "bool";
|
|
138
|
+
}];
|
|
139
|
+
}, {
|
|
140
|
+
readonly name: "hasUserPurchased";
|
|
141
|
+
readonly type: "function";
|
|
142
|
+
readonly stateMutability: "view";
|
|
143
|
+
readonly inputs: readonly [{
|
|
144
|
+
readonly name: "appId";
|
|
145
|
+
readonly type: "uint64";
|
|
146
|
+
}, {
|
|
147
|
+
readonly name: "buyer";
|
|
148
|
+
readonly type: "address";
|
|
149
|
+
}];
|
|
150
|
+
readonly outputs: readonly [{
|
|
151
|
+
readonly name: "";
|
|
152
|
+
readonly type: "bool";
|
|
153
|
+
}];
|
|
154
|
+
}, {
|
|
155
|
+
readonly name: "getTreasury";
|
|
156
|
+
readonly type: "function";
|
|
157
|
+
readonly stateMutability: "view";
|
|
158
|
+
readonly inputs: readonly [];
|
|
159
|
+
readonly outputs: readonly [{
|
|
160
|
+
readonly name: "";
|
|
161
|
+
readonly type: "address";
|
|
162
|
+
}];
|
|
163
|
+
}, {
|
|
164
|
+
readonly name: "getUsdcAddress";
|
|
165
|
+
readonly type: "function";
|
|
166
|
+
readonly stateMutability: "view";
|
|
167
|
+
readonly inputs: readonly [];
|
|
168
|
+
readonly outputs: readonly [{
|
|
169
|
+
readonly name: "";
|
|
170
|
+
readonly type: "address";
|
|
171
|
+
}];
|
|
172
|
+
}, {
|
|
173
|
+
readonly name: "purchaseApp";
|
|
174
|
+
readonly type: "function";
|
|
175
|
+
readonly stateMutability: "nonpayable";
|
|
176
|
+
readonly inputs: readonly [{
|
|
177
|
+
readonly name: "appId";
|
|
178
|
+
readonly type: "uint64";
|
|
179
|
+
}];
|
|
180
|
+
readonly outputs: readonly [];
|
|
181
|
+
}, {
|
|
182
|
+
readonly name: "setAppPrice";
|
|
183
|
+
readonly type: "function";
|
|
184
|
+
readonly stateMutability: "nonpayable";
|
|
185
|
+
readonly inputs: readonly [{
|
|
186
|
+
readonly name: "appId";
|
|
187
|
+
readonly type: "uint64";
|
|
188
|
+
}, {
|
|
189
|
+
readonly name: "priceUsdc";
|
|
190
|
+
readonly type: "uint64";
|
|
191
|
+
}, {
|
|
192
|
+
readonly name: "isSubscription";
|
|
193
|
+
readonly type: "bool";
|
|
194
|
+
}, {
|
|
195
|
+
readonly name: "intervalDays";
|
|
196
|
+
readonly type: "uint64";
|
|
197
|
+
}];
|
|
198
|
+
readonly outputs: readonly [];
|
|
199
|
+
}];
|
|
200
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/PaymentWidget/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,cAAc,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,wDAAwD;IACxD,SAAS,EAAE,MAAM,CAAC;IAClB,+BAA+B;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,qCAAqC;IACrC,cAAc,EAAE,OAAO,CAAC;IACxB,mDAAmD;IACnD,YAAY,EAAE,MAAM,CAAC;IACrB,gCAAgC;IAChC,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,iDAAiD;IACj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BAA8B;IAC9B,OAAO,EAAE,UAAU,GAAG,IAAI,CAAC;IAC3B,yBAAyB;IACzB,QAAQ,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACvC,8BAA8B;IAC9B,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,kCAAkC;IAClC,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAI/B,KAAK,MAAM,EAAE,CAAC;AAEnB;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAG,4CAAqD,CAAC;AAE7F;;GAEG;AACH,eAAO,MAAM,gBAAgB,OAAO,CAAC;AAErC;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4DtB,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PaymentWidget Types
|
|
3
|
+
* For developer apps to charge end-users with 90/10 revenue split
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* VarityPayments contract address on Arbitrum One (mainnet)
|
|
7
|
+
* Set NEXT_PUBLIC_VARITY_PAYMENTS_ADDRESS env var after deploying to Arb One.
|
|
8
|
+
*/
|
|
9
|
+
export const VARITY_PAYMENTS_ADDRESS = (typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_VARITY_PAYMENTS_ADDRESS
|
|
10
|
+
? process.env.NEXT_PUBLIC_VARITY_PAYMENTS_ADDRESS
|
|
11
|
+
: '0x0568cf3b5b9c94542aa8d32eb51ffa38912fc48c');
|
|
12
|
+
/**
|
|
13
|
+
* Varity Treasury address (receives 10% platform fee)
|
|
14
|
+
*/
|
|
15
|
+
export const VARITY_TREASURY_ADDRESS = '0xA0b83bBeF45FeE8c8E158b25b736E05eBd51b793';
|
|
16
|
+
/**
|
|
17
|
+
* Platform fee in basis points (10% = 1000 bps)
|
|
18
|
+
*/
|
|
19
|
+
export const PLATFORM_FEE_BPS = 1000;
|
|
20
|
+
/**
|
|
21
|
+
* VarityPayments contract ABI (camelCase - Stylus SDK conversion)
|
|
22
|
+
*/
|
|
23
|
+
export const VARITY_PAYMENTS_ABI = [
|
|
24
|
+
// Read functions
|
|
25
|
+
{
|
|
26
|
+
name: 'getAppPricing',
|
|
27
|
+
type: 'function',
|
|
28
|
+
stateMutability: 'view',
|
|
29
|
+
inputs: [{ name: 'appId', type: 'uint64' }],
|
|
30
|
+
outputs: [
|
|
31
|
+
{ name: 'priceUsdc', type: 'uint64' },
|
|
32
|
+
{ name: 'developer', type: 'address' },
|
|
33
|
+
{ name: 'isSubscription', type: 'bool' },
|
|
34
|
+
{ name: 'intervalDays', type: 'uint64' },
|
|
35
|
+
{ name: 'isActive', type: 'bool' },
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: 'hasUserPurchased',
|
|
40
|
+
type: 'function',
|
|
41
|
+
stateMutability: 'view',
|
|
42
|
+
inputs: [
|
|
43
|
+
{ name: 'appId', type: 'uint64' },
|
|
44
|
+
{ name: 'buyer', type: 'address' },
|
|
45
|
+
],
|
|
46
|
+
outputs: [{ name: '', type: 'bool' }],
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: 'getTreasury',
|
|
50
|
+
type: 'function',
|
|
51
|
+
stateMutability: 'view',
|
|
52
|
+
inputs: [],
|
|
53
|
+
outputs: [{ name: '', type: 'address' }],
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'getUsdcAddress',
|
|
57
|
+
type: 'function',
|
|
58
|
+
stateMutability: 'view',
|
|
59
|
+
inputs: [],
|
|
60
|
+
outputs: [{ name: '', type: 'address' }],
|
|
61
|
+
},
|
|
62
|
+
// Write functions — nonpayable (ERC-20 USDC transferFrom pattern)
|
|
63
|
+
// Users must approve() USDC spending before calling purchaseApp
|
|
64
|
+
{
|
|
65
|
+
name: 'purchaseApp',
|
|
66
|
+
type: 'function',
|
|
67
|
+
stateMutability: 'nonpayable',
|
|
68
|
+
inputs: [{ name: 'appId', type: 'uint64' }],
|
|
69
|
+
outputs: [],
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: 'setAppPrice',
|
|
73
|
+
type: 'function',
|
|
74
|
+
stateMutability: 'nonpayable',
|
|
75
|
+
inputs: [
|
|
76
|
+
{ name: 'appId', type: 'uint64' },
|
|
77
|
+
{ name: 'priceUsdc', type: 'uint64' },
|
|
78
|
+
{ name: 'isSubscription', type: 'bool' },
|
|
79
|
+
{ name: 'intervalDays', type: 'uint64' },
|
|
80
|
+
],
|
|
81
|
+
outputs: [],
|
|
82
|
+
},
|
|
83
|
+
];
|
|
84
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/PaymentWidget/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAsGH;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,mCAAmC;IAChF,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,mCAAmC;IACjD,CAAC,CAAC,4CAA4C,CAChC,CAAC;AAEnB;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,4CAAqD,CAAC;AAE7F;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAErC;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,iBAAiB;IACjB;QACE,IAAI,EAAE,eAAe;QACrB,IAAI,EAAE,UAAU;QAChB,eAAe,EAAE,MAAM;QACvB,MA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,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;QAC3C,OAAO,EAAE,EAAE;KACZ;IACD;QACE,IAAI,EAAE,aAAa;QACnB,IAAI,EAAE,UAAU;QAChB,eAAe,EAAE,YAAY;QAC7B,MAAM,EAAE;YACN,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE;YACjC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE;YACrC,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,EAAE;YACxC,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,QAAQ,EAAE;SACzC;QACD,OAAO,EAAE,EAAE;KACZ;CACO,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useSeamlessPayment - One-Click Payment with Auto On-Ramp
|
|
3
|
+
*
|
|
4
|
+
* Combines balance check + on-ramp + approval + purchase into a single flow.
|
|
5
|
+
* User just clicks "Pay" - everything happens automatically.
|
|
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
|
|
29
|
+
*/
|
|
30
|
+
export declare function useSeamlessPayment({ appId }: {
|
|
31
|
+
appId: number;
|
|
32
|
+
}): {
|
|
33
|
+
seamlessPurchase: () => Promise<{
|
|
34
|
+
success: boolean;
|
|
35
|
+
txHash?: string;
|
|
36
|
+
error?: string;
|
|
37
|
+
needsApproval?: boolean;
|
|
38
|
+
needsFunding?: boolean;
|
|
39
|
+
}>;
|
|
40
|
+
onrampStatus: "idle" | "checking" | "funding" | "approving" | "purchasing";
|
|
41
|
+
checkBalance: (address: string) => Promise<bigint>;
|
|
42
|
+
checkAllowance: (address: string) => Promise<bigint>;
|
|
43
|
+
hasPurchased: boolean;
|
|
44
|
+
isLoading: boolean;
|
|
45
|
+
isPurchasing: boolean;
|
|
46
|
+
error: string | null;
|
|
47
|
+
pricing: import("./types").AppPricing | null;
|
|
48
|
+
purchase: () => Promise<string | null>;
|
|
49
|
+
refresh: () => Promise<void>;
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=useSeamlessPayment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSeamlessPayment.d.ts","sourceRoot":"","sources":["../../../src/components/PaymentWidget/useSeamlessPayment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAaH;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE;4BAiEd,OAAO,CAAC;QACrD,OAAO,EAAE,OAAO,CAAC;QACjB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,aAAa,CAAC,EAAE,OAAO,CAAC;QACxB,YAAY,CAAC,EAAE,OAAO,CAAC;KACxB,CAAC;;4BA5D+C,MAAM,KAAG,OAAO,CAAC,MAAM,CAAC;8BAmBtB,MAAM,KAAG,OAAO,CAAC,MAAM,CAAC;;;;;;;;EA6H5E"}
|