@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,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useURLParams = exports.useTokensFromAddress = exports.useTokenPriceWithFallback = exports.useTokenPrice = exports.useTokenFromUrl = exports.useTokenData = exports.useTokenBalancesByChain = exports.useTokenBalance = exports.useSiwe = exports.useSearchParamsSSR = exports.useRouter = exports.useRemoveSessionKey = exports.useQueryBSMNT = exports.useQueryB3 = exports.useProfilePreference = exports.useProfile = exports.useOneBalance = exports.useOnchainName = exports.useNativeBalanceFromRPC = exports.useNativeBalance = exports.useMediaQuery = exports.useIsomorphicLayoutEffect = exports.useIsMobile = exports.useHasMounted = exports.useHandleConnectWithPrivy = exports.useGetGeo = exports.useGetAllTWSigners = exports.useExchangeRate = exports.useConnect = exports.useClaim = exports.useChainSwitchWithAction = exports.useBsmntProfile = exports.useBestTransactionPath = exports.useB3EnsName = exports.useB3BalanceFromAddresses = exports.useAuthentication = exports.useAddTWSessionKey = exports.useAccountWallet = exports.useAccountAssets = void 0;
3
+ exports.useURLParams = exports.useTokensFromAddress = exports.useTokenPriceWithFallback = exports.useTokenPrice = exports.useTokenFromUrl = exports.useTokenData = exports.useTokenBalancesByChain = exports.useTokenBalance = exports.useSiwe = exports.useSearchParamsSSR = exports.useRouter = exports.useRemoveSessionKey = exports.useQueryBSMNT = exports.useQueryB3 = exports.useProfilePreference = exports.useProfile = exports.useOneBalance = exports.useNativeBalanceFromRPC = exports.useNativeBalance = exports.useMediaQuery = exports.useIsomorphicLayoutEffect = exports.useIsMobile = exports.useHasMounted = exports.useHandleConnectWithPrivy = exports.useGetGeo = exports.useGetAllTWSigners = exports.useExchangeRate = exports.useConnect = exports.useClaim = exports.useChainSwitchWithAction = exports.useBestTransactionPath = exports.useB3EnsName = exports.useB3BalanceFromAddresses = exports.useAuthentication = exports.useAddTWSessionKey = exports.useAccountWallet = exports.useAccountAssets = void 0;
4
4
  var useAccountAssets_1 = require("./useAccountAssets");
5
5
  Object.defineProperty(exports, "useAccountAssets", { enumerable: true, get: function () { return useAccountAssets_1.useAccountAssets; } });
6
6
  var useAccountWallet_1 = require("./useAccountWallet");
@@ -15,8 +15,6 @@ var useB3EnsName_1 = require("./useB3EnsName");
15
15
  Object.defineProperty(exports, "useB3EnsName", { enumerable: true, get: function () { return useB3EnsName_1.useB3EnsName; } });
16
16
  var useBestTransactionPath_1 = require("./useBestTransactionPath");
17
17
  Object.defineProperty(exports, "useBestTransactionPath", { enumerable: true, get: function () { return useBestTransactionPath_1.useBestTransactionPath; } });
18
- var useBsmntProfile_1 = require("./useBsmntProfile");
19
- Object.defineProperty(exports, "useBsmntProfile", { enumerable: true, get: function () { return useBsmntProfile_1.useBsmntProfile; } });
20
18
  var useChainSwitchWithAction_1 = require("./useChainSwitchWithAction");
21
19
  Object.defineProperty(exports, "useChainSwitchWithAction", { enumerable: true, get: function () { return useChainSwitchWithAction_1.useChainSwitchWithAction; } });
22
20
  var useClaim_1 = require("./useClaim");
