@b3dotfun/sdk 0.0.70 → 0.0.71

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 (81) hide show
  1. package/dist/cjs/anyspend/index.d.ts +1 -0
  2. package/dist/cjs/anyspend/index.js +1 -0
  3. package/dist/cjs/anyspend/react/components/AnySpendCollectorClubPurchase.d.ts +57 -0
  4. package/dist/cjs/anyspend/react/components/AnySpendCollectorClubPurchase.js +82 -0
  5. package/dist/cjs/anyspend/react/components/AnySpendCustom.js +3 -1
  6. package/dist/cjs/anyspend/react/components/index.d.ts +1 -0
  7. package/dist/cjs/anyspend/react/components/index.js +3 -1
  8. package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +4 -0
  9. package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOrder.js +4 -0
  10. package/dist/cjs/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +16 -0
  11. package/dist/cjs/anyspend/react/hooks/useSigMint.d.ts +1 -1
  12. package/dist/cjs/anyspend/react/hooks/useValidatedClientReferenceId.d.ts +5 -0
  13. package/dist/cjs/anyspend/react/hooks/useValidatedClientReferenceId.js +35 -0
  14. package/dist/cjs/anyspend/services/anyspend.d.ts +2 -1
  15. package/dist/cjs/anyspend/services/anyspend.js +5 -1
  16. package/dist/cjs/anyspend/types/api.d.ts +295 -0
  17. package/dist/cjs/anyspend/utils/validation.d.ts +67 -0
  18. package/dist/cjs/anyspend/utils/validation.js +157 -0
  19. package/dist/cjs/global-account/react/components/B3DynamicModal.js +2 -0
  20. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +4 -2
  21. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +4 -3
  22. package/dist/cjs/global-account/react/components/B3Provider/types.d.ts +1 -0
  23. package/dist/cjs/global-account/react/components/B3Provider/types.js +1 -0
  24. package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +1 -1
  25. package/dist/cjs/global-account/react/hooks/useUserQuery.d.ts +1 -1
  26. package/dist/cjs/global-account/react/stores/useModalStore.d.ts +27 -1
  27. package/dist/esm/anyspend/index.d.ts +1 -0
  28. package/dist/esm/anyspend/index.js +1 -0
  29. package/dist/esm/anyspend/react/components/AnySpendCollectorClubPurchase.d.ts +57 -0
  30. package/dist/esm/anyspend/react/components/AnySpendCollectorClubPurchase.js +79 -0
  31. package/dist/esm/anyspend/react/components/AnySpendCustom.js +3 -1
  32. package/dist/esm/anyspend/react/components/index.d.ts +1 -0
  33. package/dist/esm/anyspend/react/components/index.js +1 -0
  34. package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +4 -0
  35. package/dist/esm/anyspend/react/hooks/useAnyspendCreateOrder.js +4 -0
  36. package/dist/esm/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +16 -0
  37. package/dist/esm/anyspend/react/hooks/useSigMint.d.ts +1 -1
  38. package/dist/esm/anyspend/react/hooks/useValidatedClientReferenceId.d.ts +5 -0
  39. package/dist/esm/anyspend/react/hooks/useValidatedClientReferenceId.js +32 -0
  40. package/dist/esm/anyspend/services/anyspend.d.ts +2 -1
  41. package/dist/esm/anyspend/services/anyspend.js +5 -1
  42. package/dist/esm/anyspend/types/api.d.ts +295 -0
  43. package/dist/esm/anyspend/utils/validation.d.ts +67 -0
  44. package/dist/esm/anyspend/utils/validation.js +153 -0
  45. package/dist/esm/global-account/react/components/B3DynamicModal.js +3 -1
  46. package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +4 -2
  47. package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +4 -3
  48. package/dist/esm/global-account/react/components/B3Provider/types.d.ts +1 -0
  49. package/dist/esm/global-account/react/components/B3Provider/types.js +1 -0
  50. package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +1 -1
  51. package/dist/esm/global-account/react/hooks/useUserQuery.d.ts +1 -1
  52. package/dist/esm/global-account/react/stores/useModalStore.d.ts +27 -1
  53. package/dist/types/anyspend/index.d.ts +1 -0
  54. package/dist/types/anyspend/react/components/AnySpendCollectorClubPurchase.d.ts +57 -0
  55. package/dist/types/anyspend/react/components/index.d.ts +1 -0
  56. package/dist/types/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +16 -0
  57. package/dist/types/anyspend/react/hooks/useSigMint.d.ts +1 -1
  58. package/dist/types/anyspend/react/hooks/useValidatedClientReferenceId.d.ts +5 -0
  59. package/dist/types/anyspend/services/anyspend.d.ts +2 -1
  60. package/dist/types/anyspend/types/api.d.ts +295 -0
  61. package/dist/types/anyspend/utils/validation.d.ts +67 -0
  62. package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +4 -2
  63. package/dist/types/global-account/react/components/B3Provider/types.d.ts +1 -0
  64. package/dist/types/global-account/react/hooks/useAuthentication.d.ts +1 -1
  65. package/dist/types/global-account/react/hooks/useUserQuery.d.ts +1 -1
  66. package/dist/types/global-account/react/stores/useModalStore.d.ts +27 -1
  67. package/package.json +1 -1
  68. package/src/anyspend/index.ts +1 -0
  69. package/src/anyspend/react/components/AnySpendCollectorClubPurchase.tsx +178 -0
  70. package/src/anyspend/react/components/AnySpendCustom.tsx +3 -1
  71. package/src/anyspend/react/components/index.ts +1 -0
  72. package/src/anyspend/react/hooks/useAnyspendCreateOnrampOrder.ts +5 -0
  73. package/src/anyspend/react/hooks/useAnyspendCreateOrder.ts +5 -0
  74. package/src/anyspend/react/hooks/useValidatedClientReferenceId.ts +40 -0
  75. package/src/anyspend/services/anyspend.ts +6 -0
  76. package/src/anyspend/types/api.ts +295 -0
  77. package/src/anyspend/utils/validation.ts +209 -0
  78. package/src/global-account/react/components/B3DynamicModal.tsx +3 -0
  79. package/src/global-account/react/components/B3Provider/B3Provider.tsx +6 -0
  80. package/src/global-account/react/components/B3Provider/types.ts +2 -0
  81. package/src/global-account/react/stores/useModalStore.ts +29 -1
