@b3dotfun/sdk 0.0.71 → 0.0.72-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 +1 -0
- package/dist/cjs/anyspend/react/components/webview/WebviewOnrampPayment.js +1 -3
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +9 -5
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOrder.d.ts +1 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOrder.js +9 -4
- 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/components/ui/drawer.d.ts +1 -1
- package/dist/cjs/global-account/react/components/ui/drawer.js +1 -1
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +4 -0
- package/dist/cjs/shared/react/stores/currencyStore.js +2 -1
- 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 +1 -0
- package/dist/esm/anyspend/react/components/webview/WebviewOnrampPayment.js +1 -3
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +7 -3
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOrder.d.ts +1 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOrder.js +7 -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/components/ui/drawer.d.ts +1 -1
- package/dist/esm/global-account/react/components/ui/drawer.js +1 -1
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +4 -0
- package/dist/esm/shared/react/stores/currencyStore.js +2 -1
- package/dist/types/anyspend/react/components/AnySpendCollectorClubPurchase.d.ts +9 -1
- package/dist/types/anyspend/react/hooks/useAnyspendCreateOrder.d.ts +1 -1
- 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/components/ui/drawer.d.ts +1 -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 +1 -0
- package/src/anyspend/react/components/webview/WebviewOnrampPayment.tsx +0 -3
- package/src/anyspend/react/hooks/useAnyspendCreateOnrampOrder.ts +8 -3
- package/src/anyspend/react/hooks/useAnyspendCreateOrder.ts +9 -3
- 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/components/ui/drawer.tsx +6 -2
- package/src/global-account/react/stores/useModalStore.ts +4 -0
- package/src/shared/react/stores/currencyStore.ts +3 -1
|
@@ -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;
|
|
@@ -90,7 +90,7 @@ function StripePaymentForm({ order, onPaymentSuccess, }) {
|
|
|
90
90
|
},
|
|
91
91
|
} }) })), error && ((0, jsx_runtime_1.jsx)("div", { className: "mt-4 rounded-lg border border-red-200 bg-red-50 p-3 text-sm text-red-600", children: error })), (0, jsx_runtime_1.jsx)("button", { type: "submit", disabled: !stripe || isProcessing, className: "mt-6 w-full rounded-xl bg-blue-600 px-4 py-3 font-medium text-white hover:bg-blue-700 disabled:cursor-not-allowed disabled:opacity-50", children: isProcessing ? ((0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-center gap-2", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "h-5 w-5 animate-spin" }), (0, jsx_runtime_1.jsx)("span", { children: "Processing..." })] })) : ((0, jsx_runtime_1.jsx)("span", { children: "Complete Payment" })) })] }) }) }));
|
|
92
92
|
}
|
|
93
|
-
function WebviewOnrampPaymentInner({ srcAmountOnRamp, recipientAddress, destinationToken, anyspendQuote, onPaymentSuccess, userId,
|
|
93
|
+
function WebviewOnrampPaymentInner({ srcAmountOnRamp, recipientAddress, destinationToken, anyspendQuote, onPaymentSuccess, userId, }) {
|
|
94
94
|
const [createdOrder, setCreatedOrder] = (0, react_3.useState)(null);
|
|
95
95
|
const orderCreationAttempted = (0, react_3.useRef)(false);
|
|
96
96
|
const { geoData, stripeWeb2Support, isLoading: isLoadingGeoOnramp } = (0, react_1.useGeoOnrampOptions)(srcAmountOnRamp);
|
|
@@ -136,7 +136,6 @@ function WebviewOnrampPaymentInner({ srcAmountOnRamp, recipientAddress, destinat
|
|
|
136
136
|
redirectUrl: `${window.location.origin}${userId ? `?userId=${userId}` : ""}`,
|
|
137
137
|
},
|
|
138
138
|
expectedDstAmount: anyspendQuote.data?.currencyOut?.amount?.toString() || "0",
|
|
139
|
-
partnerId,
|
|
140
139
|
});
|
|
141
140
|
}
|
|
142
141
|
catch (err) {
|
|
@@ -154,7 +153,6 @@ function WebviewOnrampPaymentInner({ srcAmountOnRamp, recipientAddress, destinat
|
|
|
154
153
|
createOrder,
|
|
155
154
|
destinationToken,
|
|
156
155
|
userId,
|
|
157
|
-
partnerId,
|
|
158
156
|
stripeWeb2Support.isSupport,
|
|
159
157
|
]);
|
|
160
158
|
// Check if all required data is loaded
|
|
@@ -4,9 +4,10 @@ exports.useAnyspendCreateOnrampOrder = useAnyspendCreateOnrampOrder;
|
|
|
4
4
|
const constants_1 = require("../../../anyspend/constants");
|
|
5
5
|
const anyspend_1 = require("../../../anyspend/services/anyspend");
|
|
6
6
|
const utils_1 = require("../../../anyspend/utils");
|
|
7
|
+
const react_1 = require("../../../global-account/react");
|
|
7
8
|
const fingerprintjs_pro_react_1 = require("@fingerprintjs/fingerprintjs-pro-react");
|
|
8
9
|
const react_query_1 = require("@tanstack/react-query");
|
|
9
|
-
const
|
|
10
|
+
const react_2 = require("react");
|
|
10
11
|
const viem_1 = require("viem");
|
|
11
12
|
const chains_1 = require("viem/chains");
|
|
12
13
|
const useValidatedClientReferenceId_1 = require("./useValidatedClientReferenceId");
|
|
@@ -15,8 +16,10 @@ const useValidatedClientReferenceId_1 = require("./useValidatedClientReferenceId
|
|
|
15
16
|
* Specifically handles orders that involve fiat-to-crypto onramp functionality
|
|
16
17
|
*/
|
|
17
18
|
function useAnyspendCreateOnrampOrder({ onSuccess, onError } = {}) {
|
|
19
|
+
// Get B3 context values
|
|
20
|
+
const { partnerId } = (0, react_1.useB3)();
|
|
18
21
|
// Get validated client reference ID from B3 context
|
|
19
|
-
const
|
|
22
|
+
const createValidatedClientReferenceId = (0, useValidatedClientReferenceId_1.useValidatedClientReferenceId)();
|
|
20
23
|
// Get fingerprint data
|
|
21
24
|
const { data: fpData } = (0, fingerprintjs_pro_react_1.useVisitorData)({ extendedResult: true }, { immediate: true });
|
|
22
25
|
const visitorData = fpData && {
|
|
@@ -25,7 +28,8 @@ function useAnyspendCreateOnrampOrder({ onSuccess, onError } = {}) {
|
|
|
25
28
|
};
|
|
26
29
|
const { mutate: createOrder, isPending } = (0, react_query_1.useMutation)({
|
|
27
30
|
mutationFn: async (params) => {
|
|
28
|
-
const { recipientAddress, orderType, dstChain, dstToken, srcFiatAmount, onramp, creatorAddress, expectedDstAmount, nft, tournament, payload,
|
|
31
|
+
const { recipientAddress, orderType, dstChain, dstToken, srcFiatAmount, onramp, creatorAddress, expectedDstAmount, nft, tournament, payload, } = params;
|
|
32
|
+
const clientReferenceId = await createValidatedClientReferenceId(params);
|
|
29
33
|
try {
|
|
30
34
|
// Validate required onramp fields
|
|
31
35
|
if (!onramp.vendor || !onramp.country) {
|
|
@@ -68,7 +72,7 @@ function useAnyspendCreateOnrampOrder({ onSuccess, onError } = {}) {
|
|
|
68
72
|
}),
|
|
69
73
|
creatorAddress: creatorAddress ? (0, utils_1.normalizeAddress)(creatorAddress) : undefined,
|
|
70
74
|
partnerId,
|
|
71
|
-
clientReferenceId
|
|
75
|
+
clientReferenceId,
|
|
72
76
|
visitorData,
|
|
73
77
|
});
|
|
74
78
|
}
|
|
@@ -88,7 +92,7 @@ function useAnyspendCreateOnrampOrder({ onSuccess, onError } = {}) {
|
|
|
88
92
|
onError?.(error);
|
|
89
93
|
},
|
|
90
94
|
});
|
|
91
|
-
return (0,
|
|
95
|
+
return (0, react_2.useMemo)(() => ({
|
|
92
96
|
createOrder,
|
|
93
97
|
isCreatingOrder: isPending,
|
|
94
98
|
}), [createOrder, isPending]);
|
|
@@ -3,9 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useAnyspendCreateOrder = useAnyspendCreateOrder;
|
|
4
4
|
const anyspend_1 = require("../../../anyspend/services/anyspend");
|
|
5
5
|
const utils_1 = require("../../../anyspend/utils");
|
|
6
|
+
const react_1 = require("../../../global-account/react");
|
|
6
7
|
const fingerprintjs_pro_react_1 = require("@fingerprintjs/fingerprintjs-pro-react");
|
|
7
8
|
const react_query_1 = require("@tanstack/react-query");
|
|
8
|
-
const
|
|
9
|
+
const react_2 = require("react");
|
|
9
10
|
const useValidatedClientReferenceId_1 = require("./useValidatedClientReferenceId");
|
|
10
11
|
/**
|
|
11
12
|
* Hook for creating orders in the Anyspend protocol
|
|
@@ -13,8 +14,10 @@ const useValidatedClientReferenceId_1 = require("./useValidatedClientReferenceId
|
|
|
13
14
|
* For onramp orders, use useAnyspendCreateOnrampOrder instead.
|
|
14
15
|
*/
|
|
15
16
|
function useAnyspendCreateOrder({ onSuccess, onError } = {}) {
|
|
17
|
+
// Get B3 context values
|
|
18
|
+
const { partnerId } = (0, react_1.useB3)();
|
|
16
19
|
// Get validated client reference ID from B3 context
|
|
17
|
-
const
|
|
20
|
+
const createValidatedClientReferenceId = (0, useValidatedClientReferenceId_1.useValidatedClientReferenceId)();
|
|
18
21
|
// Get fingerprint data
|
|
19
22
|
const { data: fpData } = (0, fingerprintjs_pro_react_1.useVisitorData)({ extendedResult: true }, { immediate: true });
|
|
20
23
|
const visitorData = fpData && {
|
|
@@ -24,6 +27,7 @@ function useAnyspendCreateOrder({ onSuccess, onError } = {}) {
|
|
|
24
27
|
const { mutate: createOrder, isPending } = (0, react_query_1.useMutation)({
|
|
25
28
|
mutationFn: async (params) => {
|
|
26
29
|
const { recipientAddress, orderType, srcChain, dstChain, srcToken, dstToken, srcAmount, creatorAddress } = params;
|
|
30
|
+
const clientReferenceId = await createValidatedClientReferenceId(params);
|
|
27
31
|
try {
|
|
28
32
|
return await anyspend_1.anyspendService.createOrder({
|
|
29
33
|
recipientAddress: (0, utils_1.normalizeAddress)(recipientAddress),
|
|
@@ -56,7 +60,8 @@ function useAnyspendCreateOrder({ onSuccess, onError } = {}) {
|
|
|
56
60
|
},
|
|
57
61
|
}),
|
|
58
62
|
creatorAddress: creatorAddress ? (0, utils_1.normalizeAddress)(creatorAddress) : undefined,
|
|
59
|
-
|
|
63
|
+
partnerId,
|
|
64
|
+
clientReferenceId,
|
|
60
65
|
visitorData,
|
|
61
66
|
});
|
|
62
67
|
}
|
|
@@ -76,7 +81,7 @@ function useAnyspendCreateOrder({ onSuccess, onError } = {}) {
|
|
|
76
81
|
onError?.(error);
|
|
77
82
|
},
|
|
78
83
|
});
|
|
79
|
-
return (0,
|
|
84
|
+
return (0, react_2.useMemo)(() => ({
|
|
80
85
|
createOrder,
|
|
81
86
|
isCreatingOrder: isPending,
|
|
82
87
|
}), [createOrder, isPending]);
|
|
@@ -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
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { Drawer as DrawerPrimitive } from "vaul";
|
|
3
3
|
declare const Drawer: {
|
|
4
|
-
({ shouldScaleBackground, ...props }: React.ComponentProps<typeof DrawerPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
({ shouldScaleBackground, repositionInputs, ...props }: React.ComponentProps<typeof DrawerPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
displayName: string;
|
|
6
6
|
};
|
|
7
7
|
declare const DrawerTrigger: React.ForwardRefExoticComponent<import("@radix-ui/react-dialog").DialogTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -39,7 +39,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
39
39
|
const React = __importStar(require("react"));
|
|
40
40
|
const vaul_1 = require("vaul");
|
|
41
41
|
const utils_1 = require("../../../../shared/utils");
|
|
42
|
-
const Drawer = ({ shouldScaleBackground = true, ...props }) => ((0, jsx_runtime_1.jsx)(vaul_1.Drawer.Root, { shouldScaleBackground: shouldScaleBackground, ...props }));
|
|
42
|
+
const Drawer = ({ shouldScaleBackground = true, repositionInputs = false, ...props }) => ((0, jsx_runtime_1.jsx)(vaul_1.Drawer.Root, { repositionInputs: repositionInputs, shouldScaleBackground: shouldScaleBackground, ...props }));
|
|
43
43
|
exports.Drawer = Drawer;
|
|
44
44
|
Drawer.displayName = "Drawer";
|
|
45
45
|
const DrawerTrigger = vaul_1.Drawer.Trigger;
|
|
@@ -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
|
|
@@ -81,7 +81,8 @@ exports.useCurrencyStore = (0, zustand_1.create)()((0, middleware_1.persist)((se
|
|
|
81
81
|
removeCurrency: code => {
|
|
82
82
|
set(state => {
|
|
83
83
|
// Remove the currency
|
|
84
|
-
const
|
|
84
|
+
const customCurrencies = state.customCurrencies;
|
|
85
|
+
const remaining = Object.fromEntries(Object.entries(customCurrencies).filter(([key]) => key !== code));
|
|
85
86
|
// Remove all exchange rates involving this currency
|
|
86
87
|
const filteredRates = {};
|
|
87
88
|
for (const [key, rate] of Object.entries(state.customExchangeRates)) {
|
|
@@ -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
|
}
|
|
@@ -84,7 +84,7 @@ function StripePaymentForm({ order, onPaymentSuccess, }) {
|
|
|
84
84
|
},
|
|
85
85
|
} }) })), error && (_jsx("div", { className: "mt-4 rounded-lg border border-red-200 bg-red-50 p-3 text-sm text-red-600", children: error })), _jsx("button", { type: "submit", disabled: !stripe || isProcessing, className: "mt-6 w-full rounded-xl bg-blue-600 px-4 py-3 font-medium text-white hover:bg-blue-700 disabled:cursor-not-allowed disabled:opacity-50", children: isProcessing ? (_jsxs("div", { className: "flex items-center justify-center gap-2", children: [_jsx(Loader2, { className: "h-5 w-5 animate-spin" }), _jsx("span", { children: "Processing..." })] })) : (_jsx("span", { children: "Complete Payment" })) })] }) }) }));
|
|
86
86
|
}
|
|
87
|
-
function WebviewOnrampPaymentInner({ srcAmountOnRamp, recipientAddress, destinationToken, anyspendQuote, onPaymentSuccess, userId,
|
|
87
|
+
function WebviewOnrampPaymentInner({ srcAmountOnRamp, recipientAddress, destinationToken, anyspendQuote, onPaymentSuccess, userId, }) {
|
|
88
88
|
const [createdOrder, setCreatedOrder] = useState(null);
|
|
89
89
|
const orderCreationAttempted = useRef(false);
|
|
90
90
|
const { geoData, stripeWeb2Support, isLoading: isLoadingGeoOnramp } = useGeoOnrampOptions(srcAmountOnRamp);
|
|
@@ -130,7 +130,6 @@ function WebviewOnrampPaymentInner({ srcAmountOnRamp, recipientAddress, destinat
|
|
|
130
130
|
redirectUrl: `${window.location.origin}${userId ? `?userId=${userId}` : ""}`,
|
|
131
131
|
},
|
|
132
132
|
expectedDstAmount: anyspendQuote.data?.currencyOut?.amount?.toString() || "0",
|
|
133
|
-
partnerId,
|
|
134
133
|
});
|
|
135
134
|
}
|
|
136
135
|
catch (err) {
|
|
@@ -148,7 +147,6 @@ function WebviewOnrampPaymentInner({ srcAmountOnRamp, recipientAddress, destinat
|
|
|
148
147
|
createOrder,
|
|
149
148
|
destinationToken,
|
|
150
149
|
userId,
|
|
151
|
-
partnerId,
|
|
152
150
|
stripeWeb2Support.isSupport,
|
|
153
151
|
]);
|
|
154
152
|
// Check if all required data is loaded
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { USDC_BASE } from "../../../anyspend/constants/index.js";
|
|
2
2
|
import { anyspendService } from "../../../anyspend/services/anyspend.js";
|
|
3
3
|
import { buildMetadata, buildPayload, normalizeAddress } from "../../../anyspend/utils/index.js";
|
|
4
|
+
import { useB3 } from "../../../global-account/react/index.js";
|
|
4
5
|
import { useVisitorData } from "@fingerprintjs/fingerprintjs-pro-react";
|
|
5
6
|
import { useMutation } from "@tanstack/react-query";
|
|
6
7
|
import { useMemo } from "react";
|
|
@@ -12,8 +13,10 @@ import { useValidatedClientReferenceId } from "./useValidatedClientReferenceId.j
|
|
|
12
13
|
* Specifically handles orders that involve fiat-to-crypto onramp functionality
|
|
13
14
|
*/
|
|
14
15
|
export function useAnyspendCreateOnrampOrder({ onSuccess, onError } = {}) {
|
|
16
|
+
// Get B3 context values
|
|
17
|
+
const { partnerId } = useB3();
|
|
15
18
|
// Get validated client reference ID from B3 context
|
|
16
|
-
const
|
|
19
|
+
const createValidatedClientReferenceId = useValidatedClientReferenceId();
|
|
17
20
|
// Get fingerprint data
|
|
18
21
|
const { data: fpData } = useVisitorData({ extendedResult: true }, { immediate: true });
|
|
19
22
|
const visitorData = fpData && {
|
|
@@ -22,7 +25,8 @@ export function useAnyspendCreateOnrampOrder({ onSuccess, onError } = {}) {
|
|
|
22
25
|
};
|
|
23
26
|
const { mutate: createOrder, isPending } = useMutation({
|
|
24
27
|
mutationFn: async (params) => {
|
|
25
|
-
const { recipientAddress, orderType, dstChain, dstToken, srcFiatAmount, onramp, creatorAddress, expectedDstAmount, nft, tournament, payload,
|
|
28
|
+
const { recipientAddress, orderType, dstChain, dstToken, srcFiatAmount, onramp, creatorAddress, expectedDstAmount, nft, tournament, payload, } = params;
|
|
29
|
+
const clientReferenceId = await createValidatedClientReferenceId(params);
|
|
26
30
|
try {
|
|
27
31
|
// Validate required onramp fields
|
|
28
32
|
if (!onramp.vendor || !onramp.country) {
|
|
@@ -65,7 +69,7 @@ export function useAnyspendCreateOnrampOrder({ onSuccess, onError } = {}) {
|
|
|
65
69
|
}),
|
|
66
70
|
creatorAddress: creatorAddress ? normalizeAddress(creatorAddress) : undefined,
|
|
67
71
|
partnerId,
|
|
68
|
-
clientReferenceId
|
|
72
|
+
clientReferenceId,
|
|
69
73
|
visitorData,
|
|
70
74
|
});
|
|
71
75
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { anyspendService } from "../../../anyspend/services/anyspend.js";
|
|
2
2
|
import { buildMetadata, buildPayload, normalizeAddress } from "../../../anyspend/utils/index.js";
|
|
3
|
+
import { useB3 } from "../../../global-account/react/index.js";
|
|
3
4
|
import { useVisitorData } from "@fingerprintjs/fingerprintjs-pro-react";
|
|
4
5
|
import { useMutation } from "@tanstack/react-query";
|
|
5
6
|
import { useMemo } from "react";
|
|
@@ -10,8 +11,10 @@ import { useValidatedClientReferenceId } from "./useValidatedClientReferenceId.j
|
|
|
10
11
|
* For onramp orders, use useAnyspendCreateOnrampOrder instead.
|
|
11
12
|
*/
|
|
12
13
|
export function useAnyspendCreateOrder({ onSuccess, onError } = {}) {
|
|
14
|
+
// Get B3 context values
|
|
15
|
+
const { partnerId } = useB3();
|
|
13
16
|
// Get validated client reference ID from B3 context
|
|
14
|
-
const
|
|
17
|
+
const createValidatedClientReferenceId = useValidatedClientReferenceId();
|
|
15
18
|
// Get fingerprint data
|
|
16
19
|
const { data: fpData } = useVisitorData({ extendedResult: true }, { immediate: true });
|
|
17
20
|
const visitorData = fpData && {
|
|
@@ -21,6 +24,7 @@ export function useAnyspendCreateOrder({ onSuccess, onError } = {}) {
|
|
|
21
24
|
const { mutate: createOrder, isPending } = useMutation({
|
|
22
25
|
mutationFn: async (params) => {
|
|
23
26
|
const { recipientAddress, orderType, srcChain, dstChain, srcToken, dstToken, srcAmount, creatorAddress } = params;
|
|
27
|
+
const clientReferenceId = await createValidatedClientReferenceId(params);
|
|
24
28
|
try {
|
|
25
29
|
return await anyspendService.createOrder({
|
|
26
30
|
recipientAddress: normalizeAddress(recipientAddress),
|
|
@@ -53,7 +57,8 @@ export function useAnyspendCreateOrder({ onSuccess, onError } = {}) {
|
|
|
53
57
|
},
|
|
54
58
|
}),
|
|
55
59
|
creatorAddress: creatorAddress ? normalizeAddress(creatorAddress) : undefined,
|
|
56
|
-
|
|
60
|
+
partnerId,
|
|
61
|
+
clientReferenceId,
|
|
57
62
|
visitorData,
|
|
58
63
|
});
|
|
59
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
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { Drawer as DrawerPrimitive } from "vaul";
|
|
3
3
|
declare const Drawer: {
|
|
4
|
-
({ shouldScaleBackground, ...props }: React.ComponentProps<typeof DrawerPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
({ shouldScaleBackground, repositionInputs, ...props }: React.ComponentProps<typeof DrawerPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
displayName: string;
|
|
6
6
|
};
|
|
7
7
|
declare const DrawerTrigger: React.ForwardRefExoticComponent<import("@radix-ui/react-dialog").DialogTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { Drawer as DrawerPrimitive } from "vaul";
|
|
5
5
|
import { cn } from "../../../../shared/utils/index.js";
|
|
6
|
-
const Drawer = ({ shouldScaleBackground = true, ...props }) => (_jsx(DrawerPrimitive.Root, { shouldScaleBackground: shouldScaleBackground, ...props }));
|
|
6
|
+
const Drawer = ({ shouldScaleBackground = true, repositionInputs = false, ...props }) => (_jsx(DrawerPrimitive.Root, { repositionInputs: repositionInputs, shouldScaleBackground: shouldScaleBackground, ...props }));
|
|
7
7
|
Drawer.displayName = "Drawer";
|
|
8
8
|
const DrawerTrigger = DrawerPrimitive.Trigger;
|
|
9
9
|
const DrawerPortal = DrawerPrimitive.Portal;
|
|
@@ -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
|
|
@@ -74,7 +74,8 @@ export const useCurrencyStore = create()(persist((set, get) => ({
|
|
|
74
74
|
removeCurrency: code => {
|
|
75
75
|
set(state => {
|
|
76
76
|
// Remove the currency
|
|
77
|
-
const
|
|
77
|
+
const customCurrencies = state.customCurrencies;
|
|
78
|
+
const remaining = Object.fromEntries(Object.entries(customCurrencies).filter(([key]) => key !== code));
|
|
78
79
|
// Remove all exchange rates involving this currency
|
|
79
80
|
const filteredRates = {};
|
|
80
81
|
for (const [key, rate] of Object.entries(state.customExchangeRates)) {
|
|
@@ -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
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { Drawer as DrawerPrimitive } from "vaul";
|
|
3
3
|
declare const Drawer: {
|
|
4
|
-
({ shouldScaleBackground, ...props }: React.ComponentProps<typeof DrawerPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
({ shouldScaleBackground, repositionInputs, ...props }: React.ComponentProps<typeof DrawerPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
displayName: string;
|
|
6
6
|
};
|
|
7
7
|
declare const DrawerTrigger: React.ForwardRefExoticComponent<import("@radix-ui/react-dialog").DialogTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -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}
|
|
@@ -157,7 +157,6 @@ function WebviewOnrampPaymentInner({
|
|
|
157
157
|
anyspendQuote,
|
|
158
158
|
onPaymentSuccess,
|
|
159
159
|
userId,
|
|
160
|
-
partnerId,
|
|
161
160
|
}: WebviewOnrampPaymentProps) {
|
|
162
161
|
const [createdOrder, setCreatedOrder] = useState<components["schemas"]["Order"] | null>(null);
|
|
163
162
|
const orderCreationAttempted = useRef(false);
|
|
@@ -214,7 +213,6 @@ function WebviewOnrampPaymentInner({
|
|
|
214
213
|
redirectUrl: `${window.location.origin}${userId ? `?userId=${userId}` : ""}`,
|
|
215
214
|
},
|
|
216
215
|
expectedDstAmount: anyspendQuote.data?.currencyOut?.amount?.toString() || "0",
|
|
217
|
-
partnerId,
|
|
218
216
|
});
|
|
219
217
|
} catch (err: any) {
|
|
220
218
|
console.error(err);
|
|
@@ -232,7 +230,6 @@ function WebviewOnrampPaymentInner({
|
|
|
232
230
|
createOrder,
|
|
233
231
|
destinationToken,
|
|
234
232
|
userId,
|
|
235
|
-
partnerId,
|
|
236
233
|
stripeWeb2Support.isSupport,
|
|
237
234
|
]);
|
|
238
235
|
|
|
@@ -3,6 +3,7 @@ import { anyspendService } from "@b3dotfun/sdk/anyspend/services/anyspend";
|
|
|
3
3
|
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
4
4
|
import { VisitorData } from "@b3dotfun/sdk/anyspend/types/fingerprint";
|
|
5
5
|
import { buildMetadata, buildPayload, normalizeAddress } from "@b3dotfun/sdk/anyspend/utils";
|
|
6
|
+
import { useB3 } from "@b3dotfun/sdk/global-account/react";
|
|
6
7
|
import { useVisitorData } from "@fingerprintjs/fingerprintjs-pro-react";
|
|
7
8
|
import { useMutation } from "@tanstack/react-query";
|
|
8
9
|
import { useMemo } from "react";
|
|
@@ -34,8 +35,11 @@ export type UseAnyspendCreateOnrampOrderProps = {
|
|
|
34
35
|
* Specifically handles orders that involve fiat-to-crypto onramp functionality
|
|
35
36
|
*/
|
|
36
37
|
export function useAnyspendCreateOnrampOrder({ onSuccess, onError }: UseAnyspendCreateOnrampOrderProps = {}) {
|
|
38
|
+
// Get B3 context values
|
|
39
|
+
const { partnerId } = useB3();
|
|
40
|
+
|
|
37
41
|
// Get validated client reference ID from B3 context
|
|
38
|
-
const
|
|
42
|
+
const createValidatedClientReferenceId = useValidatedClientReferenceId();
|
|
39
43
|
|
|
40
44
|
// Get fingerprint data
|
|
41
45
|
const { data: fpData } = useVisitorData({ extendedResult: true }, { immediate: true });
|
|
@@ -58,9 +62,10 @@ export function useAnyspendCreateOnrampOrder({ onSuccess, onError }: UseAnyspend
|
|
|
58
62
|
nft,
|
|
59
63
|
tournament,
|
|
60
64
|
payload,
|
|
61
|
-
partnerId,
|
|
62
65
|
} = params;
|
|
63
66
|
|
|
67
|
+
const clientReferenceId = await createValidatedClientReferenceId(params);
|
|
68
|
+
|
|
64
69
|
try {
|
|
65
70
|
// Validate required onramp fields
|
|
66
71
|
if (!onramp.vendor || !onramp.country) {
|
|
@@ -106,7 +111,7 @@ export function useAnyspendCreateOnrampOrder({ onSuccess, onError }: UseAnyspend
|
|
|
106
111
|
}),
|
|
107
112
|
creatorAddress: creatorAddress ? normalizeAddress(creatorAddress) : undefined,
|
|
108
113
|
partnerId,
|
|
109
|
-
clientReferenceId
|
|
114
|
+
clientReferenceId,
|
|
110
115
|
visitorData,
|
|
111
116
|
});
|
|
112
117
|
} catch (error: any) {
|
|
@@ -2,6 +2,7 @@ import { anyspendService } from "@b3dotfun/sdk/anyspend/services/anyspend";
|
|
|
2
2
|
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
3
3
|
import { VisitorData } from "@b3dotfun/sdk/anyspend/types/fingerprint";
|
|
4
4
|
import { buildMetadata, buildPayload, normalizeAddress } from "@b3dotfun/sdk/anyspend/utils";
|
|
5
|
+
import { useB3 } from "@b3dotfun/sdk/global-account/react";
|
|
5
6
|
import { useVisitorData } from "@fingerprintjs/fingerprintjs-pro-react";
|
|
6
7
|
import { useMutation } from "@tanstack/react-query";
|
|
7
8
|
import { useMemo } from "react";
|
|
@@ -20,7 +21,7 @@ export type CreateOrderParams = {
|
|
|
20
21
|
tournament?: components["schemas"]["Tournament"] & { contractAddress: string; entryPriceOrFundAmount: string };
|
|
21
22
|
creatorAddress?: string;
|
|
22
23
|
payload?: any;
|
|
23
|
-
|
|
24
|
+
metadata?: Record<string, any>;
|
|
24
25
|
};
|
|
25
26
|
|
|
26
27
|
export type UseAnyspendCreateOrderProps = {
|
|
@@ -34,8 +35,11 @@ export type UseAnyspendCreateOrderProps = {
|
|
|
34
35
|
* For onramp orders, use useAnyspendCreateOnrampOrder instead.
|
|
35
36
|
*/
|
|
36
37
|
export function useAnyspendCreateOrder({ onSuccess, onError }: UseAnyspendCreateOrderProps = {}) {
|
|
38
|
+
// Get B3 context values
|
|
39
|
+
const { partnerId } = useB3();
|
|
40
|
+
|
|
37
41
|
// Get validated client reference ID from B3 context
|
|
38
|
-
const
|
|
42
|
+
const createValidatedClientReferenceId = useValidatedClientReferenceId();
|
|
39
43
|
|
|
40
44
|
// Get fingerprint data
|
|
41
45
|
const { data: fpData } = useVisitorData({ extendedResult: true }, { immediate: true });
|
|
@@ -46,6 +50,7 @@ export function useAnyspendCreateOrder({ onSuccess, onError }: UseAnyspendCreate
|
|
|
46
50
|
const { mutate: createOrder, isPending } = useMutation({
|
|
47
51
|
mutationFn: async (params: CreateOrderParams) => {
|
|
48
52
|
const { recipientAddress, orderType, srcChain, dstChain, srcToken, dstToken, srcAmount, creatorAddress } = params;
|
|
53
|
+
const clientReferenceId = await createValidatedClientReferenceId(params);
|
|
49
54
|
|
|
50
55
|
try {
|
|
51
56
|
return await anyspendService.createOrder({
|
|
@@ -79,7 +84,8 @@ export function useAnyspendCreateOrder({ onSuccess, onError }: UseAnyspendCreate
|
|
|
79
84
|
},
|
|
80
85
|
}),
|
|
81
86
|
creatorAddress: creatorAddress ? normalizeAddress(creatorAddress) : undefined,
|
|
82
|
-
|
|
87
|
+
partnerId,
|
|
88
|
+
clientReferenceId,
|
|
83
89
|
visitorData,
|
|
84
90
|
});
|
|
85
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
|
/**
|
|
@@ -5,8 +5,12 @@ import { Drawer as DrawerPrimitive } from "vaul";
|
|
|
5
5
|
|
|
6
6
|
import { cn } from "@b3dotfun/sdk/shared/utils";
|
|
7
7
|
|
|
8
|
-
const Drawer = ({
|
|
9
|
-
|
|
8
|
+
const Drawer = ({
|
|
9
|
+
shouldScaleBackground = true,
|
|
10
|
+
repositionInputs = false,
|
|
11
|
+
...props
|
|
12
|
+
}: React.ComponentProps<typeof DrawerPrimitive.Root>) => (
|
|
13
|
+
<DrawerPrimitive.Root repositionInputs={repositionInputs} shouldScaleBackground={shouldScaleBackground} {...props} />
|
|
10
14
|
);
|
|
11
15
|
Drawer.displayName = "Drawer";
|
|
12
16
|
|
|
@@ -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
|
/**
|
|
@@ -147,7 +147,9 @@ export const useCurrencyStore = create<CurrencyState>()(
|
|
|
147
147
|
removeCurrency: code => {
|
|
148
148
|
set(state => {
|
|
149
149
|
// Remove the currency
|
|
150
|
-
const
|
|
150
|
+
const customCurrencies = state.customCurrencies;
|
|
151
|
+
|
|
152
|
+
const remaining = Object.fromEntries(Object.entries(customCurrencies).filter(([key]) => key !== code));
|
|
151
153
|
|
|
152
154
|
// Remove all exchange rates involving this currency
|
|
153
155
|
const filteredRates: Record<string, number> = {};
|