@b3dotfun/sdk 0.0.12 → 0.0.13-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.
Files changed (112) hide show
  1. package/dist/cjs/anyspend/react/components/AnySpend.js +2 -5
  2. package/dist/cjs/anyspend/react/components/AnySpendCustom.js +2 -2
  3. package/dist/cjs/anyspend/react/components/AnySpendFingerprintWrapper.d.ts +17 -0
  4. package/dist/cjs/anyspend/react/components/AnySpendFingerprintWrapper.js +40 -0
  5. package/dist/cjs/anyspend/react/components/common/OrderDetails.js +2 -1
  6. package/dist/cjs/anyspend/react/components/common/PanelOnrampPayment.d.ts +1 -1
  7. package/dist/cjs/anyspend/react/components/common/PanelOnrampPayment.js +9 -4
  8. package/dist/cjs/anyspend/react/components/common/PaymentStripeWeb2.js +6 -9
  9. package/dist/cjs/anyspend/react/components/index.d.ts +1 -0
  10. package/dist/cjs/anyspend/react/components/index.js +15 -0
  11. package/dist/cjs/anyspend/react/components/webview/WebviewOnrampPayment.d.ts +1 -1
  12. package/dist/cjs/anyspend/react/components/webview/WebviewOnrampPayment.js +6 -1
  13. package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +1 -1
  14. package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +14 -2
  15. package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOrder.js +14 -2
  16. package/dist/cjs/anyspend/react/hooks/useCoinbaseOnrampOptions.d.ts +2 -1
  17. package/dist/cjs/anyspend/react/hooks/useCoinbaseOnrampOptions.js +4 -4
  18. package/dist/cjs/anyspend/react/hooks/useGeoOnrampOptions.d.ts +1 -1
  19. package/dist/cjs/anyspend/react/hooks/useGeoOnrampOptions.js +10 -3
  20. package/dist/cjs/anyspend/react/hooks/useStripeSupport.d.ts +2 -1
  21. package/dist/cjs/anyspend/react/hooks/useStripeSupport.js +4 -4
  22. package/dist/cjs/anyspend/react/providers/StripeRedirectHandler.js +0 -3
  23. package/dist/cjs/anyspend/services/anyspend.d.ts +6 -4
  24. package/dist/cjs/anyspend/services/anyspend.js +14 -4
  25. package/dist/cjs/anyspend/types/fingerprint.d.ts +14 -0
  26. package/dist/cjs/anyspend/types/fingerprint.js +6 -0
  27. package/dist/cjs/global-account/react/hooks/index.d.ts +0 -2
  28. package/dist/cjs/global-account/react/hooks/index.js +1 -5
  29. package/dist/cjs/global-account/react/hooks/useAccountWallet.js +2 -3
  30. package/dist/cjs/global-account/react/hooks/useProfile.d.ts +27 -0
  31. package/dist/cjs/global-account/react/hooks/useProfile.js +65 -0
  32. package/dist/esm/anyspend/react/components/AnySpend.js +3 -6
  33. package/dist/esm/anyspend/react/components/AnySpendCustom.js +3 -3
  34. package/dist/esm/anyspend/react/components/AnySpendFingerprintWrapper.d.ts +17 -0
  35. package/dist/esm/anyspend/react/components/AnySpendFingerprintWrapper.js +36 -0
  36. package/dist/esm/anyspend/react/components/common/OrderDetails.js +3 -2
  37. package/dist/esm/anyspend/react/components/common/PanelOnrampPayment.d.ts +1 -1
  38. package/dist/esm/anyspend/react/components/common/PanelOnrampPayment.js +9 -4
  39. package/dist/esm/anyspend/react/components/common/PaymentStripeWeb2.js +6 -9
  40. package/dist/esm/anyspend/react/components/index.d.ts +1 -0
  41. package/dist/esm/anyspend/react/components/index.js +1 -0
  42. package/dist/esm/anyspend/react/components/webview/WebviewOnrampPayment.d.ts +1 -1
  43. package/dist/esm/anyspend/react/components/webview/WebviewOnrampPayment.js +6 -1
  44. package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +1 -1
  45. package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +14 -2
  46. package/dist/esm/anyspend/react/hooks/useAnyspendCreateOrder.js +14 -2
  47. package/dist/esm/anyspend/react/hooks/useCoinbaseOnrampOptions.d.ts +2 -1
  48. package/dist/esm/anyspend/react/hooks/useCoinbaseOnrampOptions.js +4 -4
  49. package/dist/esm/anyspend/react/hooks/useGeoOnrampOptions.d.ts +1 -1
  50. package/dist/esm/anyspend/react/hooks/useGeoOnrampOptions.js +10 -3
  51. package/dist/esm/anyspend/react/hooks/useStripeSupport.d.ts +2 -1
  52. package/dist/esm/anyspend/react/hooks/useStripeSupport.js +4 -4
  53. package/dist/esm/anyspend/react/providers/StripeRedirectHandler.js +0 -3
  54. package/dist/esm/anyspend/services/anyspend.d.ts +6 -4
  55. package/dist/esm/anyspend/services/anyspend.js +14 -4
  56. package/dist/esm/anyspend/types/fingerprint.d.ts +14 -0
  57. package/dist/esm/anyspend/types/fingerprint.js +5 -0
  58. package/dist/esm/global-account/react/hooks/index.d.ts +0 -2
  59. package/dist/esm/global-account/react/hooks/index.js +0 -2
  60. package/dist/esm/global-account/react/hooks/useAccountWallet.js +3 -4
  61. package/dist/esm/global-account/react/hooks/useProfile.d.ts +27 -0
  62. package/dist/esm/global-account/react/hooks/useProfile.js +63 -0
  63. package/dist/types/anyspend/react/components/AnySpendFingerprintWrapper.d.ts +17 -0
  64. package/dist/types/anyspend/react/components/common/PanelOnrampPayment.d.ts +1 -1
  65. package/dist/types/anyspend/react/components/index.d.ts +1 -0
  66. package/dist/types/anyspend/react/components/webview/WebviewOnrampPayment.d.ts +1 -1
  67. package/dist/types/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +1 -1
  68. package/dist/types/anyspend/react/hooks/useCoinbaseOnrampOptions.d.ts +2 -1
  69. package/dist/types/anyspend/react/hooks/useGeoOnrampOptions.d.ts +1 -1
  70. package/dist/types/anyspend/react/hooks/useStripeSupport.d.ts +2 -1
  71. package/dist/types/anyspend/services/anyspend.d.ts +6 -4
  72. package/dist/types/anyspend/types/fingerprint.d.ts +14 -0
  73. package/dist/types/global-account/react/hooks/index.d.ts +0 -2
  74. package/dist/types/global-account/react/hooks/useProfile.d.ts +27 -0
  75. package/package.json +3 -1
  76. package/src/anyspend/react/components/AnySpend.tsx +3 -7
  77. package/src/anyspend/react/components/AnySpendCustom.tsx +3 -3
  78. package/src/anyspend/react/components/AnySpendFingerprintWrapper.tsx +60 -0
  79. package/src/anyspend/react/components/common/OrderDetails.tsx +4 -2
  80. package/src/anyspend/react/components/common/PanelOnrampPayment.tsx +38 -24
  81. package/src/anyspend/react/components/common/PaymentStripeWeb2.tsx +13 -16
  82. package/src/anyspend/react/components/index.ts +1 -0
  83. package/src/anyspend/react/components/webview/WebviewOnrampPayment.tsx +11 -1
  84. package/src/anyspend/react/hooks/useAnyspendCreateOnrampOrder.ts +18 -3
  85. package/src/anyspend/react/hooks/useAnyspendCreateOrder.ts +16 -3
  86. package/src/anyspend/react/hooks/useCoinbaseOnrampOptions.ts +10 -4
  87. package/src/anyspend/react/hooks/useGeoOnrampOptions.ts +15 -4
  88. package/src/anyspend/react/hooks/useStripeSupport.ts +11 -4
  89. package/src/anyspend/react/providers/StripeRedirectHandler.tsx +0 -4
  90. package/src/anyspend/services/anyspend.ts +21 -2
  91. package/src/anyspend/types/fingerprint.ts +15 -0
  92. package/src/global-account/react/hooks/index.ts +0 -2
  93. package/src/global-account/react/hooks/useAccountWallet.tsx +3 -4
  94. package/src/global-account/react/hooks/useProfile.ts +102 -0
  95. package/dist/cjs/global-account/react/hooks/useBsmntProfile.d.ts +0 -4
  96. package/dist/cjs/global-account/react/hooks/useBsmntProfile.js +0 -13
  97. package/dist/cjs/global-account/react/hooks/useOnchainName.d.ts +0 -19
  98. package/dist/cjs/global-account/react/hooks/useOnchainName.js +0 -193
  99. package/dist/cjs/shared/utils/fetchBsmntProfile.d.ts +0 -1
  100. package/dist/cjs/shared/utils/fetchBsmntProfile.js +0 -26
  101. package/dist/esm/global-account/react/hooks/useBsmntProfile.d.ts +0 -4
  102. package/dist/esm/global-account/react/hooks/useBsmntProfile.js +0 -9
  103. package/dist/esm/global-account/react/hooks/useOnchainName.d.ts +0 -19
  104. package/dist/esm/global-account/react/hooks/useOnchainName.js +0 -187
  105. package/dist/esm/shared/utils/fetchBsmntProfile.d.ts +0 -1
  106. package/dist/esm/shared/utils/fetchBsmntProfile.js +0 -23
  107. package/dist/types/global-account/react/hooks/useBsmntProfile.d.ts +0 -4
  108. package/dist/types/global-account/react/hooks/useOnchainName.d.ts +0 -19
  109. package/dist/types/shared/utils/fetchBsmntProfile.d.ts +0 -1
  110. package/src/global-account/react/hooks/useBsmntProfile.ts +0 -14
  111. package/src/global-account/react/hooks/useOnchainName.tsx +0 -198
  112. package/src/shared/utils/fetchBsmntProfile.ts +0 -29
