@b3dotfun/sdk 0.0.13 → 0.0.14-alpha.2

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 (76) hide show
  1. package/dist/cjs/anyspend/react/components/AnySpendFingerprintWrapper.d.ts +17 -0
  2. package/dist/cjs/anyspend/react/components/AnySpendFingerprintWrapper.js +40 -0
  3. package/dist/cjs/anyspend/react/components/common/PanelOnrampPayment.d.ts +1 -1
  4. package/dist/cjs/anyspend/react/components/common/PanelOnrampPayment.js +9 -4
  5. package/dist/cjs/anyspend/react/components/common/PaymentStripeWeb2.js +6 -9
  6. package/dist/cjs/anyspend/react/components/index.d.ts +1 -0
  7. package/dist/cjs/anyspend/react/components/index.js +15 -0
  8. package/dist/cjs/anyspend/react/components/webview/WebviewOnrampPayment.d.ts +1 -1
  9. package/dist/cjs/anyspend/react/components/webview/WebviewOnrampPayment.js +6 -1
  10. package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +1 -1
  11. package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +14 -2
  12. package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOrder.js +14 -2
  13. package/dist/cjs/anyspend/react/hooks/useCoinbaseOnrampOptions.d.ts +2 -1
  14. package/dist/cjs/anyspend/react/hooks/useCoinbaseOnrampOptions.js +4 -4
  15. package/dist/cjs/anyspend/react/hooks/useGeoOnrampOptions.d.ts +1 -1
  16. package/dist/cjs/anyspend/react/hooks/useGeoOnrampOptions.js +10 -3
  17. package/dist/cjs/anyspend/react/hooks/useStripeSupport.d.ts +2 -1
  18. package/dist/cjs/anyspend/react/hooks/useStripeSupport.js +4 -4
  19. package/dist/cjs/anyspend/react/providers/StripeRedirectHandler.js +0 -3
  20. package/dist/cjs/anyspend/services/anyspend.d.ts +6 -4
  21. package/dist/cjs/anyspend/services/anyspend.js +14 -4
  22. package/dist/cjs/anyspend/types/fingerprint.d.ts +14 -0
  23. package/dist/cjs/anyspend/types/fingerprint.js +6 -0
  24. package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +1 -1
  25. package/dist/cjs/global-account/react/hooks/useTokenBalancesByChain.js +0 -1
  26. package/dist/esm/anyspend/react/components/AnySpendFingerprintWrapper.d.ts +17 -0
  27. package/dist/esm/anyspend/react/components/AnySpendFingerprintWrapper.js +36 -0
  28. package/dist/esm/anyspend/react/components/common/PanelOnrampPayment.d.ts +1 -1
  29. package/dist/esm/anyspend/react/components/common/PanelOnrampPayment.js +9 -4
  30. package/dist/esm/anyspend/react/components/common/PaymentStripeWeb2.js +6 -9
  31. package/dist/esm/anyspend/react/components/index.d.ts +1 -0
  32. package/dist/esm/anyspend/react/components/index.js +1 -0
  33. package/dist/esm/anyspend/react/components/webview/WebviewOnrampPayment.d.ts +1 -1
  34. package/dist/esm/anyspend/react/components/webview/WebviewOnrampPayment.js +6 -1
  35. package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +1 -1
  36. package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +14 -2
  37. package/dist/esm/anyspend/react/hooks/useAnyspendCreateOrder.js +14 -2
  38. package/dist/esm/anyspend/react/hooks/useCoinbaseOnrampOptions.d.ts +2 -1
  39. package/dist/esm/anyspend/react/hooks/useCoinbaseOnrampOptions.js +4 -4
  40. package/dist/esm/anyspend/react/hooks/useGeoOnrampOptions.d.ts +1 -1
  41. package/dist/esm/anyspend/react/hooks/useGeoOnrampOptions.js +10 -3
  42. package/dist/esm/anyspend/react/hooks/useStripeSupport.d.ts +2 -1
  43. package/dist/esm/anyspend/react/hooks/useStripeSupport.js +4 -4
  44. package/dist/esm/anyspend/react/providers/StripeRedirectHandler.js +0 -3
  45. package/dist/esm/anyspend/services/anyspend.d.ts +6 -4
  46. package/dist/esm/anyspend/services/anyspend.js +14 -4
  47. package/dist/esm/anyspend/types/fingerprint.d.ts +14 -0
  48. package/dist/esm/anyspend/types/fingerprint.js +5 -0
  49. package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +1 -1
  50. package/dist/esm/global-account/react/hooks/useTokenBalancesByChain.js +0 -1
  51. package/dist/types/anyspend/react/components/AnySpendFingerprintWrapper.d.ts +17 -0
  52. package/dist/types/anyspend/react/components/common/PanelOnrampPayment.d.ts +1 -1
  53. package/dist/types/anyspend/react/components/index.d.ts +1 -0
  54. package/dist/types/anyspend/react/components/webview/WebviewOnrampPayment.d.ts +1 -1
  55. package/dist/types/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +1 -1
  56. package/dist/types/anyspend/react/hooks/useCoinbaseOnrampOptions.d.ts +2 -1
  57. package/dist/types/anyspend/react/hooks/useGeoOnrampOptions.d.ts +1 -1
  58. package/dist/types/anyspend/react/hooks/useStripeSupport.d.ts +2 -1
  59. package/dist/types/anyspend/services/anyspend.d.ts +6 -4
  60. package/dist/types/anyspend/types/fingerprint.d.ts +14 -0
  61. package/dist/types/global-account/react/hooks/useAuthentication.d.ts +1 -1
  62. package/package.json +26 -25
  63. package/src/anyspend/react/components/AnySpendFingerprintWrapper.tsx +60 -0
  64. package/src/anyspend/react/components/common/PanelOnrampPayment.tsx +38 -24
  65. package/src/anyspend/react/components/common/PaymentStripeWeb2.tsx +13 -16
  66. package/src/anyspend/react/components/index.ts +1 -0
  67. package/src/anyspend/react/components/webview/WebviewOnrampPayment.tsx +11 -1
  68. package/src/anyspend/react/hooks/useAnyspendCreateOnrampOrder.ts +18 -3
  69. package/src/anyspend/react/hooks/useAnyspendCreateOrder.ts +16 -3
  70. package/src/anyspend/react/hooks/useCoinbaseOnrampOptions.ts +10 -4
  71. package/src/anyspend/react/hooks/useGeoOnrampOptions.ts +15 -4
  72. package/src/anyspend/react/hooks/useStripeSupport.ts +11 -4
  73. package/src/anyspend/react/providers/StripeRedirectHandler.tsx +0 -4
  74. package/src/anyspend/services/anyspend.ts +21 -2
  75. package/src/anyspend/types/fingerprint.ts +15 -0
  76. package/src/global-account/react/hooks/useTokenBalancesByChain.tsx +0 -1