@@ -6,6 +6,7 @@ export * from "./utils/json";
6
6
  export * from "./utils/number";
7
7
  export * from "./utils/string";
8
8
  export * from "./utils/token";
9
+ export * from "./utils/validation";
9
10
  export * from "./constants";
10
11
  export * from "./abis/abiUsdcBase";
11
12
  export * from "./abis/erc20Staking";
@@ -24,6 +24,7 @@ __exportStar(require("./utils/json"), exports);
24
24
  __exportStar(require("./utils/number"), exports);
25
25
  __exportStar(require("./utils/string"), exports);
26
26
  __exportStar(require("./utils/token"), exports);
27
+ __exportStar(require("./utils/validation"), exports);
27
28
  // Constants
28
29
  __exportStar(require("./constants"), exports);
29
30
  // Abis
@@ -0,0 +1,57 @@
1
+ import { components } from "../../../anyspend/types/api";
2
+ import { GetQuoteResponse } from "../../../anyspend/types/api_req_res";
3
+ import React from "react";
4
+ export interface AnySpendCollectorClubPurchaseProps {
5
+ /**
6
+ * Optional order ID to load existing order
7
+ */
8
+ loadOrder?: string;
9
+ /**
10
+ * Display mode
11
+ */
12
+ mode?: "modal" | "page";
13
+ /**
14
+ * Active tab (crypto or fiat payment)
15
+ */
16
+ activeTab?: "crypto" | "fiat";
17
+ /**
18
+ * The pack ID to purchase
19
+ */
20
+ packId: number;
21
+ /**
22
+ * The number of packs to purchase
23
+ */
24
+ packAmount: number;
25
+ /**
26
+ * Price per pack in wei (e.g., "10000" for 0.01 USDC with 6 decimals)
27
+ */
28
+ pricePerPack: string;
29
+ /**
30
+ * The payment token (defaults to USDC on Base)
31
+ */
32
+ paymentToken?: components["schemas"]["Token"];
33
+ /**
34
+ * Address that will receive the packs
35
+ */
36
+ recipientAddress: string;
37
+ /**
38
+ * Optional spender address (defaults to contract address)
39
+ */
40
+ spenderAddress?: string;
41
+ /**
42
+ * Success callback
43
+ */
44
+ onSuccess?: (txHash?: string) => void;
45
+ /**
46
+ * Optional custom header component
47
+ */
48
+ header?: (props: {
49
+ anyspendPrice: GetQuoteResponse | undefined;
50
+ isLoadingAnyspendPrice: boolean;
51
+ }) => React.JSX.Element;
52
+ /**
53
+ * Show recipient selection (default: true)
54
+ */
55
+ showRecipient?: boolean;
56
+ }
57
+ export declare function AnySpendCollectorClubPurchase({ loadOrder, mode, activeTab, packId, packAmount, pricePerPack, paymentToken, recipientAddress, spenderAddress, onSuccess, header, showRecipient, }: AnySpendCollectorClubPurchaseProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AnySpendCollectorClubPurchase = AnySpendCollectorClubPurchase;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ /**
6
+ * AnySpend component for Collector Club pack purchases
7
+ *
8
+ * This component enables users to purchase Collector Club packs using any token via AnySpend.
9
+ * It calls the `buyPacksFor` function on the Collector Club Shop contract on Base.
10
+ * Uses exact-out flow to ensure the contract receives exactly the required USDC amount.
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * import { AnySpendCollectorClubPurchase } from "../../..";
15
+ * import { USDC_BASE } from "../../../anyspend/constants";
16
+ *
17
+ * function MyComponent() {
18
+ * return (
19
+ * <AnySpendCollectorClubPurchase
20
+ * packId={1}
21
+ * packAmount={5}
22
+ * pricePerPack="10000" // 0.01 USDC in wei (6 decimals)
23
+ * paymentToken={USDC_BASE}
24
+ * recipientAddress="0x123..."
25
+ * onSuccess={(txHash) => console.log("Purchase successful!", txHash)}
26
+ * />
27
+ * );
28
+ * }
29
+ * ```
30
+ */
31
+ const constants_1 = require("../../../anyspend/constants");
32
+ const react_1 = require("react");
33
+ const viem_1 = require("viem");
34
+ const AnySpendCustom_1 = require("./AnySpendCustom");
35
+ // Collector Club Shop contract on Base
36
+ const CC_SHOP_ADDRESS = "0x68B32D594E3c7E5B8cd8046BD66AfB0DB5b9BF9c";
37
+ const BASE_CHAIN_ID = 8453;
38
+ // ABI for buyPacksFor function only
39
+ const BUY_PACKS_FOR_ABI = {
40
+ inputs: [
41
+ { internalType: "address", name: "user", type: "address" },
42
+ { internalType: "uint256", name: "packId", type: "uint256" },
43
+ { internalType: "uint256", name: "amount", type: "uint256" },
44
+ ],
45
+ name: "buyPacksFor",
46
+ outputs: [],
47
+ stateMutability: "nonpayable",
48
+ type: "function",
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, }) {
51
+ // Calculate total amount needed (pricePerPack * packAmount)
52
+ const totalAmount = (0, react_1.useMemo)(() => {
53
+ try {
54
+ return (BigInt(pricePerPack) * BigInt(packAmount)).toString();
55
+ }
56
+ catch (error) {
57
+ console.error("Failed to calculate total amount from props", { pricePerPack, packAmount, error });
58
+ return "0";
59
+ }
60
+ }, [pricePerPack, packAmount]);
61
+ // Encode the buyPacksFor function call
62
+ const encodedData = (0, react_1.useMemo)(() => {
63
+ try {
64
+ return (0, viem_1.encodeFunctionData)({
65
+ abi: [BUY_PACKS_FOR_ABI],
66
+ functionName: "buyPacksFor",
67
+ args: [recipientAddress, BigInt(packId), BigInt(packAmount)],
68
+ });
69
+ }
70
+ catch (error) {
71
+ console.error("Failed to encode function data", { recipientAddress, packId, packAmount, error });
72
+ return "0x";
73
+ }
74
+ }, [recipientAddress, packId, packAmount]);
75
+ // Default header if not provided
76
+ const defaultHeader = () => ((0, jsx_runtime_1.jsx)("div", { className: "mb-4 flex flex-col items-center gap-3 text-center", children: (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h1", { className: "text-as-primary text-xl font-bold", children: "Buy Collector Club Packs" }), (0, jsx_runtime_1.jsxs)("p", { className: "text-as-secondary text-sm", children: ["Purchase ", packAmount, " pack", packAmount !== 1 ? "s" : "", " using any token"] })] }) }));
77
+ return ((0, jsx_runtime_1.jsx)(AnySpendCustom_1.AnySpendCustom, { loadOrder: loadOrder, mode: mode, activeTab: activeTab, recipientAddress: recipientAddress, spenderAddress: spenderAddress, orderType: "custom", dstChainId: BASE_CHAIN_ID, dstToken: paymentToken, dstAmount: totalAmount, contractAddress: CC_SHOP_ADDRESS, encodedData: encodedData, metadata: {
78
+ packId,
79
+ packAmount,
80
+ pricePerPack,
81
+ }, header: header || defaultHeader, onSuccess: onSuccess, showRecipient: showRecipient }));
82
+ }
@@ -393,7 +393,9 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
393
393
  });
394
394
  }
395
395
  else {
396
- void createRegularOrder(createOrderParams);
396
+ void createRegularOrder({
397
+ ...createOrderParams,
398
+ });
397
399
  }
398
400
  }
