@b3dotfun/sdk 0.0.79 → 0.0.80-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/anyspend/react/components/AnySpendCollectorClubPurchase.js +9 -2
- package/dist/cjs/anyspend/react/components/AnySpendCustom.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +53 -13
- package/dist/cjs/anyspend/react/components/AnySpendNFT.js +6 -9
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.js +1 -3
- package/dist/cjs/anyspend/react/components/common/FiatPaymentMethod.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/common/FiatPaymentMethod.js +32 -12
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.js +6 -6
- package/dist/cjs/anyspend/react/components/common/PanelOnrampPayment.js +5 -3
- package/dist/cjs/anyspend/react/hooks/useGeoOnrampOptions.d.ts +2 -8
- package/dist/cjs/anyspend/react/hooks/useGeoOnrampOptions.js +4 -2
- package/dist/cjs/anyspend/react/hooks/useStripeSupport.d.ts +1 -0
- package/dist/cjs/anyspend/react/hooks/useStripeSupport.js +1 -0
- package/dist/cjs/global-account/react/components/IPFSMediaRenderer/IPFSMediaRenderer.js +5 -3
- package/dist/cjs/shared/utils/ipfs.d.ts +3 -3
- package/dist/cjs/shared/utils/ipfs.js +8 -8
- package/dist/esm/anyspend/react/components/AnySpendCollectorClubPurchase.js +9 -2
- package/dist/esm/anyspend/react/components/AnySpendCustom.d.ts +2 -0
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +53 -13
- package/dist/esm/anyspend/react/components/AnySpendNFT.js +7 -10
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.js +1 -3
- package/dist/esm/anyspend/react/components/common/FiatPaymentMethod.d.ts +2 -1
- package/dist/esm/anyspend/react/components/common/FiatPaymentMethod.js +32 -12
- package/dist/esm/anyspend/react/components/common/PanelOnramp.js +6 -6
- package/dist/esm/anyspend/react/components/common/PanelOnrampPayment.js +5 -3
- package/dist/esm/anyspend/react/hooks/useGeoOnrampOptions.d.ts +2 -8
- package/dist/esm/anyspend/react/hooks/useGeoOnrampOptions.js +4 -2
- package/dist/esm/anyspend/react/hooks/useStripeSupport.d.ts +1 -0
- package/dist/esm/anyspend/react/hooks/useStripeSupport.js +1 -0
- package/dist/esm/global-account/react/components/IPFSMediaRenderer/IPFSMediaRenderer.js +5 -3
- package/dist/esm/shared/utils/ipfs.d.ts +3 -3
- package/dist/esm/shared/utils/ipfs.js +8 -8
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/react/components/AnySpendCustom.d.ts +2 -0
- package/dist/types/anyspend/react/components/common/FiatPaymentMethod.d.ts +2 -1
- package/dist/types/anyspend/react/hooks/useGeoOnrampOptions.d.ts +2 -8
- package/dist/types/anyspend/react/hooks/useStripeSupport.d.ts +1 -0
- package/dist/types/shared/utils/ipfs.d.ts +3 -3
- package/package.json +1 -1
- package/src/anyspend/react/components/AnySpendCollectorClubPurchase.tsx +9 -1
- package/src/anyspend/react/components/AnySpendCustom.tsx +71 -26
- package/src/anyspend/react/components/AnySpendNFT.tsx +49 -48
- package/src/anyspend/react/components/common/CryptoReceiveSection.tsx +1 -4
- package/src/anyspend/react/components/common/FiatPaymentMethod.tsx +45 -21
- package/src/anyspend/react/components/common/PanelOnramp.tsx +13 -13
- package/src/anyspend/react/components/common/PanelOnrampPayment.tsx +53 -16
- package/src/anyspend/react/hooks/useGeoOnrampOptions.ts +5 -2
- package/src/anyspend/react/hooks/useStripeSupport.ts +1 -0
- package/src/global-account/react/components/IPFSMediaRenderer/IPFSMediaRenderer.tsx +5 -7
- package/src/shared/utils/ipfs.ts +8 -8
|
@@ -29,11 +29,12 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
31
|
const constants_1 = require("../../../anyspend/constants");
|
|
32
|
+
const number_1 = require("../../../shared/utils/number");
|
|
32
33
|
const react_1 = require("react");
|
|
33
34
|
const viem_1 = require("viem");
|
|
34
35
|
const AnySpendCustom_1 = require("./AnySpendCustom");
|
|
35
36
|
// Collector Club Shop contract on Base
|
|
36
|
-
const CC_SHOP_ADDRESS = "
|
|
37
|
+
const CC_SHOP_ADDRESS = "0x23887D10c81118A9a2E3Af59C423e2f4ee4Cc7Cf";
|
|
37
38
|
const BASE_CHAIN_ID = 8453;
|
|
38
39
|
// ABI for buyPacksFor function only
|
|
39
40
|
const BUY_PACKS_FOR_ABI = {
|
|
@@ -58,6 +59,12 @@ function AnySpendCollectorClubPurchase({ loadOrder, mode = "modal", activeTab =
|
|
|
58
59
|
return "0";
|
|
59
60
|
}
|
|
60
61
|
}, [pricePerPack, packAmount]);
|
|
62
|
+
// Calculate fiat amount (totalAmount in USD, assuming USDC with 6 decimals)
|
|
63
|
+
const srcFiatAmount = (0, react_1.useMemo)(() => {
|
|
64
|
+
if (!totalAmount || totalAmount === "0")
|
|
65
|
+
return "0";
|
|
66
|
+
return (0, number_1.formatUnits)(totalAmount, constants_1.USDC_BASE.decimals);
|
|
67
|
+
}, [totalAmount]);
|
|
61
68
|
// Encode the buyPacksFor function call
|
|
62
69
|
const encodedData = (0, react_1.useMemo)(() => {
|
|
63
70
|
try {
|
|
@@ -80,5 +87,5 @@ function AnySpendCollectorClubPurchase({ loadOrder, mode = "modal", activeTab =
|
|
|
80
87
|
pricePerPack,
|
|
81
88
|
vendingMachineId,
|
|
82
89
|
packType,
|
|
83
|
-
}, header: header || defaultHeader, onSuccess: onSuccess, showRecipient: showRecipient }));
|
|
90
|
+
}, header: header || defaultHeader, onSuccess: onSuccess, showRecipient: showRecipient, srcFiatAmount: srcFiatAmount }));
|
|
84
91
|
}
|
|
@@ -21,4 +21,6 @@ export declare function AnySpendCustom(props: {
|
|
|
21
21
|
onSuccess?: (txHash?: string) => void;
|
|
22
22
|
showRecipient?: boolean;
|
|
23
23
|
onShowPointsDetail?: () => void;
|
|
24
|
+
/** Fiat amount in USD for fiat payments */
|
|
25
|
+
srcFiatAmount?: string;
|
|
24
26
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -52,7 +52,6 @@ const lucide_react_1 = require("lucide-react");
|
|
|
52
52
|
const react_4 = require("motion/react");
|
|
53
53
|
const react_5 = __importStar(require("react"));
|
|
54
54
|
const chains_1 = require("viem/chains");
|
|
55
|
-
const FeatureFlagsContext_1 = require("../contexts/FeatureFlagsContext");
|
|
56
55
|
const useAutoSetActiveWalletFromWagmi_1 = require("../hooks/useAutoSetActiveWalletFromWagmi");
|
|
57
56
|
const useCryptoPaymentMethodState_1 = require("../hooks/useCryptoPaymentMethodState");
|
|
58
57
|
const useRecipientAddressState_1 = require("../hooks/useRecipientAddressState");
|
|
@@ -147,9 +146,8 @@ function AnySpendCustom(props) {
|
|
|
147
146
|
const fingerprintConfig = (0, AnySpendFingerprintWrapper_1.getFingerprintConfig)();
|
|
148
147
|
return ((0, jsx_runtime_1.jsx)(AnySpendFingerprintWrapper_1.AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: (0, jsx_runtime_1.jsx)(AnySpendCustomInner, { ...props }) }));
|
|
149
148
|
}
|
|
150
|
-
function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabProps = "crypto", recipientAddress: recipientAddressProps, spenderAddress, orderType, dstChainId, dstToken, dstAmount, contractAddress, encodedData, metadata, header, onSuccess, showRecipient = true, onShowPointsDetail, }) {
|
|
149
|
+
function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabProps = "crypto", recipientAddress: recipientAddressProps, spenderAddress, orderType, dstChainId, dstToken, dstAmount, contractAddress, encodedData, metadata, header, onSuccess, showRecipient = true, onShowPointsDetail, srcFiatAmount: srcFiatAmountProps, }) {
|
|
151
150
|
const hasMounted = (0, react_2.useHasMounted)();
|
|
152
|
-
const featureFlags = (0, FeatureFlagsContext_1.useFeatureFlags)();
|
|
153
151
|
const searchParams = (0, react_2.useSearchParamsSSR)();
|
|
154
152
|
const router = (0, react_2.useRouter)();
|
|
155
153
|
// Auto-set active wallet from wagmi
|
|
@@ -282,9 +280,29 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
282
280
|
}
|
|
283
281
|
}, [activeTab, anyspendQuote?.data]);
|
|
284
282
|
const formattedSrcAmount = srcAmount ? (0, number_1.formatTokenAmount)(srcAmount, srcToken.decimals, 6, false) : null;
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
283
|
+
// Calculate fiat amount for geo check (regardless of activeTab) to determine tab availability
|
|
284
|
+
const srcFiatAmountForGeoCheck = (0, react_5.useMemo)(() => {
|
|
285
|
+
// Use prop if provided
|
|
286
|
+
if (srcFiatAmountProps) {
|
|
287
|
+
return srcFiatAmountProps;
|
|
288
|
+
}
|
|
289
|
+
// Fallback to dstAmount if destination token is USDC
|
|
290
|
+
if (dstAmount && dstToken.address.toLowerCase() === constants_1.USDC_BASE.address.toLowerCase()) {
|
|
291
|
+
return (0, number_1.formatUnits)(dstAmount, constants_1.USDC_BASE.decimals);
|
|
292
|
+
}
|
|
293
|
+
// Use srcAmount if available (from quote)
|
|
294
|
+
if (srcAmount) {
|
|
295
|
+
return (0, number_1.formatUnits)(srcAmount.toString(), constants_1.USDC_BASE.decimals);
|
|
296
|
+
}
|
|
297
|
+
return "0";
|
|
298
|
+
}, [srcAmount, srcFiatAmountProps, dstAmount, dstToken.address]);
|
|
299
|
+
const srcFiatAmount = (0, react_5.useMemo)(() => {
|
|
300
|
+
if (activeTab !== "fiat")
|
|
301
|
+
return "0";
|
|
302
|
+
return srcFiatAmountForGeoCheck;
|
|
303
|
+
}, [activeTab, srcFiatAmountForGeoCheck]);
|
|
304
|
+
// Get geo data and onramp options (use srcFiatAmountForGeoCheck to check availability regardless of activeTab)
|
|
305
|
+
const { geoData, isOnrampSupported, coinbaseAvailablePaymentMethods, stripeOnrampSupport, stripeWeb2Support } = (0, react_1.useGeoOnrampOptions)(srcFiatAmountForGeoCheck);
|
|
288
306
|
(0, react_5.useEffect)(() => {
|
|
289
307
|
if (oat?.data?.order.status === "executed" && !onSuccessCalled.current) {
|
|
290
308
|
console.log("Calling onSuccess");
|
|
@@ -379,9 +397,13 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
379
397
|
(0, invariant_1.default)((activeTab === "fiat" ? chains_1.base.id : srcChainId) === chains_1.base.id, "Selected src chain is not base");
|
|
380
398
|
// Get the current geo data from the hook
|
|
381
399
|
const currentGeoData = geoData;
|
|
400
|
+
// Use total amount from quote (includes fees) for onramp, fallback to srcFiatAmount
|
|
401
|
+
const onrampAmount = anyspendQuote?.data?.currencyIn?.amountUsd
|
|
402
|
+
? anyspendQuote.data.currencyIn.amountUsd.toString()
|
|
403
|
+
: srcFiatAmount;
|
|
382
404
|
void createOnrampOrder({
|
|
383
405
|
...createOrderParams,
|
|
384
|
-
srcFiatAmount:
|
|
406
|
+
srcFiatAmount: onrampAmount,
|
|
385
407
|
onramp: {
|
|
386
408
|
vendor: onramp.vendor,
|
|
387
409
|
paymentMethod: onramp.paymentMethod,
|
|
@@ -451,12 +473,22 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
451
473
|
vendor = "coinbase";
|
|
452
474
|
paymentMethodString = coinbaseAvailablePaymentMethods[0]?.id || "";
|
|
453
475
|
}
|
|
454
|
-
else if (paymentMethod === FiatPaymentMethod_1.FiatPaymentMethod.
|
|
476
|
+
else if (paymentMethod === FiatPaymentMethod_1.FiatPaymentMethod.STRIPE_WEB2) {
|
|
477
|
+
// Stripe Web2 embedded payment
|
|
455
478
|
if (!stripeWeb2Support || !stripeWeb2Support.isSupport) {
|
|
456
|
-
react_3.toast.error("Stripe not available");
|
|
479
|
+
react_3.toast.error("Stripe embedded payment not available");
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
vendor = "stripe-web2";
|
|
483
|
+
paymentMethodString = "";
|
|
484
|
+
}
|
|
485
|
+
else if (paymentMethod === FiatPaymentMethod_1.FiatPaymentMethod.STRIPE) {
|
|
486
|
+
// Stripe redirect (one-click buy URL)
|
|
487
|
+
if (!stripeOnrampSupport) {
|
|
488
|
+
react_3.toast.error("Stripe redirect payment not available");
|
|
457
489
|
return;
|
|
458
490
|
}
|
|
459
|
-
vendor =
|
|
491
|
+
vendor = "stripe";
|
|
460
492
|
paymentMethodString = "";
|
|
461
493
|
}
|
|
462
494
|
else {
|
|
@@ -503,7 +535,7 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
503
535
|
const loadingView = ((0, jsx_runtime_1.jsxs)("div", { className: (0, utils_1.cn)("mx-auto flex w-full flex-col items-center gap-4 p-5", mode === "modal" && "bg-b3-react-background"), children: [(0, jsx_runtime_1.jsxs)(react_2.Badge, { variant: "default", className: "bg-b3-react-muted/30 border-b3-react-border hover:bg-b3-react-muted/50 flex items-center gap-3 px-4 py-1 text-base transition-all", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "text-b3-react-foreground size-4 animate-spin" }), (0, jsx_runtime_1.jsx)(react_2.TextShimmer, { duration: 1, className: "font-sf-rounded text-base font-semibold", children: "Loading..." })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex w-full flex-1 flex-col", children: [(0, jsx_runtime_1.jsxs)("div", { className: "mb-4 flex flex-col gap-1", children: [(0, jsx_runtime_1.jsx)(react_2.Skeleton, { className: "h-4 w-24" }), (0, jsx_runtime_1.jsxs)("div", { className: "mt-2 flex items-center gap-2", children: [(0, jsx_runtime_1.jsx)(react_2.Skeleton, { className: "h-8 w-48" }), (0, jsx_runtime_1.jsx)(react_2.Skeleton, { className: "ml-4 h-8 w-32" })] }), (0, jsx_runtime_1.jsx)(react_2.Skeleton, { className: "mt-4 h-8 w-24" })] }), (0, jsx_runtime_1.jsx)(react_2.Skeleton, { className: "mb-4 h-12 w-full" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex w-full items-center justify-between gap-4", children: [(0, jsx_runtime_1.jsxs)(react_2.Skeleton, { className: "rounded-lg bg-white/5 p-6 pb-3", children: [(0, jsx_runtime_1.jsx)("div", { className: "size-[200px]" }), (0, jsx_runtime_1.jsx)("div", { className: "mt-3 flex items-center justify-center gap-2", children: (0, jsx_runtime_1.jsx)("div", { className: "size-5 rounded-full" }) })] }), (0, jsx_runtime_1.jsx)("div", { className: "flex flex-1 flex-col gap-2", children: [1, 2, 3].map(i => ((0, jsx_runtime_1.jsx)(react_2.Skeleton, { className: "h-10 w-full" }, i))) })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "bg-b3-react-muted/30 mt-8 w-full rounded-lg p-4", children: [(0, jsx_runtime_1.jsx)(react_2.Skeleton, { className: "mb-3 h-4 w-48" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-4", children: [(0, jsx_runtime_1.jsx)(react_2.Skeleton, { className: "h-10 flex-1" }), (0, jsx_runtime_1.jsx)(react_2.Skeleton, { className: "h-10 flex-1" })] })] }), (0, jsx_runtime_1.jsx)("div", { className: "flex w-full flex-col gap-3", children: [1, 2, 3, 4, 5].map(i => ((0, jsx_runtime_1.jsxs)("div", { className: "flex w-full justify-between", children: [(0, jsx_runtime_1.jsx)(react_2.Skeleton, { className: "h-4 w-24" }), (0, jsx_runtime_1.jsx)(react_2.Skeleton, { className: "h-4 w-32" })] }, i))) }), (0, jsx_runtime_1.jsx)(react_2.Skeleton, { className: "h-10 w-full" }), mode === "page" && (0, jsx_runtime_1.jsx)("div", { className: "h-12" })] }));
|
|
504
536
|
// Render points badge if conditions are met
|
|
505
537
|
const renderPointsBadge = () => {
|
|
506
|
-
if (
|
|
538
|
+
if (anyspendQuote?.data?.pointsAmount && anyspendQuote.data.pointsAmount > 0) {
|
|
507
539
|
return ((0, jsx_runtime_1.jsx)(PointsBadge_1.PointsBadge, { pointsAmount: anyspendQuote.data.pointsAmount, pointsMultiplier: anyspendQuote.data.pointsMultiplier, onClick: () => {
|
|
508
540
|
onShowPointsDetail?.();
|
|
509
541
|
setActivePanel(PanelView.POINTS_DETAIL);
|
|
@@ -550,8 +582,16 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
550
582
|
opacity: hasMounted ? 1 : 0,
|
|
551
583
|
y: hasMounted ? 0 : 20,
|
|
552
584
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
553
|
-
}, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between gap-4", children: [(0, jsx_runtime_1.jsxs)("span", { className: "text-as-tertiarry flex flex-wrap items-center gap-1.5 text-sm", children: [(0, jsx_runtime_1.jsxs)("span", { className: "whitespace-nowrap", children: ["Total ", (0, jsx_runtime_1.jsx)("span", { className: "text-as-tertiarry", children: "(USD)" })] }), anyspendQuote?.data?.fee && ((0, jsx_runtime_1.jsx)(react_2.TooltipProvider, { children: (0, jsx_runtime_1.jsxs)(react_2.Tooltip, { children: [(0, jsx_runtime_1.jsx)(react_2.TooltipTrigger, { asChild: true, children: (0, jsx_runtime_1.jsx)("button", { className: "text-as-primary/40 hover:text-as-primary/60 transition-colors", children: (0, jsx_runtime_1.jsx)(lucide_react_1.Info, { className: "h-4 w-4" }) }) }), (0, jsx_runtime_1.jsx)(react_2.TooltipContent, { side: "top", children: (0, jsx_runtime_1.jsx)(FeeBreakDown_1.FeeBreakDown, { fee: anyspendQuote.data.fee }) })] }) }))] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-end gap-0.5", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex flex-wrap items-center justify-end gap-2", children: [renderPointsBadge(), (0, jsx_runtime_1.
|
|
554
|
-
|
|
585
|
+
}, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between gap-4", children: [(0, jsx_runtime_1.jsxs)("span", { className: "text-as-tertiarry flex flex-wrap items-center gap-1.5 text-sm", children: [(0, jsx_runtime_1.jsxs)("span", { className: "whitespace-nowrap", children: ["Total ", (0, jsx_runtime_1.jsx)("span", { className: "text-as-tertiarry", children: "(USD)" })] }), anyspendQuote?.data?.fee && ((0, jsx_runtime_1.jsx)(react_2.TooltipProvider, { children: (0, jsx_runtime_1.jsxs)(react_2.Tooltip, { children: [(0, jsx_runtime_1.jsx)(react_2.TooltipTrigger, { asChild: true, children: (0, jsx_runtime_1.jsx)("button", { className: "text-as-primary/40 hover:text-as-primary/60 transition-colors", children: (0, jsx_runtime_1.jsx)(lucide_react_1.Info, { className: "h-4 w-4" }) }) }), (0, jsx_runtime_1.jsx)(react_2.TooltipContent, { side: "top", children: (0, jsx_runtime_1.jsx)(FeeBreakDown_1.FeeBreakDown, { fee: anyspendQuote.data.fee }) })] }) }))] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-end gap-0.5", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex flex-wrap items-center justify-end gap-2", children: [renderPointsBadge(), isLoadingAnyspendQuote ? ((0, jsx_runtime_1.jsx)("div", { className: "bg-as-surface-secondary h-7 w-16 animate-pulse rounded" })) : ((0, jsx_runtime_1.jsx)("span", { className: "text-as-primary whitespace-nowrap text-xl font-semibold", children: anyspendQuote?.data?.currencyIn?.amountUsd ? (`$${Number(anyspendQuote.data.currencyIn.amountUsd).toFixed(2)}`) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["$", parseFloat(srcFiatAmount || "0").toFixed(2), (0, jsx_runtime_1.jsx)("span", { className: "text-as-tertiarry text-base", children: "+" })] })) }))] }), (() => {
|
|
586
|
+
if (anyspendQuote?.data?.fee?.type === "stripeweb2_fee" && anyspendQuote.data.fee.originalAmount) {
|
|
587
|
+
const fee = (Number(anyspendQuote.data.fee.originalAmount) - Number(anyspendQuote.data.fee.finalAmount)) /
|
|
588
|
+
1e6;
|
|
589
|
+
if (fee > 0) {
|
|
590
|
+
return (0, jsx_runtime_1.jsxs)("span", { className: "text-as-secondary text-xs", children: ["incl. $", fee.toFixed(2), " fee"] });
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
return null;
|
|
594
|
+
})()] })] })] }), (0, jsx_runtime_1.jsx)("div", { className: (0, utils_1.cn)("flex w-full flex-col items-center justify-between gap-2"), children: (0, jsx_runtime_1.jsx)(react_4.motion.div, { initial: false, animate: {
|
|
555
595
|
opacity: hasMounted ? 1 : 0,
|
|
556
596
|
y: hasMounted ? 0 : 20,
|
|
557
597
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
@@ -31,16 +31,16 @@ const CONTRACT_URI_ABI = [
|
|
|
31
31
|
];
|
|
32
32
|
function AnySpendNFT({ loadOrder, mode = "modal", recipientAddress, nftContract, onSuccess, onShowPointsDetail, }) {
|
|
33
33
|
const [imageUrlWithFallback, setFallbackImageUrl] = (0, react_3.useState)(nftContract.imageUrl);
|
|
34
|
-
const
|
|
34
|
+
const hasFetchedRef = (0, react_3.useRef)(false);
|
|
35
35
|
// Fetch contract metadata when imageUrl is empty
|
|
36
36
|
(0, react_3.useEffect)(() => {
|
|
37
37
|
async function fetchContractMetadata() {
|
|
38
38
|
// fetch image Uri if not provided
|
|
39
|
-
if (nftContract.imageUrl ||
|
|
39
|
+
if (nftContract.imageUrl || hasFetchedRef.current) {
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
42
|
+
hasFetchedRef.current = true;
|
|
42
43
|
try {
|
|
43
|
-
setIsLoadingFallback(true);
|
|
44
44
|
// Use the chainIdToPublicClient utility function
|
|
45
45
|
const publicClient = (0, anyspend_1.chainIdToPublicClient)(nftContract.chainId);
|
|
46
46
|
let metadataURI;
|
|
@@ -77,15 +77,12 @@ function AnySpendNFT({ loadOrder, mode = "modal", recipientAddress, nftContract,
|
|
|
77
77
|
catch (error) {
|
|
78
78
|
console.error("Error fetching contract metadata:", error);
|
|
79
79
|
}
|
|
80
|
-
finally {
|
|
81
|
-
setIsLoadingFallback(false);
|
|
82
|
-
}
|
|
83
80
|
}
|
|
84
81
|
fetchContractMetadata();
|
|
85
|
-
}, [nftContract.contractAddress, nftContract.chainId, nftContract.imageUrl, nftContract.tokenId
|
|
86
|
-
const header = ({ anyspendPrice, isLoadingAnyspendPrice, }) => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "relative size-[200px]", children: [(0, jsx_runtime_1.jsx)("div", { className: "absolute inset-0 scale-95 bg-black/30 blur-md" }), (0, jsx_runtime_1.jsxs)(react_1.GlareCard, { className: "overflow-hidden", children: [imageUrlWithFallback && ((0, jsx_runtime_1.jsx)("img", { src: imageUrlWithFallback, alt: nftContract.name, className: "size-full object-cover" })), (0, jsx_runtime_1.jsx)("div", { className: "absolute inset-0 rounded-xl border border-white/10" })] }), (0, jsx_runtime_1.jsx)(DropdownMenu, { nftContract: nftContract })] }), (0, jsx_runtime_1.jsxs)("div", { className: "from-b3-react-background to-as-on-surface-1 -mb-5 mt-[-100px] w-full rounded-t-lg bg-gradient-to-t", children: [(0, jsx_runtime_1.jsx)("div", { className: "h-[100px] w-full" }), (0, jsx_runtime_1.jsxs)("div", { className: "mb-1 flex w-full flex-col items-center gap-2 p-5", children: [(0, jsx_runtime_1.jsx)("span", { className: "font-sf-rounded text-2xl font-semibold", children: nftContract.name }), (0, jsx_runtime_1.jsx)("div", { className: "flex w-fit items-center gap-1", children: anyspendPrice ? ((0, jsx_runtime_1.jsx)(react_2.AnimatePresence, { mode: "wait", children: (0, jsx_runtime_1.jsx)("div", { className: (0, utils_1.cn)("text-as-primary group flex items-center text-3xl font-semibold transition-all", {
|
|
82
|
+
}, [nftContract.contractAddress, nftContract.chainId, nftContract.imageUrl, nftContract.tokenId]);
|
|
83
|
+
const header = (0, react_3.useCallback)(({ anyspendPrice, isLoadingAnyspendPrice, }) => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "relative size-[200px]", children: [(0, jsx_runtime_1.jsx)("div", { className: "absolute inset-0 scale-95 bg-black/30 blur-md" }), (0, jsx_runtime_1.jsxs)(react_1.GlareCard, { className: "overflow-hidden", children: [imageUrlWithFallback && ((0, jsx_runtime_1.jsx)("img", { src: imageUrlWithFallback, alt: nftContract.name, className: "size-full object-cover" })), (0, jsx_runtime_1.jsx)("div", { className: "absolute inset-0 rounded-xl border border-white/10" })] }), (0, jsx_runtime_1.jsx)(DropdownMenu, { nftContract: nftContract })] }), (0, jsx_runtime_1.jsxs)("div", { className: "from-b3-react-background to-as-on-surface-1 -mb-5 mt-[-100px] w-full rounded-t-lg bg-gradient-to-t", children: [(0, jsx_runtime_1.jsx)("div", { className: "h-[100px] w-full" }), (0, jsx_runtime_1.jsxs)("div", { className: "mb-1 flex w-full flex-col items-center gap-2 p-5", children: [(0, jsx_runtime_1.jsx)("span", { className: "font-sf-rounded text-2xl font-semibold", children: nftContract.name }), (0, jsx_runtime_1.jsx)("div", { className: "flex w-fit items-center gap-1", children: anyspendPrice ? ((0, jsx_runtime_1.jsx)(react_2.AnimatePresence, { mode: "wait", children: (0, jsx_runtime_1.jsx)("div", { className: (0, utils_1.cn)("text-as-primary group flex items-center text-3xl font-semibold transition-all", {
|
|
87
84
|
"opacity-0": isLoadingAnyspendPrice,
|
|
88
|
-
}), children: (0, number_1.formatDisplayNumber)(anyspendPrice?.data?.currencyIn?.amountUsd, { style: "currency" }) }) })) : ((0, jsx_runtime_1.jsx)("div", { className: "h-[36px] w-full" })) })] })] })] }));
|
|
85
|
+
}), children: (0, number_1.formatDisplayNumber)(anyspendPrice?.data?.currencyIn?.amountUsd, { style: "currency" }) }) })) : ((0, jsx_runtime_1.jsx)("div", { className: "h-[36px] w-full" })) })] })] })] })), [imageUrlWithFallback, nftContract]);
|
|
89
86
|
return ((0, jsx_runtime_1.jsx)(AnySpendCustom_1.AnySpendCustom, { loadOrder: loadOrder, mode: mode, activeTab: "fiat", recipientAddress: recipientAddress, orderType: "mint_nft", dstChainId: nftContract.chainId, dstToken: nftContract.currency, dstAmount: nftContract.price, contractAddress: nftContract.contractAddress, encodedData: "0x", metadata: {
|
|
90
87
|
type: "mint_nft",
|
|
91
88
|
nftContract: nftContract,
|
|
@@ -8,11 +8,9 @@ const formatAddress_1 = require("../../../../shared/utils/formatAddress");
|
|
|
8
8
|
const number_1 = require("../../../../shared/utils/number");
|
|
9
9
|
const lucide_react_1 = require("lucide-react");
|
|
10
10
|
const react_1 = require("motion/react");
|
|
11
|
-
const FeatureFlagsContext_1 = require("../../contexts/FeatureFlagsContext");
|
|
12
11
|
const OrderTokenAmount_1 = require("./OrderTokenAmount");
|
|
13
12
|
const PointsBadge_1 = require("./PointsBadge");
|
|
14
13
|
function CryptoReceiveSection({ isDepositMode = false, isBuyMode = false, effectiveRecipientAddress, recipientName, onSelectRecipient, dstAmount, dstToken, selectedDstChainId, setSelectedDstChainId, setSelectedDstToken, isSrcInputDirty, onChangeDstAmount, anyspendQuote, dstTokenSymbol, dstTokenLogoURI, onShowPointsDetail, onShowFeeDetail, }) {
|
|
15
|
-
const featureFlags = (0, FeatureFlagsContext_1.useFeatureFlags)();
|
|
16
14
|
return ((0, jsx_runtime_1.jsxs)(react_1.motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, className: "receive-section bg-as-surface-secondary border-as-border-secondary relative flex w-full flex-col gap-2 rounded-2xl border p-4 sm:p-6", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex w-full items-center justify-between", children: [(0, jsx_runtime_1.jsxs)("div", { className: "text-as-primary/50 flex h-7 items-center gap-1.5 text-sm", children: [isDepositMode ? "Deposit" : "Receive", isSrcInputDirty && anyspendQuote?.data?.fee && onShowFeeDetail && ((0, jsx_runtime_1.jsx)("button", { onClick: onShowFeeDetail, className: "text-as-primary/40 hover:text-as-primary/60 transition-colors", children: (0, jsx_runtime_1.jsx)(lucide_react_1.Info, { className: "h-4 w-4" }) }))] }), effectiveRecipientAddress ? ((0, jsx_runtime_1.jsx)("button", { className: (0, cn_1.cn)("text-as-tertiarry flex h-7 items-center gap-2 rounded-lg"), onClick: onSelectRecipient, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-tertiarry flex items-center gap-1 text-sm", children: recipientName ? (0, utils_1.formatUsername)(recipientName) : (0, formatAddress_1.shortenAddress)(effectiveRecipientAddress || "") }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] }) })) : ((0, jsx_runtime_1.jsx)("button", { className: "text-as-primary/70 flex items-center gap-1 rounded-lg", onClick: onSelectRecipient, children: (0, jsx_runtime_1.jsx)("div", { className: "text-sm font-medium", children: "Select recipient" }) }))] }), isBuyMode || isDepositMode ? (
|
|
17
15
|
// Fixed destination token display for buy mode and deposit mode
|
|
18
16
|
(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary text-2xl font-bold", children: dstAmount || "0" }), (0, jsx_runtime_1.jsxs)("div", { className: "bg-as-brand/10 border-as-brand/30 flex items-center gap-3 rounded-xl border px-4 py-3", children: [(dstTokenLogoURI || dstToken.metadata?.logoURI) && ((0, jsx_runtime_1.jsx)("img", { src: dstTokenLogoURI || dstToken.metadata?.logoURI, alt: dstTokenSymbol || dstToken.symbol, className: "h-8 w-8 rounded-full" })), (0, jsx_runtime_1.jsx)("span", { className: "text-as-brand text-lg font-bold", children: dstTokenSymbol || dstToken.symbol })] })] })) : (
|
|
@@ -58,5 +56,5 @@ function CryptoReceiveSection({ isDepositMode = false, isBuyMode = false, effect
|
|
|
58
56
|
}
|
|
59
57
|
// Using inline style to ensure color displays
|
|
60
58
|
return ((0, jsx_runtime_1.jsxs)("span", { className: "ml-2", style: { color: actualSlippage >= redThreshold ? "red" : "#FFD700" }, children: ["(", isNegative ? "-" : "", percentage, "%)"] }));
|
|
61
|
-
})()] }),
|
|
59
|
+
})()] }), anyspendQuote?.data?.pointsAmount > 0 && ((0, jsx_runtime_1.jsx)(PointsBadge_1.PointsBadge, { pointsAmount: anyspendQuote.data.pointsAmount, pointsMultiplier: anyspendQuote.data.pointsMultiplier, onClick: () => onShowPointsDetail?.() }))] })] }));
|
|
62
60
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export declare enum FiatPaymentMethod {
|
|
2
2
|
NONE = "none",
|
|
3
3
|
COINBASE_PAY = "coinbase_pay",
|
|
4
|
-
STRIPE = "stripe"
|
|
4
|
+
STRIPE = "stripe",// Stripe redirect (one-click buy URL)
|
|
5
|
+
STRIPE_WEB2 = "stripe_web2"
|
|
5
6
|
}
|
|
6
7
|
interface FiatPaymentMethodProps {
|
|
7
8
|
selectedPaymentMethod: FiatPaymentMethod;
|
|
@@ -12,26 +12,30 @@ var FiatPaymentMethod;
|
|
|
12
12
|
FiatPaymentMethod["NONE"] = "none";
|
|
13
13
|
FiatPaymentMethod["COINBASE_PAY"] = "coinbase_pay";
|
|
14
14
|
FiatPaymentMethod["STRIPE"] = "stripe";
|
|
15
|
+
FiatPaymentMethod["STRIPE_WEB2"] = "stripe_web2";
|
|
15
16
|
})(FiatPaymentMethod || (exports.FiatPaymentMethod = FiatPaymentMethod = {}));
|
|
16
17
|
function FiatPaymentMethodComponent({ selectedPaymentMethod, setSelectedPaymentMethod, onBack, onSelectPaymentMethod, srcAmountOnRamp, }) {
|
|
18
|
+
// Load geo-based onramp options like in PanelOnramp
|
|
19
|
+
const { coinbaseAvailablePaymentMethods, stripeOnrampSupport, stripeWeb2Support, isLoading: isLoadingGeoOnramp, } = (0, react_1.useGeoOnrampOptions)(srcAmountOnRamp);
|
|
17
20
|
// Helper function to get fees from API data
|
|
18
21
|
const getFeeFromApi = (paymentMethod) => {
|
|
19
22
|
switch (paymentMethod) {
|
|
20
23
|
case FiatPaymentMethod.COINBASE_PAY:
|
|
21
24
|
// Coinbase doesn't provide fee info in API, return null
|
|
22
25
|
return null;
|
|
23
|
-
case FiatPaymentMethod.
|
|
24
|
-
// Get fee from Stripe API response
|
|
26
|
+
case FiatPaymentMethod.STRIPE_WEB2:
|
|
27
|
+
// Get fee from Stripe Web2 API response
|
|
25
28
|
if (stripeWeb2Support && "formattedFeeUsd" in stripeWeb2Support) {
|
|
26
29
|
return stripeWeb2Support.formattedFeeUsd;
|
|
27
30
|
}
|
|
28
31
|
return null;
|
|
32
|
+
case FiatPaymentMethod.STRIPE:
|
|
33
|
+
// Stripe redirect doesn't have fee info from API
|
|
34
|
+
return null;
|
|
29
35
|
default:
|
|
30
36
|
return null; // No fee when no payment method selected
|
|
31
37
|
}
|
|
32
38
|
};
|
|
33
|
-
// Load geo-based onramp options like in PanelOnramp
|
|
34
|
-
const { coinbaseAvailablePaymentMethods, stripeWeb2Support, isLoading: isLoadingGeoOnramp, } = (0, react_1.useGeoOnrampOptions)(srcAmountOnRamp);
|
|
35
39
|
// Generate payment methods based on geo availability (like in PanelOnrampPayment)
|
|
36
40
|
const availablePaymentMethods = [];
|
|
37
41
|
// Add Coinbase Pay if available
|
|
@@ -46,15 +50,27 @@ function FiatPaymentMethodComponent({ selectedPaymentMethod, setSelectedPaymentM
|
|
|
46
50
|
available: true,
|
|
47
51
|
});
|
|
48
52
|
}
|
|
49
|
-
// Add Stripe if available
|
|
50
|
-
if (
|
|
51
|
-
const stripeFee = getFeeFromApi(FiatPaymentMethod.
|
|
53
|
+
// Add Stripe redirect (one-click) if available - primary option
|
|
54
|
+
if (stripeOnrampSupport) {
|
|
55
|
+
const stripeFee = getFeeFromApi(FiatPaymentMethod.STRIPE_WEB2); // Use same fee estimate
|
|
52
56
|
availablePaymentMethods.push({
|
|
53
57
|
id: FiatPaymentMethod.STRIPE,
|
|
54
|
-
name: "
|
|
55
|
-
description: "
|
|
56
|
-
badge: stripeFee ? `$${Number(stripeFee).toFixed(2)} fee` :
|
|
57
|
-
badgeColor: "bg-
|
|
58
|
+
name: "Credit/Debit Card",
|
|
59
|
+
description: "Pay via Stripe checkout",
|
|
60
|
+
badge: stripeFee ? `$${Number(stripeFee).toFixed(2)} fee` : undefined,
|
|
61
|
+
badgeColor: "bg-gray-100 text-gray-800",
|
|
62
|
+
available: true,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
// Add Stripe Web2 (embedded) if available - secondary option
|
|
66
|
+
if (stripeWeb2Support && stripeWeb2Support.isSupport) {
|
|
67
|
+
const stripeFee = getFeeFromApi(FiatPaymentMethod.STRIPE_WEB2);
|
|
68
|
+
availablePaymentMethods.push({
|
|
69
|
+
id: FiatPaymentMethod.STRIPE_WEB2,
|
|
70
|
+
name: "Quick Pay",
|
|
71
|
+
description: "Credit or debit card",
|
|
72
|
+
badge: stripeFee ? `$${Number(stripeFee).toFixed(2)} fee` : undefined,
|
|
73
|
+
badgeColor: "bg-gray-100 text-gray-800",
|
|
58
74
|
available: true,
|
|
59
75
|
});
|
|
60
76
|
}
|
|
@@ -67,5 +83,9 @@ function FiatPaymentMethodComponent({ selectedPaymentMethod, setSelectedPaymentM
|
|
|
67
83
|
onSelectPaymentMethod(method.id);
|
|
68
84
|
}, className: (0, cn_1.cn)("fiat-payment-method-item bg-as-surface-secondary border-as-border-secondary flex w-full items-center gap-4 rounded-2xl border p-4 transition-all duration-200", selectedPaymentMethod === method.id
|
|
69
85
|
? "border-as-brand bg-as-brand/10"
|
|
70
|
-
: "hover:border-as-brand/50 hover:bg-as-brand/5"), children: [(0, jsx_runtime_1.jsx)("div", { className: "flex h-12 w-12 items-center justify-center rounded-full bg-blue-600 text-2xl text-white", children: method.id === FiatPaymentMethod.COINBASE_PAY
|
|
86
|
+
: "hover:border-as-brand/50 hover:bg-as-brand/5"), children: [(0, jsx_runtime_1.jsx)("div", { className: "flex h-12 w-12 items-center justify-center rounded-full bg-blue-600 text-2xl text-white", children: method.id === FiatPaymentMethod.COINBASE_PAY
|
|
87
|
+
? "C"
|
|
88
|
+
: method.id === FiatPaymentMethod.STRIPE || method.id === FiatPaymentMethod.STRIPE_WEB2
|
|
89
|
+
? "S"
|
|
90
|
+
: "?" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-1 flex-col items-start text-left", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-primary text-base font-semibold", children: method.name }), method.badge && ((0, jsx_runtime_1.jsx)("span", { className: (0, cn_1.cn)("rounded-full px-2 py-1 text-xs font-medium", method.badgeColor), children: method.badge }))] }), (0, jsx_runtime_1.jsx)("span", { className: "text-as-primary/60 text-sm", children: method.description })] }), selectedPaymentMethod === method.id && (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "text-as-brand h-5 w-5" })] }, method.id)))) })] }) }));
|
|
71
91
|
}
|
|
@@ -9,13 +9,11 @@ const utils_1 = require("../../../../shared/utils");
|
|
|
9
9
|
const formatAddress_1 = require("../../../../shared/utils/formatAddress");
|
|
10
10
|
const lucide_react_1 = require("lucide-react");
|
|
11
11
|
const react_3 = require("react");
|
|
12
|
-
const FeatureFlagsContext_1 = require("../../contexts/FeatureFlagsContext");
|
|
13
12
|
const FiatPaymentMethod_1 = require("./FiatPaymentMethod");
|
|
14
13
|
const OrderTokenAmountFiat_1 = require("./OrderTokenAmountFiat");
|
|
15
14
|
const PointsBadge_1 = require("./PointsBadge");
|
|
16
15
|
const ONE_CHAR_WIDTH = 30;
|
|
17
16
|
function PanelOnramp({ srcAmountOnRamp, setSrcAmountOnRamp, selectedPaymentMethod, setActivePanel, _recipientAddress, destinationToken, destinationChainId, destinationAmount, onDestinationTokenChange, onDestinationChainChange, fiatPaymentMethodIndex, recipientSelectionPanelIndex, dstTokenSymbol, hideDstToken = false, anyspendQuote, onShowPointsDetail, onShowFeeDetail, customUsdInputValues = ["5", "10", "20", "25"], }) {
|
|
18
|
-
const featureFlags = (0, FeatureFlagsContext_1.useFeatureFlags)();
|
|
19
17
|
// Helper function to get fees from anyspend quote
|
|
20
18
|
const getFeeFromApi = (paymentMethod) => {
|
|
21
19
|
// Try to get fee from anyspend quote first (most accurate)
|
|
@@ -41,10 +39,14 @@ function PanelOnramp({ srcAmountOnRamp, setSrcAmountOnRamp, selectedPaymentMetho
|
|
|
41
39
|
// Helper function to get total amount from API (for Stripe) or calculate it (for others)
|
|
42
40
|
const getTotalAmount = (paymentMethod) => {
|
|
43
41
|
const baseAmount = parseFloat(srcAmountOnRamp) || 5;
|
|
44
|
-
//
|
|
42
|
+
// For stripeweb2_fee, use the originalAmount
|
|
45
43
|
if (anyspendQuote?.data?.fee?.type === "stripeweb2_fee") {
|
|
46
44
|
return Number(anyspendQuote.data.fee.originalAmount) / 1e6; // Convert from wei to USD
|
|
47
45
|
}
|
|
46
|
+
// Use currencyIn.amountUsd from quote when available (includes fees, most accurate for custom orders)
|
|
47
|
+
if (anyspendQuote?.data?.currencyIn?.amountUsd) {
|
|
48
|
+
return Number(anyspendQuote.data.currencyIn.amountUsd);
|
|
49
|
+
}
|
|
48
50
|
const fee = getFeeFromApi(paymentMethod);
|
|
49
51
|
// For Coinbase or when fee is available, calculate manually
|
|
50
52
|
if (fee !== null) {
|
|
@@ -82,9 +84,7 @@ function PanelOnramp({ srcAmountOnRamp, setSrcAmountOnRamp, selectedPaymentMetho
|
|
|
82
84
|
.filter(v => !isNaN(Number(v)))
|
|
83
85
|
.map(value => ((0, jsx_runtime_1.jsxs)("button", { onClick: () => handleQuickAmount(value), className: `bg-as-surface-secondary border-as-border-secondary hover:border-as-border-secondary h-7 w-14 rounded-lg border text-sm font-medium transition-all duration-200 ${srcAmountOnRamp === value
|
|
84
86
|
? "border-as-border-secondary bg-as-surface-secondary"
|
|
85
|
-
: "bg-as-surface-secondary hover:bg-as-surface-secondary"}`, children: ["$", value] }, value))) }), destinationToken && destinationChainId && !hideDstToken && ((0, jsx_runtime_1.jsx)(OrderTokenAmountFiat_1.OrderTokenAmountFiat, { address: _recipientAddress, context: "to", inputValue: destinationAmount || "0", onChangeInput: () => { }, chainId: destinationChainId, setChainId: onDestinationChainChange || (() => { }), token: destinationToken, setToken: onDestinationTokenChange || (() => { }) }))] }), (0, jsx_runtime_1.jsxs)("div", { className: "border-as-border-secondary bg-as-surface-secondary mt-4 flex w-full flex-col gap-3 rounded-xl border p-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex w-full items-center justify-between gap-2", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-tertiarry flex items-center text-sm", children: "Recipient" }), _recipientAddress ? ((0, jsx_runtime_1.jsxs)("button", { className: "text-as-tertiarry flex h-7 items-center gap-1 text-sm transition-colors hover:text-blue-700", onClick: () => setActivePanel(recipientSelectionPanelIndex), children: [(0, jsx_runtime_1.jsx)("span", { className: "text-sm", children: recipientName ? (0, utils_1.formatUsername)(recipientName) : (0, formatAddress_1.formatAddress)(_recipientAddress) }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { size: 16 })] })) : ((0, jsx_runtime_1.jsxs)("button", { className: "text-as-tertiarry flex h-7 items-center gap-1 text-sm transition-colors hover:text-blue-700", onClick: () => setActivePanel(5), children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Wallet, { className: "text-as-brand", size: 16 }), "Select recipient", (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { size: 16 })] }))] }), (0, jsx_runtime_1.jsx)("div", { className: "divider w-full" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between gap-4", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-tertiarry text-sm", children: "Expected to receive" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-wrap items-center justify-end gap-1", children: [(0, jsx_runtime_1.jsxs)("span", { className: "text-as-primary font-semibold", children: [destinationAmount || "0", " ", dstTokenSymbol || destinationToken?.symbol || ""] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-1", children: [(0, jsx_runtime_1.jsxs)("span", { className: "text-as-tertiarry text-sm", children: ["on ", destinationChainId ? chain_1.ALL_CHAINS[destinationChainId]?.name : ""] }), destinationToken && destinationChainId && destinationToken.metadata?.logoURI && ((0, jsx_runtime_1.jsx)("img", { src: chain_1.ALL_CHAINS[destinationChainId]?.logoUrl, alt: "Chain", className: "h-4 w-4 rounded-full" }))] })] })] }), (0, jsx_runtime_1.jsx)("div", { className: "divider w-full" }), (0, jsx_runtime_1.jsx)("div", { className: "", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-1.5", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-tertiarry text-sm", children: "Total" }), anyspendQuote?.data?.fee && onShowFeeDetail && ((0, jsx_runtime_1.jsx)("button", { onClick: onShowFeeDetail, className: "text-as-primary/40 hover:text-as-primary/60 transition-colors", children: (0, jsx_runtime_1.jsx)(lucide_react_1.Info, { className: "h-4 w-4" }) })),
|
|
86
|
-
anyspendQuote?.data?.pointsAmount &&
|
|
87
|
-
anyspendQuote?.data?.pointsAmount > 0 && ((0, jsx_runtime_1.jsx)(PointsBadge_1.PointsBadge, { pointsAmount: anyspendQuote.data.pointsAmount, pointsMultiplier: anyspendQuote.data.pointsMultiplier, onClick: () => onShowPointsDetail?.() }))] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-end gap-0.5", children: [(0, jsx_runtime_1.jsxs)("span", { className: "text-as-primary font-semibold", children: ["$", getTotalAmount(selectedPaymentMethod || FiatPaymentMethod_1.FiatPaymentMethod.NONE).toFixed(2)] }), (() => {
|
|
87
|
+
: "bg-as-surface-secondary hover:bg-as-surface-secondary"}`, children: ["$", value] }, value))) }), destinationToken && destinationChainId && !hideDstToken && ((0, jsx_runtime_1.jsx)(OrderTokenAmountFiat_1.OrderTokenAmountFiat, { address: _recipientAddress, context: "to", inputValue: destinationAmount || "0", onChangeInput: () => { }, chainId: destinationChainId, setChainId: onDestinationChainChange || (() => { }), token: destinationToken, setToken: onDestinationTokenChange || (() => { }) }))] }), (0, jsx_runtime_1.jsxs)("div", { className: "border-as-border-secondary bg-as-surface-secondary mt-4 flex w-full flex-col gap-3 rounded-xl border p-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex w-full items-center justify-between gap-2", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-tertiarry flex items-center text-sm", children: "Recipient" }), _recipientAddress ? ((0, jsx_runtime_1.jsxs)("button", { className: "text-as-tertiarry flex h-7 items-center gap-1 text-sm transition-colors hover:text-blue-700", onClick: () => setActivePanel(recipientSelectionPanelIndex), children: [(0, jsx_runtime_1.jsx)("span", { className: "text-sm", children: recipientName ? (0, utils_1.formatUsername)(recipientName) : (0, formatAddress_1.formatAddress)(_recipientAddress) }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { size: 16 })] })) : ((0, jsx_runtime_1.jsxs)("button", { className: "text-as-tertiarry flex h-7 items-center gap-1 text-sm transition-colors hover:text-blue-700", onClick: () => setActivePanel(5), children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Wallet, { className: "text-as-brand", size: 16 }), "Select recipient", (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { size: 16 })] }))] }), (0, jsx_runtime_1.jsx)("div", { className: "divider w-full" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between gap-4", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-tertiarry text-sm", children: "Expected to receive" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-wrap items-center justify-end gap-1", children: [(0, jsx_runtime_1.jsxs)("span", { className: "text-as-primary font-semibold", children: [destinationAmount || "0", " ", dstTokenSymbol || destinationToken?.symbol || ""] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-1", children: [(0, jsx_runtime_1.jsxs)("span", { className: "text-as-tertiarry text-sm", children: ["on ", destinationChainId ? chain_1.ALL_CHAINS[destinationChainId]?.name : ""] }), destinationToken && destinationChainId && destinationToken.metadata?.logoURI && ((0, jsx_runtime_1.jsx)("img", { src: chain_1.ALL_CHAINS[destinationChainId]?.logoUrl, alt: "Chain", className: "h-4 w-4 rounded-full" }))] })] })] }), (0, jsx_runtime_1.jsx)("div", { className: "divider w-full" }), (0, jsx_runtime_1.jsx)("div", { className: "", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-1.5", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-tertiarry text-sm", children: "Total" }), anyspendQuote?.data?.fee && onShowFeeDetail && ((0, jsx_runtime_1.jsx)("button", { onClick: onShowFeeDetail, className: "text-as-primary/40 hover:text-as-primary/60 transition-colors", children: (0, jsx_runtime_1.jsx)(lucide_react_1.Info, { className: "h-4 w-4" }) })), anyspendQuote?.data?.pointsAmount && anyspendQuote?.data?.pointsAmount > 0 && ((0, jsx_runtime_1.jsx)(PointsBadge_1.PointsBadge, { pointsAmount: anyspendQuote.data.pointsAmount, pointsMultiplier: anyspendQuote.data.pointsMultiplier, onClick: () => onShowPointsDetail?.() }))] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-end gap-0.5", children: [(0, jsx_runtime_1.jsxs)("span", { className: "text-as-primary font-semibold", children: ["$", getTotalAmount(selectedPaymentMethod || FiatPaymentMethod_1.FiatPaymentMethod.NONE).toFixed(2)] }), (() => {
|
|
88
88
|
// For fiat payments, show the fee from the payment method
|
|
89
89
|
const fiatFee = getFeeFromApi(selectedPaymentMethod || FiatPaymentMethod_1.FiatPaymentMethod.NONE);
|
|
90
90
|
if (fiatFee !== null && fiatFee > 0) {
|
|
@@ -18,7 +18,7 @@ function PanelOnrampPayment(props) {
|
|
|
18
18
|
}
|
|
19
19
|
function PanelOnrampPaymentInner(props) {
|
|
20
20
|
const { srcAmountOnRamp, recipientAddress, isBuyMode, destinationTokenChainId, destinationTokenAddress, selectedDstChainId, selectedDstToken, anyspendQuote, globalAddress, onOrderCreated, onBack, orderType, nft, tournament, payload, recipientEnsName, recipientImageUrl, } = props;
|
|
21
|
-
const { geoData, coinbaseOnrampOptions, coinbaseAvailablePaymentMethods, stripeWeb2Support, isLoading: isLoadingGeoOnramp, } = (0, react_1.useGeoOnrampOptions)(srcAmountOnRamp);
|
|
21
|
+
const { geoData, coinbaseOnrampOptions, coinbaseAvailablePaymentMethods, stripeOnrampSupport, stripeWeb2Support, isLoading: isLoadingGeoOnramp, } = (0, react_1.useGeoOnrampOptions)(srcAmountOnRamp);
|
|
22
22
|
const isLoading = isLoadingGeoOnramp;
|
|
23
23
|
const { createOrder, isCreatingOrder } = (0, react_1.useAnyspendCreateOnrampOrder)({
|
|
24
24
|
onSuccess: data => {
|
|
@@ -97,7 +97,9 @@ function PanelOnrampPaymentInner(props) {
|
|
|
97
97
|
? "Receive NFT at"
|
|
98
98
|
: orderType === "join_tournament"
|
|
99
99
|
? "Join for"
|
|
100
|
-
: "Recipient" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2", children: [recipientImageUrl && ((0, jsx_runtime_1.jsx)("img", { src: recipientImageUrl, alt: recipientImageUrl, className: "bg-b3-react-foreground size-7 rounded-full object-cover opacity-100" })), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-end gap-1", children: [recipientEnsName && (0, jsx_runtime_1.jsxs)("span", { className: "text-b3-react-foreground/80", children: ["@", recipientEnsName] }), (0, jsx_runtime_1.jsx)("span", { className: "text-b3-react-foreground/80", children: (0, centerTruncate_1.default)(recipientAddress) })] })] })] })), (0, jsx_runtime_1.jsx)("div", { className: "border-b3-react-border border-t pt-3", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("p", { className: "text-b3-react-foreground font-semibold", children: "Amount" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-end gap-0.5", children: [(0, jsx_runtime_1.jsxs)("p", { className: "text-b3-react-foreground hover:text-b3-react-foreground/80 cursor-pointer text-xl font-semibold transition-colors", onClick: onBack, children: ["$", parseFloat(srcAmountOnRamp).toFixed(2)] }), anyspendQuote?.data?.fee?.type === "standard_fee" &&
|
|
100
|
+
: "Recipient" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2", children: [recipientImageUrl && ((0, jsx_runtime_1.jsx)("img", { src: recipientImageUrl, alt: recipientImageUrl, className: "bg-b3-react-foreground size-7 rounded-full object-cover opacity-100" })), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-end gap-1", children: [recipientEnsName && (0, jsx_runtime_1.jsxs)("span", { className: "text-b3-react-foreground/80", children: ["@", recipientEnsName] }), (0, jsx_runtime_1.jsx)("span", { className: "text-b3-react-foreground/80", children: (0, centerTruncate_1.default)(recipientAddress) })] })] })] })), (0, jsx_runtime_1.jsx)("div", { className: "border-b3-react-border border-t pt-3", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("p", { className: "text-b3-react-foreground font-semibold", children: "Amount" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-end gap-0.5", children: [(0, jsx_runtime_1.jsxs)("p", { className: "text-b3-react-foreground hover:text-b3-react-foreground/80 cursor-pointer text-xl font-semibold transition-colors", onClick: onBack, children: ["$", parseFloat(srcAmountOnRamp).toFixed(2)] }), anyspendQuote?.data?.fee?.type === "standard_fee" &&
|
|
101
|
+
anyspendQuote.data.currencyIn?.amountUsd &&
|
|
102
|
+
anyspendQuote.data.fee.finalFeeBps > 0 && ((0, jsx_runtime_1.jsxs)("p", { className: "text-b3-react-foreground/60 text-xs", children: ["incl. $", ((Number(anyspendQuote.data.currencyIn.amountUsd) * anyspendQuote.data.fee.finalFeeBps) /
|
|
101
103
|
10000).toFixed(2), " ", "fee"] }))] })] }) })] })] }), isCreatingOrder ? ((0, jsx_runtime_1.jsxs)("div", { className: "bg-b3-react-background border-b3-react-border flex items-center justify-center gap-3 rounded-lg border p-6", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "h-4 w-4 animate-spin" }), (0, jsx_runtime_1.jsx)("span", { className: "text-as-primary/70", children: "Creating onramp order..." })] })) : isLoading ? ((0, jsx_runtime_1.jsxs)("div", { className: "bg-b3-react-background border-b3-react-border flex items-center justify-center gap-3 rounded-lg border p-6", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "h-4 w-4 animate-spin" }), (0, jsx_runtime_1.jsx)("span", { className: "text-as-primary/70", children: "Loading payment options..." })] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "mb-3 flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("h2", { className: "text-lg font-semibold", children: "Payment method" }), (0, jsx_runtime_1.jsx)("div", { className: "flex items-center gap-1", children: coinbaseAvailablePaymentMethods.length > 0 &&
|
|
102
104
|
(() => {
|
|
103
105
|
const hasCard = coinbaseAvailablePaymentMethods.some(m => m.id === "CARD");
|
|
@@ -108,5 +110,5 @@ function PanelOnrampPaymentInner(props) {
|
|
|
108
110
|
(() => {
|
|
109
111
|
const method = coinbaseAvailablePaymentMethods[0];
|
|
110
112
|
return ((0, jsx_runtime_1.jsxs)("button", { onClick: () => handlePaymentMethodClick("coinbase", method.id), disabled: isCreatingOrder, className: "bg-b3-react-background border-b3-react-border hover:border-as-brand disabled:hover:border-b3-react-border group flex w-full items-center justify-between gap-4 rounded-xl border p-5 transition-all duration-200 hover:shadow-md disabled:cursor-not-allowed disabled:opacity-50", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-4", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex h-12 w-12 items-center justify-center rounded-full bg-blue-50", children: (0, jsx_runtime_1.jsx)("img", { src: "https://cdn.b3.fun/coinbase-wordmark-blue.svg", alt: "Coinbase", className: "h-6" }) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-start text-left", children: [(0, jsx_runtime_1.jsx)("h4", { className: "text-b3-react-foreground text-lg font-semibold", children: "Coinbase Pay" }), (0, jsx_runtime_1.jsxs)("p", { className: "text-b3-react-foreground/60 text-sm", children: [method.id === "CARD" && "Debit card, bank account, or Coinbase Account", method.id === "FIAT_WALLET" && "Pay with your Coinbase account balance", method.id === "APPLE_PAY" && "Quick payment with Apple Pay", method.id === "ACH_BANK_ACCOUNT" && "Direct bank account transfer"] }), (0, jsx_runtime_1.jsx)("div", { className: "mt-1 flex items-center gap-1", children: (0, jsx_runtime_1.jsx)("span", { className: "text-xs font-medium text-green-600", children: "Free" }) })] })] }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "text-b3-react-foreground/40 group-hover:text-b3-react-foreground/60 h-5 w-5 transition-colors" })] }));
|
|
111
|
-
})(),
|
|
113
|
+
})(), stripeOnrampSupport && ((0, jsx_runtime_1.jsxs)("button", { onClick: () => handlePaymentMethodClick("stripe"), className: "bg-b3-react-background border-b3-react-border hover:border-as-brand group flex w-full items-center justify-between gap-4 rounded-xl border p-5 transition-all duration-200 hover:shadow-md", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-4", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex h-12 w-12 items-center justify-center rounded-full bg-purple-50", children: (0, jsx_runtime_1.jsx)("img", { src: "https://raw.githubusercontent.com/stripe/stripe.github.io/455f506a628dc3f6c505e3001db45a64e29e9fc3/images/stripe-logo.svg", alt: "Stripe", className: "h-5" }) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-start text-left", children: [(0, jsx_runtime_1.jsx)("h4", { className: "text-b3-react-foreground text-lg font-semibold", children: "Credit/Debit Card" }), (0, jsx_runtime_1.jsx)("p", { className: "text-b3-react-foreground/60 text-sm", children: "Pay via Stripe checkout" }), stripeWeb2Support?.isSupport && stripeWeb2Support.formattedFeeUsd && ((0, jsx_runtime_1.jsx)("div", { className: "mt-1", children: (0, jsx_runtime_1.jsxs)("span", { className: "text-xs text-gray-500", children: ["$", Number(stripeWeb2Support.formattedFeeUsd).toFixed(2), " fee"] }) }))] })] }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "text-b3-react-foreground/40 group-hover:text-b3-react-foreground/60 h-5 w-5 transition-colors" })] })), stripeWeb2Support.isSupport && ((0, jsx_runtime_1.jsxs)("button", { onClick: () => handlePaymentMethodClick("stripe-web2"), className: "bg-b3-react-background border-b3-react-border hover:border-as-brand group flex w-full items-center justify-between gap-4 rounded-xl border p-5 transition-all duration-200 hover:shadow-md", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-4", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex h-12 w-12 items-center justify-center rounded-full bg-purple-50", children: (0, jsx_runtime_1.jsx)("img", { src: "https://raw.githubusercontent.com/stripe/stripe.github.io/455f506a628dc3f6c505e3001db45a64e29e9fc3/images/stripe-logo.svg", alt: "Stripe", className: "h-5" }) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-start text-left", children: [(0, jsx_runtime_1.jsx)("h4", { className: "text-b3-react-foreground text-lg font-semibold", children: "Quick Pay" }), (0, jsx_runtime_1.jsx)("p", { className: "text-b3-react-foreground/60 text-sm", children: "Credit or debit card" }), stripeWeb2Support.formattedFeeUsd && ((0, jsx_runtime_1.jsx)("div", { className: "mt-1", children: (0, jsx_runtime_1.jsxs)("span", { className: "text-xs text-gray-500", children: ["$", Number(stripeWeb2Support.formattedFeeUsd).toFixed(2), " fee"] }) }))] })] }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "text-b3-react-foreground/40 group-hover:text-b3-react-foreground/60 h-5 w-5 transition-colors" })] })), (0, jsx_runtime_1.jsxs)(react_2.Button, { variant: "link", onClick: onBack, className: "text-b3-react-foreground/70 hover:text-b3-react-foreground/90 mt-2 w-full", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.ChevronLeft, { className: "mr-2 h-4 w-4" }), "Back"] })] })] }))] }));
|
|
112
114
|
}
|
|
@@ -30,6 +30,7 @@ export declare function useGeoOnrampOptions(srcFiatAmount: string): {
|
|
|
30
30
|
min?: string;
|
|
31
31
|
max?: string;
|
|
32
32
|
}[];
|
|
33
|
+
stripeOnrampSupport: boolean;
|
|
33
34
|
stripeWeb2Support: {
|
|
34
35
|
isSupport: false;
|
|
35
36
|
} | {
|
|
@@ -38,14 +39,7 @@ export declare function useGeoOnrampOptions(srcFiatAmount: string): {
|
|
|
38
39
|
formattedOnrampUsd: string;
|
|
39
40
|
formattedFeeUsd: string;
|
|
40
41
|
};
|
|
41
|
-
isOnrampSupported:
|
|
42
|
-
isSupport: false;
|
|
43
|
-
} | {
|
|
44
|
-
isSupport: true;
|
|
45
|
-
formattedTotalUsd: string;
|
|
46
|
-
formattedOnrampUsd: string;
|
|
47
|
-
formattedFeeUsd: string;
|
|
48
|
-
};
|
|
42
|
+
isOnrampSupported: boolean;
|
|
49
43
|
isLoading: boolean | undefined;
|
|
50
44
|
isLoadingGeo: boolean;
|
|
51
45
|
isLoadingCoinbaseOnrampOptions: boolean;
|
|
@@ -16,7 +16,7 @@ function useGeoOnrampOptions(srcFiatAmount) {
|
|
|
16
16
|
// Use existing hooks
|
|
17
17
|
const { geoData, loading: isLoadingGeo, error: geoError } = (0, useGetGeo_1.useGetGeo)();
|
|
18
18
|
const { coinbaseOnrampOptions, isLoadingCoinbaseOnrampOptions, coinbaseOnrampOptionsError } = (0, useCoinbaseOnrampOptions_1.useCoinbaseOnrampOptions)(geoData?.country, visitorData);
|
|
19
|
-
const { stripeWeb2Support, isLoadingStripeSupport, stripeSupportError } = (0, useStripeSupport_1.useStripeSupport)(srcFiatAmount, visitorData);
|
|
19
|
+
const { stripeOnrampSupport, stripeWeb2Support, isLoadingStripeSupport, stripeSupportError } = (0, useStripeSupport_1.useStripeSupport)(srcFiatAmount, visitorData);
|
|
20
20
|
// Calculate available payment methods based on the amount
|
|
21
21
|
const coinbaseAvailablePaymentMethods = (0, react_1.useMemo)(() => {
|
|
22
22
|
if (!coinbaseOnrampOptions?.paymentCurrencies?.[0]?.limits || !srcFiatAmount)
|
|
@@ -34,8 +34,9 @@ function useGeoOnrampOptions(srcFiatAmount) {
|
|
|
34
34
|
geoData,
|
|
35
35
|
coinbaseOnrampOptions,
|
|
36
36
|
coinbaseAvailablePaymentMethods,
|
|
37
|
+
stripeOnrampSupport,
|
|
37
38
|
stripeWeb2Support,
|
|
38
|
-
isOnrampSupported: coinbaseAvailablePaymentMethods.length > 0 || stripeWeb2Support,
|
|
39
|
+
isOnrampSupported: coinbaseAvailablePaymentMethods.length > 0 || stripeOnrampSupport || stripeWeb2Support.isSupport,
|
|
39
40
|
isLoading: isLoadingGeo || isLoadingCoinbaseOnrampOptions || isLoadingStripeSupport || isLoadingVisitorData,
|
|
40
41
|
isLoadingGeo,
|
|
41
42
|
isLoadingCoinbaseOnrampOptions,
|
|
@@ -47,6 +48,7 @@ function useGeoOnrampOptions(srcFiatAmount) {
|
|
|
47
48
|
geoData,
|
|
48
49
|
coinbaseOnrampOptions,
|
|
49
50
|
coinbaseAvailablePaymentMethods,
|
|
51
|
+
stripeOnrampSupport,
|
|
50
52
|
stripeWeb2Support,
|
|
51
53
|
isLoadingGeo,
|
|
52
54
|
isLoadingCoinbaseOnrampOptions,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { VisitorData } from "../../../anyspend/types/fingerprint";
|
|
2
2
|
export declare function useStripeSupport(usdAmount?: string, visitorData?: VisitorData, isLoadingVisitorData?: boolean): {
|
|
3
|
+
stripeOnrampSupport: boolean;
|
|
3
4
|
stripeWeb2Support: {
|
|
4
5
|
isSupport: false;
|
|
5
6
|
} | {
|
|
@@ -11,6 +11,7 @@ function useStripeSupport(usdAmount, visitorData, isLoadingVisitorData) {
|
|
|
11
11
|
enabled: !isLoadingVisitorData,
|
|
12
12
|
});
|
|
13
13
|
return (0, react_1.useMemo)(() => ({
|
|
14
|
+
stripeOnrampSupport: data?.stripeOnramp || false,
|
|
14
15
|
stripeWeb2Support: data?.stripeWeb2 || { isSupport: false },
|
|
15
16
|
isLoadingStripeSupport: isLoading,
|
|
16
17
|
stripeSupportError: error,
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.IPFSMediaRenderer = IPFSMediaRenderer;
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const ipfs_1 = require("../../../../shared/utils/ipfs");
|
|
6
7
|
const thirdweb_1 = require("../../../../shared/utils/thirdweb");
|
|
7
8
|
const react_1 = require("thirdweb/react");
|
|
8
9
|
/**
|
|
@@ -28,7 +29,8 @@ function IPFSMediaRenderer({ src, alt = "Media", className, client = thirdweb_1.
|
|
|
28
29
|
if (!src) {
|
|
29
30
|
return ((0, jsx_runtime_1.jsx)("div", { className: className, style: style, "aria-label": alt, children: (0, jsx_runtime_1.jsx)("div", { className: "bg-b3-primary-wash flex h-full w-full items-center justify-center rounded-full", children: (0, jsx_runtime_1.jsx)("span", { className: "text-b3-grey font-neue-montreal-semibold text-xs", children: alt.charAt(0).toUpperCase() }) }) }));
|
|
30
31
|
}
|
|
31
|
-
// Convert IPFS URLs to HTTP gateway URLs
|
|
32
|
-
// This
|
|
33
|
-
|
|
32
|
+
// Convert IPFS URLs to HTTP gateway URLs using our preferred gateway
|
|
33
|
+
// This avoids Thirdweb's default cloudflare-ipfs.com which can be unreliable
|
|
34
|
+
const resolvedSrc = src.startsWith("ipfs://") ? (0, ipfs_1.getIpfsUrl)(src) : src;
|
|
35
|
+
return ((0, jsx_runtime_1.jsx)(react_1.MediaRenderer, { src: resolvedSrc, client: client, alt: alt, className: className, width: width ? width.toString() : undefined, height: height ? height.toString() : undefined, controls: controls, style: style }));
|
|
34
36
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Converts an IPFS URL to a gateway URL
|
|
3
3
|
* @param ipfsUrl - URL in format ipfs://CID/path or just the CID
|
|
4
|
-
* @param gatewayIndex - Optional index to specify which gateway to use (0:
|
|
4
|
+
* @param gatewayIndex - Optional index to specify which gateway to use (0: dweb.link, 1: w3s.link, etc.)
|
|
5
5
|
* @returns HTTP URL using the specified IPFS gateway
|
|
6
6
|
* @example
|
|
7
|
-
* // returns 'https://
|
|
7
|
+
* // returns 'https://dweb.link/ipfs/QmUbJ4p.../2.png'
|
|
8
8
|
* getIpfsUrl('ipfs://QmUbJ4pnHMNXGeWWhBFFSEqCGuc6cEtDyz35wQfv7k2TXy/2.png')
|
|
9
|
-
* // returns 'https://
|
|
9
|
+
* // returns 'https://w3s.link/ipfs/QmUbJ4p.../2.png'
|
|
10
10
|
* getIpfsUrl('ipfs://QmUbJ4pnHMNXGeWWhBFFSEqCGuc6cEtDyz35wQfv7k2TXy/2.png', 1)
|
|
11
11
|
*/
|
|
12
12
|
export declare function getIpfsUrl(ipfsUrl: string, gatewayIndex?: number): string;
|
|
@@ -6,22 +6,22 @@ exports.getIpfsUrl = getIpfsUrl;
|
|
|
6
6
|
* These gateways must match the allowed list in profileDisplay.ts validateImageUrl()
|
|
7
7
|
*/
|
|
8
8
|
const IPFS_GATEWAYS = [
|
|
9
|
-
"https://
|
|
9
|
+
"https://dweb.link/ipfs", // Primary gateway - Protocol Labs maintained
|
|
10
|
+
"https://w3s.link/ipfs", // web3.storage gateway - reliable
|
|
11
|
+
"https://nftstorage.link/ipfs", // NFT.storage gateway
|
|
12
|
+
"https://gateway.pinata.cloud/ipfs", // Pinata gateway
|
|
10
13
|
"https://ipfs.io/ipfs", // Fallback gateway
|
|
11
|
-
"https://
|
|
12
|
-
"https://dweb.link/ipfs", // Additional option
|
|
13
|
-
"https://nftstorage.link/ipfs", // Additional option
|
|
14
|
-
"https://w3s.link/ipfs", // Additional option
|
|
14
|
+
"https://cloudflare-ipfs.com/ipfs", // Cloudflare gateway (can be slow/unreliable)
|
|
15
15
|
];
|
|
16
16
|
/**
|
|
17
17
|
* Converts an IPFS URL to a gateway URL
|
|
18
18
|
* @param ipfsUrl - URL in format ipfs://CID/path or just the CID
|
|
19
|
-
* @param gatewayIndex - Optional index to specify which gateway to use (0:
|
|
19
|
+
* @param gatewayIndex - Optional index to specify which gateway to use (0: dweb.link, 1: w3s.link, etc.)
|
|
20
20
|
* @returns HTTP URL using the specified IPFS gateway
|
|
21
21
|
* @example
|
|
22
|
-
* // returns 'https://
|
|
22
|
+
* // returns 'https://dweb.link/ipfs/QmUbJ4p.../2.png'
|
|
23
23
|
* getIpfsUrl('ipfs://QmUbJ4pnHMNXGeWWhBFFSEqCGuc6cEtDyz35wQfv7k2TXy/2.png')
|
|
24
|
-
* // returns 'https://
|
|
24
|
+
* // returns 'https://w3s.link/ipfs/QmUbJ4p.../2.png'
|
|
25
25
|
* getIpfsUrl('ipfs://QmUbJ4pnHMNXGeWWhBFFSEqCGuc6cEtDyz35wQfv7k2TXy/2.png', 1)
|
|
26
26
|
*/
|
|
27
27
|
function getIpfsUrl(ipfsUrl, gatewayIndex = 0) {
|