@@ -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
+ }
@@ -4,7 +4,7 @@ export declare function useAuthentication(partnerId: string, loginWithSiwe?: boo
4
4
  isAuthenticating: boolean;
5
5
  isAuthenticated: boolean;
6
6
  isReady: boolean;
7
- wallet: import("thirdweb/wallets").Wallet<`ecosystem.${string}`>;
7
+ wallet: import("thirdweb/dist/types/wallets/in-app/core/wallet/types").EcosystemWallet;
8
8
  preAuthenticate: typeof preAuthenticate;
9
9
  connect: (strategyOptions?: import("thirdweb/wallets").SingleStepAuthArgsType) => Promise<import("thirdweb/wallets").Wallet | null>;
10
10
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@b3dotfun/sdk",
3
- "version": "0.0.13",
3
+ "version": "0.0.14-alpha.2",
4
4
  "source": "src/index.ts",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "react-native": "./dist/cjs/index.native.js",
@@ -189,27 +189,6 @@
189
189
  "utils",
190
190
  "constants"
191
191
  ],
192
- "scripts": {
193
- "clean": "rm -rf dist",
194
- "prebuild": "pnpm clean",
195
- "fix-dist": "[ -d ./dist/react/src ] && cp -r ./dist/react/src/* ./dist/ && rm -rf ./dist/react || echo \"No react directory found\"",
196
- "build": "pnpm clean && pnpm lint && pnpm build:types && pnpm build:cjs && pnpm build:esm && pnpm build:css",
197
- "build:types": "tsc -p tsconfig.cjs.json --emitDeclarationOnly --declarationDir dist/types",
198
- "build:cjs": "tsc -p tsconfig.cjs.json --outDir dist/cjs --module commonjs && tsc-alias -p tsconfig.cjs.json --outDir dist/cjs && mkdir -p dist/cjs/shared/generated && cp src/shared/generated/chain-networks.json src/shared/generated/coingecko-chains.json dist/cjs/shared/generated/",
199
- "build:esm": "tsc -p tsconfig.esm.json --outDir dist/esm --module esnext && tsc-alias -p tsconfig.esm.json --outDir dist/esm && mkdir -p dist/esm/shared/generated && cp src/shared/generated/chain-networks.json src/shared/generated/coingecko-chains.json dist/esm/shared/generated/ && node scripts/fix-esm-imports.js",
200
- "build:css": "postcss src/styles/index.css -o dist/styles/index.css",
201
- "dev:cjs": "tsc-watch -p tsconfig.cjs.json --onSuccess \"tsc-alias -p tsconfig.cjs.json --outDir dist/cjs\"",
202
- "dev:esm": "tsc-watch -p tsconfig.esm.json --onSuccess \"tsc-alias -p tsconfig.esm.json --outDir dist/esm\"",
203
- "dev": "concurrently \"pnpm dev:cjs\" \"pnpm dev:esm\" \"pnpm dev:css\"",
204
- "dev:css": "postcss src/styles/index.css -o dist/styles/index.css --watch",
205
- "prepublishOnly": "pnpm build",
206
- "release:test": "pnpm version prerelease --preid test && git push --follow-tags && pnpm publish --tag test --no-git-checks",
207
- "release:alpha": "pnpm version prerelease --preid alpha && git push --follow-tags && pnpm publish --tag alpha --no-git-checks",
208
- "typecheck": "tsc --noEmit",
209
- "generate:thirdweb": "npx @hey-api/openapi-ts --file src/thirdweb/openapi-ts.config.ts --input src/thirdweb/insight-service.json",
210
- "lint": "eslint 'src/**/*.{ts,tsx}'",
211
- "lint:fix": "eslint 'src/**/*.{ts,tsx}' --fix"
212
- },
213
192
  "dependencies": {
214
193
  "@amplitude/analytics-browser": "2.14.0",
215
194
  "@b3dotfun/b3-api": "0.0.28",
@@ -220,6 +199,7 @@
220
199
  "@feathersjs/feathers": "5.0.33",
221
200
  "@feathersjs/socketio-client": "5.0.33",
222
201
  "@feathersjs/typebox": "5.0.33",
202
+ "@fingerprintjs/fingerprintjs-pro-react": "^2.7.0",
223
203
  "@hey-api/client-fetch": "0.8.3",
224
204
  "@hey-api/openapi-ts": "0.64.13",
225
205
  "@lottiefiles/dotlottie-react": "0.7.2",
@@ -256,7 +236,7 @@
256
236
  "sonner": "1.7.4",
257
237
  "stripe": "18.2.1",
258
238
  "tailwind-merge": "2.6.0",
259
- "thirdweb": "5.93.16",
239
+ "thirdweb": "5.105.20",
260
240
  "typescript": "5.8.2",
261
241
  "vaul": "^1.1.2",
262
242
  "viem": "2.27.2",
@@ -307,11 +287,12 @@
307
287
  "@react-three/postprocessing": "2.16.6",
308
288
  "@readyplayerme/visage": "6.10.0",
309
289
  "@tanstack/react-query": "5.55.0",
290
+ "@fingerprintjs/fingerprintjs-pro-react": "^2.7.0",
310
291
  "framer-motion": "12.0.0",
311
292
  "react": "^18.0.0 || ^19.0.0",
312
293
  "react-dom": "^18.0.0 || ^19.0.0",
313
294
  "react-native-mmkv": "^3.2.0",
314
- "thirdweb": "5.93.16",
295
+ "thirdweb": "5.105.20",
315
296
  "three": "0.175.0"
316
297
  },