399
401
  catch (err) {
@@ -1,6 +1,7 @@
1
1
  export { AnySpend } from "./AnySpend";
2
2
  export { AnySpendBondKit } from "./AnySpendBondKit";
3
3
  export { AnySpendBuySpin } from "./AnySpendBuySpin";
4
+ export { AnySpendCollectorClubPurchase } from "./AnySpendCollectorClubPurchase";
4
5
  export { AnySpendCustom } from "./AnySpendCustom";
5
6
  export { AnySpendCustomExactIn } from "./AnySpendCustomExactIn";
6
7
  export { AnySpendDepositHype, HYPE_TOKEN_DETAILS } from "./AnyspendDepositHype";
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.WebviewOnrampPayment = exports.WebviewOnrampOrderStatus = exports.TransferCryptoDetails = exports.TokenBalance = exports.StepProgress = exports.RecipientSelection = exports.OrderTokenAmount = exports.OrderToken = exports.OrderStatus = exports.OrderHistoryItem = exports.OrderHistory = exports.OrderDetailsCollapsible = exports.OrderDetails = exports.CryptoReceiveSection = exports.CryptoPaySection = exports.ChainTokenIcon = exports.AnySpendNFTButton = exports.AnySpendTournament = exports.AnySpendStakeUpsideExactIn = exports.AnySpendStakeUpside = exports.AnySpendStakeB3ExactIn = exports.AnySpendStakeB3 = exports.AnyspendSignatureMint = exports.AnySpendNFT = exports.HYPE_TOKEN_DETAILS = exports.AnySpendDepositHype = exports.AnySpendCustomExactIn = exports.AnySpendCustom = exports.AnySpendBuySpin = exports.AnySpendBondKit = exports.AnySpend = void 0;
17
+ exports.WebviewOnrampPayment = exports.WebviewOnrampOrderStatus = exports.TransferCryptoDetails = exports.TokenBalance = exports.StepProgress = exports.RecipientSelection = exports.OrderTokenAmount = exports.OrderToken = exports.OrderStatus = exports.OrderHistoryItem = exports.OrderHistory = exports.OrderDetailsCollapsible = exports.OrderDetails = exports.CryptoReceiveSection = exports.CryptoPaySection = exports.ChainTokenIcon = exports.AnySpendNFTButton = exports.AnySpendTournament = exports.AnySpendStakeUpsideExactIn = exports.AnySpendStakeUpside = exports.AnySpendStakeB3ExactIn = exports.AnySpendStakeB3 = exports.AnyspendSignatureMint = exports.AnySpendNFT = exports.HYPE_TOKEN_DETAILS = exports.AnySpendDepositHype = exports.AnySpendCustomExactIn = exports.AnySpendCustom = exports.AnySpendCollectorClubPurchase = exports.AnySpendBuySpin = exports.AnySpendBondKit = exports.AnySpend = void 0;
18
18
  // Components
19
19
  var AnySpend_1 = require("./AnySpend");
20
20
  Object.defineProperty(exports, "AnySpend", { enumerable: true, get: function () { return AnySpend_1.AnySpend; } });
@@ -22,6 +22,8 @@ var AnySpendBondKit_1 = require("./AnySpendBondKit");
22
22
  Object.defineProperty(exports, "AnySpendBondKit", { enumerable: true, get: function () { return AnySpendBondKit_1.AnySpendBondKit; } });
23
23
  var AnySpendBuySpin_1 = require("./AnySpendBuySpin");
24
24
  Object.defineProperty(exports, "AnySpendBuySpin", { enumerable: true, get: function () { return AnySpendBuySpin_1.AnySpendBuySpin; } });
25
+ var AnySpendCollectorClubPurchase_1 = require("./AnySpendCollectorClubPurchase");
26
+ Object.defineProperty(exports, "AnySpendCollectorClubPurchase", { enumerable: true, get: function () { return AnySpendCollectorClubPurchase_1.AnySpendCollectorClubPurchase; } });
25
27
  var AnySpendCustom_1 = require("./AnySpendCustom");
26
28
  Object.defineProperty(exports, "AnySpendCustom", { enumerable: true, get: function () { return AnySpendCustom_1.AnySpendCustom; } });
27
29
  var AnySpendCustomExactIn_1 = require("./AnySpendCustomExactIn");
@@ -9,11 +9,14 @@ const react_query_1 = require("@tanstack/react-query");
9
9
  const react_1 = require("react");
10
10
  const viem_1 = require("viem");
11
11
  const chains_1 = require("viem/chains");
12
+ const useValidatedClientReferenceId_1 = require("./useValidatedClientReferenceId");
12
13
  /**
13
14
  * Hook for creating onramp orders in the Anyspend protocol
14
15
  * Specifically handles orders that involve fiat-to-crypto onramp functionality
15
16
  */
16
17
  function useAnyspendCreateOnrampOrder({ onSuccess, onError } = {}) {
18
+ // Get validated client reference ID from B3 context
19
+ const validatedClientReferenceId = (0, useValidatedClientReferenceId_1.useValidatedClientReferenceId)();
17
20
  // Get fingerprint data
18
21
  const { data: fpData } = (0, fingerprintjs_pro_react_1.useVisitorData)({ extendedResult: true }, { immediate: true });
19
22
  const visitorData = fpData && {
@@ -65,6 +68,7 @@ function useAnyspendCreateOnrampOrder({ onSuccess, onError } = {}) {
65
68
  }),
66
69
  creatorAddress: creatorAddress ? (0, utils_1.normalizeAddress)(creatorAddress) : undefined,
67
70
  partnerId,
71
+ clientReferenceId: validatedClientReferenceId,
68
72
  visitorData,
69
73
  });