@@ -42,8 +40,6 @@ Object.defineProperty(exports, "useMediaQuery", { enumerable: true, get: functio
42
40
  var useNativeBalance_1 = require("./useNativeBalance");
43
41
  Object.defineProperty(exports, "useNativeBalance", { enumerable: true, get: function () { return useNativeBalance_1.useNativeBalance; } });
44
42
  Object.defineProperty(exports, "useNativeBalanceFromRPC", { enumerable: true, get: function () { return useNativeBalance_1.useNativeBalanceFromRPC; } });
45
- var useOnchainName_1 = require("./useOnchainName");
46
- Object.defineProperty(exports, "useOnchainName", { enumerable: true, get: function () { return useOnchainName_1.useOnchainName; } });
47
43
  var useOneBalance_1 = require("./useOneBalance");
48
44
  Object.defineProperty(exports, "useOneBalance", { enumerable: true, get: function () { return useOneBalance_1.useOneBalance; } });
49
45
  var useProfile_1 = require("./useProfile");
@@ -6,7 +6,6 @@ const constants_1 = require("../../../shared/constants");
6
6
  const react_2 = require("react");
7
7
  const react_3 = require("thirdweb/react");
8
8
  const in_app_1 = require("thirdweb/wallets/in-app");
9
- const useBsmntProfile_1 = require("./useBsmntProfile");
10
9
  function useLastAuthProvider() {
11
10
  const [lastAuthProvider, setLastAuthProvider] = (0, react_2.useState)(null);
12
11
  (0, react_2.useEffect)(() => {
@@ -32,8 +31,8 @@ function useAccountWallet() {
32
31
  const smartWalletIcon = lastAuthProvider && !connectedEOAWallet
33
32
  ? in_app_1.socialIcons[lastAuthProvider]
34
33
  : "https://gradvatar.com/0x0000000000000000000000000000000000000000"; // show smart wallet of eoa wallet is gradvatar
35
- const { data: profileData } = (0, useBsmntProfile_1.useBsmntProfile)({ address: account?.address });
36
- const ensName = profileData?.username?.replace(/\.b3\.fun/g, "");
34
+ const { data: profileData } = (0, react_1.useProfile)({ address: account?.address });
35
+ const ensName = profileData?.displayName?.replace(/\.b3\.fun/g, "");
37
36
  const avatarUrl = profileData?.avatar;
38
37
  const res = (0, react_2.useMemo)(() => ({
39
38
  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;
@@ -2,6 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useProfile = useProfile;
4
4
  exports.useProfilePreference = useProfilePreference;
5
+ exports.useDisplayName = useDisplayName;
6
+ exports.useProfileSettings = useProfileSettings;
5
7
  const react_query_1 = require("@tanstack/react-query");
6
8
  const PROFILES_API_URL = "https://profiles.b3.fun";
7
9
  async function fetchProfile({ address, name, fresh = false, }) {
@@ -40,6 +42,25 @@ async function setProfilePreference({ key, preferredType, signature, signer, tim
40
42
  }
41
43
  return response.json();
42
44
  }
45
+ async function setDisplayName({ key, displayName, signature, signer, timestamp, }) {
46
+ const response = await fetch(`${PROFILES_API_URL}/display-name`, {
47
+ method: "POST",
48
+ headers: {
49
+ "Content-Type": "application/json",
50
+ },
51
+ body: JSON.stringify({
52
+ key,
53
+ displayName,
54
+ signature,
55
+ signer,
56
+ timestamp,
57
+ }),
58
+ });
59
+ if (!response.ok) {
60
+ throw new Error(`Failed to set display name: ${response.statusText}`);
61
+ }
62
+ return response.json();
63
+ }
43
64
  function useProfile({ address, name, fresh = false, }, options) {
44
65
  return (0, react_query_1.useQuery)({
45
66
  queryKey: ["profile", address || name, fresh],
@@ -69,4 +90,48 @@ function useProfilePreference() {
69
90
  };
70
91
  return { setPreference };
71
92
  }
93
+ function useDisplayName() {
94
+ const setName = async (key, displayName, signerAddress, signMessage) => {
95
+ const timestamp = Math.floor(Date.now() / 1000);
96
+ const message = `SetDisplayName:${key}:${displayName}:${timestamp}`;
97
+ try {
98
+ const signature = await signMessage(message);
99
+ return setDisplayName({
100
+ key,
101
+ displayName,
102
+ signature,
103
+ signer: signerAddress,
104
+ timestamp,
105
+ });
106
+ }
107
+ catch (error) {
108
+ throw new Error(`Failed to set display name: ${error}`);
109
+ }
110
+ };
111
+ return { setName };
112
+ }
113
+ function useProfileSettings() {
114
+ const { setPreference } = useProfilePreference();
115
+ const { setName } = useDisplayName();
116
+ const updateSettings = async (key, signerAddress, signMessage, settings) => {
117
+ const results = {};
118
+ try {
119
+ if (settings.preferredType) {
120
+ results.preference = await setPreference(key, settings.preferredType, signerAddress, signMessage);
121
+ }
122
+ if (settings.displayName) {
123
+ results.displayName = await setName(key, settings.displayName, signerAddress, signMessage);
124
+ }
125
+ return results;
126
+ }
127
+ catch (error) {
128
+ throw new Error(`Failed to update profile settings: ${error}`);
129
+ }
130
+ };
131
+ return {
132
+ setPreference,
133
+ setDisplayName: setName,
134
+ updateSettings,
135
+ };
136
+ }
72
137
  exports.default = useProfile;
@@ -2,7 +2,7 @@
2
2
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { getDefaultToken, USDC_BASE } from "../../../anyspend/index.js";
4
4
  import { useAnyspendCreateOrder, useAnyspendOrderAndTransactions, useAnyspendQuote, } from "../../../anyspend/react/index.js";
5
- import { Button, ShinyButton, StyleRoot, TransitionPanel, useAccountWallet, useOnchainName, useRouter, useSearchParamsSSR, useTokenData, useTokenFromUrl, } from "../../../global-account/react/index.js";
5
+ import { Button, ShinyButton, StyleRoot, TransitionPanel, useAccountWallet, useProfile, useRouter, useSearchParamsSSR, useTokenData, useTokenFromUrl, } from "../../../global-account/react/index.js";
6
6
  import { cn } from "../../../shared/utils/cn.js";
7
7
  import { shortenAddress } from "../../../shared/utils/formatAddress.js";
8
8
  import { formatDisplayNumber, formatTokenAmount } from "../../../shared/utils/number.js";
@@ -299,11 +299,8 @@ export function AnySpend({ destinationTokenAddress, destinationTokenChainId, isM
299
299
  tradeType: "EXACT_INPUT",
300
300
  amount: srcAmountOnrampInWei,
301
301
  });
302
- // Replace the old ENS lookup with our new hooks
303
- const { name: recipientName } = useOnchainName(recipientAddress);
304
- // const { name: walletName } = useOnchainName(globalAddress);
305
- // Batch lookup for custom recipients
306
- // const { names: customRecipientNames } = useOnchainNames(customRecipients.map(r => r.address));
302
+ const recipientProfile = useProfile({ address: recipientAddress });
303
+ const recipientName = recipientProfile.data?.name?.replace(/\.b3\.fun/g, "");
307
304
  // Load custom recipients from local storage on mount
308
305
  useEffect(() => {
309
306
  try {
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
2
2
  import { eqci, getDefaultToken } from "../../../anyspend/index.js";
3
3
  import { RELAY_ETH_ADDRESS, USDC_BASE } from "../../../anyspend/constants/index.js";
4
4
  import { useAnyspendCreateOnrampOrder, useAnyspendCreateOrder, useAnyspendOrderAndTransactions, useAnyspendQuote, useAnyspendTokenList, useGeoOnrampOptions, } from "../../../anyspend/react/index.js";
5
- import { Badge, Button, Dialog, DialogContent, Input, ShinyButton, Skeleton, StyleRoot, Tabs, TabsContent, TabsList, TabTrigger, TextShimmer, Tooltip, TooltipContent, TooltipTrigger, TransitionPanel, useAccountWallet, useBsmntProfile, useHasMounted, useRouter, useSearchParamsSSR, useTokenBalancesByChain, } from "../../../global-account/react/index.js";
5
+ import { Badge, Button, Dialog, DialogContent, Input, ShinyButton, Skeleton, StyleRoot, Tabs, TabsContent, TabsList, TabTrigger, TextShimmer, Tooltip, TooltipContent, TooltipTrigger, TransitionPanel, useAccountWallet, useHasMounted, useProfile, useRouter, useSearchParamsSSR, useTokenBalancesByChain, } from "../../../global-account/react/index.js";
6
6
  import { cn } from "../../../shared/utils/index.js";
7
7
  import centerTruncate from "../../../shared/utils/centerTruncate.js";
8
8
  import { formatTokenAmount } from "../../../shared/utils/number.js";
@@ -96,8 +96,8 @@ export function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", re
96
96
  const [customRecipientAddress, setCustomRecipientAddress] = useState(recipientAddressProps);
97
97
  // Update recipient logic to use custom recipient
98
98
  const recipientAddress = customRecipientAddress || currentWallet.address;
99
- const recipientPropsProfile = useBsmntProfile({ address: recipientAddress });
100
- const recipientEnsName = recipientPropsProfile.data?.username?.replace(/\.b3\.fun/g, "");
99
+ const recipientPropsProfile = useProfile({ address: recipientAddress });
100
+ const recipientEnsName = recipientPropsProfile.data?.name?.replace(/\.b3\.fun/g, "");
101
101
  const recipientImageUrl = recipientPropsProfile.data?.avatar || currentWallet.wallet.meta?.icon;
102
102
  const [orderId, setOrderId] = useState(loadOrder);
103
103
  const [srcChainId, setSrcChainId] = useState(isMainnet ? base.id : baseSepolia.id);
@@ -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 {};
@@ -0,0 +1,36 @@
1
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
+ import { FingerprintJSPro, FpjsProvider } from "@fingerprintjs/fingerprintjs-pro-react";
3
+ /**
4
+ * Internal wrapper that only initializes FingerprintJS when AnySpend components are actually used.
5
+ * This prevents unnecessary fingerprinting of users who don't interact with AnySpend.
6
+ */
7
+ export function AnySpendFingerprintWrapper({ children, fingerprint }) {
8
+ // If no fingerprint config is provided, render children without fingerprinting
9
+ if (!fingerprint?.apiKey) {
10
+ console.warn("No Fingerprint API key provided. Fingerprinting will be disabled.");
11
+ return _jsx(_Fragment, { children: children });
12
+ }
13
+ // Ensure endpoint has https:// prefix
14
+ const endpoint = fingerprint.endpoint && !fingerprint.endpoint.startsWith("http")
15
+ ? `https://${fingerprint.endpoint}`
16
+ : fingerprint.endpoint;
17
+ return (_jsx(FpjsProvider, { loadOptions: {
18
+ apiKey: fingerprint.apiKey,
19
+ endpoint: endpoint ? [endpoint, FingerprintJSPro.defaultEndpoint] : undefined,
20
+ scriptUrlPattern: fingerprint.scriptUrlPattern
21
+ ? [fingerprint.scriptUrlPattern, FingerprintJSPro.defaultScriptUrlPattern]
22
+ : undefined,
23
+ }, children: children }));
24
+ }
25
+ // Helper function to get fingerprint config from environment variables
26
+ export function getFingerprintConfig() {
27
+ const apiKey = process.env.NEXT_PUBLIC_FINGERPRINT_API_KEY;
28
+ if (!apiKey) {
29
+ return undefined;
30
+ }
31
+ return {
32
+ apiKey,
33
+ endpoint: process.env.NEXT_PUBLIC_FINGERPRINT_ENDPOINT,
34
+ scriptUrlPattern: process.env.NEXT_PUBLIC_FINGERPRINT_SCRIPT_URL,
35
+ };
36
+ }
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { ALL_CHAINS, capitalizeFirstLetter, EVM_CHAINS, getChainName, getErrorDisplay, getExplorerTxUrl, getPaymentUrl, getStatusDisplay, isNativeToken, RELAY_ETH_ADDRESS, RELAY_SOLANA_MAINNET_CHAIN_ID, } from "../../../../anyspend/index.js";
4
- import { Badge, Button, CopyToClipboard, ShinyButton, Skeleton, TextLoop, TextShimmer, useAccountWallet, useChainSwitchWithAction, useModalStore, useOnchainName, } from "../../../../global-account/react/index.js";
4
+ import { Badge, Button, CopyToClipboard, ShinyButton, Skeleton, TextLoop, TextShimmer, useAccountWallet, useChainSwitchWithAction, useModalStore, useProfile, } from "../../../../global-account/react/index.js";
5
5
  import { useRouter, useSearchParams } from "../../../../shared/react/hooks/index.js";
6
6
  import { cn } from "../../../../shared/utils/index.js";
7
7
  import centerTruncate from "../../../../shared/utils/centerTruncate.js";
@@ -124,7 +124,8 @@ export const OrderDetails = memo(function OrderDetails({ isMainnet, mode = "moda
124
124
  const dstToken = order.metadata.dstToken;
125
125
  const nft = order.type === "mint_nft" ? order.metadata.nft : undefined;
126
126
  const tournament = order.type === "join_tournament" || order.type === "fund_tournament" ? order.metadata.tournament : undefined;
127
- const { name: recipientName } = useOnchainName(order.recipientAddress);
127
+ const profile = useProfile({ address: order.recipientAddress });
128
+ const recipientName = profile.data?.name?.replace(/\.b3\.fun/g, "");
128
129
  const account = useAccountWallet();
129
130
  const { data: walletClient } = useWalletClient();
130
131
  const [txHash, setTxHash] = useState();
@@ -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 {};
@@ -7,9 +7,13 @@ import invariant from "invariant";
7
7
  import { ChevronLeft, ChevronRight, Landmark, Loader2 } from "lucide-react";
8
8
  import { useEffect, useRef, useState } from "react";
9
9
  import { toast } from "sonner";
10
- export function PanelOnrampPayment({ srcAmountOnRamp,
11
- // recipientName,
12
- recipientAddress, isMainnet, isBuyMode, destinationTokenChainId, destinationTokenAddress, selectedDstChainId, selectedDstToken, anyspendQuote, globalAddress, onOrderCreated, onBack, orderType, nft, tournament, payload, recipientEnsName, recipientImageUrl, }) {
10
+ import { AnySpendFingerprintWrapper, getFingerprintConfig } from "../AnySpendFingerprintWrapper.js";
11
+ export function PanelOnrampPayment(props) {
12
+ const fingerprintConfig = getFingerprintConfig();
13
+ return (_jsx(AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: _jsx(PanelOnrampPaymentInner, { ...props }) }));
14
+ }
15
+ function PanelOnrampPaymentInner(props) {
16
+ const { srcAmountOnRamp, recipientAddress, isMainnet, isBuyMode, destinationTokenChainId, destinationTokenAddress, selectedDstChainId, selectedDstToken, anyspendQuote, globalAddress, onOrderCreated, onBack, orderType, nft, tournament, payload, recipientEnsName, recipientImageUrl, } = props;
13
17
  // Use a stable amount for geo onramp options to prevent unnecessary refetches
14
18
  const [stableAmountForGeo, setStableAmountForGeo] = useState(srcAmountOnRamp);
15
19
  const hasInitialized = useRef(false);
@@ -21,6 +25,7 @@ recipientAddress, isMainnet, isBuyMode, destinationTokenChainId, destinationToke
21
25
  }
22
26
  }, [srcAmountOnRamp]);
23
27
  const { geoData, coinbaseOnrampOptions, coinbaseAvailablePaymentMethods, isStripeOnrampSupported, isStripeWeb2Supported, isLoading: isLoadingGeoOnramp, } = useGeoOnrampOptions(isMainnet, stableAmountForGeo);
28
+ const isLoading = isLoadingGeoOnramp;
24
29
  const { createOrder, isCreatingOrder } = useAnyspendCreateOnrampOrder({
25
30
  onSuccess: data => {
26
31
  const orderId = data.data.id;
@@ -104,7 +109,7 @@ recipientAddress, isMainnet, isBuyMode, destinationTokenChainId, destinationToke
104
109
  ? "Receive NFT at"
105
110
  : orderType === "join_tournament"
106
111
  ? "Join for"
107
- : "Recipient" }), _jsxs("div", { className: "flex items-center gap-2", children: [recipientImageUrl && (_jsx("img", { src: recipientImageUrl, alt: recipientImageUrl, className: "bg-b3-react-foreground size-7 rounded-full object-cover opacity-100" })), _jsxs("div", { className: "flex flex-col items-end gap-1", children: [recipientEnsName && _jsxs("span", { className: "text-b3-react-foreground/80", children: ["@", recipientEnsName] }), _jsx("span", { className: "text-b3-react-foreground/80", children: centerTruncate(recipientAddress) })] })] })] })), _jsx("div", { className: "border-b3-react-border border-t pt-3", children: _jsxs("div", { className: "flex items-center justify-between", children: [_jsx("p", { className: "text-b3-react-foreground font-semibold", children: "Amount" }), _jsxs("p", { className: "text-b3-react-foreground hover:text-b3-react-foreground/80 cursor-pointer text-xl font-semibold transition-colors", onClick: onBack, children: ["$", parseFloat(srcAmountOnRamp).toFixed(2)] })] }) })] })] }), isCreatingOrder ? (_jsxs("div", { className: "bg-b3-react-background border-b3-react-border flex items-center justify-center gap-3 rounded-lg border p-6", children: [_jsx(Loader2, { className: "h-4 w-4 animate-spin" }), _jsx("span", { className: "text-as-primary/70", children: "Creating onramp order..." })] })) : isLoadingGeoOnramp ? (_jsxs("div", { className: "bg-b3-react-background border-b3-react-border flex items-center justify-center gap-3 rounded-lg border p-6", children: [_jsx(Loader2, { className: "h-4 w-4 animate-spin" }), _jsx("span", { className: "text-as-primary/70", children: "Loading payment options..." })] })) : (_jsxs(_Fragment, { children: [_jsxs("div", { className: "mb-3 flex items-center justify-between", children: [_jsx("h2", { className: "text-lg font-semibold", children: "Payment method" }), _jsx("div", { className: "flex items-center gap-1", children: coinbaseAvailablePaymentMethods.length > 0 &&
112
+ : "Recipient" }), _jsxs("div", { className: "flex items-center gap-2", children: [recipientImageUrl && (_jsx("img", { src: recipientImageUrl, alt: recipientImageUrl, className: "bg-b3-react-foreground size-7 rounded-full object-cover opacity-100" })), _jsxs("div", { className: "flex flex-col items-end gap-1", children: [recipientEnsName && _jsxs("span", { className: "text-b3-react-foreground/80", children: ["@", recipientEnsName] }), _jsx("span", { className: "text-b3-react-foreground/80", children: centerTruncate(recipientAddress) })] })] })] })), _jsx("div", { className: "border-b3-react-border border-t pt-3", children: _jsxs("div", { className: "flex items-center justify-between", children: [_jsx("p", { className: "text-b3-react-foreground font-semibold", children: "Amount" }), _jsxs("p", { className: "text-b3-react-foreground hover:text-b3-react-foreground/80 cursor-pointer text-xl font-semibold transition-colors", onClick: onBack, children: ["$", parseFloat(srcAmountOnRamp).toFixed(2)] })] }) })] })] }), isCreatingOrder ? (_jsxs("div", { className: "bg-b3-react-background border-b3-react-border flex items-center justify-center gap-3 rounded-lg border p-6", children: [_jsx(Loader2, { className: "h-4 w-4 animate-spin" }), _jsx("span", { className: "text-as-primary/70", children: "Creating onramp order..." })] })) : isLoading ? (_jsxs("div", { className: "bg-b3-react-background border-b3-react-border flex items-center justify-center gap-3 rounded-lg border p-6", children: [_jsx(Loader2, { className: "h-4 w-4 animate-spin" }), _jsx("span", { className: "text-as-primary/70", children: "Loading payment options..." })] })) : (_jsxs(_Fragment, { children: [_jsxs("div", { className: "mb-3 flex items-center justify-between", children: [_jsx("h2", { className: "text-lg font-semibold", children: "Payment method" }), _jsx("div", { className: "flex items-center gap-1", children: coinbaseAvailablePaymentMethods.length > 0 &&
108
113
  (() => {
109
114
  const hasCard = coinbaseAvailablePaymentMethods.some(m => m.id === "CARD");
110
115
  const hasApplePay = coinbaseAvailablePaymentMethods.some(m => m.id === "APPLE_PAY");
@@ -8,11 +8,13 @@ import { AddressElement, Elements, PaymentElement, useElements, useStripe } from
8
8
  import { loadStripe } from "@stripe/stripe-js";
9
9
  import { HelpCircle, Info, X } from "lucide-react";
10
10
  import { useEffect, useState } from "react";
11
+ import { AnySpendFingerprintWrapper, getFingerprintConfig } from "../AnySpendFingerprintWrapper.js";
11
12
  import HowItWorks from "./HowItWorks.js";
12
13
  import PaymentMethodIcons from "./PaymentMethodIcons.js";
13
14
  const stripePromise = loadStripe(STRIPE_CONFIG.publishableKey);
14
15
  export default function PaymentStripeWeb2({ isMainnet, order, onPaymentSuccess }) {
15
16
  const { theme } = useB3();
17
+ const fingerprintConfig = getFingerprintConfig();
16
18
  const { clientSecret, isLoadingStripeClientSecret, stripeClientSecretError } = useStripeClientSecret(isMainnet, order.stripePaymentIntentId);
17
19
  if (isLoadingStripeClientSecret) {
18
20
  return _jsx(StripeLoadingState, {});
@@ -20,10 +22,10 @@ export default function PaymentStripeWeb2({ isMainnet, order, onPaymentSuccess }
20
22
  if (stripeClientSecretError) {
21
23
  return _jsx(StripeErrorState, { error: stripeClientSecretError.message });
22
24
  }
23
- return (_jsx(Elements, { stripe: stripePromise, options: {
24
- clientSecret: clientSecret || undefined,
25
- appearance: { theme: theme === "light" ? "stripe" : "night" },
26
- }, children: _jsx(StripePaymentForm, { order: order, clientSecret: clientSecret, onPaymentSuccess: onPaymentSuccess }) }));
25
+ return (_jsx(AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: _jsx(Elements, { stripe: stripePromise, options: {
26
+ clientSecret: clientSecret || undefined,
27
+ appearance: { theme: theme === "light" ? "stripe" : "night" },
28
+ }, children: _jsx(StripePaymentForm, { order: order, clientSecret: clientSecret, onPaymentSuccess: onPaymentSuccess }) }) }));
27
29
  }
28
30
  function StripeLoadingState() {
29
31
  return (_jsx("div", { className: "relative my-8 flex w-full flex-1 flex-col items-center justify-center", children: _jsxs("div", { className: "bg-as-on-surface-1 flex w-full flex-col items-center justify-center gap-4 rounded-2xl p-8", children: [_jsx("div", { className: "bg-as-brand/20 flex h-16 w-16 items-center justify-center rounded-full", children: _jsx("div", { className: "text-as-brand h-8 w-8 animate-spin rounded-full border-2 border-current border-t-transparent" }) }), _jsxs("div", { className: "text-as-primary/70 text-center", children: [_jsx("div", { className: "text-lg font-medium", children: "Initializing payment" }), _jsx("div", { className: "text-as-primary/50 mt-2 text-sm", children: "Setting up secure payment form..." })] })] }) }));
@@ -44,7 +46,6 @@ function StripePaymentForm({ order, clientSecret, onPaymentSuccess, }) {
44
46
  useEffect(() => {
45
47
  if (stripe && elements) {
46
48
  setStripeReady(true);
47
- console.log("@@stripe-web2-payment:initialized:", JSON.stringify({ orderId: order.id }, null, 2));
48
49
  }
49
50
  }, [stripe, elements, order.id]);
50
51
  useEffect(() => {
@@ -67,7 +68,6 @@ function StripePaymentForm({ order, clientSecret, onPaymentSuccess, }) {
67
68
  // Handle payment element changes
68
69
  const handlePaymentElementChange = (event) => {
69
70
  // Show address element only for card payments
70
- console.log("@@stripe-web2-payment:payment-element-change:", JSON.stringify(event, null, 2));
71
71
  setShowAddressElement(event.value.type === "card");
72
72
  };
73
73
  const handleSubmit = async (e) => {
@@ -79,7 +79,6 @@ function StripePaymentForm({ order, clientSecret, onPaymentSuccess, }) {
79
79
  setLoading(true);
80
80
  setMessage(null);
81
81
  try {
82
- console.log("@@stripe-web2-payment:confirming-payment:", JSON.stringify({ orderId: order.id }, null, 2));
83
82
  const result = (await stripe.confirmPayment({
84
83
  elements,
85
84
  confirmParams: {
@@ -118,8 +117,6 @@ function StripePaymentForm({ order, clientSecret, onPaymentSuccess, }) {
118
117
  const url = new URL(window.location.href);
119
118
  const fromStripe = url.searchParams.get("fromStripe");
120
119
  const paymentIntent = url.searchParams.get("payment_intent");
121
- console.log("@@stripe-web2-payment:fromStripe:", fromStripe);
122
- console.log("@@stripe-web2-payment:paymentIntent:", paymentIntent);
123
120
  if (fromStripe && paymentIntent) {
124
121
  // Close the modal as we're returning from 3DS
125
122
  setB3ModalOpen(true);
@@ -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";
@@ -3,6 +3,7 @@ export { AnySpend } from "./AnySpend.js";
3
3
  export { AnySpendBondKit } from "./AnySpendBondKit.js";
4
4
  export { AnySpendBuySpin } from "./AnySpendBuySpin.js";
5
5
  export { AnySpendCustom } from "./AnySpendCustom.js";
6
+ export * from "./AnySpendFingerprintWrapper.js";
6
7
  export { AnySpendNFT } from "./AnySpendNFT.js";
7
8
  export { AnyspendSignatureMint } from "./AnyspendSignatureMint.js";
8
9
  export { AnySpendStakeB3 } from "./AnySpendStakeB3.js";
@@ -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 {};
@@ -9,7 +9,12 @@ import { Loader2 } from "lucide-react";
9
9
  import { useEffect, useRef, useState } from "react";
10
10
  import { toast } from "sonner";
11
11
  import { formatUnits } from "viem";
12
+ import { AnySpendFingerprintWrapper, getFingerprintConfig } from "../AnySpendFingerprintWrapper.js";
12
13
  const stripePromise = loadStripe(STRIPE_CONFIG.publishableKey);
14
+ export function WebviewOnrampPayment(props) {
15
+ const fingerprintConfig = getFingerprintConfig();
16
+ return (_jsx(AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: _jsx(WebviewOnrampPaymentInner, { ...props }) }));
17
+ }
13
18
  // Stripe Payment Form Component
14
19
  function StripePaymentForm({ order, onPaymentSuccess, }) {
15
20
  const stripe = useStripe();
@@ -79,7 +84,7 @@ function StripePaymentForm({ order, onPaymentSuccess, }) {
79
84
  },
80
85
  } }) })), error && (_jsx("div", { className: "mt-4 rounded-lg border border-red-200 bg-red-50 p-3 text-sm text-red-600", children: error })), _jsx("button", { type: "submit", disabled: !stripe || isProcessing, className: "mt-6 w-full rounded-xl bg-blue-600 px-4 py-3 font-medium text-white hover:bg-blue-700 disabled:cursor-not-allowed disabled:opacity-50", children: isProcessing ? (_jsxs("div", { className: "flex items-center justify-center gap-2", children: [_jsx(Loader2, { className: "h-5 w-5 animate-spin" }), _jsx("span", { children: "Processing..." })] })) : (_jsx("span", { children: "Complete Payment" })) })] }) }) }));
81
86
  }
82
- export function WebviewOnrampPayment({ srcAmountOnRamp, recipientAddress, destinationToken, anyspendQuote, onPaymentSuccess, userId, partnerId, }) {
87
+ function WebviewOnrampPaymentInner({ srcAmountOnRamp, recipientAddress, destinationToken, anyspendQuote, onPaymentSuccess, userId, partnerId, }) {
83
88
  const [stableAmountForGeo, setStableAmountForGeo] = useState(srcAmountOnRamp);
84
89
  const hasInitialized = useRef(false);
85
90
  const [createdOrder, setCreatedOrder] = useState(null);
@@ -1,5 +1,5 @@
1
- import { CreateOrderParams } from "./useAnyspendCreateOrder";
2
1
  import { components } from "../../../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,6 +1,7 @@
1
1
  import { USDC_BASE } from "../../../anyspend/constants/index.js";
2
2
  import { anyspendService } from "../../../anyspend/services/anyspend.js";
3
3
  import { buildMetadata, buildPayload, normalizeAddress } from "../../../anyspend/utils/index.js";
4
+ import { useVisitorData } from "@fingerprintjs/fingerprintjs-pro-react";
4
5
  import { useMutation } from "@tanstack/react-query";
5
6
  import { useMemo } from "react";
6
7
  import { parseUnits } from "viem";
@@ -10,6 +11,12 @@ import { base } from "viem/chains";
10
11
  * Specifically handles orders that involve fiat-to-crypto onramp functionality
11
12
  */
12
13
  export function useAnyspendCreateOnrampOrder({ onSuccess, onError } = {}) {
14
+ // Get fingerprint data
15
+ const { data: fpData } = useVisitorData({ extendedResult: true }, { immediate: true });
16
+ const visitorData = fpData && {
17
+ requestId: fpData.requestId,
18
+ visitorId: fpData.visitorId,
19
+ };
13
20
  const { mutate: createOrder, isPending } = useMutation({
14
21
  mutationFn: async (params) => {
15
22
  const { isMainnet, recipientAddress, orderType, dstChain, dstToken, srcFiatAmount, onramp, creatorAddress, expectedDstAmount, nft, tournament, payload, partnerId, } = params;
@@ -42,7 +49,9 @@ export function useAnyspendCreateOnrampOrder({ onSuccess, onError } = {}) {
42
49
  expectedDstAmount,
43
50
  nft,
44
51
  tournament,
45
- payload,
52
+ payload: {
53
+ ...payload,
54
+ },
46
55
  }),
47
56
  onramp,
48
57
  metadata: buildMetadata(orderType, {
@@ -52,10 +61,13 @@ export function useAnyspendCreateOnrampOrder({ onSuccess, onError } = {}) {
52
61
  expectedDstAmount,
53
62
  nft,
54
63
  tournament,
55
- payload,
64
+ payload: {
65
+ ...payload,
66
+ },
56
67
  }),
57
68
  creatorAddress: creatorAddress ? normalizeAddress(creatorAddress) : undefined,
58
69
  partnerId,
70
+ visitorData,
59
71
  });
60
72
  }
61
73
  catch (error) {
@@ -1,5 +1,6 @@
1
1
  import { anyspendService } from "../../../anyspend/services/anyspend.js";
2
2
  import { buildMetadata, buildPayload, normalizeAddress } from "../../../anyspend/utils/index.js";
3
+ import { useVisitorData } from "@fingerprintjs/fingerprintjs-pro-react";
3
4
  import { useMutation } from "@tanstack/react-query";
4
5
  import { useMemo } from "react";
5
6
  /**
@@ -8,6 +9,12 @@ import { useMemo } from "react";
8
9
  * For onramp orders, use useAnyspendCreateOnrampOrder instead.
9
10
  */
10
11
  export function useAnyspendCreateOrder({ onSuccess, onError } = {}) {
12
+ // Get fingerprint data
13
+ const { data: fpData } = useVisitorData({ extendedResult: true }, { immediate: true });
14
+ const visitorData = fpData && {
15
+ requestId: fpData.requestId,
16
+ visitorId: fpData.visitorId,
17
+ };
11
18
  const { mutate: createOrder, isPending } = useMutation({
12
19
  mutationFn: async (params) => {
13
20
  const { isMainnet, recipientAddress, orderType, srcChain, dstChain, srcToken, dstToken, srcAmount, creatorAddress, } = params;
@@ -28,7 +35,9 @@ export function useAnyspendCreateOrder({ onSuccess, onError } = {}) {
28
35
  expectedDstAmount: params.expectedDstAmount,
29
36
  nft: params.nft,
30
37
  tournament: params.tournament,
31
- payload: params.payload,
38
+ payload: {
39
+ ...params.payload,
40
+ },
32
41
  }),
33
42
  metadata: buildMetadata(orderType, {
34
43
  orderType,
@@ -37,9 +46,12 @@ export function useAnyspendCreateOrder({ onSuccess, onError } = {}) {
37
46
  expectedDstAmount: params.expectedDstAmount,
38
47
  nft: params.nft,
39
48
  tournament: params.tournament,
40
- payload: params.payload,
49
+ payload: {
50
+ ...params.payload,
51
+ },
41
52
  }),
42
53
  creatorAddress: creatorAddress ? normalizeAddress(creatorAddress) : undefined,
54
+ visitorData,
43
55
  });
44
56
  }
45
57
  catch (error) {
@@ -1,4 +1,5 @@
1
- export declare function useCoinbaseOnrampOptions(isMainnet: boolean, country?: string): {
1
+ import { VisitorData } from "../../../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;
@@ -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 useCoinbaseOnrampOptions(isMainnet, country) {
4
+ export function useCoinbaseOnrampOptions(isMainnet, country, visitorData, isLoadingVisitorData) {
5
5
  const { data, isLoading, error, refetch } = useQuery({
6
- queryKey: ["getCoinbaseOnrampOptions", isMainnet, country],
7
- queryFn: () => anyspendService.getCoinbaseOnrampOptions(isMainnet, country),
8
- enabled: Boolean(country),
6
+ queryKey: ["getCoinbaseOnrampOptions", isMainnet, country, visitorData],
7
+ queryFn: () => anyspendService.getCoinbaseOnrampOptions(isMainnet, country, visitorData),
8
+ enabled: Boolean(country) && !isLoadingVisitorData,
9
9
  });
10
10
  return useMemo(() => ({
11
11
  coinbaseOnrampOptions: data?.data,
@@ -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,12 +1,19 @@
1
+ import { useVisitorData } from "@fingerprintjs/fingerprintjs-pro-react";
1
2
  import { useMemo } from "react";
2
3
  import { useCoinbaseOnrampOptions } from "./useCoinbaseOnrampOptions.js";
3
4
  import { useGetGeo } from "./useGetGeo.js";
4
5
  import { useStripeSupport } from "./useStripeSupport.js";
5
6
  export function useGeoOnrampOptions(isMainnet, srcFiatAmount) {
7
+ // Get fingerprint data
8
+ const { data: fpData, isLoading: isLoadingVisitorData } = useVisitorData({ extendedResult: true }, { immediate: true });
9
+ const visitorData = fpData && {
10
+ requestId: fpData.requestId,
11
+ visitorId: fpData.visitorId,
12
+ };
6
13
  // Use existing hooks
7
14
  const { geoData, loading: isLoadingGeo, error: geoError } = useGetGeo();
8
- const { coinbaseOnrampOptions, isLoadingCoinbaseOnrampOptions, coinbaseOnrampOptionsError } = useCoinbaseOnrampOptions(isMainnet, geoData?.country);
9
- const { isStripeOnrampSupported, isStripeWeb2Supported, isLoadingStripeSupport, stripeSupportError } = useStripeSupport(isMainnet, geoData?.ip || "", srcFiatAmount);
15
+ const { coinbaseOnrampOptions, isLoadingCoinbaseOnrampOptions, coinbaseOnrampOptionsError } = useCoinbaseOnrampOptions(isMainnet, geoData?.country, visitorData);
16
+ const { isStripeOnrampSupported, isStripeWeb2Supported, isLoadingStripeSupport, stripeSupportError } = useStripeSupport(isMainnet, geoData?.ip || "", srcFiatAmount, visitorData);
10
17
  // Calculate available payment methods based on the amount
11
18
  const coinbaseAvailablePaymentMethods = useMemo(() => {
12
19
  if (!coinbaseOnrampOptions?.paymentCurrencies?.[0]?.limits || !srcFiatAmount)
@@ -27,7 +34,7 @@ export function useGeoOnrampOptions(isMainnet, srcFiatAmount) {
27
34
  isStripeOnrampSupported,
28
35
  isStripeWeb2Supported,
29
36
  isOnrampSupported: coinbaseAvailablePaymentMethods.length > 0 || isStripeOnrampSupported || isStripeWeb2Supported,
30
- isLoading: isLoadingGeo || isLoadingCoinbaseOnrampOptions || isLoadingStripeSupport,
37
+ isLoading: isLoadingGeo || isLoadingCoinbaseOnrampOptions || isLoadingStripeSupport || isLoadingVisitorData,
31
38
  isLoadingGeo,
32
39
  isLoadingCoinbaseOnrampOptions,
33
40
  isLoadingStripeSupport,