@@ -1,4 +1,5 @@
1
- export declare function useStripeSupport(isMainnet: boolean, ipAddress: string, usdAmount?: string): {
1
+ import { VisitorData } from "../../../anyspend/types/fingerprint";
2
+ export declare function useStripeSupport(isMainnet: boolean, ipAddress: string, usdAmount?: string, visitorData?: VisitorData, isLoadingVisitorData?: boolean): {
2
3
  isStripeOnrampSupported: boolean;
3
4
  isStripeWeb2Supported: boolean;
4
5
  isLoadingStripeSupport: boolean;
@@ -1,11 +1,11 @@
1
1
  import { anyspendService } from "../../../anyspend/services/anyspend.js";
2
2
  import { useQuery } from "@tanstack/react-query";
3
3
  import { useMemo } from "react";
4
- export function useStripeSupport(isMainnet, ipAddress, usdAmount) {
4
+ export function useStripeSupport(isMainnet, ipAddress, usdAmount, visitorData, isLoadingVisitorData) {
5
5
  const { data, isLoading, error, refetch } = useQuery({
6
- queryKey: ["useStripeSupport", isMainnet, ipAddress, usdAmount],
7
- queryFn: () => anyspendService.checkStripeSupport(isMainnet, ipAddress, usdAmount),
8
- enabled: !!ipAddress,
6
+ queryKey: ["useStripeSupport", isMainnet, ipAddress, usdAmount, visitorData?.requestId, visitorData?.visitorId],
7
+ queryFn: () => anyspendService.checkStripeSupport(isMainnet, ipAddress, usdAmount, visitorData),
8
+ enabled: !!ipAddress && !isLoadingVisitorData,
9
9
  });
10
10
  return useMemo(() => ({
11
11
  isStripeOnrampSupported: data?.stripeOnramp || false,
@@ -16,9 +16,6 @@ export function StripeRedirectHandler() {
16
16
  const fromStripe = url.searchParams.get("fromStripe");
17
17
  const paymentIntent = url.searchParams.get("payment_intent");
18
18
  const orderId = url.searchParams.get("orderId");
19
- console.log("@@stripe-web2-payment:fromStripe:", fromStripe);
20
- console.log("@@stripe-web2-payment:paymentIntent:", paymentIntent);
21
- console.log("@@stripe-web2-payment:orderId:", orderId);
22
19
  if (fromStripe && paymentIntent && orderId) {
23
20
  // Re-open the modal with the order details
24
21
  setB3ModalOpen(true);
@@ -1,11 +1,12 @@
1
1
  import { OnrampOptions } from "../../anyspend/react";
2
- import { GetCoinbaseOnrampOptionsResponse, GetOrderAndTxsResponse, GetOrderHistoryResponse, GetQuoteRequest, GetQuoteResponse } from "../types/api_req_res";
3
2
  import { components } from "../types/api";
3
+ import { GetCoinbaseOnrampOptionsResponse, GetOrderAndTxsResponse, GetOrderHistoryResponse, GetQuoteRequest, GetQuoteResponse } from "../types/api_req_res";
4
+ import { VisitorData } from "../types/fingerprint";
4
5
  export declare const anyspendService: {
5
6
  getTokenList: (isMainnet: boolean, chainId: number, query: string) => Promise<components["schemas"]["Token"][]>;
6
7
  getToken: (isMainnet: boolean, chainId: number, tokenAddress: string) => Promise<components["schemas"]["Token"]>;
7
8
  getQuote: (isMainnet: boolean, req: GetQuoteRequest) => Promise<GetQuoteResponse>;
8
- createOrder: ({ isMainnet, recipientAddress, type, srcChain, dstChain, srcTokenAddress, dstTokenAddress, srcAmount, payload, onramp, metadata, creatorAddress, partnerId, }: {
9
+ createOrder: ({ isMainnet, recipientAddress, type, srcChain, dstChain, srcTokenAddress, dstTokenAddress, srcAmount, payload, onramp, metadata, creatorAddress, partnerId, visitorData, }: {
9
10
  isMainnet: boolean;
10
11
  recipientAddress: string;
11
12
  type: string;
@@ -19,6 +20,7 @@ export declare const anyspendService: {
19
20
  metadata: Record<string, any>;
20
21
  creatorAddress?: string;
21
22
  partnerId?: string;
23
+ visitorData?: VisitorData;
22
24
  }) => Promise<{
23
25
  success: boolean;
24
26
  message: string;
@@ -27,8 +29,8 @@ export declare const anyspendService: {
27
29
  }>;
28
30
  getOrderAndTransactions: (isMainnet: boolean, orderId: string | undefined) => Promise<GetOrderAndTxsResponse>;
29
31
  getOrderHistory: (isMainnet: boolean, creatorAddress: string | undefined, limit?: number, offset?: number) => Promise<GetOrderHistoryResponse>;
30
- getCoinbaseOnrampOptions: (isMainnet: boolean, country: string) => Promise<GetCoinbaseOnrampOptionsResponse>;
31
- checkStripeSupport: (isMainnet: boolean, ipAddress: string, usdAmount?: string) => Promise<{
32
+ getCoinbaseOnrampOptions: (isMainnet: boolean, country: string, visitorData?: VisitorData) => Promise<GetCoinbaseOnrampOptionsResponse>;
33
+ checkStripeSupport: (isMainnet: boolean, ipAddress: string, usdAmount?: string, visitorData?: VisitorData) => Promise<{
32
34
  stripeOnramp: boolean;
33
35
  stripeWeb2: boolean;
34
36
  }>;
@@ -35,11 +35,13 @@ export const anyspendService = {
35
35
  return data;
36
36
  },
37
37
  // Order related
38
- createOrder: async ({ isMainnet, recipientAddress, type, srcChain, dstChain, srcTokenAddress, dstTokenAddress, srcAmount, payload, onramp, metadata, creatorAddress, partnerId, }) => {
38
+ createOrder: async ({ isMainnet, recipientAddress, type, srcChain, dstChain, srcTokenAddress, dstTokenAddress, srcAmount, payload, onramp, metadata, creatorAddress, partnerId, visitorData, }) => {
39
39
  const response = await fetch(`${isMainnet ? ANYSPEND_MAINNET_BASE_URL : ANYSPEND_TESTNET_BASE_URL}/orders`, {
40
40
  method: "POST",
41
41
  headers: {
42
42
  "Content-Type": "application/json",
43
+ ...(visitorData?.requestId && { "X-Fingerprint-Request-Id": visitorData.requestId }),
44
+ ...(visitorData?.visitorId && { "X-Fingerprint-Visitor-Id": visitorData.visitorId }),
43
45
  },
44
46
  body: JSON.stringify({
45
47
  recipientAddress,
@@ -77,20 +79,28 @@ export const anyspendService = {
77
79
  const data = await response.json();
78
80
  return data;
79
81
  },
80
- getCoinbaseOnrampOptions: async (isMainnet, country) => {
82
+ getCoinbaseOnrampOptions: async (isMainnet, country, visitorData) => {
81
83
  const params = new URLSearchParams({
82
84
  country,
85
+ // include fingerprintId and requestId in the query params
86
+ ...(visitorData?.requestId && { requestId: visitorData.requestId }),
87
+ ...(visitorData?.visitorId && { fingerprintId: visitorData.visitorId }),
83
88
  });
84
89
  const response = await fetch(`${isMainnet ? ANYSPEND_MAINNET_BASE_URL : ANYSPEND_TESTNET_BASE_URL}/onramp/coinbase/options?${params.toString()}`);
85
90
  const data = await response.json();
86
91
  return data;
87
92
  },
88
- checkStripeSupport: async (isMainnet, ipAddress, usdAmount) => {
93
+ checkStripeSupport: async (isMainnet, ipAddress, usdAmount, visitorData) => {
89
94
  const params = new URLSearchParams({
90
95
  ipAddress,
91
96
  usdAmount: usdAmount || "",
92
97
  });
93
- const response = await fetch(`${isMainnet ? ANYSPEND_MAINNET_BASE_URL : ANYSPEND_TESTNET_BASE_URL}/onramp/stripe/supported?${params.toString()}`);
98
+ const response = await fetch(`${isMainnet ? ANYSPEND_MAINNET_BASE_URL : ANYSPEND_TESTNET_BASE_URL}/onramp/stripe/supported?${params.toString()}`, {
99
+ headers: {
100
+ ...(visitorData?.requestId && { "X-Fingerprint-Request-Id": visitorData.requestId }),
101
+ ...(visitorData?.visitorId && { "X-Fingerprint-Visitor-Id": visitorData.visitorId }),
102
+ },
103
+ });
94
104
  const data = await response.json();
95
105
  invariant(response.status === 200, "Failed to check Stripe support");
96
106
  return data.data;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Types related to FingerprintJS integration
3
+ * We only need requestId and visitorId from the full FingerprintJS visitor data
4
+ */
5
+ export interface VisitorData {
6
+ /**
7
+ * @description The unique identifier of the request to get visitor data
8
+ */
9
+ requestId: string;
10
+ /**
11
+ * @description The unique identifier of the visitor
12
+ */
13
+ visitorId: string;
14
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Types related to FingerprintJS integration
3
+ * We only need requestId and visitorId from the full FingerprintJS visitor data
4
+ */
5
+ export {};
@@ -5,7 +5,6 @@ export { useAuthentication } from "./useAuthentication";
5
5
  export { useB3BalanceFromAddresses } from "./useB3BalanceFromAddresses";
6
6
  export { useB3EnsName } from "./useB3EnsName";
7
7
  export { useBestTransactionPath } from "./useBestTransactionPath";
8
- export { useBsmntProfile } from "./useBsmntProfile";
9
8
  export { useChainSwitchWithAction } from "./useChainSwitchWithAction";
10
9
  export { useClaim } from "./useClaim";
11
10
  export { useConnect } from "./useConnect";
@@ -18,7 +17,6 @@ export { useIsMobile } from "./useIsMobile";
18
17
  export { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect";
19
18
  export { useMediaQuery } from "./useMediaQuery";
20
19
  export { useNativeBalance, useNativeBalanceFromRPC } from "./useNativeBalance";
21
- export { useOnchainName } from "./useOnchainName";
22
20
  export { useOneBalance } from "./useOneBalance";
23
21
  export { useProfile, useProfilePreference, type Profile, type CombinedProfile, type PreferenceRequestBody, } from "./useProfile";
24
22
  export { useQueryB3 } from "./useQueryB3";
@@ -5,7 +5,6 @@ export { useAuthentication } from "./useAuthentication.js";
5
5
  export { useB3BalanceFromAddresses } from "./useB3BalanceFromAddresses.js";
6
6
  export { useB3EnsName } from "./useB3EnsName.js";
7
7
  export { useBestTransactionPath } from "./useBestTransactionPath.js";
8
- export { useBsmntProfile } from "./useBsmntProfile.js";
9
8
  export { useChainSwitchWithAction } from "./useChainSwitchWithAction.js";
10
9
  export { useClaim } from "./useClaim.js";
11
10
  export { useConnect } from "./useConnect.js";
@@ -18,7 +17,6 @@ export { useIsMobile } from "./useIsMobile.js";
18
17
  export { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect.js";
19
18
  export { useMediaQuery } from "./useMediaQuery.js";
20
19
  export { useNativeBalance, useNativeBalanceFromRPC } from "./useNativeBalance.js";
21
- export { useOnchainName } from "./useOnchainName.js";
22
20
  export { useOneBalance } from "./useOneBalance.js";
23
21
  export { useProfile, useProfilePreference, } from "./useProfile.js";
24
22
  export { useQueryB3 } from "./useQueryB3.js";
@@ -1,9 +1,8 @@
1
- import { useB3 } from "../../../global-account/react/index.js";
1
+ import { useB3, useProfile } from "../../../global-account/react/index.js";
2
2
  import { ecosystemWalletId } from "../../../shared/constants/index.js";
3
3
  import { useEffect, useMemo, useState } from "react";
4
4
  import { getLastAuthProvider, useActiveWallet, useConnectedWallets, useWalletImage } from "thirdweb/react";
5
5
  import { socialIcons } from "thirdweb/wallets/in-app";
6
- import { useBsmntProfile } from "./useBsmntProfile.js";
7
6
  function useLastAuthProvider() {
8
7
  const [lastAuthProvider, setLastAuthProvider] = useState(null);
9
8
  useEffect(() => {
@@ -29,8 +28,8 @@ export function useAccountWallet() {
29
28
  const smartWalletIcon = lastAuthProvider && !connectedEOAWallet
30
29
  ? socialIcons[lastAuthProvider]
31
30
  : "https://gradvatar.com/0x0000000000000000000000000000000000000000"; // show smart wallet of eoa wallet is gradvatar
32
- const { data: profileData } = useBsmntProfile({ address: account?.address });
33
- const ensName = profileData?.username?.replace(/\.b3\.fun/g, "");
31
+ const { data: profileData } = useProfile({ address: account?.address });
32
+ const ensName = profileData?.displayName?.replace(/\.b3\.fun/g, "");
34
33
  const avatarUrl = profileData?.avatar;
35
34
  const res = useMemo(() => ({
36
35
  wallet: {
@@ -21,6 +21,13 @@ export interface PreferenceRequestBody {
21
21
  signer: string;
22
22
  timestamp: number;
23
23
  }
24
+ export interface DisplayNameRequestBody {
25
+ key: string;
26
+ displayName: string;
27
+ signature: string;
28
+ signer: string;
29
+ timestamp: number;
30
+ }
24
31
  export declare function useProfile({ address, name, fresh, }: {
25
32
  address?: string;
26
33
  name?: string;
@@ -35,4 +42,24 @@ export declare function useProfilePreference(): {
35
42
  success: boolean;
36
43
  }>;
37
44
  };
45
+ export declare function useDisplayName(): {
46
+ setName: (key: string, displayName: string, signerAddress: string, signMessage: (message: string) => Promise<string>) => Promise<{
47
+ success: boolean;
48
+ }>;
49
+ };
50
+ export declare function useProfileSettings(): {
51
+ setPreference: (key: string, preferredType: string, signerAddress: string, signMessage: (message: string) => Promise<string>) => Promise<{
52
+ success: boolean;
53
+ }>;
54
+ setDisplayName: (key: string, displayName: string, signerAddress: string, signMessage: (message: string) => Promise<string>) => Promise<{
55
+ success: boolean;
56
+ }>;
57
+ updateSettings: (key: string, signerAddress: string, signMessage: (message: string) => Promise<string>, settings: {
58
+ preferredType?: string;
59
+ displayName?: string;
60
+ }) => Promise<{
61
+ preference?: any;
62
+ displayName?: any;
63
+ }>;
64
+ };
38
65
  export default useProfile;
@@ -36,6 +36,25 @@ async function setProfilePreference({ key, preferredType, signature, signer, tim
36
36
  }
37
37
  return response.json();
38
38
  }
39
+ async function setDisplayName({ key, displayName, signature, signer, timestamp, }) {
40
+ const response = await fetch(`${PROFILES_API_URL}/display-name`, {
41
+ method: "POST",
42
+ headers: {
43
+ "Content-Type": "application/json",
44
+ },
45
+ body: JSON.stringify({
46
+ key,
47
+ displayName,
48
+ signature,
49
+ signer,
50
+ timestamp,
51
+ }),
52
+ });
53
+ if (!response.ok) {
54
+ throw new Error(`Failed to set display name: ${response.statusText}`);
55
+ }
56
+ return response.json();
57
+ }
39
58
  export function useProfile({ address, name, fresh = false, }, options) {
40
59
  return useQuery({
41
60
  queryKey: ["profile", address || name, fresh],
@@ -65,4 +84,48 @@ export function useProfilePreference() {
65
84
  };
66
85
  return { setPreference };
67
86
  }
87
+ export function useDisplayName() {
88
+ const setName = async (key, displayName, signerAddress, signMessage) => {
89
+ const timestamp = Math.floor(Date.now() / 1000);
90
+ const message = `SetDisplayName:${key}:${displayName}:${timestamp}`;
91
+ try {
92
+ const signature = await signMessage(message);
93
+ return setDisplayName({
94
+ key,
95
+ displayName,
96
+ signature,
97
+ signer: signerAddress,
98
+ timestamp,
99
+ });
100
+ }
101
+ catch (error) {
102
+ throw new Error(`Failed to set display name: ${error}`);
103
+ }
104
+ };
105
+ return { setName };
106
+ }
107
+ export function useProfileSettings() {
108
+ const { setPreference } = useProfilePreference();
109
+ const { setName } = useDisplayName();
110
+ const updateSettings = async (key, signerAddress, signMessage, settings) => {
111
+ const results = {};
112
+ try {
113
+ if (settings.preferredType) {
114
+ results.preference = await setPreference(key, settings.preferredType, signerAddress, signMessage);
115
+ }
116
+ if (settings.displayName) {
117
+ results.displayName = await setName(key, settings.displayName, signerAddress, signMessage);
118
+ }
119
+ return results;
120
+ }
121
+ catch (error) {
122
+ throw new Error(`Failed to update profile settings: ${error}`);
123
+ }
124
+ };
125
+ return {
126
+ setPreference,
127
+ setDisplayName: setName,
128
+ updateSettings,
129
+ };
130
+ }
68
131
  export default useProfile;
@@ -0,0 +1,17 @@
1
+ import { ReactNode } from "react";
2
+ interface FingerprintConfig {
3
+ apiKey: string;
4
+ endpoint?: string;
5
+ scriptUrlPattern?: string;
6
+ }
7
+ interface AnySpendFingerprintWrapperProps {
8
+ children: ReactNode;
9
+ fingerprint?: FingerprintConfig;
10
+ }
11
+ /**
12
+ * Internal wrapper that only initializes FingerprintJS when AnySpend components are actually used.
13
+ * This prevents unnecessary fingerprinting of users who don't interact with AnySpend.
14
+ */
15
+ export declare function AnySpendFingerprintWrapper({ children, fingerprint }: AnySpendFingerprintWrapperProps): import("react/jsx-runtime").JSX.Element;
16
+ export declare function getFingerprintConfig(): FingerprintConfig | undefined;
17
+ export {};
@@ -26,5 +26,5 @@ interface PanelOnrampPaymentProps {
26
26
  recipientEnsName?: string;
27
27
  recipientImageUrl?: string;
28
28
  }
29
- export declare function PanelOnrampPayment({ srcAmountOnRamp, recipientAddress, isMainnet, isBuyMode, destinationTokenChainId, destinationTokenAddress, selectedDstChainId, selectedDstToken, anyspendQuote, globalAddress, onOrderCreated, onBack, orderType, nft, tournament, payload, recipientEnsName, recipientImageUrl, }: PanelOnrampPaymentProps): import("react/jsx-runtime").JSX.Element;
29
+ export declare function PanelOnrampPayment(props: PanelOnrampPaymentProps): import("react/jsx-runtime").JSX.Element;
30
30
  export {};
@@ -2,6 +2,7 @@ export { AnySpend } from "./AnySpend";
2
2
  export { AnySpendBondKit } from "./AnySpendBondKit";
3
3
  export { AnySpendBuySpin } from "./AnySpendBuySpin";
4
4
  export { AnySpendCustom } from "./AnySpendCustom";
5
+ export * from "./AnySpendFingerprintWrapper";
5
6
  export { AnySpendNFT } from "./AnySpendNFT";
6
7
  export { AnyspendSignatureMint } from "./AnyspendSignatureMint";
7
8
  export { AnySpendStakeB3 } from "./AnySpendStakeB3";
@@ -9,5 +9,5 @@ interface WebviewOnrampPaymentProps {
9
9
  onPaymentSuccess: (orderId: string) => void;
10
10
  userId?: string;
11
11
  }
12
- export declare function WebviewOnrampPayment({ srcAmountOnRamp, recipientAddress, destinationToken, anyspendQuote, onPaymentSuccess, userId, partnerId, }: WebviewOnrampPaymentProps): import("react/jsx-runtime").JSX.Element;
12
+ export declare function WebviewOnrampPayment(props: WebviewOnrampPaymentProps): import("react/jsx-runtime").JSX.Element;
13
13
  export {};
@@ -1,5 +1,5 @@
1
- import { CreateOrderParams } from "./useAnyspendCreateOrder";
2
1
  import { components } from "@b3dotfun/sdk/anyspend/types/api";
2
+ import { CreateOrderParams } from "./useAnyspendCreateOrder";
3
3
  export type OnrampOptions = {
4
4
  vendor: components["schemas"]["OnrampMetadata"]["vendor"];
5
5
  paymentMethod: string;
@@ -1,4 +1,5 @@
1
- export declare function useCoinbaseOnrampOptions(isMainnet: boolean, country?: string): {
1
+ import { VisitorData } from "@b3dotfun/sdk/anyspend/types/fingerprint";
2
+ export declare function useCoinbaseOnrampOptions(isMainnet: boolean, country?: string, visitorData?: VisitorData, isLoadingVisitorData?: boolean): {
2
3
  coinbaseOnrampOptions: {
3
4
  paymentCurrencies: {
4
5
  id?: string;
@@ -33,7 +33,7 @@ export declare function useGeoOnrampOptions(isMainnet: boolean, srcFiatAmount: s
33
33
  isStripeOnrampSupported: boolean;
34
34
  isStripeWeb2Supported: boolean;
35
35
  isOnrampSupported: boolean;
36
- isLoading: boolean;
36
+ isLoading: boolean | undefined;
37
37
  isLoadingGeo: boolean;
38
38
  isLoadingCoinbaseOnrampOptions: boolean;
39
39
  isLoadingStripeSupport: boolean;
@@ -1,4 +1,5 @@
1
- export declare function useStripeSupport(isMainnet: boolean, ipAddress: string, usdAmount?: string): {
1
+ import { VisitorData } from "@b3dotfun/sdk/anyspend/types/fingerprint";
2
+ export declare function useStripeSupport(isMainnet: boolean, ipAddress: string, usdAmount?: string, visitorData?: VisitorData, isLoadingVisitorData?: boolean): {
2
3
  isStripeOnrampSupported: boolean;
3
4
  isStripeWeb2Supported: boolean;
4
5
  isLoadingStripeSupport: boolean;
@@ -1,11 +1,12 @@
1
1
  import { OnrampOptions } from "@b3dotfun/sdk/anyspend/react";
2
- import { GetCoinbaseOnrampOptionsResponse, GetOrderAndTxsResponse, GetOrderHistoryResponse, GetQuoteRequest, GetQuoteResponse } from "../types/api_req_res";
3
2
  import { components } from "../types/api";
3
+ import { GetCoinbaseOnrampOptionsResponse, GetOrderAndTxsResponse, GetOrderHistoryResponse, GetQuoteRequest, GetQuoteResponse } from "../types/api_req_res";
4
+ import { VisitorData } from "../types/fingerprint";
4
5
  export declare const anyspendService: {
5
6
  getTokenList: (isMainnet: boolean, chainId: number, query: string) => Promise<components["schemas"]["Token"][]>;
6
7
  getToken: (isMainnet: boolean, chainId: number, tokenAddress: string) => Promise<components["schemas"]["Token"]>;
7
8
  getQuote: (isMainnet: boolean, req: GetQuoteRequest) => Promise<GetQuoteResponse>;
8
- createOrder: ({ isMainnet, recipientAddress, type, srcChain, dstChain, srcTokenAddress, dstTokenAddress, srcAmount, payload, onramp, metadata, creatorAddress, partnerId, }: {
9
+ createOrder: ({ isMainnet, recipientAddress, type, srcChain, dstChain, srcTokenAddress, dstTokenAddress, srcAmount, payload, onramp, metadata, creatorAddress, partnerId, visitorData, }: {
9
10
  isMainnet: boolean;
10
11
  recipientAddress: string;
11
12
  type: string;
@@ -19,6 +20,7 @@ export declare const anyspendService: {
19
20
  metadata: Record<string, any>;
20
21
  creatorAddress?: string;
21
22
  partnerId?: string;
23
+ visitorData?: VisitorData;
22
24
  }) => Promise<{
23
25
  success: boolean;
24
26
  message: string;
@@ -27,8 +29,8 @@ export declare const anyspendService: {
27
29
  }>;
28
30
  getOrderAndTransactions: (isMainnet: boolean, orderId: string | undefined) => Promise<GetOrderAndTxsResponse>;
29
31
  getOrderHistory: (isMainnet: boolean, creatorAddress: string | undefined, limit?: number, offset?: number) => Promise<GetOrderHistoryResponse>;
30
- getCoinbaseOnrampOptions: (isMainnet: boolean, country: string) => Promise<GetCoinbaseOnrampOptionsResponse>;
31
- checkStripeSupport: (isMainnet: boolean, ipAddress: string, usdAmount?: string) => Promise<{
32
+ getCoinbaseOnrampOptions: (isMainnet: boolean, country: string, visitorData?: VisitorData) => Promise<GetCoinbaseOnrampOptionsResponse>;
33
+ checkStripeSupport: (isMainnet: boolean, ipAddress: string, usdAmount?: string, visitorData?: VisitorData) => Promise<{
32
34
  stripeOnramp: boolean;
33
35
  stripeWeb2: boolean;
34
36
  }>;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Types related to FingerprintJS integration
3
+ * We only need requestId and visitorId from the full FingerprintJS visitor data
4
+ */
5
+ export interface VisitorData {
6
+ /**
7
+ * @description The unique identifier of the request to get visitor data
8
+ */
9
+ requestId: string;
10
+ /**
11
+ * @description The unique identifier of the visitor
12
+ */
13
+ visitorId: string;
14
+ }
@@ -5,7 +5,6 @@ export { useAuthentication } from "./useAuthentication";
5
5
  export { useB3BalanceFromAddresses } from "./useB3BalanceFromAddresses";
6
6
  export { useB3EnsName } from "./useB3EnsName";
7
7
  export { useBestTransactionPath } from "./useBestTransactionPath";
8
- export { useBsmntProfile } from "./useBsmntProfile";
9
8
  export { useChainSwitchWithAction } from "./useChainSwitchWithAction";
10
9
  export { useClaim } from "./useClaim";
11
10
  export { useConnect } from "./useConnect";
@@ -18,7 +17,6 @@ export { useIsMobile } from "./useIsMobile";
18
17
  export { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect";
19
18
  export { useMediaQuery } from "./useMediaQuery";
20
19
  export { useNativeBalance, useNativeBalanceFromRPC } from "./useNativeBalance";
21
- export { useOnchainName } from "./useOnchainName";
22
20
  export { useOneBalance } from "./useOneBalance";
23
21
  export { useProfile, useProfilePreference, type Profile, type CombinedProfile, type PreferenceRequestBody, } from "./useProfile";
24
22
  export { useQueryB3 } from "./useQueryB3";
@@ -21,6 +21,13 @@ export interface PreferenceRequestBody {
21
21
  signer: string;
22
22
  timestamp: number;
23
23
  }
24
+ export interface DisplayNameRequestBody {
25
+ key: string;
26
+ displayName: string;
27
+ signature: string;
28
+ signer: string;
29
+ timestamp: number;
30
+ }
24
31
  export declare function useProfile({ address, name, fresh, }: {
25
32
  address?: string;
26
33
  name?: string;
@@ -35,4 +42,24 @@ export declare function useProfilePreference(): {
35
42
  success: boolean;
36
43
  }>;
37
44
  };
45
+ export declare function useDisplayName(): {
46
+ setName: (key: string, displayName: string, signerAddress: string, signMessage: (message: string) => Promise<string>) => Promise<{
47
+ success: boolean;
48
+ }>;
49
+ };
50
+ export declare function useProfileSettings(): {
51
+ setPreference: (key: string, preferredType: string, signerAddress: string, signMessage: (message: string) => Promise<string>) => Promise<{
52
+ success: boolean;
53
+ }>;
54
+ setDisplayName: (key: string, displayName: string, signerAddress: string, signMessage: (message: string) => Promise<string>) => Promise<{
55
+ success: boolean;
56
+ }>;
57
+ updateSettings: (key: string, signerAddress: string, signMessage: (message: string) => Promise<string>, settings: {
58
+ preferredType?: string;
59
+ displayName?: string;
60
+ }) => Promise<{
61
+ preference?: any;
62
+ displayName?: any;
63
+ }>;
64
+ };
38
65
  export default useProfile;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@b3dotfun/sdk",
3
- "version": "0.0.12",
3
+ "version": "0.0.13-alpha.1",
4
4
  "source": "src/index.ts",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "react-native": "./dist/cjs/index.native.js",
@@ -199,6 +199,7 @@
199
199
  "@feathersjs/feathers": "5.0.33",
200
200
  "@feathersjs/socketio-client": "5.0.33",
201
201
  "@feathersjs/typebox": "5.0.33",
202
+ "@fingerprintjs/fingerprintjs-pro-react": "^2.7.0",
202
203
  "@hey-api/client-fetch": "0.8.3",
203
204
  "@hey-api/openapi-ts": "0.64.13",
204
205
  "@lottiefiles/dotlottie-react": "0.7.2",
@@ -286,6 +287,7 @@
286
287
  "@react-three/postprocessing": "2.16.6",
287
288
  "@readyplayerme/visage": "6.10.0",
288
289
  "@tanstack/react-query": "5.55.0",
290
+ "@fingerprintjs/fingerprintjs-pro-react": "^2.7.0",
289
291
  "framer-motion": "12.0.0",
290
292
  "react": "^18.0.0 || ^19.0.0",
291
293
  "react-dom": "^18.0.0 || ^19.0.0",
@@ -12,7 +12,7 @@ import {
12
12
  StyleRoot,
13
13
  TransitionPanel,
14
14
  useAccountWallet,
15
- useOnchainName,
15
+ useProfile,
16
16
  useRouter,
17
17
  useSearchParamsSSR,
18
18
  useTokenData,
@@ -405,12 +405,8 @@ export function AnySpend({
405
405
  },
406
406
  );
407
407
 
408
- // Replace the old ENS lookup with our new hooks
409
- const { name: recipientName } = useOnchainName(recipientAddress);
410
- // const { name: walletName } = useOnchainName(globalAddress);
411
-
412
- // Batch lookup for custom recipients
413
- // const { names: customRecipientNames } = useOnchainNames(customRecipients.map(r => r.address));
408
+ const recipientProfile = useProfile({ address: recipientAddress });
409
+ const recipientName = recipientProfile.data?.name?.replace(/\.b3\.fun/g, "");
414
410
 
415
411
  // Load custom recipients from local storage on mount
416
412
  useEffect(() => {
@@ -30,8 +30,8 @@ import {
30
30
  TooltipTrigger,
31
31
  TransitionPanel,
32
32
  useAccountWallet,
33
- useBsmntProfile,
34
33
  useHasMounted,
34
+ useProfile,
35
35
  useRouter,
36
36
  useSearchParamsSSR,
37
37
  useTokenBalancesByChain,
@@ -201,8 +201,8 @@ export function AnySpendCustom({
201
201
 
202
202
  // Update recipient logic to use custom recipient
203
203
  const recipientAddress = customRecipientAddress || currentWallet.address;
204
- const recipientPropsProfile = useBsmntProfile({ address: recipientAddress });
205
- const recipientEnsName = recipientPropsProfile.data?.username?.replace(/\.b3\.fun/g, "");
204
+ const recipientPropsProfile = useProfile({ address: recipientAddress });
205
+ const recipientEnsName = recipientPropsProfile.data?.name?.replace(/\.b3\.fun/g, "");
206
206
  const recipientImageUrl = recipientPropsProfile.data?.avatar || currentWallet.wallet.meta?.icon;
207
207
 
208
208
  const [orderId, setOrderId] = useState<string | undefined>(loadOrder);
@@ -0,0 +1,60 @@
1
+ import { FingerprintJSPro, FpjsProvider } from "@fingerprintjs/fingerprintjs-pro-react";
2
+ import { ReactNode } from "react";
3
+
4
+ interface FingerprintConfig {
5
+ apiKey: string;
6
+ endpoint?: string;
7
+ scriptUrlPattern?: string;
8
+ }
9
+
10
+ interface AnySpendFingerprintWrapperProps {
11
+ children: ReactNode;
12
+ fingerprint?: FingerprintConfig;
13
+ }
14
+
15
+ /**
16
+ * Internal wrapper that only initializes FingerprintJS when AnySpend components are actually used.
17
+ * This prevents unnecessary fingerprinting of users who don't interact with AnySpend.
18
+ */
19
+ export function AnySpendFingerprintWrapper({ children, fingerprint }: AnySpendFingerprintWrapperProps) {
20
+ // If no fingerprint config is provided, render children without fingerprinting
21
+ if (!fingerprint?.apiKey) {
22
+ console.warn("No Fingerprint API key provided. Fingerprinting will be disabled.");
23
+ return <>{children}</>;
24
+ }
25
+
26
+ // Ensure endpoint has https:// prefix
27
+ const endpoint =
28
+ fingerprint.endpoint && !fingerprint.endpoint.startsWith("http")
29
+ ? `https://${fingerprint.endpoint}`
30
+ : fingerprint.endpoint;
31
+
32
+ return (
33
+ <FpjsProvider
34
+ loadOptions={{
35
+ apiKey: fingerprint.apiKey,
36
+ endpoint: endpoint ? [endpoint, FingerprintJSPro.defaultEndpoint] : undefined,
37
+ scriptUrlPattern: fingerprint.scriptUrlPattern
38
+ ? [fingerprint.scriptUrlPattern, FingerprintJSPro.defaultScriptUrlPattern]
39
+ : undefined,
40
+ }}
41
+ >
42
+ {children}
43
+ </FpjsProvider>
44
+ );
45
+ }
46
+
47
+ // Helper function to get fingerprint config from environment variables
48
+ export function getFingerprintConfig(): FingerprintConfig | undefined {
49
+ const apiKey = process.env.NEXT_PUBLIC_FINGERPRINT_API_KEY;
50
+
51
+ if (!apiKey) {
52
+ return undefined;
53
+ }
54
+
55
+ return {
56
+ apiKey,
57
+ endpoint: process.env.NEXT_PUBLIC_FINGERPRINT_ENDPOINT,
58
+ scriptUrlPattern: process.env.NEXT_PUBLIC_FINGERPRINT_SCRIPT_URL,
59
+ };
60
+ }