70
74
  }
@@ -6,12 +6,15 @@ const utils_1 = require("../../../anyspend/utils");
6
6
  const fingerprintjs_pro_react_1 = require("@fingerprintjs/fingerprintjs-pro-react");
7
7
  const react_query_1 = require("@tanstack/react-query");
8
8
  const react_1 = require("react");
9
+ const useValidatedClientReferenceId_1 = require("./useValidatedClientReferenceId");
9
10
  /**
10
11
  * Hook for creating orders in the Anyspend protocol
11
12
  * Handles regular order creation for swaps, NFT minting, tournament participation, etc.
12
13
  * For onramp orders, use useAnyspendCreateOnrampOrder instead.
13
14
  */
14
15
  function useAnyspendCreateOrder({ onSuccess, onError } = {}) {
16
+ // Get validated client reference ID from B3 context
17
+ const validatedClientReferenceId = (0, useValidatedClientReferenceId_1.useValidatedClientReferenceId)();
15
18
  // Get fingerprint data
16
19
  const { data: fpData } = (0, fingerprintjs_pro_react_1.useVisitorData)({ extendedResult: true }, { immediate: true });
17
20
  const visitorData = fpData && {
@@ -53,6 +56,7 @@ function useAnyspendCreateOrder({ onSuccess, onError } = {}) {
53
56
  },
54
57
  }),
