@b3dotfun/sdk 0.0.72 → 0.0.73-alpha.1
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.d.ts +9 -1
- package/dist/cjs/anyspend/react/components/AnySpendCollectorClubPurchase.js +3 -1
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +6 -5
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +3 -2
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOrder.d.ts +1 -0
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOrder.js +3 -2
- package/dist/cjs/anyspend/react/hooks/useValidatedClientReferenceId.d.ts +3 -1
- package/dist/cjs/anyspend/react/hooks/useValidatedClientReferenceId.js +3 -3
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +4 -2
- package/dist/cjs/global-account/react/components/B3Provider/types.d.ts +3 -1
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +4 -0
- package/dist/esm/anyspend/react/components/AnySpendCollectorClubPurchase.d.ts +9 -1
- package/dist/esm/anyspend/react/components/AnySpendCollectorClubPurchase.js +3 -1
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +7 -6
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +3 -2
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOrder.d.ts +1 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOrder.js +3 -2
- package/dist/esm/anyspend/react/hooks/useValidatedClientReferenceId.d.ts +3 -1
- package/dist/esm/anyspend/react/hooks/useValidatedClientReferenceId.js +4 -4
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +4 -2
- package/dist/esm/global-account/react/components/B3Provider/types.d.ts +3 -1
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +4 -0
- package/dist/types/anyspend/react/components/AnySpendCollectorClubPurchase.d.ts +9 -1
- package/dist/types/anyspend/react/hooks/useAnyspendCreateOrder.d.ts +1 -0
- package/dist/types/anyspend/react/hooks/useValidatedClientReferenceId.d.ts +3 -1
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +4 -2
- package/dist/types/global-account/react/components/B3Provider/types.d.ts +3 -1
- package/dist/types/global-account/react/stores/useModalStore.d.ts +4 -0
- package/package.json +1 -1
- package/src/anyspend/react/components/AnySpendCollectorClubPurchase.tsx +12 -0
- package/src/anyspend/react/components/AnySpendCustom.tsx +77 -72
- package/src/anyspend/react/hooks/useAnyspendCreateOnrampOrder.ts +4 -2
- package/src/anyspend/react/hooks/useAnyspendCreateOrder.ts +4 -2
- package/src/anyspend/react/hooks/useValidatedClientReferenceId.ts +28 -23
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +4 -2
- package/src/global-account/react/components/B3Provider/types.ts +3 -1
- package/src/global-account/react/stores/useModalStore.ts +4 -0
|
@@ -53,5 +53,13 @@ export interface AnySpendCollectorClubPurchaseProps {
|
|
|
53
53
|
* Show recipient selection (default: true)
|
|
54
54
|
*/
|
|
55
55
|
showRecipient?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* The vending machine ID
|
|
58
|
+
*/
|
|
59
|
+
vendingMachineId: string;
|
|
60
|
+
/**
|
|
61
|
+
* The partner ID
|
|
62
|
+
*/
|
|
63
|
+
packType: string;
|
|
56
64
|
}
|
|
57
|
-
export declare function AnySpendCollectorClubPurchase({ loadOrder, mode, activeTab, packId, packAmount, pricePerPack, paymentToken, recipientAddress, spenderAddress, onSuccess, header, showRecipient, }: AnySpendCollectorClubPurchaseProps): import("react/jsx-runtime").JSX.Element;
|
|
65
|
+
export declare function AnySpendCollectorClubPurchase({ loadOrder, mode, activeTab, packId, packAmount, pricePerPack, paymentToken, recipientAddress, spenderAddress, onSuccess, header, showRecipient, vendingMachineId, packType, }: AnySpendCollectorClubPurchaseProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -47,7 +47,7 @@ const BUY_PACKS_FOR_ABI = {
|
|
|
47
47
|
stateMutability: "nonpayable",
|
|
48
48
|
type: "function",
|
|
49
49
|
};
|
|
50
|
-
function AnySpendCollectorClubPurchase({ loadOrder, mode = "modal", activeTab = "crypto", packId, packAmount, pricePerPack, paymentToken = constants_1.USDC_BASE, recipientAddress, spenderAddress = CC_SHOP_ADDRESS, onSuccess, header, showRecipient = true, }) {
|
|
50
|
+
function AnySpendCollectorClubPurchase({ loadOrder, mode = "modal", activeTab = "crypto", packId, packAmount, pricePerPack, paymentToken = constants_1.USDC_BASE, recipientAddress, spenderAddress = CC_SHOP_ADDRESS, onSuccess, header, showRecipient = true, vendingMachineId, packType, }) {
|
|
51
51
|
// Calculate total amount needed (pricePerPack * packAmount)
|
|
52
52
|
const totalAmount = (0, react_1.useMemo)(() => {
|
|
53
53
|
try {
|
|
@@ -78,5 +78,7 @@ function AnySpendCollectorClubPurchase({ loadOrder, mode = "modal", activeTab =
|
|
|
78
78
|
packId,
|
|
79
79
|
packAmount,
|
|
80
80
|
pricePerPack,
|
|
81
|
+
vendingMachineId,
|
|
82
|
+
packType,
|
|
81
83
|
}, header: header || defaultHeader, onSuccess: onSuccess, showRecipient: showRecipient }));
|
|
82
84
|
}
|
|
@@ -371,6 +371,7 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
371
371
|
to: contractAddress,
|
|
372
372
|
}
|
|
373
373
|
: undefined,
|
|
374
|
+
metadata,
|
|
374
375
|
};
|
|
375
376
|
if (onramp) {
|
|
376
377
|
const effectiveSrcToken = activeTab === "fiat" ? constants_1.USDC_BASE : srcToken;
|
|
@@ -482,7 +483,7 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
482
483
|
? "Receive NFT at"
|
|
483
484
|
: orderType === "join_tournament"
|
|
484
485
|
? "Join for"
|
|
485
|
-
: "Recipient" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2", children: [recipientAddress ? ((0, jsx_runtime_1.jsx)("button", { className: (0, utils_1.cn)("text-as-tertiarry flex
|
|
486
|
+
: "Recipient" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-wrap items-center justify-end gap-2", children: [recipientAddress ? ((0, jsx_runtime_1.jsx)("button", { className: (0, utils_1.cn)("text-as-tertiarry flex items-center gap-2 rounded-lg"), onClick: () => setActivePanel(PanelView.RECIPIENT_SELECTION), children: (0, jsx_runtime_1.jsx)("div", { className: "text-as-tertiarry flex items-center gap-1 text-sm", children: (0, jsx_runtime_1.jsx)("span", { className: "whitespace-nowrap", children: recipientName ? (0, utils_1.formatUsername)(recipientName) : (0, formatAddress_1.shortenAddress)(recipientAddress) }) }) })) : ((0, jsx_runtime_1.jsx)("button", { className: "text-as-primary/70 flex items-center gap-1 rounded-lg", onClick: () => setActivePanel(PanelView.RECIPIENT_SELECTION), children: (0, jsx_runtime_1.jsx)("div", { className: "whitespace-nowrap text-sm font-medium", children: "Select recipient" }) })), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4 shrink-0" })] })] }, recipientAddress)) : null;
|
|
486
487
|
const historyView = ((0, jsx_runtime_1.jsx)("div", { className: (0, utils_1.cn)("mx-auto flex w-full max-w-2xl flex-col items-center p-5", mode === "modal" && "bg-b3-react-background"), children: (0, jsx_runtime_1.jsx)(OrderHistory_1.OrderHistory, { mode: mode, onBack: () => {
|
|
487
488
|
setActivePanel(PanelView.HISTORY);
|
|
488
489
|
}, onSelectOrder: onSelectOrder }) }));
|
|
@@ -525,7 +526,7 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
525
526
|
opacity: hasMounted ? 1 : 0,
|
|
526
527
|
y: hasMounted ? 0 : 20,
|
|
527
528
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
528
|
-
}, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-tertiarry flex h-7 items-center text-sm", children: "Pay" }), (0, jsx_runtime_1.jsx)("button", { className: "text-as-tertiarry flex
|
|
529
|
+
}, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-tertiarry flex h-7 items-center text-sm", children: "Pay" }), (0, jsx_runtime_1.jsx)("button", { className: "text-as-tertiarry flex flex-wrap items-center justify-end gap-2 text-sm transition-colors hover:text-blue-700", onClick: () => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD), children: effectiveCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.CONNECT_WALLET ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [connectedAddress ? ((0, jsx_runtime_1.jsx)("span", { className: "text-as-tertiarry whitespace-nowrap", children: connectedName ? (0, utils_1.formatUsername)(connectedName) : (0, formatAddress_1.shortenAddress)(connectedAddress || "") })) : ((0, jsx_runtime_1.jsx)("span", { className: "whitespace-nowrap", children: "Connect wallet" })), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4 shrink-0" })] })) : effectiveCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.TRANSFER_CRYPTO ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { className: "whitespace-nowrap", children: "Transfer crypto" }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4 shrink-0" })] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { className: "whitespace-nowrap", children: "Select payment method" }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4 shrink-0" })] })) })] }), (0, jsx_runtime_1.jsx)("div", { className: "divider w-full" }), recipientSection, (0, jsx_runtime_1.jsx)("div", { className: "divider w-full" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-4", children: [(0, jsx_runtime_1.jsxs)(react_3.motion.div, { initial: false, animate: {
|
|
529
530
|
opacity: hasMounted ? 1 : 0,
|
|
530
531
|
y: hasMounted ? 0 : 20,
|
|
531
532
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
@@ -536,7 +537,7 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
536
537
|
opacity: hasMounted ? 1 : 0,
|
|
537
538
|
y: hasMounted ? 0 : 20,
|
|
538
539
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
539
|
-
}, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between", children: [(0, jsx_runtime_1.jsxs)("
|
|
540
|
+
}, 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: "(with fee)" })] }), 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.jsxs)("span", { className: "text-as-primary whitespace-nowrap font-semibold", children: [formattedSrcAmount || "--", " ", srcToken.symbol] })] }), anyspendQuote?.data?.fee?.type === "standard_fee" && anyspendQuote.data.currencyIn?.amountUsd && ((0, jsx_runtime_1.jsxs)("span", { className: "text-as-secondary text-xs", children: ["incl. $", ((Number(anyspendQuote.data.currencyIn.amountUsd) * anyspendQuote.data.fee.finalFeeBps) /
|
|
540
541
|
10000).toFixed(2), " ", "fee"] }))] })] })] })] }), (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_3.motion.div, { initial: false, animate: {
|
|
541
542
|
opacity: hasMounted ? 1 : 0,
|
|
542
543
|
y: hasMounted ? 0 : 20,
|
|
@@ -545,11 +546,11 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
545
546
|
opacity: hasMounted ? 1 : 0,
|
|
546
547
|
y: hasMounted ? 0 : 20,
|
|
547
548
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
548
|
-
}, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-tertiarry flex h-7 items-center text-sm", children: "Pay with" }), (0, jsx_runtime_1.jsx)("button", { className: "text-as-tertiarry flex
|
|
549
|
+
}, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-tertiarry flex h-7 items-center text-sm", children: "Pay with" }), (0, jsx_runtime_1.jsx)("button", { className: "text-as-tertiarry flex flex-wrap items-center justify-end gap-2 text-sm transition-colors hover:text-blue-700", onClick: () => setActivePanel(PanelView.FIAT_PAYMENT_METHOD), children: selectedFiatPaymentMethod === FiatPaymentMethod_1.FiatPaymentMethod.COINBASE_PAY ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2 whitespace-nowrap", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-blue-600", children: (0, jsx_runtime_1.jsx)("span", { className: "text-xs font-bold text-white", children: "C" }) }), "Coinbase Pay"] }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4 shrink-0" })] })) : selectedFiatPaymentMethod === FiatPaymentMethod_1.FiatPaymentMethod.STRIPE ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2 whitespace-nowrap", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-blue-600", children: (0, jsx_runtime_1.jsx)("span", { className: "text-xs font-bold text-white", children: "S" }) }), "Credit/Debit Card"] }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4 shrink-0" })] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { className: "whitespace-nowrap", children: "Select payment method" }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4 shrink-0" })] })) })] }), (0, jsx_runtime_1.jsx)("div", { className: "divider w-full" }), recipientSection, (0, jsx_runtime_1.jsx)("div", { className: "divider w-full" }), (0, jsx_runtime_1.jsxs)(react_3.motion.div, { initial: false, animate: {
|
|
549
550
|
opacity: hasMounted ? 1 : 0,
|
|
550
551
|
y: hasMounted ? 0 : 20,
|
|
551
552
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
552
|
-
}, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between", children: [(0, jsx_runtime_1.jsxs)("
|
|
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.jsxs)("span", { className: "text-as-primary whitespace-nowrap text-xl font-semibold", children: ["$", srcFiatAmount || "0.00"] })] }), anyspendQuote?.data?.fee?.type === "stripeweb2_fee" && anyspendQuote.data.fee.originalAmount && ((0, jsx_runtime_1.jsxs)("span", { className: "text-as-secondary text-xs", children: ["incl. $", ((Number(anyspendQuote.data.fee.originalAmount) - Number(anyspendQuote.data.fee.finalAmount)) /
|
|
553
554
|
1e6).toFixed(2), " ", "fee"] }))] })] })] }), (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_3.motion.div, { initial: false, animate: {
|
|
554
555
|
opacity: hasMounted ? 1 : 0,
|
|
555
556
|
y: hasMounted ? 0 : 20,
|
|
@@ -19,7 +19,7 @@ function useAnyspendCreateOnrampOrder({ onSuccess, onError } = {}) {
|
|
|
19
19
|
// Get B3 context values
|
|
20
20
|
const { partnerId } = (0, react_1.useB3)();
|
|
21
21
|
// Get validated client reference ID from B3 context
|
|
22
|
-
const
|
|
22
|
+
const createValidatedClientReferenceId = (0, useValidatedClientReferenceId_1.useValidatedClientReferenceId)();
|
|
23
23
|
// Get fingerprint data
|
|
24
24
|
const { data: fpData } = (0, fingerprintjs_pro_react_1.useVisitorData)({ extendedResult: true }, { immediate: true });
|
|
25
25
|
const visitorData = fpData && {
|
|
@@ -29,6 +29,7 @@ function useAnyspendCreateOnrampOrder({ onSuccess, onError } = {}) {
|
|
|
29
29
|
const { mutate: createOrder, isPending } = (0, react_query_1.useMutation)({
|
|
30
30
|
mutationFn: async (params) => {
|
|
31
31
|
const { recipientAddress, orderType, dstChain, dstToken, srcFiatAmount, onramp, creatorAddress, expectedDstAmount, nft, tournament, payload, } = params;
|
|
32
|
+
const clientReferenceId = await createValidatedClientReferenceId(params);
|
|
32
33
|
try {
|
|
33
34
|
// Validate required onramp fields
|
|
34
35
|
if (!onramp.vendor || !onramp.country) {
|
|
@@ -71,7 +72,7 @@ function useAnyspendCreateOnrampOrder({ onSuccess, onError } = {}) {
|
|
|
71
72
|
}),
|
|
72
73
|
creatorAddress: creatorAddress ? (0, utils_1.normalizeAddress)(creatorAddress) : undefined,
|
|
73
74
|
partnerId,
|
|
74
|
-
clientReferenceId
|
|
75
|
+
clientReferenceId,
|
|
75
76
|
visitorData,
|
|
76
77
|
});
|
|
77
78
|
}
|
|
@@ -17,7 +17,7 @@ function useAnyspendCreateOrder({ onSuccess, onError } = {}) {
|
|
|
17
17
|
// Get B3 context values
|
|
18
18
|
const { partnerId } = (0, react_1.useB3)();
|
|
19
19
|
// Get validated client reference ID from B3 context
|
|
20
|
-
const
|
|
20
|
+
const createValidatedClientReferenceId = (0, useValidatedClientReferenceId_1.useValidatedClientReferenceId)();
|
|
21
21
|
// Get fingerprint data
|
|
22
22
|
const { data: fpData } = (0, fingerprintjs_pro_react_1.useVisitorData)({ extendedResult: true }, { immediate: true });
|
|
23
23
|
const visitorData = fpData && {
|
|
@@ -27,6 +27,7 @@ function useAnyspendCreateOrder({ onSuccess, onError } = {}) {
|
|
|
27
27
|
const { mutate: createOrder, isPending } = (0, react_query_1.useMutation)({
|
|
28
28
|
mutationFn: async (params) => {
|
|
29
29
|
const { recipientAddress, orderType, srcChain, dstChain, srcToken, dstToken, srcAmount, creatorAddress } = params;
|
|
30
|
+
const clientReferenceId = await createValidatedClientReferenceId(params);
|
|
30
31
|
try {
|
|
31
32
|
return await anyspend_1.anyspendService.createOrder({
|
|
32
33
|
recipientAddress: (0, utils_1.normalizeAddress)(recipientAddress),
|
|
@@ -60,7 +61,7 @@ function useAnyspendCreateOrder({ onSuccess, onError } = {}) {
|
|
|
60
61
|
}),
|
|
61
62
|
creatorAddress: creatorAddress ? (0, utils_1.normalizeAddress)(creatorAddress) : undefined,
|
|
62
63
|
partnerId,
|
|
63
|
-
clientReferenceId
|
|
64
|
+
clientReferenceId,
|
|
64
65
|
visitorData,
|
|
65
66
|
});
|
|
66
67
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { CreateOnrampOrderParams } from "./useAnyspendCreateOnrampOrder";
|
|
2
|
+
import { CreateOrderParams } from "./useAnyspendCreateOrder";
|
|
1
3
|
/**
|
|
2
4
|
* Hook that provides a validated client reference ID
|
|
3
5
|
* Gets the createClientReferenceId function from B3 context and validates the result
|
|
4
6
|
*/
|
|
5
|
-
export declare function useValidatedClientReferenceId(): string | undefined
|
|
7
|
+
export declare function useValidatedClientReferenceId(): (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string | undefined>;
|
|
@@ -10,14 +10,14 @@ const react_2 = require("react");
|
|
|
10
10
|
*/
|
|
11
11
|
function useValidatedClientReferenceId() {
|
|
12
12
|
const { createClientReferenceId } = (0, react_1.useB3)();
|
|
13
|
-
const
|
|
13
|
+
const createValidatedClientReferenceId = (0, react_2.useCallback)(async (params) => {
|
|
14
14
|
// If no function provided, return undefined
|
|
15
15
|
if (!createClientReferenceId) {
|
|
16
16
|
return undefined;
|
|
17
17
|
}
|
|
18
18
|
try {
|
|
19
19
|
// Call the function to generate the ID
|
|
20
|
-
const generatedId = createClientReferenceId();
|
|
20
|
+
const generatedId = await createClientReferenceId(params);
|
|
21
21
|
// Validate the generated ID
|
|
22
22
|
const validation = validation_1.Validators.clientReferenceId(generatedId);
|
|
23
23
|
if (!validation.isValid) {
|
|
@@ -31,5 +31,5 @@ function useValidatedClientReferenceId() {
|
|
|
31
31
|
return undefined;
|
|
32
32
|
}
|
|
33
33
|
}, [createClientReferenceId]);
|
|
34
|
-
return
|
|
34
|
+
return createValidatedClientReferenceId;
|
|
35
35
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { CreateOnrampOrderParams } from "../../../../anyspend/react/hooks/useAnyspendCreateOnrampOrder";
|
|
2
|
+
import { CreateOrderParams } from "../../../../anyspend/react/hooks/useAnyspendCreateOrder";
|
|
1
3
|
import { PermissionsConfig } from "../../../../global-account/types/permissions";
|
|
2
4
|
import "@relayprotocol/relay-kit-ui/styles.css";
|
|
3
5
|
import { Account, Wallet } from "thirdweb/wallets";
|
|
@@ -24,7 +26,7 @@ export declare function B3Provider({ theme, children, accountOverride, environme
|
|
|
24
26
|
onConnect?: (wallet: Wallet, b3Jwt: string) => void | Promise<void>;
|
|
25
27
|
connectors?: CreateConnectorFn[];
|
|
26
28
|
overrideDefaultConnectors?: boolean;
|
|
27
|
-
createClientReferenceId?: () => string
|
|
29
|
+
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
28
30
|
}): import("react/jsx-runtime").JSX.Element;
|
|
29
31
|
/**
|
|
30
32
|
* Inner provider component that provides the actual B3Context
|
|
@@ -38,5 +40,5 @@ export declare function InnerProvider({ children, accountOverride, environment,
|
|
|
38
40
|
theme: "light" | "dark";
|
|
39
41
|
clientType?: ClientType;
|
|
40
42
|
partnerId: string;
|
|
41
|
-
createClientReferenceId?: () => string
|
|
43
|
+
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
42
44
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { Users } from "@b3dotfun/b3-api";
|
|
2
|
+
import { CreateOnrampOrderParams } from "../../../../anyspend/react/hooks/useAnyspendCreateOnrampOrder";
|
|
3
|
+
import { CreateOrderParams } from "../../../../anyspend/react/hooks/useAnyspendCreateOrder";
|
|
2
4
|
import { PermissionsConfig } from "../../../../global-account/types/permissions";
|
|
3
5
|
import { Account, Wallet } from "thirdweb/wallets";
|
|
4
6
|
import { ClientType } from "../../../client-manager";
|
|
@@ -20,7 +22,7 @@ export interface B3ContextType {
|
|
|
20
22
|
theme: "light" | "dark";
|
|
21
23
|
clientType: ClientType;
|
|
22
24
|
partnerId: string;
|
|
23
|
-
createClientReferenceId?: () => string
|
|
25
|
+
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
24
26
|
}
|
|
25
27
|
/**
|
|
26
28
|
* Context for B3 provider
|
|
@@ -402,6 +402,10 @@ export interface AnySpendCollectorClubPurchaseProps extends BaseModalProps {
|
|
|
402
402
|
onSuccess?: (txHash?: string) => void;
|
|
403
403
|
/** Client-provided reference ID for tracking orders */
|
|
404
404
|
clientReferenceId?: string;
|
|
405
|
+
/** The vending machine ID */
|
|
406
|
+
vendingMachineId: string;
|
|
407
|
+
/** The pack type */
|
|
408
|
+
packType: string;
|
|
405
409
|
}
|
|
406
410
|
/**
|
|
407
411
|
* Union type of all possible modal content types
|
|
@@ -53,5 +53,13 @@ export interface AnySpendCollectorClubPurchaseProps {
|
|
|
53
53
|
* Show recipient selection (default: true)
|
|
54
54
|
*/
|
|
55
55
|
showRecipient?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* The vending machine ID
|
|
58
|
+
*/
|
|
59
|
+
vendingMachineId: string;
|
|
60
|
+
/**
|
|
61
|
+
* The partner ID
|
|
62
|
+
*/
|
|
63
|
+
packType: string;
|
|
56
64
|
}
|
|
57
|
-
export declare function AnySpendCollectorClubPurchase({ loadOrder, mode, activeTab, packId, packAmount, pricePerPack, paymentToken, recipientAddress, spenderAddress, onSuccess, header, showRecipient, }: AnySpendCollectorClubPurchaseProps): import("react/jsx-runtime").JSX.Element;
|
|
65
|
+
export declare function AnySpendCollectorClubPurchase({ loadOrder, mode, activeTab, packId, packAmount, pricePerPack, paymentToken, recipientAddress, spenderAddress, onSuccess, header, showRecipient, vendingMachineId, packType, }: AnySpendCollectorClubPurchaseProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -44,7 +44,7 @@ const BUY_PACKS_FOR_ABI = {
|
|
|
44
44
|
stateMutability: "nonpayable",
|
|
45
45
|
type: "function",
|
|
46
46
|
};
|
|
47
|
-
export function AnySpendCollectorClubPurchase({ loadOrder, mode = "modal", activeTab = "crypto", packId, packAmount, pricePerPack, paymentToken = USDC_BASE, recipientAddress, spenderAddress = CC_SHOP_ADDRESS, onSuccess, header, showRecipient = true, }) {
|
|
47
|
+
export function AnySpendCollectorClubPurchase({ loadOrder, mode = "modal", activeTab = "crypto", packId, packAmount, pricePerPack, paymentToken = USDC_BASE, recipientAddress, spenderAddress = CC_SHOP_ADDRESS, onSuccess, header, showRecipient = true, vendingMachineId, packType, }) {
|
|
48
48
|
// Calculate total amount needed (pricePerPack * packAmount)
|
|
49
49
|
const totalAmount = useMemo(() => {
|
|
50
50
|
try {
|
|
@@ -75,5 +75,7 @@ export function AnySpendCollectorClubPurchase({ loadOrder, mode = "modal", activ
|
|
|
75
75
|
packId,
|
|
76
76
|
packAmount,
|
|
77
77
|
pricePerPack,
|
|
78
|
+
vendingMachineId,
|
|
79
|
+
packType,
|
|
78
80
|
}, header: header || defaultHeader, onSuccess: onSuccess, showRecipient: showRecipient }));
|
|
79
81
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx,
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { eqci, getDefaultToken, roundUpUSDCBaseAmountToNearest } from "../../../anyspend/index.js";
|
|
3
3
|
import { RELAY_ETH_ADDRESS, USDC_BASE } from "../../../anyspend/constants/index.js";
|
|
4
4
|
import { useAnyspendCreateOnrampOrder, useAnyspendCreateOrder, useAnyspendOrderAndTransactions, useAnyspendQuote, useAnyspendTokenList, useConnectedUserProfile, useGeoOnrampOptions, } from "../../../anyspend/react/index.js";
|
|
@@ -332,6 +332,7 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
332
332
|
to: contractAddress,
|
|
333
333
|
}
|
|
334
334
|
: undefined,
|
|
335
|
+
metadata,
|
|
335
336
|
};
|
|
336
337
|
if (onramp) {
|
|
337
338
|
const effectiveSrcToken = activeTab === "fiat" ? USDC_BASE : srcToken;
|
|
@@ -443,7 +444,7 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
443
444
|
? "Receive NFT at"
|
|
444
445
|
: orderType === "join_tournament"
|
|
445
446
|
? "Join for"
|
|
446
|
-
: "Recipient" }), _jsxs("div", { className: "flex items-center gap-2", children: [recipientAddress ? (_jsx("button", { className: cn("text-as-tertiarry flex
|
|
447
|
+
: "Recipient" }), _jsxs("div", { className: "flex flex-wrap items-center justify-end gap-2", children: [recipientAddress ? (_jsx("button", { className: cn("text-as-tertiarry flex items-center gap-2 rounded-lg"), onClick: () => setActivePanel(PanelView.RECIPIENT_SELECTION), children: _jsx("div", { className: "text-as-tertiarry flex items-center gap-1 text-sm", children: _jsx("span", { className: "whitespace-nowrap", children: recipientName ? formatUsername(recipientName) : shortenAddress(recipientAddress) }) }) })) : (_jsx("button", { className: "text-as-primary/70 flex items-center gap-1 rounded-lg", onClick: () => setActivePanel(PanelView.RECIPIENT_SELECTION), children: _jsx("div", { className: "whitespace-nowrap text-sm font-medium", children: "Select recipient" }) })), _jsx(ChevronRight, { className: "h-4 w-4 shrink-0" })] })] }, recipientAddress)) : null;
|
|
447
448
|
const historyView = (_jsx("div", { className: cn("mx-auto flex w-full max-w-2xl flex-col items-center p-5", mode === "modal" && "bg-b3-react-background"), children: _jsx(OrderHistory, { mode: mode, onBack: () => {
|
|
448
449
|
setActivePanel(PanelView.HISTORY);
|
|
449
450
|
}, onSelectOrder: onSelectOrder }) }));
|
|
@@ -486,7 +487,7 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
486
487
|
opacity: hasMounted ? 1 : 0,
|
|
487
488
|
y: hasMounted ? 0 : 20,
|
|
488
489
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
489
|
-
}, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between", children: [_jsx("div", { className: "text-as-tertiarry flex h-7 items-center text-sm", children: "Pay" }), _jsx("button", { className: "text-as-tertiarry flex
|
|
490
|
+
}, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between", children: [_jsx("div", { className: "text-as-tertiarry flex h-7 items-center text-sm", children: "Pay" }), _jsx("button", { className: "text-as-tertiarry flex flex-wrap items-center justify-end gap-2 text-sm transition-colors hover:text-blue-700", onClick: () => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD), children: effectiveCryptoPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET ? (_jsxs(_Fragment, { children: [connectedAddress ? (_jsx("span", { className: "text-as-tertiarry whitespace-nowrap", children: connectedName ? formatUsername(connectedName) : shortenAddress(connectedAddress || "") })) : (_jsx("span", { className: "whitespace-nowrap", children: "Connect wallet" })), _jsx(ChevronRight, { className: "h-4 w-4 shrink-0" })] })) : effectiveCryptoPaymentMethod === CryptoPaymentMethodType.TRANSFER_CRYPTO ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "whitespace-nowrap", children: "Transfer crypto" }), _jsx(ChevronRight, { className: "h-4 w-4 shrink-0" })] })) : (_jsxs(_Fragment, { children: [_jsx("span", { className: "whitespace-nowrap", children: "Select payment method" }), _jsx(ChevronRight, { className: "h-4 w-4 shrink-0" })] })) })] }), _jsx("div", { className: "divider w-full" }), recipientSection, _jsx("div", { className: "divider w-full" }), _jsxs("div", { className: "flex flex-col gap-4", children: [_jsxs(motion.div, { initial: false, animate: {
|
|
490
491
|
opacity: hasMounted ? 1 : 0,
|
|
491
492
|
y: hasMounted ? 0 : 20,
|
|
492
493
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
@@ -497,7 +498,7 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
497
498
|
opacity: hasMounted ? 1 : 0,
|
|
498
499
|
y: hasMounted ? 0 : 20,
|
|
499
500
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
500
|
-
}, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between", children: [_jsxs("
|
|
501
|
+
}, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between gap-4", children: [_jsxs("span", { className: "text-as-tertiarry flex flex-wrap items-center gap-1.5 text-sm", children: [_jsxs("span", { className: "whitespace-nowrap", children: ["Total ", _jsx("span", { className: "text-as-tertiarry", children: "(with fee)" })] }), anyspendQuote?.data?.fee && (_jsx(TooltipProvider, { children: _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx("button", { className: "text-as-primary/40 hover:text-as-primary/60 transition-colors", children: _jsx(Info, { className: "h-4 w-4" }) }) }), _jsx(TooltipContent, { side: "top", children: _jsx(FeeBreakDown, { fee: anyspendQuote.data.fee }) })] }) }))] }), _jsxs("div", { className: "flex flex-col items-end gap-0.5", children: [_jsxs("div", { className: "flex flex-wrap items-center justify-end gap-2", children: [renderPointsBadge(), _jsxs("span", { className: "text-as-primary whitespace-nowrap font-semibold", children: [formattedSrcAmount || "--", " ", srcToken.symbol] })] }), anyspendQuote?.data?.fee?.type === "standard_fee" && anyspendQuote.data.currencyIn?.amountUsd && (_jsxs("span", { className: "text-as-secondary text-xs", children: ["incl. $", ((Number(anyspendQuote.data.currencyIn.amountUsd) * anyspendQuote.data.fee.finalFeeBps) /
|
|
501
502
|
10000).toFixed(2), " ", "fee"] }))] })] })] })] }), _jsx("div", { className: cn("flex w-full flex-col items-center justify-between gap-2"), children: _jsx(motion.div, { initial: false, animate: {
|
|
502
503
|
opacity: hasMounted ? 1 : 0,
|
|
503
504
|
y: hasMounted ? 0 : 20,
|
|
@@ -506,11 +507,11 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
506
507
|
opacity: hasMounted ? 1 : 0,
|
|
507
508
|
y: hasMounted ? 0 : 20,
|
|
508
509
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
509
|
-
}, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between", children: [_jsx("div", { className: "text-as-tertiarry flex h-7 items-center text-sm", children: "Pay with" }), _jsx("button", { className: "text-as-tertiarry flex
|
|
510
|
+
}, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between", children: [_jsx("div", { className: "text-as-tertiarry flex h-7 items-center text-sm", children: "Pay with" }), _jsx("button", { className: "text-as-tertiarry flex flex-wrap items-center justify-end gap-2 text-sm transition-colors hover:text-blue-700", onClick: () => setActivePanel(PanelView.FIAT_PAYMENT_METHOD), children: selectedFiatPaymentMethod === FiatPaymentMethod.COINBASE_PAY ? (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex items-center gap-2 whitespace-nowrap", children: [_jsx("div", { className: "flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-blue-600", children: _jsx("span", { className: "text-xs font-bold text-white", children: "C" }) }), "Coinbase Pay"] }), _jsx(ChevronRight, { className: "h-4 w-4 shrink-0" })] })) : selectedFiatPaymentMethod === FiatPaymentMethod.STRIPE ? (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex items-center gap-2 whitespace-nowrap", children: [_jsx("div", { className: "flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-blue-600", children: _jsx("span", { className: "text-xs font-bold text-white", children: "S" }) }), "Credit/Debit Card"] }), _jsx(ChevronRight, { className: "h-4 w-4 shrink-0" })] })) : (_jsxs(_Fragment, { children: [_jsx("span", { className: "whitespace-nowrap", children: "Select payment method" }), _jsx(ChevronRight, { className: "h-4 w-4 shrink-0" })] })) })] }), _jsx("div", { className: "divider w-full" }), recipientSection, _jsx("div", { className: "divider w-full" }), _jsxs(motion.div, { initial: false, animate: {
|
|
510
511
|
opacity: hasMounted ? 1 : 0,
|
|
511
512
|
y: hasMounted ? 0 : 20,
|
|
512
513
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
513
|
-
}, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between", children: [_jsxs("
|
|
514
|
+
}, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between gap-4", children: [_jsxs("span", { className: "text-as-tertiarry flex flex-wrap items-center gap-1.5 text-sm", children: [_jsxs("span", { className: "whitespace-nowrap", children: ["Total ", _jsx("span", { className: "text-as-tertiarry", children: "(USD)" })] }), anyspendQuote?.data?.fee && (_jsx(TooltipProvider, { children: _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx("button", { className: "text-as-primary/40 hover:text-as-primary/60 transition-colors", children: _jsx(Info, { className: "h-4 w-4" }) }) }), _jsx(TooltipContent, { side: "top", children: _jsx(FeeBreakDown, { fee: anyspendQuote.data.fee }) })] }) }))] }), _jsxs("div", { className: "flex flex-col items-end gap-0.5", children: [_jsxs("div", { className: "flex flex-wrap items-center justify-end gap-2", children: [renderPointsBadge(), _jsxs("span", { className: "text-as-primary whitespace-nowrap text-xl font-semibold", children: ["$", srcFiatAmount || "0.00"] })] }), anyspendQuote?.data?.fee?.type === "stripeweb2_fee" && anyspendQuote.data.fee.originalAmount && (_jsxs("span", { className: "text-as-secondary text-xs", children: ["incl. $", ((Number(anyspendQuote.data.fee.originalAmount) - Number(anyspendQuote.data.fee.finalAmount)) /
|
|
514
515
|
1e6).toFixed(2), " ", "fee"] }))] })] })] }), _jsx("div", { className: cn("flex w-full flex-col items-center justify-between gap-2"), children: _jsx(motion.div, { initial: false, animate: {
|
|
515
516
|
opacity: hasMounted ? 1 : 0,
|
|
516
517
|
y: hasMounted ? 0 : 20,
|
|
@@ -16,7 +16,7 @@ export function useAnyspendCreateOnrampOrder({ onSuccess, onError } = {}) {
|
|
|
16
16
|
// Get B3 context values
|
|
17
17
|
const { partnerId } = useB3();
|
|
18
18
|
// Get validated client reference ID from B3 context
|
|
19
|
-
const
|
|
19
|
+
const createValidatedClientReferenceId = useValidatedClientReferenceId();
|
|
20
20
|
// Get fingerprint data
|
|
21
21
|
const { data: fpData } = useVisitorData({ extendedResult: true }, { immediate: true });
|
|
22
22
|
const visitorData = fpData && {
|
|
@@ -26,6 +26,7 @@ export function useAnyspendCreateOnrampOrder({ onSuccess, onError } = {}) {
|
|
|
26
26
|
const { mutate: createOrder, isPending } = useMutation({
|
|
27
27
|
mutationFn: async (params) => {
|
|
28
28
|
const { recipientAddress, orderType, dstChain, dstToken, srcFiatAmount, onramp, creatorAddress, expectedDstAmount, nft, tournament, payload, } = params;
|
|
29
|
+
const clientReferenceId = await createValidatedClientReferenceId(params);
|
|
29
30
|
try {
|
|
30
31
|
// Validate required onramp fields
|
|
31
32
|
if (!onramp.vendor || !onramp.country) {
|
|
@@ -68,7 +69,7 @@ export function useAnyspendCreateOnrampOrder({ onSuccess, onError } = {}) {
|
|
|
68
69
|
}),
|
|
69
70
|
creatorAddress: creatorAddress ? normalizeAddress(creatorAddress) : undefined,
|
|
70
71
|
partnerId,
|
|
71
|
-
clientReferenceId
|
|
72
|
+
clientReferenceId,
|
|
72
73
|
visitorData,
|
|
73
74
|
});
|
|
74
75
|
}
|
|
@@ -14,7 +14,7 @@ export function useAnyspendCreateOrder({ onSuccess, onError } = {}) {
|
|
|
14
14
|
// Get B3 context values
|
|
15
15
|
const { partnerId } = useB3();
|
|
16
16
|
// Get validated client reference ID from B3 context
|
|
17
|
-
const
|
|
17
|
+
const createValidatedClientReferenceId = useValidatedClientReferenceId();
|
|
18
18
|
// Get fingerprint data
|
|
19
19
|
const { data: fpData } = useVisitorData({ extendedResult: true }, { immediate: true });
|
|
20
20
|
const visitorData = fpData && {
|
|
@@ -24,6 +24,7 @@ export function useAnyspendCreateOrder({ onSuccess, onError } = {}) {
|
|
|
24
24
|
const { mutate: createOrder, isPending } = useMutation({
|
|
25
25
|
mutationFn: async (params) => {
|
|
26
26
|
const { recipientAddress, orderType, srcChain, dstChain, srcToken, dstToken, srcAmount, creatorAddress } = params;
|
|
27
|
+
const clientReferenceId = await createValidatedClientReferenceId(params);
|
|
27
28
|
try {
|
|
28
29
|
return await anyspendService.createOrder({
|
|
29
30
|
recipientAddress: normalizeAddress(recipientAddress),
|
|
@@ -57,7 +58,7 @@ export function useAnyspendCreateOrder({ onSuccess, onError } = {}) {
|
|
|
57
58
|
}),
|
|
58
59
|
creatorAddress: creatorAddress ? normalizeAddress(creatorAddress) : undefined,
|
|
59
60
|
partnerId,
|
|
60
|
-
clientReferenceId
|
|
61
|
+
clientReferenceId,
|
|
61
62
|
visitorData,
|
|
62
63
|
});
|
|
63
64
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { CreateOnrampOrderParams } from "./useAnyspendCreateOnrampOrder";
|
|
2
|
+
import { CreateOrderParams } from "./useAnyspendCreateOrder";
|
|
1
3
|
/**
|
|
2
4
|
* Hook that provides a validated client reference ID
|
|
3
5
|
* Gets the createClientReferenceId function from B3 context and validates the result
|
|
4
6
|
*/
|
|
5
|
-
export declare function useValidatedClientReferenceId(): string | undefined
|
|
7
|
+
export declare function useValidatedClientReferenceId(): (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string | undefined>;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { Validators } from "../../../anyspend/utils/validation.js";
|
|
2
2
|
import { useB3 } from "../../../global-account/react/index.js";
|
|
3
|
-
import {
|
|
3
|
+
import { useCallback } from "react";
|
|
4
4
|
/**
|
|
5
5
|
* Hook that provides a validated client reference ID
|
|
6
6
|
* Gets the createClientReferenceId function from B3 context and validates the result
|
|
7
7
|
*/
|
|
8
8
|
export function useValidatedClientReferenceId() {
|
|
9
9
|
const { createClientReferenceId } = useB3();
|
|
10
|
-
const
|
|
10
|
+
const createValidatedClientReferenceId = useCallback(async (params) => {
|
|
11
11
|
// If no function provided, return undefined
|
|
12
12
|
if (!createClientReferenceId) {
|
|
13
13
|
return undefined;
|
|
14
14
|
}
|
|
15
15
|
try {
|
|
16
16
|
// Call the function to generate the ID
|
|
17
|
-
const generatedId = createClientReferenceId();
|
|
17
|
+
const generatedId = await createClientReferenceId(params);
|
|
18
18
|
// Validate the generated ID
|
|
19
19
|
const validation = Validators.clientReferenceId(generatedId);
|
|
20
20
|
if (!validation.isValid) {
|
|
@@ -28,5 +28,5 @@ export function useValidatedClientReferenceId() {
|
|
|
28
28
|
return undefined;
|
|
29
29
|
}
|
|
30
30
|
}, [createClientReferenceId]);
|
|
31
|
-
return
|
|
31
|
+
return createValidatedClientReferenceId;
|
|
32
32
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { CreateOnrampOrderParams } from "../../../../anyspend/react/hooks/useAnyspendCreateOnrampOrder";
|
|
2
|
+
import { CreateOrderParams } from "../../../../anyspend/react/hooks/useAnyspendCreateOrder";
|
|
1
3
|
import { PermissionsConfig } from "../../../../global-account/types/permissions";
|
|
2
4
|
import "@relayprotocol/relay-kit-ui/styles.css";
|
|
3
5
|
import { Account, Wallet } from "thirdweb/wallets";
|
|
@@ -24,7 +26,7 @@ export declare function B3Provider({ theme, children, accountOverride, environme
|
|
|
24
26
|
onConnect?: (wallet: Wallet, b3Jwt: string) => void | Promise<void>;
|
|
25
27
|
connectors?: CreateConnectorFn[];
|
|
26
28
|
overrideDefaultConnectors?: boolean;
|
|
27
|
-
createClientReferenceId?: () => string
|
|
29
|
+
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
28
30
|
}): import("react/jsx-runtime").JSX.Element;
|
|
29
31
|
/**
|
|
30
32
|
* Inner provider component that provides the actual B3Context
|
|
@@ -38,5 +40,5 @@ export declare function InnerProvider({ children, accountOverride, environment,
|
|
|
38
40
|
theme: "light" | "dark";
|
|
39
41
|
clientType?: ClientType;
|
|
40
42
|
partnerId: string;
|
|
41
|
-
createClientReferenceId?: () => string
|
|
43
|
+
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
42
44
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { Users } from "@b3dotfun/b3-api";
|
|
2
|
+
import { CreateOnrampOrderParams } from "../../../../anyspend/react/hooks/useAnyspendCreateOnrampOrder";
|
|
3
|
+
import { CreateOrderParams } from "../../../../anyspend/react/hooks/useAnyspendCreateOrder";
|
|
2
4
|
import { PermissionsConfig } from "../../../../global-account/types/permissions";
|
|
3
5
|
import { Account, Wallet } from "thirdweb/wallets";
|
|
4
6
|
import { ClientType } from "../../../client-manager";
|
|
@@ -20,7 +22,7 @@ export interface B3ContextType {
|
|
|
20
22
|
theme: "light" | "dark";
|
|
21
23
|
clientType: ClientType;
|
|
22
24
|
partnerId: string;
|
|
23
|
-
createClientReferenceId?: () => string
|
|
25
|
+
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
24
26
|
}
|
|
25
27
|
/**
|
|
26
28
|
* Context for B3 provider
|
|
@@ -402,6 +402,10 @@ export interface AnySpendCollectorClubPurchaseProps extends BaseModalProps {
|
|
|
402
402
|
onSuccess?: (txHash?: string) => void;
|
|
403
403
|
/** Client-provided reference ID for tracking orders */
|
|
404
404
|
clientReferenceId?: string;
|
|
405
|
+
/** The vending machine ID */
|
|
406
|
+
vendingMachineId: string;
|
|
407
|
+
/** The pack type */
|
|
408
|
+
packType: string;
|
|
405
409
|
}
|
|
406
410
|
/**
|
|
407
411
|
* Union type of all possible modal content types
|
|
@@ -53,5 +53,13 @@ export interface AnySpendCollectorClubPurchaseProps {
|
|
|
53
53
|
* Show recipient selection (default: true)
|
|
54
54
|
*/
|
|
55
55
|
showRecipient?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* The vending machine ID
|
|
58
|
+
*/
|
|
59
|
+
vendingMachineId: string;
|
|
60
|
+
/**
|
|
61
|
+
* The partner ID
|
|
62
|
+
*/
|
|
63
|
+
packType: string;
|
|
56
64
|
}
|
|
57
|
-
export declare function AnySpendCollectorClubPurchase({ loadOrder, mode, activeTab, packId, packAmount, pricePerPack, paymentToken, recipientAddress, spenderAddress, onSuccess, header, showRecipient, }: AnySpendCollectorClubPurchaseProps): import("react/jsx-runtime").JSX.Element;
|
|
65
|
+
export declare function AnySpendCollectorClubPurchase({ loadOrder, mode, activeTab, packId, packAmount, pricePerPack, paymentToken, recipientAddress, spenderAddress, onSuccess, header, showRecipient, vendingMachineId, packType, }: AnySpendCollectorClubPurchaseProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { CreateOnrampOrderParams } from "./useAnyspendCreateOnrampOrder";
|
|
2
|
+
import { CreateOrderParams } from "./useAnyspendCreateOrder";
|
|
1
3
|
/**
|
|
2
4
|
* Hook that provides a validated client reference ID
|
|
3
5
|
* Gets the createClientReferenceId function from B3 context and validates the result
|
|
4
6
|
*/
|
|
5
|
-
export declare function useValidatedClientReferenceId(): string | undefined
|
|
7
|
+
export declare function useValidatedClientReferenceId(): (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string | undefined>;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { CreateOnrampOrderParams } from "@b3dotfun/sdk/anyspend/react/hooks/useAnyspendCreateOnrampOrder";
|
|
2
|
+
import { CreateOrderParams } from "@b3dotfun/sdk/anyspend/react/hooks/useAnyspendCreateOrder";
|
|
1
3
|
import { PermissionsConfig } from "@b3dotfun/sdk/global-account/types/permissions";
|
|
2
4
|
import "@relayprotocol/relay-kit-ui/styles.css";
|
|
3
5
|
import { Account, Wallet } from "thirdweb/wallets";
|
|
@@ -24,7 +26,7 @@ export declare function B3Provider({ theme, children, accountOverride, environme
|
|
|
24
26
|
onConnect?: (wallet: Wallet, b3Jwt: string) => void | Promise<void>;
|
|
25
27
|
connectors?: CreateConnectorFn[];
|
|
26
28
|
overrideDefaultConnectors?: boolean;
|
|
27
|
-
createClientReferenceId?: () => string
|
|
29
|
+
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
28
30
|
}): import("react/jsx-runtime").JSX.Element;
|
|
29
31
|
/**
|
|
30
32
|
* Inner provider component that provides the actual B3Context
|
|
@@ -38,5 +40,5 @@ export declare function InnerProvider({ children, accountOverride, environment,
|
|
|
38
40
|
theme: "light" | "dark";
|
|
39
41
|
clientType?: ClientType;
|
|
40
42
|
partnerId: string;
|
|
41
|
-
createClientReferenceId?: () => string
|
|
43
|
+
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
42
44
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { Users } from "@b3dotfun/b3-api";
|
|
2
|
+
import { CreateOnrampOrderParams } from "@b3dotfun/sdk/anyspend/react/hooks/useAnyspendCreateOnrampOrder";
|
|
3
|
+
import { CreateOrderParams } from "@b3dotfun/sdk/anyspend/react/hooks/useAnyspendCreateOrder";
|
|
2
4
|
import { PermissionsConfig } from "@b3dotfun/sdk/global-account/types/permissions";
|
|
3
5
|
import { Account, Wallet } from "thirdweb/wallets";
|
|
4
6
|
import { ClientType } from "../../../client-manager";
|
|
@@ -20,7 +22,7 @@ export interface B3ContextType {
|
|
|
20
22
|
theme: "light" | "dark";
|
|
21
23
|
clientType: ClientType;
|
|
22
24
|
partnerId: string;
|
|
23
|
-
createClientReferenceId?: () => string
|
|
25
|
+
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
24
26
|
}
|
|
25
27
|
/**
|
|
26
28
|
* Context for B3 provider
|
|
@@ -402,6 +402,10 @@ export interface AnySpendCollectorClubPurchaseProps extends BaseModalProps {
|
|
|
402
402
|
onSuccess?: (txHash?: string) => void;
|
|
403
403
|
/** Client-provided reference ID for tracking orders */
|
|
404
404
|
clientReferenceId?: string;
|
|
405
|
+
/** The vending machine ID */
|
|
406
|
+
vendingMachineId: string;
|
|
407
|
+
/** The pack type */
|
|
408
|
+
packType: string;
|
|
405
409
|
}
|
|
406
410
|
/**
|
|
407
411
|
* Union type of all possible modal content types
|
package/package.json
CHANGED
|
@@ -100,6 +100,14 @@ export interface AnySpendCollectorClubPurchaseProps {
|
|
|
100
100
|
* Show recipient selection (default: true)
|
|
101
101
|
*/
|
|
102
102
|
showRecipient?: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* The vending machine ID
|
|
105
|
+
*/
|
|
106
|
+
vendingMachineId: string;
|
|
107
|
+
/**
|
|
108
|
+
* The partner ID
|
|
109
|
+
*/
|
|
110
|
+
packType: string;
|
|
103
111
|
}
|
|
104
112
|
|
|
105
113
|
export function AnySpendCollectorClubPurchase({
|
|
@@ -115,6 +123,8 @@ export function AnySpendCollectorClubPurchase({
|
|
|
115
123
|
onSuccess,
|
|
116
124
|
header,
|
|
117
125
|
showRecipient = true,
|
|
126
|
+
vendingMachineId,
|
|
127
|
+
packType,
|
|
118
128
|
}: AnySpendCollectorClubPurchaseProps) {
|
|
119
129
|
// Calculate total amount needed (pricePerPack * packAmount)
|
|
120
130
|
const totalAmount = useMemo(() => {
|
|
@@ -169,6 +179,8 @@ export function AnySpendCollectorClubPurchase({
|
|
|
169
179
|
packId,
|
|
170
180
|
packAmount,
|
|
171
181
|
pricePerPack,
|
|
182
|
+
vendingMachineId,
|
|
183
|
+
packType,
|
|
172
184
|
}}
|
|
173
185
|
header={header || defaultHeader}
|
|
174
186
|
onSuccess={onSuccess}
|
|
@@ -509,6 +509,7 @@ function AnySpendCustomInner({
|
|
|
509
509
|
to: contractAddress,
|
|
510
510
|
}
|
|
511
511
|
: undefined,
|
|
512
|
+
metadata,
|
|
512
513
|
} as CreateOrderParams;
|
|
513
514
|
|
|
514
515
|
if (onramp) {
|
|
@@ -642,27 +643,27 @@ function AnySpendCustomInner({
|
|
|
642
643
|
? "Join for"
|
|
643
644
|
: "Recipient"}
|
|
644
645
|
</div>
|
|
645
|
-
<div className="flex items-center gap-2">
|
|
646
|
+
<div className="flex flex-wrap items-center justify-end gap-2">
|
|
646
647
|
{recipientAddress ? (
|
|
647
648
|
<button
|
|
648
|
-
className={cn("text-as-tertiarry flex
|
|
649
|
+
className={cn("text-as-tertiarry flex items-center gap-2 rounded-lg")}
|
|
649
650
|
onClick={() => setActivePanel(PanelView.RECIPIENT_SELECTION)}
|
|
650
651
|
>
|
|
651
|
-
|
|
652
|
-
<
|
|
653
|
-
|
|
654
|
-
</
|
|
655
|
-
|
|
652
|
+
<div className="text-as-tertiarry flex items-center gap-1 text-sm">
|
|
653
|
+
<span className="whitespace-nowrap">
|
|
654
|
+
{recipientName ? formatUsername(recipientName) : shortenAddress(recipientAddress)}
|
|
655
|
+
</span>
|
|
656
|
+
</div>
|
|
656
657
|
</button>
|
|
657
658
|
) : (
|
|
658
659
|
<button
|
|
659
660
|
className="text-as-primary/70 flex items-center gap-1 rounded-lg"
|
|
660
661
|
onClick={() => setActivePanel(PanelView.RECIPIENT_SELECTION)}
|
|
661
662
|
>
|
|
662
|
-
<div className="text-sm font-medium">Select recipient</div>
|
|
663
|
+
<div className="whitespace-nowrap text-sm font-medium">Select recipient</div>
|
|
663
664
|
</button>
|
|
664
665
|
)}
|
|
665
|
-
<ChevronRight className="h-4 w-4" />
|
|
666
|
+
<ChevronRight className="h-4 w-4 shrink-0" />
|
|
666
667
|
</div>
|
|
667
668
|
</motion.div>
|
|
668
669
|
) : null;
|
|
@@ -912,31 +913,29 @@ function AnySpendCustomInner({
|
|
|
912
913
|
>
|
|
913
914
|
<div className="text-as-tertiarry flex h-7 items-center text-sm">Pay</div>
|
|
914
915
|
<button
|
|
915
|
-
className="text-as-tertiarry flex
|
|
916
|
+
className="text-as-tertiarry flex flex-wrap items-center justify-end gap-2 text-sm transition-colors hover:text-blue-700"
|
|
916
917
|
onClick={() => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD)}
|
|
917
918
|
>
|
|
918
919
|
{effectiveCryptoPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET ? (
|
|
919
920
|
<>
|
|
920
921
|
{connectedAddress ? (
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
</span>
|
|
925
|
-
</>
|
|
922
|
+
<span className="text-as-tertiarry whitespace-nowrap">
|
|
923
|
+
{connectedName ? formatUsername(connectedName) : shortenAddress(connectedAddress || "")}
|
|
924
|
+
</span>
|
|
926
925
|
) : (
|
|
927
|
-
"Connect wallet
|
|
926
|
+
<span className="whitespace-nowrap">Connect wallet</span>
|
|
928
927
|
)}
|
|
929
|
-
<ChevronRight className="h-4 w-4" />
|
|
928
|
+
<ChevronRight className="h-4 w-4 shrink-0" />
|
|
930
929
|
</>
|
|
931
930
|
) : effectiveCryptoPaymentMethod === CryptoPaymentMethodType.TRANSFER_CRYPTO ? (
|
|
932
931
|
<>
|
|
933
|
-
Transfer crypto
|
|
934
|
-
<ChevronRight className="h-4 w-4" />
|
|
932
|
+
<span className="whitespace-nowrap">Transfer crypto</span>
|
|
933
|
+
<ChevronRight className="h-4 w-4 shrink-0" />
|
|
935
934
|
</>
|
|
936
935
|
) : (
|
|
937
936
|
<>
|
|
938
|
-
Select payment method
|
|
939
|
-
<ChevronRight className="h-4 w-4" />
|
|
937
|
+
<span className="whitespace-nowrap">Select payment method</span>
|
|
938
|
+
<ChevronRight className="h-4 w-4 shrink-0" />
|
|
940
939
|
</>
|
|
941
940
|
)}
|
|
942
941
|
</button>
|
|
@@ -984,32 +983,34 @@ function AnySpendCustomInner({
|
|
|
984
983
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
985
984
|
}}
|
|
986
985
|
transition={{ duration: 0.3, delay: 0.1, ease: "easeInOut" }}
|
|
987
|
-
className="relative flex w-full items-center justify-between"
|
|
986
|
+
className="relative flex w-full items-center justify-between gap-4"
|
|
988
987
|
>
|
|
989
|
-
<
|
|
990
|
-
<span className="
|
|
988
|
+
<span className="text-as-tertiarry flex flex-wrap items-center gap-1.5 text-sm">
|
|
989
|
+
<span className="whitespace-nowrap">
|
|
991
990
|
Total <span className="text-as-tertiarry">(with fee)</span>
|
|
992
|
-
{anyspendQuote?.data?.fee && (
|
|
993
|
-
<TooltipProvider>
|
|
994
|
-
<Tooltip>
|
|
995
|
-
<TooltipTrigger asChild>
|
|
996
|
-
<button className="text-as-primary/40 hover:text-as-primary/60 transition-colors">
|
|
997
|
-
<Info className="h-4 w-4" />
|
|
998
|
-
</button>
|
|
999
|
-
</TooltipTrigger>
|
|
1000
|
-
<TooltipContent side="top">
|
|
1001
|
-
<FeeBreakDown fee={anyspendQuote.data.fee} />
|
|
1002
|
-
</TooltipContent>
|
|
1003
|
-
</Tooltip>
|
|
1004
|
-
</TooltipProvider>
|
|
1005
|
-
)}
|
|
1006
991
|
</span>
|
|
1007
|
-
{
|
|
1008
|
-
|
|
992
|
+
{anyspendQuote?.data?.fee && (
|
|
993
|
+
<TooltipProvider>
|
|
994
|
+
<Tooltip>
|
|
995
|
+
<TooltipTrigger asChild>
|
|
996
|
+
<button className="text-as-primary/40 hover:text-as-primary/60 transition-colors">
|
|
997
|
+
<Info className="h-4 w-4" />
|
|
998
|
+
</button>
|
|
999
|
+
</TooltipTrigger>
|
|
1000
|
+
<TooltipContent side="top">
|
|
1001
|
+
<FeeBreakDown fee={anyspendQuote.data.fee} />
|
|
1002
|
+
</TooltipContent>
|
|
1003
|
+
</Tooltip>
|
|
1004
|
+
</TooltipProvider>
|
|
1005
|
+
)}
|
|
1006
|
+
</span>
|
|
1009
1007
|
<div className="flex flex-col items-end gap-0.5">
|
|
1010
|
-
<
|
|
1011
|
-
{
|
|
1012
|
-
|
|
1008
|
+
<div className="flex flex-wrap items-center justify-end gap-2">
|
|
1009
|
+
{renderPointsBadge()}
|
|
1010
|
+
<span className="text-as-primary whitespace-nowrap font-semibold">
|
|
1011
|
+
{formattedSrcAmount || "--"} {srcToken.symbol}
|
|
1012
|
+
</span>
|
|
1013
|
+
</div>
|
|
1013
1014
|
{anyspendQuote?.data?.fee?.type === "standard_fee" && anyspendQuote.data.currencyIn?.amountUsd && (
|
|
1014
1015
|
<span className="text-as-secondary text-xs">
|
|
1015
1016
|
incl. $
|
|
@@ -1089,33 +1090,33 @@ function AnySpendCustomInner({
|
|
|
1089
1090
|
>
|
|
1090
1091
|
<div className="text-as-tertiarry flex h-7 items-center text-sm">Pay with</div>
|
|
1091
1092
|
<button
|
|
1092
|
-
className="text-as-tertiarry flex
|
|
1093
|
+
className="text-as-tertiarry flex flex-wrap items-center justify-end gap-2 text-sm transition-colors hover:text-blue-700"
|
|
1093
1094
|
onClick={() => setActivePanel(PanelView.FIAT_PAYMENT_METHOD)}
|
|
1094
1095
|
>
|
|
1095
1096
|
{selectedFiatPaymentMethod === FiatPaymentMethod.COINBASE_PAY ? (
|
|
1096
1097
|
<>
|
|
1097
|
-
<div className="flex items-center gap-2">
|
|
1098
|
-
<div className="flex h-5 w-5 items-center justify-center rounded-full bg-blue-600">
|
|
1098
|
+
<div className="flex items-center gap-2 whitespace-nowrap">
|
|
1099
|
+
<div className="flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-blue-600">
|
|
1099
1100
|
<span className="text-xs font-bold text-white">C</span>
|
|
1100
1101
|
</div>
|
|
1101
1102
|
Coinbase Pay
|
|
1102
1103
|
</div>
|
|
1103
|
-
<ChevronRight className="h-4 w-4" />
|
|
1104
|
+
<ChevronRight className="h-4 w-4 shrink-0" />
|
|
1104
1105
|
</>
|
|
1105
1106
|
) : selectedFiatPaymentMethod === FiatPaymentMethod.STRIPE ? (
|
|
1106
1107
|
<>
|
|
1107
|
-
<div className="flex items-center gap-2">
|
|
1108
|
-
<div className="flex h-5 w-5 items-center justify-center rounded-full bg-blue-600">
|
|
1108
|
+
<div className="flex items-center gap-2 whitespace-nowrap">
|
|
1109
|
+
<div className="flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-blue-600">
|
|
1109
1110
|
<span className="text-xs font-bold text-white">S</span>
|
|
1110
1111
|
</div>
|
|
1111
1112
|
Credit/Debit Card
|
|
1112
1113
|
</div>
|
|
1113
|
-
<ChevronRight className="h-4 w-4" />
|
|
1114
|
+
<ChevronRight className="h-4 w-4 shrink-0" />
|
|
1114
1115
|
</>
|
|
1115
1116
|
) : (
|
|
1116
1117
|
<>
|
|
1117
|
-
Select payment method
|
|
1118
|
-
<ChevronRight className="h-4 w-4" />
|
|
1118
|
+
<span className="whitespace-nowrap">Select payment method</span>
|
|
1119
|
+
<ChevronRight className="h-4 w-4 shrink-0" />
|
|
1119
1120
|
</>
|
|
1120
1121
|
)}
|
|
1121
1122
|
</button>
|
|
@@ -1136,30 +1137,34 @@ function AnySpendCustomInner({
|
|
|
1136
1137
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
1137
1138
|
}}
|
|
1138
1139
|
transition={{ duration: 0.3, delay: 0.1, ease: "easeInOut" }}
|
|
1139
|
-
className="relative flex w-full items-center justify-between"
|
|
1140
|
+
className="relative flex w-full items-center justify-between gap-4"
|
|
1140
1141
|
>
|
|
1141
|
-
<
|
|
1142
|
-
<span className="
|
|
1142
|
+
<span className="text-as-tertiarry flex flex-wrap items-center gap-1.5 text-sm">
|
|
1143
|
+
<span className="whitespace-nowrap">
|
|
1143
1144
|
Total <span className="text-as-tertiarry">(USD)</span>
|
|
1144
|
-
{anyspendQuote?.data?.fee && (
|
|
1145
|
-
<TooltipProvider>
|
|
1146
|
-
<Tooltip>
|
|
1147
|
-
<TooltipTrigger asChild>
|
|
1148
|
-
<button className="text-as-primary/40 hover:text-as-primary/60 transition-colors">
|
|
1149
|
-
<Info className="h-4 w-4" />
|
|
1150
|
-
</button>
|
|
1151
|
-
</TooltipTrigger>
|
|
1152
|
-
<TooltipContent side="top">
|
|
1153
|
-
<FeeBreakDown fee={anyspendQuote.data.fee} />
|
|
1154
|
-
</TooltipContent>
|
|
1155
|
-
</Tooltip>
|
|
1156
|
-
</TooltipProvider>
|
|
1157
|
-
)}
|
|
1158
1145
|
</span>
|
|
1159
|
-
{
|
|
1160
|
-
|
|
1146
|
+
{anyspendQuote?.data?.fee && (
|
|
1147
|
+
<TooltipProvider>
|
|
1148
|
+
<Tooltip>
|
|
1149
|
+
<TooltipTrigger asChild>
|
|
1150
|
+
<button className="text-as-primary/40 hover:text-as-primary/60 transition-colors">
|
|
1151
|
+
<Info className="h-4 w-4" />
|
|
1152
|
+
</button>
|
|
1153
|
+
</TooltipTrigger>
|
|
1154
|
+
<TooltipContent side="top">
|
|
1155
|
+
<FeeBreakDown fee={anyspendQuote.data.fee} />
|
|
1156
|
+
</TooltipContent>
|
|
1157
|
+
</Tooltip>
|
|
1158
|
+
</TooltipProvider>
|
|
1159
|
+
)}
|
|
1160
|
+
</span>
|
|
1161
1161
|
<div className="flex flex-col items-end gap-0.5">
|
|
1162
|
-
<
|
|
1162
|
+
<div className="flex flex-wrap items-center justify-end gap-2">
|
|
1163
|
+
{renderPointsBadge()}
|
|
1164
|
+
<span className="text-as-primary whitespace-nowrap text-xl font-semibold">
|
|
1165
|
+
${srcFiatAmount || "0.00"}
|
|
1166
|
+
</span>
|
|
1167
|
+
</div>
|
|
1163
1168
|
{anyspendQuote?.data?.fee?.type === "stripeweb2_fee" && anyspendQuote.data.fee.originalAmount && (
|
|
1164
1169
|
<span className="text-as-secondary text-xs">
|
|
1165
1170
|
incl. $
|
|
@@ -39,7 +39,7 @@ export function useAnyspendCreateOnrampOrder({ onSuccess, onError }: UseAnyspend
|
|
|
39
39
|
const { partnerId } = useB3();
|
|
40
40
|
|
|
41
41
|
// Get validated client reference ID from B3 context
|
|
42
|
-
const
|
|
42
|
+
const createValidatedClientReferenceId = useValidatedClientReferenceId();
|
|
43
43
|
|
|
44
44
|
// Get fingerprint data
|
|
45
45
|
const { data: fpData } = useVisitorData({ extendedResult: true }, { immediate: true });
|
|
@@ -64,6 +64,8 @@ export function useAnyspendCreateOnrampOrder({ onSuccess, onError }: UseAnyspend
|
|
|
64
64
|
payload,
|
|
65
65
|
} = params;
|
|
66
66
|
|
|
67
|
+
const clientReferenceId = await createValidatedClientReferenceId(params);
|
|
68
|
+
|
|
67
69
|
try {
|
|
68
70
|
// Validate required onramp fields
|
|
69
71
|
if (!onramp.vendor || !onramp.country) {
|
|
@@ -109,7 +111,7 @@ export function useAnyspendCreateOnrampOrder({ onSuccess, onError }: UseAnyspend
|
|
|
109
111
|
}),
|
|
110
112
|
creatorAddress: creatorAddress ? normalizeAddress(creatorAddress) : undefined,
|
|
111
113
|
partnerId,
|
|
112
|
-
clientReferenceId
|
|
114
|
+
clientReferenceId,
|
|
113
115
|
visitorData,
|
|
114
116
|
});
|
|
115
117
|
} catch (error: any) {
|
|
@@ -21,6 +21,7 @@ export type CreateOrderParams = {
|
|
|
21
21
|
tournament?: components["schemas"]["Tournament"] & { contractAddress: string; entryPriceOrFundAmount: string };
|
|
22
22
|
creatorAddress?: string;
|
|
23
23
|
payload?: any;
|
|
24
|
+
metadata?: Record<string, any>;
|
|
24
25
|
};
|
|
25
26
|
|
|
26
27
|
export type UseAnyspendCreateOrderProps = {
|
|
@@ -38,7 +39,7 @@ export function useAnyspendCreateOrder({ onSuccess, onError }: UseAnyspendCreate
|
|
|
38
39
|
const { partnerId } = useB3();
|
|
39
40
|
|
|
40
41
|
// Get validated client reference ID from B3 context
|
|
41
|
-
const
|
|
42
|
+
const createValidatedClientReferenceId = useValidatedClientReferenceId();
|
|
42
43
|
|
|
43
44
|
// Get fingerprint data
|
|
44
45
|
const { data: fpData } = useVisitorData({ extendedResult: true }, { immediate: true });
|
|
@@ -49,6 +50,7 @@ export function useAnyspendCreateOrder({ onSuccess, onError }: UseAnyspendCreate
|
|
|
49
50
|
const { mutate: createOrder, isPending } = useMutation({
|
|
50
51
|
mutationFn: async (params: CreateOrderParams) => {
|
|
51
52
|
const { recipientAddress, orderType, srcChain, dstChain, srcToken, dstToken, srcAmount, creatorAddress } = params;
|
|
53
|
+
const clientReferenceId = await createValidatedClientReferenceId(params);
|
|
52
54
|
|
|
53
55
|
try {
|
|
54
56
|
return await anyspendService.createOrder({
|
|
@@ -83,7 +85,7 @@ export function useAnyspendCreateOrder({ onSuccess, onError }: UseAnyspendCreate
|
|
|
83
85
|
}),
|
|
84
86
|
creatorAddress: creatorAddress ? normalizeAddress(creatorAddress) : undefined,
|
|
85
87
|
partnerId,
|
|
86
|
-
clientReferenceId
|
|
88
|
+
clientReferenceId,
|
|
87
89
|
visitorData,
|
|
88
90
|
});
|
|
89
91
|
} catch (error: any) {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Validators } from "@b3dotfun/sdk/anyspend/utils/validation";
|
|
2
2
|
import { useB3 } from "@b3dotfun/sdk/global-account/react";
|
|
3
|
-
import {
|
|
3
|
+
import { useCallback } from "react";
|
|
4
|
+
import { CreateOnrampOrderParams } from "./useAnyspendCreateOnrampOrder";
|
|
5
|
+
import { CreateOrderParams } from "./useAnyspendCreateOrder";
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* Hook that provides a validated client reference ID
|
|
@@ -9,32 +11,35 @@ import { useMemo } from "react";
|
|
|
9
11
|
export function useValidatedClientReferenceId() {
|
|
10
12
|
const { createClientReferenceId } = useB3();
|
|
11
13
|
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
const createValidatedClientReferenceId = useCallback(
|
|
15
|
+
async (params: CreateOrderParams | CreateOnrampOrderParams) => {
|
|
16
|
+
// If no function provided, return undefined
|
|
17
|
+
if (!createClientReferenceId) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
try {
|
|
22
|
+
// Call the function to generate the ID
|
|
23
|
+
const generatedId = await createClientReferenceId(params);
|
|
21
24
|
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
// Validate the generated ID
|
|
26
|
+
const validation = Validators.clientReferenceId(generatedId);
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
if (!validation.isValid) {
|
|
29
|
+
console.error(
|
|
30
|
+
`[AnySpend] Invalid clientReferenceId generated: ${validation.error || "Validation failed"}. Will be set to undefined.`,
|
|
31
|
+
);
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return validation.cleaned;
|
|
36
|
+
} catch (error) {
|
|
37
|
+
console.error("[AnySpend] Error generating clientReferenceId:", error);
|
|
29
38
|
return undefined;
|
|
30
39
|
}
|
|
40
|
+
},
|
|
41
|
+
[createClientReferenceId],
|
|
42
|
+
);
|
|
31
43
|
|
|
32
|
-
|
|
33
|
-
} catch (error) {
|
|
34
|
-
console.error("[AnySpend] Error generating clientReferenceId:", error);
|
|
35
|
-
return undefined;
|
|
36
|
-
}
|
|
37
|
-
}, [createClientReferenceId]);
|
|
38
|
-
|
|
39
|
-
return validatedClientReferenceId;
|
|
44
|
+
return createValidatedClientReferenceId;
|
|
40
45
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { CreateOnrampOrderParams } from "@b3dotfun/sdk/anyspend/react/hooks/useAnyspendCreateOnrampOrder";
|
|
2
|
+
import { CreateOrderParams } from "@b3dotfun/sdk/anyspend/react/hooks/useAnyspendCreateOrder";
|
|
1
3
|
import {
|
|
2
4
|
RelayKitProviderWrapper,
|
|
3
5
|
TooltipProvider,
|
|
@@ -76,7 +78,7 @@ export function B3Provider({
|
|
|
76
78
|
onConnect?: (wallet: Wallet, b3Jwt: string) => void | Promise<void>;
|
|
77
79
|
connectors?: CreateConnectorFn[];
|
|
78
80
|
overrideDefaultConnectors?: boolean;
|
|
79
|
-
createClientReferenceId?: () => string
|
|
81
|
+
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
80
82
|
}) {
|
|
81
83
|
// Initialize Google Analytics on mount
|
|
82
84
|
useEffect(() => {
|
|
@@ -141,7 +143,7 @@ export function InnerProvider({
|
|
|
141
143
|
theme: "light" | "dark";
|
|
142
144
|
clientType?: ClientType;
|
|
143
145
|
partnerId: string;
|
|
144
|
-
createClientReferenceId?: () => string
|
|
146
|
+
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
145
147
|
}) {
|
|
146
148
|
const activeAccount = useActiveAccount();
|
|
147
149
|
const [manuallySelectedWallet, setManuallySelectedWallet] = useState<Wallet | undefined>(undefined);
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { Users } from "@b3dotfun/b3-api";
|
|
2
|
+
import { CreateOnrampOrderParams } from "@b3dotfun/sdk/anyspend/react/hooks/useAnyspendCreateOnrampOrder";
|
|
3
|
+
import { CreateOrderParams } from "@b3dotfun/sdk/anyspend/react/hooks/useAnyspendCreateOrder";
|
|
2
4
|
import { PermissionsConfig } from "@b3dotfun/sdk/global-account/types/permissions";
|
|
3
5
|
import { createContext } from "react";
|
|
4
6
|
import { Account, Wallet } from "thirdweb/wallets";
|
|
@@ -22,7 +24,7 @@ export interface B3ContextType {
|
|
|
22
24
|
theme: "light" | "dark";
|
|
23
25
|
clientType: ClientType;
|
|
24
26
|
partnerId: string;
|
|
25
|
-
createClientReferenceId?: () => string
|
|
27
|
+
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
/**
|
|
@@ -426,6 +426,10 @@ export interface AnySpendCollectorClubPurchaseProps extends BaseModalProps {
|
|
|
426
426
|
onSuccess?: (txHash?: string) => void;
|
|
427
427
|
/** Client-provided reference ID for tracking orders */
|
|
428
428
|
clientReferenceId?: string;
|
|
429
|
+
/** The vending machine ID */
|
|
430
|
+
vendingMachineId: string;
|
|
431
|
+
/** The pack type */
|
|
432
|
+
packType: string;
|
|
429
433
|
}
|
|
430
434
|
|
|
431
435
|
/**
|