317
298
  "peerDependenciesMeta": {
@@ -327,5 +308,25 @@
327
308
  "three": {
328
309
  "optional": true
329
310
  }
311
+ },
312
+ "scripts": {
313
+ "clean": "rm -rf dist",
314
+ "prebuild": "pnpm clean",
315
+ "fix-dist": "[ -d ./dist/react/src ] && cp -r ./dist/react/src/* ./dist/ && rm -rf ./dist/react || echo \"No react directory found\"",
316
+ "build": "pnpm clean && pnpm lint && pnpm build:types && pnpm build:cjs && pnpm build:esm && pnpm build:css",
317
+ "build:types": "tsc -p tsconfig.cjs.json --emitDeclarationOnly --declarationDir dist/types",
318
+ "build:cjs": "tsc -p tsconfig.cjs.json --outDir dist/cjs --module commonjs && tsc-alias -p tsconfig.cjs.json --outDir dist/cjs && mkdir -p dist/cjs/shared/generated && cp src/shared/generated/chain-networks.json src/shared/generated/coingecko-chains.json dist/cjs/shared/generated/",
319
+ "build:esm": "tsc -p tsconfig.esm.json --outDir dist/esm --module esnext && tsc-alias -p tsconfig.esm.json --outDir dist/esm && mkdir -p dist/esm/shared/generated && cp src/shared/generated/chain-networks.json src/shared/generated/coingecko-chains.json dist/esm/shared/generated/ && node scripts/fix-esm-imports.js",
320
+ "build:css": "postcss src/styles/index.css -o dist/styles/index.css",
321
+ "dev:cjs": "tsc-watch -p tsconfig.cjs.json --onSuccess \"tsc-alias -p tsconfig.cjs.json --outDir dist/cjs\"",
322
+ "dev:esm": "tsc-watch -p tsconfig.esm.json --onSuccess \"tsc-alias -p tsconfig.esm.json --outDir dist/esm\"",
323
+ "dev": "concurrently \"pnpm dev:cjs\" \"pnpm dev:esm\" \"pnpm dev:css\"",
324
+ "dev:css": "postcss src/styles/index.css -o dist/styles/index.css --watch",
325
+ "release:test": "pnpm version prerelease --preid test && git push --follow-tags && pnpm publish --tag test --no-git-checks",
326
+ "release:alpha": "pnpm version prerelease --preid alpha && git push --follow-tags && pnpm publish --tag alpha --no-git-checks",
327
+ "typecheck": "tsc --noEmit",
328
+ "generate:thirdweb": "npx @hey-api/openapi-ts --file src/thirdweb/openapi-ts.config.ts --input src/thirdweb/insight-service.json",
329
+ "lint": "eslint 'src/**/*.{ts,tsx}'",
330
+ "lint:fix": "eslint 'src/**/*.{ts,tsx}' --fix"
330
331
  }