55
58
  creatorAddress: creatorAddress ? (0, utils_1.normalizeAddress)(creatorAddress) : undefined,
59
+ clientReferenceId: validatedClientReferenceId,
56
60
  visitorData,
57
61
  });
58
62
  }
@@ -16,6 +16,7 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
16
16
  receivedDepositAt: number | null;
17
17
  creatorAddress: string | null;
18
18
  partnerId: string | null;
19
+ clientReferenceId?: string | null;
19
20
  onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
20
21
  oneClickBuyUrl: string | null;
21
22
  stripePaymentIntentId: string | null;
@@ -45,6 +46,7 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
45
46
  receivedDepositAt: number | null;
46
47
  creatorAddress: string | null;
47
48
  partnerId: string | null;
49
+ clientReferenceId?: string | null;
48
50
  onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
49
51
  oneClickBuyUrl: string | null;
50
52
  stripePaymentIntentId: string | null;
@@ -74,6 +76,7 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
74
76
  receivedDepositAt: number | null;
75
77
  creatorAddress: string | null;
76
78
  partnerId: string | null;
79
+ clientReferenceId?: string | null;
77
80
  onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
78
81
  oneClickBuyUrl: string | null;
79
82
  stripePaymentIntentId: string | null;
@@ -103,6 +106,7 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
103
106
  receivedDepositAt: number | null;
