@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
@@ -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,32 @@
1
+ import { Validators } from "../../../anyspend/utils/validation.js";
2
+ import { useB3 } from "../../../global-account/react/index.js";
3
+ import { useMemo } from "react";
4
+ /**
5
+ * Hook that provides a validated client reference ID
6
+ * Gets the createClientReferenceId function from B3 context and validates the result
7
+ */
8
+ export function useValidatedClientReferenceId() {
9
+ const { createClientReferenceId } = useB3();
10
+ const validatedClientReferenceId = useMemo(() => {
11
+ // If no function provided, return undefined
12
+ if (!createClientReferenceId) {
13
+ return undefined;
14
+ }
15
+ try {
16
+ // Call the function to generate the ID
17
+ const generatedId = createClientReferenceId();
18
+ // Validate the generated ID
19
+ const validation = Validators.clientReferenceId(generatedId);
20
+ if (!validation.isValid) {
21
+ console.error(`[AnySpend] Invalid clientReferenceId generated: ${validation.error || "Validation failed"}. Will be set to undefined.`);
22
+ return undefined;
23
+ }
24
+ return validation.cleaned;
25
+ }
26
+ catch (error) {
27
+ console.error("[AnySpend] Error generating clientReferenceId:", error);
28
+ return undefined;
29
+ }
30
+ }, [createClientReferenceId]);
31
+ return validatedClientReferenceId;
32
+ }
@@ -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;
@@ -1,5 +1,6 @@
1
1
  import { ANYSPEND_MAINNET_BASE_URL } from "../../anyspend/constants/index.js";
2
2
  import { getNativeToken, isNativeToken } from "../../anyspend/utils/index.js";
3
+ import app from "../../global-account/app.js";
3
4
  import invariant from "invariant";
4
5
  // Service functions
5
6
  export const anyspendService = {
@@ -35,13 +36,15 @@ export const anyspendService = {
35
36
  return data;
36
37
  },
37
38
  // Order related
38
- createOrder: async ({ recipientAddress, type, srcChain, dstChain, srcTokenAddress, dstTokenAddress, srcAmount, payload, onramp, metadata, creatorAddress, partnerId, visitorData, }) => {
39
+ createOrder: async ({ recipientAddress, type, srcChain, dstChain, srcTokenAddress, dstTokenAddress, srcAmount, payload, onramp, metadata, creatorAddress, partnerId, clientReferenceId, visitorData, }) => {
40
+ const accessToken = await app.authentication.getAccessToken();
39
41
  const response = await fetch(`${ANYSPEND_MAINNET_BASE_URL}/orders`, {
40
42
  method: "POST",
41
43
  headers: {
42
44
  "Content-Type": "application/json",
43
45
  ...(visitorData?.requestId && { "X-Fingerprint-Request-Id": visitorData.requestId }),
44
46
  ...(visitorData?.visitorId && { "X-Fingerprint-Visitor-Id": visitorData.visitorId }),
47
+ ...(accessToken && { Authorization: `Bearer ${accessToken}` }),
45
48
  },
46
49
  body: JSON.stringify({
47
50
  recipientAddress,
@@ -56,6 +59,7 @@ export const anyspendService = {
56
59
  metadata,
57
60
  creatorAddress,
58
61
  partnerId,
62
+ ...(clientReferenceId && { clientReferenceId }),
59
63
  }),
60
64
  });
61
65
  const data = await response.json();