@b3dotfun/sdk 0.0.72 → 0.0.73-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/cjs/anyspend/react/components/AnySpendCollectorClubPurchase.d.ts +9 -1
  2. package/dist/cjs/anyspend/react/components/AnySpendCollectorClubPurchase.js +3 -1
  3. package/dist/cjs/anyspend/react/components/AnySpendCustom.js +1 -0
  4. package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +3 -2
  5. package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOrder.d.ts +1 -0
  6. package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOrder.js +3 -2
  7. package/dist/cjs/anyspend/react/hooks/useValidatedClientReferenceId.d.ts +3 -1
  8. package/dist/cjs/anyspend/react/hooks/useValidatedClientReferenceId.js +3 -3
  9. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +4 -2
  10. package/dist/cjs/global-account/react/components/B3Provider/types.d.ts +3 -1
  11. package/dist/cjs/global-account/react/stores/useModalStore.d.ts +4 -0
  12. package/dist/esm/anyspend/react/components/AnySpendCollectorClubPurchase.d.ts +9 -1
  13. package/dist/esm/anyspend/react/components/AnySpendCollectorClubPurchase.js +3 -1
  14. package/dist/esm/anyspend/react/components/AnySpendCustom.js +1 -0
  15. package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +3 -2
  16. package/dist/esm/anyspend/react/hooks/useAnyspendCreateOrder.d.ts +1 -0
  17. package/dist/esm/anyspend/react/hooks/useAnyspendCreateOrder.js +3 -2
  18. package/dist/esm/anyspend/react/hooks/useValidatedClientReferenceId.d.ts +3 -1
  19. package/dist/esm/anyspend/react/hooks/useValidatedClientReferenceId.js +4 -4
  20. package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +4 -2
  21. package/dist/esm/global-account/react/components/B3Provider/types.d.ts +3 -1
  22. package/dist/esm/global-account/react/stores/useModalStore.d.ts +4 -0
  23. package/dist/types/anyspend/react/components/AnySpendCollectorClubPurchase.d.ts +9 -1
  24. package/dist/types/anyspend/react/hooks/useAnyspendCreateOrder.d.ts +1 -0
  25. package/dist/types/anyspend/react/hooks/useValidatedClientReferenceId.d.ts +3 -1
  26. package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +4 -2
  27. package/dist/types/global-account/react/components/B3Provider/types.d.ts +3 -1
  28. package/dist/types/global-account/react/stores/useModalStore.d.ts +4 -0
  29. package/package.json +1 -1
  30. package/src/anyspend/react/components/AnySpendCollectorClubPurchase.tsx +12 -0
  31. package/src/anyspend/react/components/AnySpendCustom.tsx +1 -0
  32. package/src/anyspend/react/hooks/useAnyspendCreateOnrampOrder.ts +4 -2
  33. package/src/anyspend/react/hooks/useAnyspendCreateOrder.ts +4 -2
  34. package/src/anyspend/react/hooks/useValidatedClientReferenceId.ts +28 -23
  35. package/src/global-account/react/components/B3Provider/B3Provider.tsx +4 -2
  36. package/src/global-account/react/components/B3Provider/types.ts +3 -1
  37. 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;
@@ -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 validatedClientReferenceId = (0, useValidatedClientReferenceId_1.useValidatedClientReferenceId)();
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: validatedClientReferenceId,
75
+ clientReferenceId,
75
76
  visitorData,
76
77
  });
77
78
  }
@@ -17,6 +17,7 @@ export type CreateOrderParams = {
17
17
  };
18
18
  creatorAddress?: string;
19
19
  payload?: any;
20
+ metadata?: Record<string, any>;
20
21
  };
21
22
  export type UseAnyspendCreateOrderProps = {
22
23
  onSuccess?: (data: any) => void;
@@ -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 validatedClientReferenceId = (0, useValidatedClientReferenceId_1.useValidatedClientReferenceId)();
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: validatedClientReferenceId,
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 validatedClientReferenceId = (0, react_2.useMemo)(() => {
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 validatedClientReferenceId;
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
  }
@@ -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;
@@ -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 validatedClientReferenceId = useValidatedClientReferenceId();
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: validatedClientReferenceId,
72
+ clientReferenceId,
72
73
  visitorData,
73
74
  });
74
75
  }
@@ -17,6 +17,7 @@ export type CreateOrderParams = {
17
17
  };
18
18
  creatorAddress?: string;
19
19
  payload?: any;
20
+ metadata?: Record<string, any>;
20
21
  };
21
22
  export type UseAnyspendCreateOrderProps = {
22
23
  onSuccess?: (data: any) => void;
@@ -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 validatedClientReferenceId = useValidatedClientReferenceId();
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: validatedClientReferenceId,
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 { useMemo } from "react";
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 validatedClientReferenceId = useMemo(() => {
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 validatedClientReferenceId;
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;
@@ -17,6 +17,7 @@ export type CreateOrderParams = {
17
17
  };
18
18
  creatorAddress?: string;
19
19
  payload?: any;
20
+ metadata?: Record<string, any>;
20
21
  };
21
22
  export type UseAnyspendCreateOrderProps = {
22
23
  onSuccess?: (data: any) => void;
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@b3dotfun/sdk",
3
- "version": "0.0.72",
3
+ "version": "0.0.73-alpha.0",
4
4
  "source": "src/index.ts",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "react-native": "./dist/cjs/index.native.js",
@@ -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) {
@@ -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 validatedClientReferenceId = useValidatedClientReferenceId();
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: validatedClientReferenceId,
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 validatedClientReferenceId = useValidatedClientReferenceId();
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: validatedClientReferenceId,
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 { useMemo } from "react";
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 validatedClientReferenceId = useMemo(() => {
13
- // If no function provided, return undefined
14
- if (!createClientReferenceId) {
15
- return undefined;
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
- try {
19
- // Call the function to generate the ID
20
- const generatedId = createClientReferenceId();
21
+ try {
22
+ // Call the function to generate the ID
23
+ const generatedId = await createClientReferenceId(params);
21
24
 
22
- // Validate the generated ID
23
- const validation = Validators.clientReferenceId(generatedId);
25
+ // Validate the generated ID
26
+ const validation = Validators.clientReferenceId(generatedId);
24
27
 
25
- if (!validation.isValid) {
26
- console.error(
27
- `[AnySpend] Invalid clientReferenceId generated: ${validation.error || "Validation failed"}. Will be set to undefined.`,
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
- return validation.cleaned;
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
  /**