104
107
  creatorAddress: string | null;
105
108
  partnerId: string | null;
109
+ clientReferenceId?: string | null;
106
110
  onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
107
111
  oneClickBuyUrl: string | null;
108
112
  stripePaymentIntentId: string | null;
@@ -132,6 +136,7 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
132
136
  receivedDepositAt: number | null;
133
137
  creatorAddress: string | null;
134
138
  partnerId: string | null;
139
+ clientReferenceId?: string | null;
135
140
  onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
136
141
  oneClickBuyUrl: string | null;
137
142
  stripePaymentIntentId: string | null;
@@ -161,6 +166,7 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
161
166
  receivedDepositAt: number | null;
162
167
  creatorAddress: string | null;
163
168
  partnerId: string | null;
169
+ clientReferenceId?: string | null;
164
170
  onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
165
171
  oneClickBuyUrl: string | null;
166
172
  stripePaymentIntentId: string | null;
@@ -190,6 +196,7 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
190
196
  receivedDepositAt: number | null;
191
197
  creatorAddress: string | null;
192
198
  partnerId: string | null;
199
+ clientReferenceId?: string | null;
193
200
  onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
194
201
  oneClickBuyUrl: string | null;
195
202
  stripePaymentIntentId: string | null;
@@ -219,6 +226,7 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
219
226
  receivedDepositAt: number | null;
220
227
  creatorAddress: string | null;
221
228
  partnerId: string | null;
229
+ clientReferenceId?: string | null;
222
230
  onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
223
231
  oneClickBuyUrl: string | null;
224
232
  stripePaymentIntentId: string | null;
