@b3dotfun/sdk 0.1.66-alpha.2 → 0.1.66-alpha.3
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/dist/cjs/anyspend/react/components/checkout/CryptoCheckoutPanel.js +1 -1
- package/dist/cjs/anyspend/react/components/checkout/FiatCheckoutPanel.js +0 -18
- package/dist/cjs/global-account/react/components/ui/dialog.js +1 -1
- package/dist/esm/anyspend/react/components/checkout/CryptoCheckoutPanel.js +1 -1
- package/dist/esm/anyspend/react/components/checkout/FiatCheckoutPanel.js +0 -18
- package/dist/esm/global-account/react/components/ui/dialog.js +1 -1
- package/package.json +1 -1
- package/src/anyspend/react/components/checkout/CryptoCheckoutPanel.tsx +1 -1
- package/src/anyspend/react/components/checkout/FiatCheckoutPanel.tsx +0 -49
- package/src/global-account/react/components/ui/dialog.tsx +1 -1
|
@@ -170,7 +170,7 @@ function CryptoCheckoutPanel({ recipientAddress, destinationTokenAddress, destin
|
|
|
170
170
|
},
|
|
171
171
|
});
|
|
172
172
|
const isWaitingForExecution = !!orderId && oat?.data?.order.status !== "executed";
|
|
173
|
-
const handlePay = (0, react_5.useCallback)(() => {
|
|
173
|
+
const handlePay = (0, react_5.useCallback)(async () => {
|
|
174
174
|
if (!selectedSrcToken || !walletAddress)
|
|
175
175
|
return;
|
|
176
176
|
depositSentRef.current = false;
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.FiatCheckoutPanel = FiatCheckoutPanel;
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
6
|
const react_1 = require("../../../../anyspend/react");
|
|
7
|
-
const constants_1 = require("../../../../anyspend/constants");
|
|
8
7
|
const cn_1 = require("../../../../shared/utils/cn");
|
|
9
8
|
const number_1 = require("../../../../shared/utils/number");
|
|
10
9
|
const payment_utils_1 = require("../../../../shared/utils/payment.utils");
|
|
@@ -21,12 +20,6 @@ function FiatCheckoutPanel({ recipientAddress, destinationTokenAddress, destinat
|
|
|
21
20
|
return (0, number_1.formatTokenAmount)(BigInt(totalAmount), decimals);
|
|
22
21
|
}, [totalAmount, tokenData]);
|
|
23
22
|
const { geoData, stripeOnrampSupport, stripeWeb2Support, isLoading: isLoadingGeo, } = (0, react_1.useGeoOnrampOptions)(formattedAmount);
|
|
24
|
-
// Detect if destination token is the same as the onramp source (USDC on Base)
|
|
25
|
-
// In this case, onramp order creation would fail with "Cannot swap same token on same chain"
|
|
26
|
-
const isSameAsOnrampSource = (0, react_4.useMemo)(() => {
|
|
27
|
-
return (destinationTokenChainId === constants_1.USDC_BASE.chainId &&
|
|
28
|
-
destinationTokenAddress.toLowerCase() === constants_1.USDC_BASE.address.toLowerCase());
|
|
29
|
-
}, [destinationTokenAddress, destinationTokenChainId]);
|
|
30
23
|
// Order state
|
|
31
24
|
const [orderId, setOrderId] = (0, react_4.useState)(null);
|
|
32
25
|
const [stripePaymentIntentId, setStripePaymentIntentId] = (0, react_4.useState)(null);
|
|
@@ -50,11 +43,9 @@ function FiatCheckoutPanel({ recipientAddress, destinationTokenAddress, destinat
|
|
|
50
43
|
},
|
|
51
44
|
});
|
|
52
45
|
// Auto-create onramp order when Stripe Web2 is supported and all data is ready
|
|
53
|
-
// Skip auto-creation when destination is same as source (USDC on Base)
|
|
54
46
|
(0, react_4.useEffect)(() => {
|
|
55
47
|
if (!isLoadingGeo &&
|
|
56
48
|
stripeWeb2Support?.isSupport &&
|
|
57
|
-
!isSameAsOnrampSource &&
|
|
58
49
|
!orderCreatedRef.current &&
|
|
59
50
|
!orderId &&
|
|
60
51
|
!isCreatingOrder &&
|
|
@@ -90,7 +81,6 @@ function FiatCheckoutPanel({ recipientAddress, destinationTokenAddress, destinat
|
|
|
90
81
|
}, [
|
|
91
82
|
isLoadingGeo,
|
|
92
83
|
stripeWeb2Support,
|
|
93
|
-
isSameAsOnrampSource,
|
|
94
84
|
orderId,
|
|
95
85
|
isCreatingOrder,
|
|
96
86
|
orderError,
|
|
@@ -120,14 +110,6 @@ function FiatCheckoutPanel({ recipientAddress, destinationTokenAddress, destinat
|
|
|
120
110
|
orderCreatedRef.current = false;
|
|
121
111
|
}, className: "anyspend-fiat-retry text-sm font-medium text-blue-600 hover:text-blue-700 dark:text-blue-400", children: "Try again" })] }));
|
|
122
112
|
}
|
|
123
|
-
// Same-token fallback: USDC on Base uses Stripe redirect instead of embedded
|
|
124
|
-
if (isSameAsOnrampSource && hasStripeRedirect) {
|
|
125
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, cn_1.cn)("anyspend-fiat-redirect flex flex-col gap-3 py-2", classes?.fiatPanel), children: [(0, jsx_runtime_1.jsx)("p", { className: "text-sm text-gray-600 dark:text-gray-400", children: "You'll be redirected to Stripe to complete your payment securely." }), (0, jsx_runtime_1.jsxs)("button", { className: (0, cn_1.cn)("anyspend-fiat-redirect-btn flex w-full items-center justify-center gap-2 rounded-xl px-4 py-3.5 text-sm font-semibold text-white transition-all active:scale-[0.98]", "bg-blue-600 hover:bg-blue-700"), style: themeColor ? { backgroundColor: themeColor } : undefined, children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Lock, { className: "h-3.5 w-3.5" }), "Pay with Card"] }), (0, jsx_runtime_1.jsxs)("p", { className: "anyspend-fiat-secured flex items-center justify-center gap-1 text-xs text-gray-400", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Lock, { className: "h-3 w-3" }), "Secured by Stripe"] })] }));
|
|
126
|
-
}
|
|
127
|
-
// Same-token without redirect support
|
|
128
|
-
if (isSameAsOnrampSource) {
|
|
129
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)("anyspend-fiat-unavailable py-4 text-center", classes?.fiatPanel), children: (0, jsx_runtime_1.jsx)("p", { className: "text-sm text-gray-500 dark:text-gray-400", children: "Card payments are not available for this token configuration." }) }));
|
|
130
|
-
}
|
|
131
113
|
// Creating order / waiting for PaymentIntent
|
|
132
114
|
if (hasStripeWeb2 && (isCreatingOrder || !stripePaymentIntentId)) {
|
|
133
115
|
return ((0, jsx_runtime_1.jsxs)(react_3.motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { duration: 0.2, ease: "easeOut" }, className: (0, cn_1.cn)("anyspend-fiat-initializing flex flex-col items-center gap-3 py-6", classes?.fiatPanel), children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "h-5 w-5 animate-spin text-gray-400" }), (0, jsx_runtime_1.jsx)(react_2.TextShimmer, { duration: 1.5, className: "text-sm", children: "Initializing secure payment..." })] }));
|
|
@@ -53,7 +53,7 @@ exports.DialogOverlay = DialogOverlay;
|
|
|
53
53
|
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
54
54
|
const DialogContent = React.forwardRef(({ className, children, hideCloseButton = true, closeBtnClassName, ...props }, ref) => {
|
|
55
55
|
const container = typeof window !== "undefined" ? document.getElementById("b3-root") : null;
|
|
56
|
-
return ((0, jsx_runtime_1.jsxs)(DialogPortal, { container: container, children: [(0, jsx_runtime_1.jsx)(DialogOverlay, {}), (0, jsx_runtime_1.jsxs)(DialogPrimitive.Content, { ref: ref, className: (0, utils_1.cn)("fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2 border shadow-lg !outline-none", "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 duration-500", "data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95", "data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]", "[perspective:1200px] [transform-style:preserve-3d] sm:rounded-xl", "transition-all ease-out", className), ...props, children: [(0, jsx_runtime_1.jsxs)("div", { className: "modal-inner-content mb-[23px] flex flex-1 flex-col overflow-hidden rounded-xl border border-[#D1D1D6] bg-white shadow-[0_20px_24px_-4px_rgba(10,13,18,0.08),0_8px_8px_-4px_rgba(10,13,18,0.03),0_3px_3px_-1.5px_rgba(10,13,18,0.04)]", children: [children, !hideCloseButton && ((0, jsx_runtime_1.jsxs)(DialogPrimitive.Close, { className: (0, utils_1.cn)("modal-close-button data-[state=open]:bg-b3-react-background data-[state=open]:text-b3-react-muted-foreground absolute right-2 top-2 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none disabled:pointer-events-none dark:data-[state=open]:bg-gray-800 dark:data-[state=open]:text-gray-400", closeBtnClassName), children: [(0, jsx_runtime_1.jsx)(lucide_react_1.X, { className: "h-5 w-5" }), (0, jsx_runtime_1.jsx)("span", { className: "sr-only", children: "Close" })] }))] }), (0, jsx_runtime_1.jsxs)("div", { className: "b3-modal-ga-branding absolute bottom-[10px] left-0 right-0 flex items-center justify-center gap-1.5 pt-[10px]", children: [(0, jsx_runtime_1.jsx)("img", { src: "https://cdn.b3.fun/b3_logo.svg", alt: "B3", className: "h-4 w-4" }), (0, jsx_runtime_1.jsx)("span", { className: "font-neue-montreal-semibold text-xs uppercase leading-none tracking-[0.72px] text-[#0B57C2]", children: "Global Account" })] })] })] }));
|
|
56
|
+
return ((0, jsx_runtime_1.jsxs)(DialogPortal, { container: container, children: [(0, jsx_runtime_1.jsx)(DialogOverlay, {}), (0, jsx_runtime_1.jsxs)(DialogPrimitive.Content, { ref: ref, className: (0, utils_1.cn)("fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2 border shadow-lg !outline-none", "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 duration-500", "data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95", "data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]", "[perspective:1200px] [transform-style:preserve-3d] sm:rounded-xl", "transition-all ease-out", className), ...props, children: [(0, jsx_runtime_1.jsxs)("div", { className: "modal-inner-content mb-[23px] flex flex-1 flex-col overflow-hidden rounded-xl border border-[#D1D1D6] bg-white shadow-[0_20px_24px_-4px_rgba(10,13,18,0.08),0_8px_8px_-4px_rgba(10,13,18,0.03),0_3px_3px_-1.5px_rgba(10,13,18,0.04)] dark:border-gray-700 dark:bg-gray-900", children: [children, !hideCloseButton && ((0, jsx_runtime_1.jsxs)(DialogPrimitive.Close, { className: (0, utils_1.cn)("modal-close-button data-[state=open]:bg-b3-react-background data-[state=open]:text-b3-react-muted-foreground absolute right-2 top-2 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none disabled:pointer-events-none dark:data-[state=open]:bg-gray-800 dark:data-[state=open]:text-gray-400", closeBtnClassName), children: [(0, jsx_runtime_1.jsx)(lucide_react_1.X, { className: "h-5 w-5" }), (0, jsx_runtime_1.jsx)("span", { className: "sr-only", children: "Close" })] }))] }), (0, jsx_runtime_1.jsxs)("div", { className: "b3-modal-ga-branding absolute bottom-[10px] left-0 right-0 flex items-center justify-center gap-1.5 pt-[10px]", children: [(0, jsx_runtime_1.jsx)("img", { src: "https://cdn.b3.fun/b3_logo.svg", alt: "B3", className: "h-4 w-4" }), (0, jsx_runtime_1.jsx)("span", { className: "font-neue-montreal-semibold text-xs uppercase leading-none tracking-[0.72px] text-[#0B57C2]", children: "Global Account" })] })] })] }));
|
|
57
57
|
});
|
|
58
58
|
exports.DialogContent = DialogContent;
|
|
59
59
|
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
@@ -166,7 +166,7 @@ export function CryptoCheckoutPanel({ recipientAddress, destinationTokenAddress,
|
|
|
166
166
|
},
|
|
167
167
|
});
|
|
168
168
|
const isWaitingForExecution = !!orderId && oat?.data?.order.status !== "executed";
|
|
169
|
-
const handlePay = useCallback(() => {
|
|
169
|
+
const handlePay = useCallback(async () => {
|
|
170
170
|
if (!selectedSrcToken || !walletAddress)
|
|
171
171
|
return;
|
|
172
172
|
depositSentRef.current = false;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { useAnyspendCreateOnrampOrder, useGeoOnrampOptions, useStripeClientSecret } from "../../../../anyspend/react/index.js";
|
|
4
|
-
import { USDC_BASE } from "../../../../anyspend/constants/index.js";
|
|
5
4
|
import { cn } from "../../../../shared/utils/cn.js";
|
|
6
5
|
import { formatTokenAmount } from "../../../../shared/utils/number.js";
|
|
7
6
|
import { getStripePromise } from "../../../../shared/utils/payment.utils.js";
|
|
@@ -18,12 +17,6 @@ export function FiatCheckoutPanel({ recipientAddress, destinationTokenAddress, d
|
|
|
18
17
|
return formatTokenAmount(BigInt(totalAmount), decimals);
|
|
19
18
|
}, [totalAmount, tokenData]);
|
|
20
19
|
const { geoData, stripeOnrampSupport, stripeWeb2Support, isLoading: isLoadingGeo, } = useGeoOnrampOptions(formattedAmount);
|
|
21
|
-
// Detect if destination token is the same as the onramp source (USDC on Base)
|
|
22
|
-
// In this case, onramp order creation would fail with "Cannot swap same token on same chain"
|
|
23
|
-
const isSameAsOnrampSource = useMemo(() => {
|
|
24
|
-
return (destinationTokenChainId === USDC_BASE.chainId &&
|
|
25
|
-
destinationTokenAddress.toLowerCase() === USDC_BASE.address.toLowerCase());
|
|
26
|
-
}, [destinationTokenAddress, destinationTokenChainId]);
|
|
27
20
|
// Order state
|
|
28
21
|
const [orderId, setOrderId] = useState(null);
|
|
29
22
|
const [stripePaymentIntentId, setStripePaymentIntentId] = useState(null);
|
|
@@ -47,11 +40,9 @@ export function FiatCheckoutPanel({ recipientAddress, destinationTokenAddress, d
|
|
|
47
40
|
},
|
|
48
41
|
});
|
|
49
42
|
// Auto-create onramp order when Stripe Web2 is supported and all data is ready
|
|
50
|
-
// Skip auto-creation when destination is same as source (USDC on Base)
|
|
51
43
|
useEffect(() => {
|
|
52
44
|
if (!isLoadingGeo &&
|
|
53
45
|
stripeWeb2Support?.isSupport &&
|
|
54
|
-
!isSameAsOnrampSource &&
|
|
55
46
|
!orderCreatedRef.current &&
|
|
56
47
|
!orderId &&
|
|
57
48
|
!isCreatingOrder &&
|
|
@@ -87,7 +78,6 @@ export function FiatCheckoutPanel({ recipientAddress, destinationTokenAddress, d
|
|
|
87
78
|
}, [
|
|
88
79
|
isLoadingGeo,
|
|
89
80
|
stripeWeb2Support,
|
|
90
|
-
isSameAsOnrampSource,
|
|
91
81
|
orderId,
|
|
92
82
|
isCreatingOrder,
|
|
93
83
|
orderError,
|
|
@@ -117,14 +107,6 @@ export function FiatCheckoutPanel({ recipientAddress, destinationTokenAddress, d
|
|
|
117
107
|
orderCreatedRef.current = false;
|
|
118
108
|
}, className: "anyspend-fiat-retry text-sm font-medium text-blue-600 hover:text-blue-700 dark:text-blue-400", children: "Try again" })] }));
|
|
119
109
|
}
|
|
120
|
-
// Same-token fallback: USDC on Base uses Stripe redirect instead of embedded
|
|
121
|
-
if (isSameAsOnrampSource && hasStripeRedirect) {
|
|
122
|
-
return (_jsxs("div", { className: cn("anyspend-fiat-redirect flex flex-col gap-3 py-2", classes?.fiatPanel), children: [_jsx("p", { className: "text-sm text-gray-600 dark:text-gray-400", children: "You'll be redirected to Stripe to complete your payment securely." }), _jsxs("button", { className: cn("anyspend-fiat-redirect-btn flex w-full items-center justify-center gap-2 rounded-xl px-4 py-3.5 text-sm font-semibold text-white transition-all active:scale-[0.98]", "bg-blue-600 hover:bg-blue-700"), style: themeColor ? { backgroundColor: themeColor } : undefined, children: [_jsx(Lock, { className: "h-3.5 w-3.5" }), "Pay with Card"] }), _jsxs("p", { className: "anyspend-fiat-secured flex items-center justify-center gap-1 text-xs text-gray-400", children: [_jsx(Lock, { className: "h-3 w-3" }), "Secured by Stripe"] })] }));
|
|
123
|
-
}
|
|
124
|
-
// Same-token without redirect support
|
|
125
|
-
if (isSameAsOnrampSource) {
|
|
126
|
-
return (_jsx("div", { className: cn("anyspend-fiat-unavailable py-4 text-center", classes?.fiatPanel), children: _jsx("p", { className: "text-sm text-gray-500 dark:text-gray-400", children: "Card payments are not available for this token configuration." }) }));
|
|
127
|
-
}
|
|
128
110
|
// Creating order / waiting for PaymentIntent
|
|
129
111
|
if (hasStripeWeb2 && (isCreatingOrder || !stripePaymentIntentId)) {
|
|
130
112
|
return (_jsxs(motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { duration: 0.2, ease: "easeOut" }, className: cn("anyspend-fiat-initializing flex flex-col items-center gap-3 py-6", classes?.fiatPanel), children: [_jsx(Loader2, { className: "h-5 w-5 animate-spin text-gray-400" }), _jsx(TextShimmer, { duration: 1.5, className: "text-sm", children: "Initializing secure payment..." })] }));
|
|
@@ -12,7 +12,7 @@ const DialogOverlay = React.forwardRef(({ className, ...props }, ref) => (_jsx(D
|
|
|
12
12
|
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
13
13
|
const DialogContent = React.forwardRef(({ className, children, hideCloseButton = true, closeBtnClassName, ...props }, ref) => {
|
|
14
14
|
const container = typeof window !== "undefined" ? document.getElementById("b3-root") : null;
|
|
15
|
-
return (_jsxs(DialogPortal, { container: container, children: [_jsx(DialogOverlay, {}), _jsxs(DialogPrimitive.Content, { ref: ref, className: cn("fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2 border shadow-lg !outline-none", "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 duration-500", "data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95", "data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]", "[perspective:1200px] [transform-style:preserve-3d] sm:rounded-xl", "transition-all ease-out", className), ...props, children: [_jsxs("div", { className: "modal-inner-content mb-[23px] flex flex-1 flex-col overflow-hidden rounded-xl border border-[#D1D1D6] bg-white shadow-[0_20px_24px_-4px_rgba(10,13,18,0.08),0_8px_8px_-4px_rgba(10,13,18,0.03),0_3px_3px_-1.5px_rgba(10,13,18,0.04)]", children: [children, !hideCloseButton && (_jsxs(DialogPrimitive.Close, { className: cn("modal-close-button data-[state=open]:bg-b3-react-background data-[state=open]:text-b3-react-muted-foreground absolute right-2 top-2 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none disabled:pointer-events-none dark:data-[state=open]:bg-gray-800 dark:data-[state=open]:text-gray-400", closeBtnClassName), children: [_jsx(X, { className: "h-5 w-5" }), _jsx("span", { className: "sr-only", children: "Close" })] }))] }), _jsxs("div", { className: "b3-modal-ga-branding absolute bottom-[10px] left-0 right-0 flex items-center justify-center gap-1.5 pt-[10px]", children: [_jsx("img", { src: "https://cdn.b3.fun/b3_logo.svg", alt: "B3", className: "h-4 w-4" }), _jsx("span", { className: "font-neue-montreal-semibold text-xs uppercase leading-none tracking-[0.72px] text-[#0B57C2]", children: "Global Account" })] })] })] }));
|
|
15
|
+
return (_jsxs(DialogPortal, { container: container, children: [_jsx(DialogOverlay, {}), _jsxs(DialogPrimitive.Content, { ref: ref, className: cn("fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2 border shadow-lg !outline-none", "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 duration-500", "data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95", "data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]", "[perspective:1200px] [transform-style:preserve-3d] sm:rounded-xl", "transition-all ease-out", className), ...props, children: [_jsxs("div", { className: "modal-inner-content mb-[23px] flex flex-1 flex-col overflow-hidden rounded-xl border border-[#D1D1D6] bg-white shadow-[0_20px_24px_-4px_rgba(10,13,18,0.08),0_8px_8px_-4px_rgba(10,13,18,0.03),0_3px_3px_-1.5px_rgba(10,13,18,0.04)] dark:border-gray-700 dark:bg-gray-900", children: [children, !hideCloseButton && (_jsxs(DialogPrimitive.Close, { className: cn("modal-close-button data-[state=open]:bg-b3-react-background data-[state=open]:text-b3-react-muted-foreground absolute right-2 top-2 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none disabled:pointer-events-none dark:data-[state=open]:bg-gray-800 dark:data-[state=open]:text-gray-400", closeBtnClassName), children: [_jsx(X, { className: "h-5 w-5" }), _jsx("span", { className: "sr-only", children: "Close" })] }))] }), _jsxs("div", { className: "b3-modal-ga-branding absolute bottom-[10px] left-0 right-0 flex items-center justify-center gap-1.5 pt-[10px]", children: [_jsx("img", { src: "https://cdn.b3.fun/b3_logo.svg", alt: "B3", className: "h-4 w-4" }), _jsx("span", { className: "font-neue-montreal-semibold text-xs uppercase leading-none tracking-[0.72px] text-[#0B57C2]", children: "Global Account" })] })] })] }));
|
|
16
16
|
});
|
|
17
17
|
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
18
18
|
const DialogHeader = ({ className, ...props }) => (_jsx("div", { className: cn("flex flex-col space-y-1.5 text-center sm:text-left", className), ...props }));
|
package/package.json
CHANGED
|
@@ -228,7 +228,7 @@ export function CryptoCheckoutPanel({
|
|
|
228
228
|
|
|
229
229
|
const isWaitingForExecution = !!orderId && oat?.data?.order.status !== "executed";
|
|
230
230
|
|
|
231
|
-
const handlePay = useCallback(() => {
|
|
231
|
+
const handlePay = useCallback(async () => {
|
|
232
232
|
if (!selectedSrcToken || !walletAddress) return;
|
|
233
233
|
|
|
234
234
|
depositSentRef.current = false;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { useAnyspendCreateOnrampOrder, useGeoOnrampOptions, useStripeClientSecret } from "@b3dotfun/sdk/anyspend/react";
|
|
4
|
-
import { USDC_BASE } from "@b3dotfun/sdk/anyspend/constants";
|
|
5
4
|
import { cn } from "@b3dotfun/sdk/shared/utils/cn";
|
|
6
5
|
import { formatTokenAmount } from "@b3dotfun/sdk/shared/utils/number";
|
|
7
6
|
import { getStripePromise } from "@b3dotfun/sdk/shared/utils/payment.utils";
|
|
@@ -49,15 +48,6 @@ export function FiatCheckoutPanel({
|
|
|
49
48
|
isLoading: isLoadingGeo,
|
|
50
49
|
} = useGeoOnrampOptions(formattedAmount);
|
|
51
50
|
|
|
52
|
-
// Detect if destination token is the same as the onramp source (USDC on Base)
|
|
53
|
-
// In this case, onramp order creation would fail with "Cannot swap same token on same chain"
|
|
54
|
-
const isSameAsOnrampSource = useMemo(() => {
|
|
55
|
-
return (
|
|
56
|
-
destinationTokenChainId === USDC_BASE.chainId &&
|
|
57
|
-
destinationTokenAddress.toLowerCase() === USDC_BASE.address.toLowerCase()
|
|
58
|
-
);
|
|
59
|
-
}, [destinationTokenAddress, destinationTokenChainId]);
|
|
60
|
-
|
|
61
51
|
// Order state
|
|
62
52
|
const [orderId, setOrderId] = useState<string | null>(null);
|
|
63
53
|
const [stripePaymentIntentId, setStripePaymentIntentId] = useState<string | null>(null);
|
|
@@ -82,12 +72,10 @@ export function FiatCheckoutPanel({
|
|
|
82
72
|
});
|
|
83
73
|
|
|
84
74
|
// Auto-create onramp order when Stripe Web2 is supported and all data is ready
|
|
85
|
-
// Skip auto-creation when destination is same as source (USDC on Base)
|
|
86
75
|
useEffect(() => {
|
|
87
76
|
if (
|
|
88
77
|
!isLoadingGeo &&
|
|
89
78
|
stripeWeb2Support?.isSupport &&
|
|
90
|
-
!isSameAsOnrampSource &&
|
|
91
79
|
!orderCreatedRef.current &&
|
|
92
80
|
!orderId &&
|
|
93
81
|
!isCreatingOrder &&
|
|
@@ -126,7 +114,6 @@ export function FiatCheckoutPanel({
|
|
|
126
114
|
}, [
|
|
127
115
|
isLoadingGeo,
|
|
128
116
|
stripeWeb2Support,
|
|
129
|
-
isSameAsOnrampSource,
|
|
130
117
|
orderId,
|
|
131
118
|
isCreatingOrder,
|
|
132
119
|
orderError,
|
|
@@ -199,42 +186,6 @@ export function FiatCheckoutPanel({
|
|
|
199
186
|
);
|
|
200
187
|
}
|
|
201
188
|
|
|
202
|
-
// Same-token fallback: USDC on Base uses Stripe redirect instead of embedded
|
|
203
|
-
if (isSameAsOnrampSource && hasStripeRedirect) {
|
|
204
|
-
return (
|
|
205
|
-
<div className={cn("anyspend-fiat-redirect flex flex-col gap-3 py-2", classes?.fiatPanel)}>
|
|
206
|
-
<p className="text-sm text-gray-600 dark:text-gray-400">
|
|
207
|
-
You'll be redirected to Stripe to complete your payment securely.
|
|
208
|
-
</p>
|
|
209
|
-
<button
|
|
210
|
-
className={cn(
|
|
211
|
-
"anyspend-fiat-redirect-btn flex w-full items-center justify-center gap-2 rounded-xl px-4 py-3.5 text-sm font-semibold text-white transition-all active:scale-[0.98]",
|
|
212
|
-
"bg-blue-600 hover:bg-blue-700",
|
|
213
|
-
)}
|
|
214
|
-
style={themeColor ? { backgroundColor: themeColor } : undefined}
|
|
215
|
-
>
|
|
216
|
-
<Lock className="h-3.5 w-3.5" />
|
|
217
|
-
Pay with Card
|
|
218
|
-
</button>
|
|
219
|
-
<p className="anyspend-fiat-secured flex items-center justify-center gap-1 text-xs text-gray-400">
|
|
220
|
-
<Lock className="h-3 w-3" />
|
|
221
|
-
Secured by Stripe
|
|
222
|
-
</p>
|
|
223
|
-
</div>
|
|
224
|
-
);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
// Same-token without redirect support
|
|
228
|
-
if (isSameAsOnrampSource) {
|
|
229
|
-
return (
|
|
230
|
-
<div className={cn("anyspend-fiat-unavailable py-4 text-center", classes?.fiatPanel)}>
|
|
231
|
-
<p className="text-sm text-gray-500 dark:text-gray-400">
|
|
232
|
-
Card payments are not available for this token configuration.
|
|
233
|
-
</p>
|
|
234
|
-
</div>
|
|
235
|
-
);
|
|
236
|
-
}
|
|
237
|
-
|
|
238
189
|
// Creating order / waiting for PaymentIntent
|
|
239
190
|
if (hasStripeWeb2 && (isCreatingOrder || !stripePaymentIntentId)) {
|
|
240
191
|
return (
|
|
@@ -60,7 +60,7 @@ const DialogContent: React.ForwardRefExoticComponent<DialogContentProps & React.
|
|
|
60
60
|
)}
|
|
61
61
|
{...props}
|
|
62
62
|
>
|
|
63
|
-
<div className="modal-inner-content mb-[23px] flex flex-1 flex-col overflow-hidden rounded-xl border border-[#D1D1D6] bg-white shadow-[0_20px_24px_-4px_rgba(10,13,18,0.08),0_8px_8px_-4px_rgba(10,13,18,0.03),0_3px_3px_-1.5px_rgba(10,13,18,0.04)]">
|
|
63
|
+
<div className="modal-inner-content mb-[23px] flex flex-1 flex-col overflow-hidden rounded-xl border border-[#D1D1D6] bg-white shadow-[0_20px_24px_-4px_rgba(10,13,18,0.08),0_8px_8px_-4px_rgba(10,13,18,0.03),0_3px_3px_-1.5px_rgba(10,13,18,0.04)] dark:border-gray-700 dark:bg-gray-900">
|
|
64
64
|
{children}
|
|
65
65
|
{!hideCloseButton && (
|
|
66
66
|
<DialogPrimitive.Close
|