331
- }
332
+ }
@@ -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
+ }
@@ -1,4 +1,6 @@
1
1
  import { useAnyspendCreateOnrampOrder, useGeoOnrampOptions } from "@b3dotfun/sdk/anyspend/react";
2
+ import { components } from "@b3dotfun/sdk/anyspend/types/api";
3
+ import { GetQuoteResponse } from "@b3dotfun/sdk/anyspend/types/api_req_res";
2
4
  import { Button } from "@b3dotfun/sdk/global-account/react";
3
5
  import centerTruncate from "@b3dotfun/sdk/shared/utils/centerTruncate";
4
6
  import { motion } from "framer-motion";
@@ -6,8 +8,7 @@ import invariant from "invariant";
6
8
  import { ChevronLeft, ChevronRight, Landmark, Loader2 } from "lucide-react";
7
9
  import { useEffect, useRef, useState } from "react";
8
10
  import { toast } from "sonner";
9
- import { components } from "@b3dotfun/sdk/anyspend/types/api";
10
- import { GetQuoteResponse } from "@b3dotfun/sdk/anyspend/types/api_req_res";
11
+ import { AnySpendFingerprintWrapper, getFingerprintConfig } from "../AnySpendFingerprintWrapper";
11
12
 
12
13
  interface PanelOnrampPaymentProps {
13
14
  srcAmountOnRamp: string;
@@ -31,27 +32,38 @@ interface PanelOnrampPaymentProps {
31
32
  recipientImageUrl?: string;
32
33
  }
33
34
 
34
- export function PanelOnrampPayment({
35
- srcAmountOnRamp,
36
- // recipientName,
37
- recipientAddress,
38
- isMainnet,
39
- isBuyMode,
40
- destinationTokenChainId,
41
- destinationTokenAddress,
42
- selectedDstChainId,
43
- selectedDstToken,
44
- anyspendQuote,
45
- globalAddress,
46
- onOrderCreated,
47
- onBack,
48
- orderType,
49
- nft,
50
- tournament,
51
- payload,
52
- recipientEnsName,
53
- recipientImageUrl,
54
- }: PanelOnrampPaymentProps) {
35
+ export function PanelOnrampPayment(props: PanelOnrampPaymentProps) {
36
+ const fingerprintConfig = getFingerprintConfig();
37
+
38
+ return (
39
+ <AnySpendFingerprintWrapper fingerprint={fingerprintConfig}>
40
+ <PanelOnrampPaymentInner {...props} />
41
+ </AnySpendFingerprintWrapper>
42
+ );
43
+ }
44
+
45
+ function PanelOnrampPaymentInner(props: PanelOnrampPaymentProps) {
46
+ const {
47
+ srcAmountOnRamp,
48
+ recipientAddress,
49
+ isMainnet,
50
+ isBuyMode,
51
+ destinationTokenChainId,
52
+ destinationTokenAddress,
53
+ selectedDstChainId,
54
+ selectedDstToken,
55
+ anyspendQuote,
56
+ globalAddress,
57
+ onOrderCreated,
58
+ onBack,
59
+ orderType,
60
+ nft,
61
+ tournament,
62
+ payload,
63
+ recipientEnsName,
64
+ recipientImageUrl,
65
+ } = props;
66
+
55
67
  // Use a stable amount for geo onramp options to prevent unnecessary refetches
56
68
  const [stableAmountForGeo, setStableAmountForGeo] = useState(srcAmountOnRamp);
57
69
  const hasInitialized = useRef(false);
@@ -73,6 +85,8 @@ export function PanelOnrampPayment({
73
85
  isLoading: isLoadingGeoOnramp,
74
86
  } = useGeoOnrampOptions(isMainnet, stableAmountForGeo);
75
87
 
88
+ const isLoading = isLoadingGeoOnramp;
89
+
76
90
  const { createOrder, isCreatingOrder } = useAnyspendCreateOnrampOrder({
77
91
  onSuccess: data => {
78
92
  const orderId = data.data.id;
@@ -219,7 +233,7 @@ export function PanelOnrampPayment({
219
233
  <Loader2 className="h-4 w-4 animate-spin" />
220
234
  <span className="text-as-primary/70">Creating onramp order...</span>
221
235
  </div>
222
- ) : isLoadingGeoOnramp ? (
236
+ ) : isLoading ? (
223
237
  <div className="bg-b3-react-background border-b3-react-border flex items-center justify-center gap-3 rounded-lg border p-6">
224
238
  <Loader2 className="h-4 w-4 animate-spin" />
225
239
  <span className="text-as-primary/70">Loading payment options...</span>
@@ -8,6 +8,7 @@ import { AddressElement, Elements, PaymentElement, useElements, useStripe } from
8
8
  import { loadStripe, PaymentIntentResult, StripePaymentElementOptions } 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";
11
12
  import HowItWorks from "./HowItWorks";
12
13
  import PaymentMethodIcons from "./PaymentMethodIcons";
13
14
 
@@ -21,6 +22,7 @@ interface PaymentStripeWeb2Props {
21
22
 
22
23
  export default function PaymentStripeWeb2({ isMainnet, order, onPaymentSuccess }: PaymentStripeWeb2Props) {
23
24
  const { theme } = useB3();
25
+ const fingerprintConfig = getFingerprintConfig();
24
26
 
25
27
  const { clientSecret, isLoadingStripeClientSecret, stripeClientSecretError } = useStripeClientSecret(
26
28
  isMainnet,
@@ -36,15 +38,17 @@ export default function PaymentStripeWeb2({ isMainnet, order, onPaymentSuccess }
36
38
  }
37
39
 
38
40
  return (
39
- <Elements
40
- stripe={stripePromise}
41
- options={{
42
- clientSecret: clientSecret || undefined,
43
- appearance: { theme: theme === "light" ? "stripe" : "night" },
44
- }}
45
- >
46
- <StripePaymentForm order={order} clientSecret={clientSecret} onPaymentSuccess={onPaymentSuccess} />
47
- </Elements>
41
+ <AnySpendFingerprintWrapper fingerprint={fingerprintConfig}>
42
+ <Elements
43
+ stripe={stripePromise}
44
+ options={{
45
+ clientSecret: clientSecret || undefined,
46
+ appearance: { theme: theme === "light" ? "stripe" : "night" },
47
+ }}
48
+ >
49
+ <StripePaymentForm order={order} clientSecret={clientSecret} onPaymentSuccess={onPaymentSuccess} />
50
+ </Elements>
51
+ </AnySpendFingerprintWrapper>
48
52
  );
49
53
  }
50
54
 
@@ -102,7 +106,6 @@ function StripePaymentForm({
102
106
  useEffect(() => {
103
107
  if (stripe && elements) {
104
108
  setStripeReady(true);
105
- console.log("@@stripe-web2-payment:initialized:", JSON.stringify({ orderId: order.id }, null, 2));
106
109
  }
107
110
  }, [stripe, elements, order.id]);
108
111
 
@@ -127,7 +130,6 @@ function StripePaymentForm({
127
130
  // Handle payment element changes
128
131
  const handlePaymentElementChange = (event: any) => {
129
132
  // Show address element only for card payments
130
- console.log("@@stripe-web2-payment:payment-element-change:", JSON.stringify(event, null, 2));
131
133
  setShowAddressElement(event.value.type === "card");
132
134
  };
133
135
 
@@ -143,8 +145,6 @@ function StripePaymentForm({
143
145
  setMessage(null);
144
146
 
145
147
  try {
146
- console.log("@@stripe-web2-payment:confirming-payment:", JSON.stringify({ orderId: order.id }, null, 2));
147
-
148
148
  const result = (await stripe.confirmPayment({
149
149
  elements,
150
150
  confirmParams: {
@@ -191,9 +191,6 @@ function StripePaymentForm({
191
191
  const fromStripe = url.searchParams.get("fromStripe");
192
192
  const paymentIntent = url.searchParams.get("payment_intent");
193
193
 
194
- console.log("@@stripe-web2-payment:fromStripe:", fromStripe);
195
- console.log("@@stripe-web2-payment:paymentIntent:", paymentIntent);
196
-
197
194
  if (fromStripe && paymentIntent) {
198
195
  // Close the modal as we're returning from 3DS
199
196
  setB3ModalOpen(true);
@@ -3,6 +3,7 @@ export { AnySpend } from "./AnySpend";
3
3
  export { AnySpendBondKit } from "./AnySpendBondKit";
4
4
  export { AnySpendBuySpin } from "./AnySpendBuySpin";
5
5
  export { AnySpendCustom } from "./AnySpendCustom";
6
+ export * from "./AnySpendFingerprintWrapper";
6
7
  export { AnySpendNFT } from "./AnySpendNFT";
7
8
  export { AnyspendSignatureMint } from "./AnyspendSignatureMint";
8
9
  export { AnySpendStakeB3 } from "./AnySpendStakeB3";
@@ -10,6 +10,7 @@ import { Loader2 } from "lucide-react";
10
10
  import { useEffect, useRef, useState } from "react";
11
11
  import { toast } from "sonner";
12
12
  import { formatUnits } from "viem";
13
+ import { AnySpendFingerprintWrapper, getFingerprintConfig } from "../AnySpendFingerprintWrapper";
13
14
 
14
15
  const stripePromise = loadStripe(STRIPE_CONFIG.publishableKey);
15
16
 
@@ -23,6 +24,15 @@ interface WebviewOnrampPaymentProps {
23
24
  userId?: string;
24
25
  }
25
26
 
27
+ export function WebviewOnrampPayment(props: WebviewOnrampPaymentProps) {
28
+ const fingerprintConfig = getFingerprintConfig();
29
+ return (
30
+ <AnySpendFingerprintWrapper fingerprint={fingerprintConfig}>
31
+ <WebviewOnrampPaymentInner {...props} />
32
+ </AnySpendFingerprintWrapper>
33
+ );
34
+ }
35
+
26
36
  // Stripe Payment Form Component
27
37
  function StripePaymentForm({
28
38
  order,
@@ -140,7 +150,7 @@ function StripePaymentForm({
140
150
  );
141
151
  }
142
152
 
143
- export function WebviewOnrampPayment({
153
+ function WebviewOnrampPaymentInner({
144
154
  srcAmountOnRamp,
145
155
  recipientAddress,
146
156
  destinationToken,
@@ -1,12 +1,15 @@
1
1
  import { USDC_BASE } from "@b3dotfun/sdk/anyspend/constants";
2
2
  import { anyspendService } from "@b3dotfun/sdk/anyspend/services/anyspend";
3
+ import { components } from "@b3dotfun/sdk/anyspend/types/api";
4
+ import { VisitorData } from "@b3dotfun/sdk/anyspend/types/fingerprint";
3
5
  import { buildMetadata, buildPayload, normalizeAddress } from "@b3dotfun/sdk/anyspend/utils";
6
+ import { useVisitorData } from "@fingerprintjs/fingerprintjs-pro-react";
4
7
  import { useMutation } from "@tanstack/react-query";
5
8
  import { useMemo } from "react";
9
+
6
10
  import { parseUnits } from "viem";
7
11
  import { base } from "viem/chains";
8
12
  import { CreateOrderParams } from "./useAnyspendCreateOrder";
9
- import { components } from "@b3dotfun/sdk/anyspend/types/api";
10
13
 
11
14
  export type OnrampOptions = {
12
15
  vendor: components["schemas"]["OnrampMetadata"]["vendor"];
@@ -31,6 +34,13 @@ export type UseAnyspendCreateOnrampOrderProps = {
31
34
  * Specifically handles orders that involve fiat-to-crypto onramp functionality
32
35
  */
33
36
  export function useAnyspendCreateOnrampOrder({ onSuccess, onError }: UseAnyspendCreateOnrampOrderProps = {}) {
37
+ // Get fingerprint data
38
+ const { data: fpData } = useVisitorData({ extendedResult: true }, { immediate: true });
39
+ const visitorData: VisitorData | undefined = fpData && {
40
+ requestId: fpData.requestId,
41
+ visitorId: fpData.visitorId,
42
+ };
43
+
34
44
  const { mutate: createOrder, isPending } = useMutation({
35
45
  mutationFn: async (params: CreateOnrampOrderParams) => {
36
46
  const {
@@ -82,7 +92,9 @@ export function useAnyspendCreateOnrampOrder({ onSuccess, onError }: UseAnyspend
82
92
  expectedDstAmount,
83
93
  nft,
84
94
  tournament,
85
- payload,
95
+ payload: {
96
+ ...payload,
97
+ },
86
98
  }),
87
99
  onramp,
88
100
  metadata: buildMetadata(orderType, {
@@ -92,10 +104,13 @@ export function useAnyspendCreateOnrampOrder({ onSuccess, onError }: UseAnyspend
92
104
  expectedDstAmount,
93
105
  nft,
94
106
  tournament,
95
- payload,
107
+ payload: {
108
+ ...payload,
109
+ },
96
110
  }),
97
111
  creatorAddress: creatorAddress ? normalizeAddress(creatorAddress) : undefined,
98
112
  partnerId,
113
+ visitorData,
99
114
  });
100
115
  } catch (error: any) {
101
116
  // If the error has a response with message and statusCode, throw that
@@ -1,6 +1,8 @@
1
1
  import { anyspendService } from "@b3dotfun/sdk/anyspend/services/anyspend";
2
- import { buildMetadata, buildPayload, normalizeAddress } from "@b3dotfun/sdk/anyspend/utils";
3
2
  import { components } from "@b3dotfun/sdk/anyspend/types/api";
3
+ import { VisitorData } from "@b3dotfun/sdk/anyspend/types/fingerprint";
4
+ import { buildMetadata, buildPayload, normalizeAddress } from "@b3dotfun/sdk/anyspend/utils";
5
+ import { useVisitorData } from "@fingerprintjs/fingerprintjs-pro-react";
4
6
  import { useMutation } from "@tanstack/react-query";
5
7
  import { useMemo } from "react";
6
8
 
@@ -32,6 +34,12 @@ export type UseAnyspendCreateOrderProps = {
32
34
  * For onramp orders, use useAnyspendCreateOnrampOrder instead.
33
35
  */
34
36
  export function useAnyspendCreateOrder({ onSuccess, onError }: UseAnyspendCreateOrderProps = {}) {
37
+ // Get fingerprint data
38
+ const { data: fpData } = useVisitorData({ extendedResult: true }, { immediate: true });
39
+ const visitorData: VisitorData | undefined = fpData && {
40
+ requestId: fpData.requestId,
41
+ visitorId: fpData.visitorId,
42
+ };
35
43
  const { mutate: createOrder, isPending } = useMutation({
36
44
  mutationFn: async (params: CreateOrderParams) => {
37
45
  const {
@@ -63,7 +71,9 @@ export function useAnyspendCreateOrder({ onSuccess, onError }: UseAnyspendCreate
63
71
  expectedDstAmount: params.expectedDstAmount,
64
72
  nft: params.nft,
65
73
  tournament: params.tournament,
66
- payload: params.payload,
74
+ payload: {
75
+ ...params.payload,
76
+ },
67
77
  }),
68
78
  metadata: buildMetadata(orderType, {
69
79
  orderType,
@@ -72,9 +82,12 @@ export function useAnyspendCreateOrder({ onSuccess, onError }: UseAnyspendCreate
72
82
  expectedDstAmount: params.expectedDstAmount,
73
83
  nft: params.nft,
74
84
  tournament: params.tournament,
75
- payload: params.payload,
85
+ payload: {
86
+ ...params.payload,
87
+ },
76
88
  }),
77
89
  creatorAddress: creatorAddress ? normalizeAddress(creatorAddress) : undefined,
90
+ visitorData,
78
91
  });
79
92
  } catch (error: any) {
80
93
  // If the error has a response with message and statusCode, throw that
@@ -1,12 +1,18 @@
1
1
  import { anyspendService } from "@b3dotfun/sdk/anyspend/services/anyspend";
2
+ import { VisitorData } from "@b3dotfun/sdk/anyspend/types/fingerprint";
2
3
  import { useQuery } from "@tanstack/react-query";
3
4
  import { useMemo } from "react";
4
5
 
5
- export function useCoinbaseOnrampOptions(isMainnet: boolean, country?: string) {
6
+ export function useCoinbaseOnrampOptions(
7
+ isMainnet: boolean,
8
+ country?: string,
9
+ visitorData?: VisitorData,
10
+ isLoadingVisitorData?: boolean,
11
+ ) {
6
12
  const { data, isLoading, error, refetch } = useQuery({
7
- queryKey: ["getCoinbaseOnrampOptions", isMainnet, country],
8
- queryFn: () => anyspendService.getCoinbaseOnrampOptions(isMainnet, country!),
9
- enabled: Boolean(country),
13
+ queryKey: ["getCoinbaseOnrampOptions", isMainnet, country, visitorData],
14
+ queryFn: () => anyspendService.getCoinbaseOnrampOptions(isMainnet, country!, visitorData),
15
+ enabled: Boolean(country) && !isLoadingVisitorData,
10
16
  });
11
17
 
12
18
  return useMemo(
@@ -1,16 +1,27 @@
1
+ import { useVisitorData } from "@fingerprintjs/fingerprintjs-pro-react";
1
2
  import { useMemo } from "react";
2
-
3
+ import { VisitorData } from "../../types/fingerprint";
3
4
  import { useCoinbaseOnrampOptions } from "./useCoinbaseOnrampOptions";
4
5
  import { useGetGeo } from "./useGetGeo";
5
6
  import { useStripeSupport } from "./useStripeSupport";
6
7
 
7
8
  export function useGeoOnrampOptions(isMainnet: boolean, srcFiatAmount: string) {
9
+ // Get fingerprint data
10
+ const { data: fpData, isLoading: isLoadingVisitorData } = useVisitorData(
11
+ { extendedResult: true },
12
+ { immediate: true },
13
+ );
14
+ const visitorData: VisitorData | undefined = fpData && {
15
+ requestId: fpData.requestId,
16
+ visitorId: fpData.visitorId,
17
+ };
18
+
8
19
  // Use existing hooks
9
20
  const { geoData, loading: isLoadingGeo, error: geoError } = useGetGeo();
10
21
  const { coinbaseOnrampOptions, isLoadingCoinbaseOnrampOptions, coinbaseOnrampOptionsError } =
11
- useCoinbaseOnrampOptions(isMainnet, geoData?.country);
22
+ useCoinbaseOnrampOptions(isMainnet, geoData?.country, visitorData);
12
23
  const { isStripeOnrampSupported, isStripeWeb2Supported, isLoadingStripeSupport, stripeSupportError } =
13
- useStripeSupport(isMainnet, geoData?.ip || "", srcFiatAmount);
24
+ useStripeSupport(isMainnet, geoData?.ip || "", srcFiatAmount, visitorData);
14
25
 
15
26
  // Calculate available payment methods based on the amount
16
27
  const coinbaseAvailablePaymentMethods = useMemo(() => {
@@ -33,7 +44,7 @@ export function useGeoOnrampOptions(isMainnet: boolean, srcFiatAmount: string) {
33
44
  isStripeOnrampSupported,
34
45
  isStripeWeb2Supported,
35
46
  isOnrampSupported: coinbaseAvailablePaymentMethods.length > 0 || isStripeOnrampSupported || isStripeWeb2Supported,
36
- isLoading: isLoadingGeo || isLoadingCoinbaseOnrampOptions || isLoadingStripeSupport,
47
+ isLoading: isLoadingGeo || isLoadingCoinbaseOnrampOptions || isLoadingStripeSupport || isLoadingVisitorData,
37
48
  isLoadingGeo,
38
49
  isLoadingCoinbaseOnrampOptions,
39
50
  isLoadingStripeSupport,
@@ -1,12 +1,19 @@
1
1
  import { anyspendService } from "@b3dotfun/sdk/anyspend/services/anyspend";
2
+ import { VisitorData } from "@b3dotfun/sdk/anyspend/types/fingerprint";
2
3
  import { useQuery } from "@tanstack/react-query";
3
4
  import { useMemo } from "react";
4
5
 
5
- export function useStripeSupport(isMainnet: boolean, ipAddress: string, usdAmount?: string) {
6
+ export function useStripeSupport(
7
+ isMainnet: boolean,
8
+ ipAddress: string,
9
+ usdAmount?: string,
10
+ visitorData?: VisitorData,
11
+ isLoadingVisitorData?: boolean,
12
+ ) {
6
13
  const { data, isLoading, error, refetch } = useQuery({
7
- queryKey: ["useStripeSupport", isMainnet, ipAddress, usdAmount],
8
- queryFn: () => anyspendService.checkStripeSupport(isMainnet, ipAddress, usdAmount),
9
- enabled: !!ipAddress,
14
+ queryKey: ["useStripeSupport", isMainnet, ipAddress, usdAmount, visitorData?.requestId, visitorData?.visitorId],
15
+ queryFn: () => anyspendService.checkStripeSupport(isMainnet, ipAddress, usdAmount, visitorData),
16
+ enabled: !!ipAddress && !isLoadingVisitorData,
10
17
  });
11
18
 
12
19
  return useMemo(
@@ -20,10 +20,6 @@ export function StripeRedirectHandler() {
20
20
  const paymentIntent = url.searchParams.get("payment_intent");
21
21
  const orderId = url.searchParams.get("orderId");
22
22
 
23
- console.log("@@stripe-web2-payment:fromStripe:", fromStripe);
24
- console.log("@@stripe-web2-payment:paymentIntent:", paymentIntent);
25
- console.log("@@stripe-web2-payment:orderId:", orderId);
26
-
27
23
  if (fromStripe && paymentIntent && orderId) {
28
24
  // Re-open the modal with the order details
29
25
  setB3ModalOpen(true);