@@ -251,6 +259,7 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
251
259
  receivedDepositAt: number | null;
252
260
  creatorAddress: string | null;
253
261
  partnerId: string | null;
262
+ clientReferenceId?: string | null;
254
263
  onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
255
264
  oneClickBuyUrl: string | null;
256
265
  stripePaymentIntentId: string | null;
@@ -280,6 +289,7 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
280
289
  receivedDepositAt: number | null;
281
290
  creatorAddress: string | null;
282
291
  partnerId: string | null;
292
+ clientReferenceId?: string | null;
283
293
  onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
284
294
  oneClickBuyUrl: string | null;
285
295
  stripePaymentIntentId: string | null;
@@ -309,6 +319,7 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
309
319
  receivedDepositAt: number | null;
310
320
  creatorAddress: string | null;
311
321
  partnerId: string | null;
322
+ clientReferenceId?: string | null;
312
323
  onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
313
324
  oneClickBuyUrl: string | null;
314
325
  stripePaymentIntentId: string | null;
@@ -338,6 +349,7 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
338
349
  receivedDepositAt: number | null;
339
350
  creatorAddress: string | null;
340
351
  partnerId: string | null;
352
+ clientReferenceId?: string | null;
341
353
  onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
342
354
  oneClickBuyUrl: string | null;
343
355
  stripePaymentIntentId: string | null;
@@ -367,6 +379,7 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
367
379
  receivedDepositAt: number | null;
368
380
  creatorAddress: string | null;
369
381
  partnerId: string | null;
382
+ clientReferenceId?: string | null;
370
383
  onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
371
384
  oneClickBuyUrl: string | null;
372
385
  stripePaymentIntentId: string | null;
@@ -396,6 +409,7 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
396
409
  receivedDepositAt: number | null;
397
410
  creatorAddress: string | null;
398
411
  partnerId: string | null;
412
+ clientReferenceId?: string | null;
399
413
  onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
400
414
  oneClickBuyUrl: string | null;
401
415
  stripePaymentIntentId: string | null;
@@ -425,6 +439,7 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
425
439
  receivedDepositAt: number | null;
426
440
  creatorAddress: string | null;
427
441
  partnerId: string | null;
442
+ clientReferenceId?: string | null;
428
443
  onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
429
444
  oneClickBuyUrl: string | null;
430
445
  stripePaymentIntentId: string | null;
@@ -454,6 +469,7 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
454
469
  receivedDepositAt: number | null;
455
470
  creatorAddress: string | null;
456
471
  partnerId: string | null;
472
+ clientReferenceId?: string | null;
457
473
  onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
458
474
  oneClickBuyUrl: string | null;
459
475
  stripePaymentIntentId: string | null;
@@ -48,8 +48,8 @@ export declare const useGenerateSigMintData: ({ recipientAddress, contractAddres
48
48
  creatorMap?: {} | undefined;
49
49
  chainId: number;
50
50
  address: string;
51
- title: string;
52
51
  _id: string | {};
52
+ title: string;
53
53
  };
54
54
  } | null;
55
55
  error: Error | null;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Hook that provides a validated client reference ID
3
+ * Gets the createClientReferenceId function from B3 context and validates the result
4
+ */
5
+ export declare function useValidatedClientReferenceId(): string | undefined;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useValidatedClientReferenceId = useValidatedClientReferenceId;
4
+ const validation_1 = require("../../../anyspend/utils/validation");
5
+ const react_1 = require("../../../global-account/react");
6
+ const react_2 = require("react");
7
+ /**
8
+ * Hook that provides a validated client reference ID
9
+ * Gets the createClientReferenceId function from B3 context and validates the result
10
+ */
11
+ function useValidatedClientReferenceId() {
12
+ const { createClientReferenceId } = (0, react_1.useB3)();
13
+ const validatedClientReferenceId = (0, react_2.useMemo)(() => {
14
+ // If no function provided, return undefined
15
+ if (!createClientReferenceId) {
16
+ return undefined;
17
+ }
18
+ try {
19
+ // Call the function to generate the ID
20
+ const generatedId = createClientReferenceId();
21
+ // Validate the generated ID
22
+ const validation = validation_1.Validators.clientReferenceId(generatedId);
23
+ if (!validation.isValid) {
24
+ console.error(`[AnySpend] Invalid clientReferenceId generated: ${validation.error || "Validation failed"}. Will be set to undefined.`);
25
+ return undefined;
26
+ }
27
+ return validation.cleaned;
28
+ }
29
+ catch (error) {
30
+ console.error("[AnySpend] Error generating clientReferenceId:", error);
31
+ return undefined;
32
+ }
33
+ }, [createClientReferenceId]);
34
+ return validatedClientReferenceId;
35
+ }
@@ -6,7 +6,7 @@ export declare const anyspendService: {
6
6
  getTokenList: (chainId: number, query: string) => Promise<components["schemas"]["Token"][]>;
7
7
  getToken: (chainId: number, tokenAddress: string) => Promise<components["schemas"]["Token"]>;
8
8
  getQuote: (req: GetQuoteRequest) => Promise<GetQuoteResponse>;
9
- createOrder: ({ recipientAddress, type, srcChain, dstChain, srcTokenAddress, dstTokenAddress, srcAmount, payload, onramp, metadata, creatorAddress, partnerId, visitorData, }: {
9
+ createOrder: ({ recipientAddress, type, srcChain, dstChain, srcTokenAddress, dstTokenAddress, srcAmount, payload, onramp, metadata, creatorAddress, partnerId, clientReferenceId, visitorData, }: {
10
10
  recipientAddress: string;
11
11
  type: string;
12
12
  srcChain: number;
@@ -19,6 +19,7 @@ export declare const anyspendService: {
19
19
  metadata: Record<string, any>;
20
20
  creatorAddress?: string;
21
21
  partnerId?: string;
22
+ clientReferenceId?: string;
22
23
  visitorData?: VisitorData;
23
24
  }) => Promise<{
24
25
  success: boolean;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.anyspendService = void 0;
7
7
  const constants_1 = require("../../anyspend/constants");
8
8
  const utils_1 = require("../../anyspend/utils");
9
+ const app_1 = __importDefault(require("../../global-account/app"));
9
10
  const invariant_1 = __importDefault(require("invariant"));
10
11
  // Service functions
11
12
  exports.anyspendService = {
@@ -41,13 +42,15 @@ exports.anyspendService = {
41
42
  return data;
42
43
  },
43
44
  // Order related
44
- createOrder: async ({ recipientAddress, type, srcChain, dstChain, srcTokenAddress, dstTokenAddress, srcAmount, payload, onramp, metadata, creatorAddress, partnerId, visitorData, }) => {
45
+ createOrder: async ({ recipientAddress, type, srcChain, dstChain, srcTokenAddress, dstTokenAddress, srcAmount, payload, onramp, metadata, creatorAddress, partnerId, clientReferenceId, visitorData, }) => {
46
+ const accessToken = await app_1.default.authentication.getAccessToken();
45
47
  const response = await fetch(`${constants_1.ANYSPEND_MAINNET_BASE_URL}/orders`, {
46
48
  method: "POST",
47
49
  headers: {
48
50
  "Content-Type": "application/json",
49
51
  ...(visitorData?.requestId && { "X-Fingerprint-Request-Id": visitorData.requestId }),
50
52
  ...(visitorData?.visitorId && { "X-Fingerprint-Visitor-Id": visitorData.visitorId }),
53
+ ...(accessToken && { Authorization: `Bearer ${accessToken}` }),
51
54
  },
52
55
  body: JSON.stringify({
53
56
  recipientAddress,
@@ -62,6 +65,7 @@ exports.anyspendService = {
62
65
  metadata,
63
66
  creatorAddress,
64
67
  partnerId,
68
+ ...(clientReferenceId && { clientReferenceId }),
65
69
  }),
66
70
  });
67
71
  const data = await response.json();