@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.
- package/dist/cjs/anyspend/react/components/AnySpend.js +2 -5
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendFingerprintWrapper.d.ts +17 -0
- package/dist/cjs/anyspend/react/components/AnySpendFingerprintWrapper.js +40 -0
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +2 -1
- package/dist/cjs/anyspend/react/components/common/PanelOnrampPayment.d.ts +1 -1
- package/dist/cjs/anyspend/react/components/common/PanelOnrampPayment.js +9 -4
- package/dist/cjs/anyspend/react/components/common/PaymentStripeWeb2.js +6 -9
- package/dist/cjs/anyspend/react/components/index.d.ts +1 -0
- package/dist/cjs/anyspend/react/components/index.js +15 -0
- package/dist/cjs/anyspend/react/components/webview/WebviewOnrampPayment.d.ts +1 -1
- package/dist/cjs/anyspend/react/components/webview/WebviewOnrampPayment.js +6 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +1 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +14 -2
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOrder.js +14 -2
- package/dist/cjs/anyspend/react/hooks/useCoinbaseOnrampOptions.d.ts +2 -1
- package/dist/cjs/anyspend/react/hooks/useCoinbaseOnrampOptions.js +4 -4
- package/dist/cjs/anyspend/react/hooks/useGeoOnrampOptions.d.ts +1 -1
- package/dist/cjs/anyspend/react/hooks/useGeoOnrampOptions.js +10 -3
- package/dist/cjs/anyspend/react/hooks/useStripeSupport.d.ts +2 -1
- package/dist/cjs/anyspend/react/hooks/useStripeSupport.js +4 -4
- package/dist/cjs/anyspend/react/providers/StripeRedirectHandler.js +0 -3
- package/dist/cjs/anyspend/services/anyspend.d.ts +6 -4
- package/dist/cjs/anyspend/services/anyspend.js +14 -4
- package/dist/cjs/anyspend/types/fingerprint.d.ts +14 -0
- package/dist/cjs/anyspend/types/fingerprint.js +6 -0
- package/dist/cjs/global-account/react/hooks/index.d.ts +0 -2
- package/dist/cjs/global-account/react/hooks/index.js +1 -5
- package/dist/cjs/global-account/react/hooks/useAccountWallet.js +2 -3
- package/dist/cjs/global-account/react/hooks/useProfile.d.ts +27 -0
- package/dist/cjs/global-account/react/hooks/useProfile.js +65 -0
- package/dist/esm/anyspend/react/components/AnySpend.js +3 -6
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +3 -3
- package/dist/esm/anyspend/react/components/AnySpendFingerprintWrapper.d.ts +17 -0
- package/dist/esm/anyspend/react/components/AnySpendFingerprintWrapper.js +36 -0
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +3 -2
- package/dist/esm/anyspend/react/components/common/PanelOnrampPayment.d.ts +1 -1
- package/dist/esm/anyspend/react/components/common/PanelOnrampPayment.js +9 -4
- package/dist/esm/anyspend/react/components/common/PaymentStripeWeb2.js +6 -9
- package/dist/esm/anyspend/react/components/index.d.ts +1 -0
- package/dist/esm/anyspend/react/components/index.js +1 -0
- package/dist/esm/anyspend/react/components/webview/WebviewOnrampPayment.d.ts +1 -1
- package/dist/esm/anyspend/react/components/webview/WebviewOnrampPayment.js +6 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +1 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +14 -2
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOrder.js +14 -2
- package/dist/esm/anyspend/react/hooks/useCoinbaseOnrampOptions.d.ts +2 -1
- package/dist/esm/anyspend/react/hooks/useCoinbaseOnrampOptions.js +4 -4
- package/dist/esm/anyspend/react/hooks/useGeoOnrampOptions.d.ts +1 -1
- package/dist/esm/anyspend/react/hooks/useGeoOnrampOptions.js +10 -3
- package/dist/esm/anyspend/react/hooks/useStripeSupport.d.ts +2 -1
- package/dist/esm/anyspend/react/hooks/useStripeSupport.js +4 -4
- package/dist/esm/anyspend/react/providers/StripeRedirectHandler.js +0 -3
- package/dist/esm/anyspend/services/anyspend.d.ts +6 -4
- package/dist/esm/anyspend/services/anyspend.js +14 -4
- package/dist/esm/anyspend/types/fingerprint.d.ts +14 -0
- package/dist/esm/anyspend/types/fingerprint.js +5 -0
- package/dist/esm/global-account/react/hooks/index.d.ts +0 -2
- package/dist/esm/global-account/react/hooks/index.js +0 -2
- package/dist/esm/global-account/react/hooks/useAccountWallet.js +3 -4
- package/dist/esm/global-account/react/hooks/useProfile.d.ts +27 -0
- package/dist/esm/global-account/react/hooks/useProfile.js +63 -0
- package/dist/types/anyspend/react/components/AnySpendFingerprintWrapper.d.ts +17 -0
- package/dist/types/anyspend/react/components/common/PanelOnrampPayment.d.ts +1 -1
- package/dist/types/anyspend/react/components/index.d.ts +1 -0
- package/dist/types/anyspend/react/components/webview/WebviewOnrampPayment.d.ts +1 -1
- package/dist/types/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +1 -1
- package/dist/types/anyspend/react/hooks/useCoinbaseOnrampOptions.d.ts +2 -1
- package/dist/types/anyspend/react/hooks/useGeoOnrampOptions.d.ts +1 -1
- package/dist/types/anyspend/react/hooks/useStripeSupport.d.ts +2 -1
- package/dist/types/anyspend/services/anyspend.d.ts +6 -4
- package/dist/types/anyspend/types/fingerprint.d.ts +14 -0
- package/dist/types/global-account/react/hooks/index.d.ts +0 -2
- package/dist/types/global-account/react/hooks/useProfile.d.ts +27 -0
- package/package.json +3 -1
- package/src/anyspend/react/components/AnySpend.tsx +3 -7
- package/src/anyspend/react/components/AnySpendCustom.tsx +3 -3
- package/src/anyspend/react/components/AnySpendFingerprintWrapper.tsx +60 -0
- package/src/anyspend/react/components/common/OrderDetails.tsx +4 -2
- package/src/anyspend/react/components/common/PanelOnrampPayment.tsx +38 -24
- package/src/anyspend/react/components/common/PaymentStripeWeb2.tsx +13 -16
- package/src/anyspend/react/components/index.ts +1 -0
- package/src/anyspend/react/components/webview/WebviewOnrampPayment.tsx +11 -1
- package/src/anyspend/react/hooks/useAnyspendCreateOnrampOrder.ts +18 -3
- package/src/anyspend/react/hooks/useAnyspendCreateOrder.ts +16 -3
- package/src/anyspend/react/hooks/useCoinbaseOnrampOptions.ts +10 -4
- package/src/anyspend/react/hooks/useGeoOnrampOptions.ts +15 -4
- package/src/anyspend/react/hooks/useStripeSupport.ts +11 -4
- package/src/anyspend/react/providers/StripeRedirectHandler.tsx +0 -4
- package/src/anyspend/services/anyspend.ts +21 -2
- package/src/anyspend/types/fingerprint.ts +15 -0
- package/src/global-account/react/hooks/index.ts +0 -2
- package/src/global-account/react/hooks/useAccountWallet.tsx +3 -4
- package/src/global-account/react/hooks/useProfile.ts +102 -0
- package/dist/cjs/global-account/react/hooks/useBsmntProfile.d.ts +0 -4
- package/dist/cjs/global-account/react/hooks/useBsmntProfile.js +0 -13
- package/dist/cjs/global-account/react/hooks/useOnchainName.d.ts +0 -19
- package/dist/cjs/global-account/react/hooks/useOnchainName.js +0 -193
- package/dist/cjs/shared/utils/fetchBsmntProfile.d.ts +0 -1
- package/dist/cjs/shared/utils/fetchBsmntProfile.js +0 -26
- package/dist/esm/global-account/react/hooks/useBsmntProfile.d.ts +0 -4
- package/dist/esm/global-account/react/hooks/useBsmntProfile.js +0 -9
- package/dist/esm/global-account/react/hooks/useOnchainName.d.ts +0 -19
- package/dist/esm/global-account/react/hooks/useOnchainName.js +0 -187
- package/dist/esm/shared/utils/fetchBsmntProfile.d.ts +0 -1
- package/dist/esm/shared/utils/fetchBsmntProfile.js +0 -23
- package/dist/types/global-account/react/hooks/useBsmntProfile.d.ts +0 -4
- package/dist/types/global-account/react/hooks/useOnchainName.d.ts +0 -19
- package/dist/types/shared/utils/fetchBsmntProfile.d.ts +0 -1
- package/src/global-account/react/hooks/useBsmntProfile.ts +0 -14
- package/src/global-account/react/hooks/useOnchainName.tsx +0 -198
- package/src/shared/utils/fetchBsmntProfile.ts +0 -29
|
@@ -306,11 +306,8 @@ function AnySpend({ destinationTokenAddress, destinationTokenChainId, isMainnet
|
|
|
306
306
|
tradeType: "EXACT_INPUT",
|
|
307
307
|
amount: srcAmountOnrampInWei,
|
|
308
308
|
});
|
|
309
|
-
|
|
310
|
-
const
|
|
311
|
-
// const { name: walletName } = useOnchainName(globalAddress);
|
|
312
|
-
// Batch lookup for custom recipients
|
|
313
|
-
// const { names: customRecipientNames } = useOnchainNames(customRecipients.map(r => r.address));
|
|
309
|
+
const recipientProfile = (0, react_2.useProfile)({ address: recipientAddress });
|
|
310
|
+
const recipientName = recipientProfile.data?.name?.replace(/\.b3\.fun/g, "");
|
|
314
311
|
// Load custom recipients from local storage on mount
|
|
315
312
|
(0, react_3.useEffect)(() => {
|
|
316
313
|
try {
|
|
@@ -102,8 +102,8 @@ function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", recipient
|
|
|
102
102
|
const [customRecipientAddress, setCustomRecipientAddress] = (0, react_3.useState)(recipientAddressProps);
|
|
103
103
|
// Update recipient logic to use custom recipient
|
|
104
104
|
const recipientAddress = customRecipientAddress || currentWallet.address;
|
|
105
|
-
const recipientPropsProfile = (0, react_2.
|
|
106
|
-
const recipientEnsName = recipientPropsProfile.data?.
|
|
105
|
+
const recipientPropsProfile = (0, react_2.useProfile)({ address: recipientAddress });
|
|
106
|
+
const recipientEnsName = recipientPropsProfile.data?.name?.replace(/\.b3\.fun/g, "");
|
|
107
107
|
const recipientImageUrl = recipientPropsProfile.data?.avatar || currentWallet.wallet.meta?.icon;
|
|
108
108
|
const [orderId, setOrderId] = (0, react_3.useState)(loadOrder);
|
|
109
109
|
const [srcChainId, setSrcChainId] = (0, react_3.useState)(isMainnet ? chains_1.base.id : chains_1.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,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AnySpendFingerprintWrapper = AnySpendFingerprintWrapper;
|
|
4
|
+
exports.getFingerprintConfig = getFingerprintConfig;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const fingerprintjs_pro_react_1 = require("@fingerprintjs/fingerprintjs-pro-react");
|
|
7
|
+
/**
|
|
8
|
+
* Internal wrapper that only initializes FingerprintJS when AnySpend components are actually used.
|
|
9
|
+
* This prevents unnecessary fingerprinting of users who don't interact with AnySpend.
|
|
10
|
+
*/
|
|
11
|
+
function AnySpendFingerprintWrapper({ children, fingerprint }) {
|
|
12
|
+
// If no fingerprint config is provided, render children without fingerprinting
|
|
13
|
+
if (!fingerprint?.apiKey) {
|
|
14
|
+
console.warn("No Fingerprint API key provided. Fingerprinting will be disabled.");
|
|
15
|
+
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children });
|
|
16
|
+
}
|
|
17
|
+
// Ensure endpoint has https:// prefix
|
|
18
|
+
const endpoint = fingerprint.endpoint && !fingerprint.endpoint.startsWith("http")
|
|
19
|
+
? `https://${fingerprint.endpoint}`
|
|
20
|
+
: fingerprint.endpoint;
|
|
21
|
+
return ((0, jsx_runtime_1.jsx)(fingerprintjs_pro_react_1.FpjsProvider, { loadOptions: {
|
|
22
|
+
apiKey: fingerprint.apiKey,
|
|
23
|
+
endpoint: endpoint ? [endpoint, fingerprintjs_pro_react_1.FingerprintJSPro.defaultEndpoint] : undefined,
|
|
24
|
+
scriptUrlPattern: fingerprint.scriptUrlPattern
|
|
25
|
+
? [fingerprint.scriptUrlPattern, fingerprintjs_pro_react_1.FingerprintJSPro.defaultScriptUrlPattern]
|
|
26
|
+
: undefined,
|
|
27
|
+
}, children: children }));
|
|
28
|
+
}
|
|
29
|
+
// Helper function to get fingerprint config from environment variables
|
|
30
|
+
function getFingerprintConfig() {
|
|
31
|
+
const apiKey = process.env.NEXT_PUBLIC_FINGERPRINT_API_KEY;
|
|
32
|
+
if (!apiKey) {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
apiKey,
|
|
37
|
+
endpoint: process.env.NEXT_PUBLIC_FINGERPRINT_ENDPOINT,
|
|
38
|
+
scriptUrlPattern: process.env.NEXT_PUBLIC_FINGERPRINT_SCRIPT_URL,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -130,7 +130,8 @@ exports.OrderDetails = (0, react_4.memo)(function OrderDetails({ isMainnet, mode
|
|
|
130
130
|
const dstToken = order.metadata.dstToken;
|
|
131
131
|
const nft = order.type === "mint_nft" ? order.metadata.nft : undefined;
|
|
132
132
|
const tournament = order.type === "join_tournament" || order.type === "fund_tournament" ? order.metadata.tournament : undefined;
|
|
133
|
-
const
|
|
133
|
+
const profile = (0, react_1.useProfile)({ address: order.recipientAddress });
|
|
134
|
+
const recipientName = profile.data?.name?.replace(/\.b3\.fun/g, "");
|
|
134
135
|
const account = (0, react_1.useAccountWallet)();
|
|
135
136
|
const { data: walletClient } = (0, wagmi_1.useWalletClient)();
|
|
136
137
|
const [txHash, setTxHash] = (0, react_4.useState)();
|
|
@@ -26,5 +26,5 @@ interface PanelOnrampPaymentProps {
|
|
|
26
26
|
recipientEnsName?: string;
|
|
27
27
|
recipientImageUrl?: string;
|
|
28
28
|
}
|
|
29
|
-
export declare function PanelOnrampPayment(
|
|
29
|
+
export declare function PanelOnrampPayment(props: PanelOnrampPaymentProps): import("react/jsx-runtime").JSX.Element;
|
|
30
30
|
export {};
|
|
@@ -13,9 +13,13 @@ const invariant_1 = __importDefault(require("invariant"));
|
|
|
13
13
|
const lucide_react_1 = require("lucide-react");
|
|
14
14
|
const react_3 = require("react");
|
|
15
15
|
const sonner_1 = require("sonner");
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
const AnySpendFingerprintWrapper_1 = require("../AnySpendFingerprintWrapper");
|
|
17
|
+
function PanelOnrampPayment(props) {
|
|
18
|
+
const fingerprintConfig = (0, AnySpendFingerprintWrapper_1.getFingerprintConfig)();
|
|
19
|
+
return ((0, jsx_runtime_1.jsx)(AnySpendFingerprintWrapper_1.AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: (0, jsx_runtime_1.jsx)(PanelOnrampPaymentInner, { ...props }) }));
|
|
20
|
+
}
|
|
21
|
+
function PanelOnrampPaymentInner(props) {
|
|
22
|
+
const { srcAmountOnRamp, recipientAddress, isMainnet, isBuyMode, destinationTokenChainId, destinationTokenAddress, selectedDstChainId, selectedDstToken, anyspendQuote, globalAddress, onOrderCreated, onBack, orderType, nft, tournament, payload, recipientEnsName, recipientImageUrl, } = props;
|
|
19
23
|
// Use a stable amount for geo onramp options to prevent unnecessary refetches
|
|
20
24
|
const [stableAmountForGeo, setStableAmountForGeo] = (0, react_3.useState)(srcAmountOnRamp);
|
|
21
25
|
const hasInitialized = (0, react_3.useRef)(false);
|
|
@@ -27,6 +31,7 @@ recipientAddress, isMainnet, isBuyMode, destinationTokenChainId, destinationToke
|
|
|
27
31
|
}
|
|
28
32
|
}, [srcAmountOnRamp]);
|
|
29
33
|
const { geoData, coinbaseOnrampOptions, coinbaseAvailablePaymentMethods, isStripeOnrampSupported, isStripeWeb2Supported, isLoading: isLoadingGeoOnramp, } = (0, react_1.useGeoOnrampOptions)(isMainnet, stableAmountForGeo);
|
|
34
|
+
const isLoading = isLoadingGeoOnramp;
|
|
30
35
|
const { createOrder, isCreatingOrder } = (0, react_1.useAnyspendCreateOnrampOrder)({
|
|
31
36
|
onSuccess: data => {
|
|
32
37
|
const orderId = data.data.id;
|
|
@@ -110,7 +115,7 @@ recipientAddress, isMainnet, isBuyMode, destinationTokenChainId, destinationToke
|
|
|
110
115
|
? "Receive NFT at"
|
|
111
116
|
: orderType === "join_tournament"
|
|
112
117
|
? "Join for"
|
|
113
|
-
: "Recipient" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2", children: [recipientImageUrl && ((0, jsx_runtime_1.jsx)("img", { src: recipientImageUrl, alt: recipientImageUrl, className: "bg-b3-react-foreground size-7 rounded-full object-cover opacity-100" })), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-end gap-1", children: [recipientEnsName && (0, jsx_runtime_1.jsxs)("span", { className: "text-b3-react-foreground/80", children: ["@", recipientEnsName] }), (0, jsx_runtime_1.jsx)("span", { className: "text-b3-react-foreground/80", children: (0, centerTruncate_1.default)(recipientAddress) })] })] })] })), (0, jsx_runtime_1.jsx)("div", { className: "border-b3-react-border border-t pt-3", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("p", { className: "text-b3-react-foreground font-semibold", children: "Amount" }), (0, jsx_runtime_1.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 ? ((0, jsx_runtime_1.jsxs)("div", { className: "bg-b3-react-background border-b3-react-border flex items-center justify-center gap-3 rounded-lg border p-6", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "h-4 w-4 animate-spin" }), (0, jsx_runtime_1.jsx)("span", { className: "text-as-primary/70", children: "Creating onramp order..." })] })) :
|
|
118
|
+
: "Recipient" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2", children: [recipientImageUrl && ((0, jsx_runtime_1.jsx)("img", { src: recipientImageUrl, alt: recipientImageUrl, className: "bg-b3-react-foreground size-7 rounded-full object-cover opacity-100" })), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-end gap-1", children: [recipientEnsName && (0, jsx_runtime_1.jsxs)("span", { className: "text-b3-react-foreground/80", children: ["@", recipientEnsName] }), (0, jsx_runtime_1.jsx)("span", { className: "text-b3-react-foreground/80", children: (0, centerTruncate_1.default)(recipientAddress) })] })] })] })), (0, jsx_runtime_1.jsx)("div", { className: "border-b3-react-border border-t pt-3", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("p", { className: "text-b3-react-foreground font-semibold", children: "Amount" }), (0, jsx_runtime_1.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 ? ((0, jsx_runtime_1.jsxs)("div", { className: "bg-b3-react-background border-b3-react-border flex items-center justify-center gap-3 rounded-lg border p-6", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "h-4 w-4 animate-spin" }), (0, jsx_runtime_1.jsx)("span", { className: "text-as-primary/70", children: "Creating onramp order..." })] })) : isLoading ? ((0, jsx_runtime_1.jsxs)("div", { className: "bg-b3-react-background border-b3-react-border flex items-center justify-center gap-3 rounded-lg border p-6", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "h-4 w-4 animate-spin" }), (0, jsx_runtime_1.jsx)("span", { className: "text-as-primary/70", children: "Loading payment options..." })] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "mb-3 flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("h2", { className: "text-lg font-semibold", children: "Payment method" }), (0, jsx_runtime_1.jsx)("div", { className: "flex items-center gap-1", children: coinbaseAvailablePaymentMethods.length > 0 &&
|
|
114
119
|
(() => {
|
|
115
120
|
const hasCard = coinbaseAvailablePaymentMethods.some(m => m.id === "CARD");
|
|
116
121
|
const hasApplePay = coinbaseAvailablePaymentMethods.some(m => m.id === "APPLE_PAY");
|
|
@@ -14,11 +14,13 @@ const react_stripe_js_1 = require("@stripe/react-stripe-js");
|
|
|
14
14
|
const stripe_js_1 = require("@stripe/stripe-js");
|
|
15
15
|
const lucide_react_1 = require("lucide-react");
|
|
16
16
|
const react_3 = require("react");
|
|
17
|
+
const AnySpendFingerprintWrapper_1 = require("../AnySpendFingerprintWrapper");
|
|
17
18
|
const HowItWorks_1 = __importDefault(require("./HowItWorks"));
|
|
18
19
|
const PaymentMethodIcons_1 = __importDefault(require("./PaymentMethodIcons"));
|
|
19
20
|
const stripePromise = (0, stripe_js_1.loadStripe)(constants_1.STRIPE_CONFIG.publishableKey);
|
|
20
21
|
function PaymentStripeWeb2({ isMainnet, order, onPaymentSuccess }) {
|
|
21
22
|
const { theme } = (0, react_2.useB3)();
|
|
23
|
+
const fingerprintConfig = (0, AnySpendFingerprintWrapper_1.getFingerprintConfig)();
|
|
22
24
|
const { clientSecret, isLoadingStripeClientSecret, stripeClientSecretError } = (0, react_1.useStripeClientSecret)(isMainnet, order.stripePaymentIntentId);
|
|
23
25
|
if (isLoadingStripeClientSecret) {
|
|
24
26
|
return (0, jsx_runtime_1.jsx)(StripeLoadingState, {});
|
|
@@ -26,10 +28,10 @@ function PaymentStripeWeb2({ isMainnet, order, onPaymentSuccess }) {
|
|
|
26
28
|
if (stripeClientSecretError) {
|
|
27
29
|
return (0, jsx_runtime_1.jsx)(StripeErrorState, { error: stripeClientSecretError.message });
|
|
28
30
|
}
|
|
29
|
-
return ((0, jsx_runtime_1.jsx)(react_stripe_js_1.Elements, { stripe: stripePromise, options: {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
return ((0, jsx_runtime_1.jsx)(AnySpendFingerprintWrapper_1.AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: (0, jsx_runtime_1.jsx)(react_stripe_js_1.Elements, { stripe: stripePromise, options: {
|
|
32
|
+
clientSecret: clientSecret || undefined,
|
|
33
|
+
appearance: { theme: theme === "light" ? "stripe" : "night" },
|
|
34
|
+
}, children: (0, jsx_runtime_1.jsx)(StripePaymentForm, { order: order, clientSecret: clientSecret, onPaymentSuccess: onPaymentSuccess }) }) }));
|
|
33
35
|
}
|
|
34
36
|
function StripeLoadingState() {
|
|
35
37
|
return ((0, jsx_runtime_1.jsx)("div", { className: "relative my-8 flex w-full flex-1 flex-col items-center justify-center", children: (0, jsx_runtime_1.jsxs)("div", { className: "bg-as-on-surface-1 flex w-full flex-col items-center justify-center gap-4 rounded-2xl p-8", children: [(0, jsx_runtime_1.jsx)("div", { className: "bg-as-brand/20 flex h-16 w-16 items-center justify-center rounded-full", children: (0, jsx_runtime_1.jsx)("div", { className: "text-as-brand h-8 w-8 animate-spin rounded-full border-2 border-current border-t-transparent" }) }), (0, jsx_runtime_1.jsxs)("div", { className: "text-as-primary/70 text-center", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-lg font-medium", children: "Initializing payment" }), (0, jsx_runtime_1.jsx)("div", { className: "text-as-primary/50 mt-2 text-sm", children: "Setting up secure payment form..." })] })] }) }));
|
|
@@ -50,7 +52,6 @@ function StripePaymentForm({ order, clientSecret, onPaymentSuccess, }) {
|
|
|
50
52
|
(0, react_3.useEffect)(() => {
|
|
51
53
|
if (stripe && elements) {
|
|
52
54
|
setStripeReady(true);
|
|
53
|
-
console.log("@@stripe-web2-payment:initialized:", JSON.stringify({ orderId: order.id }, null, 2));
|
|
54
55
|
}
|
|
55
56
|
}, [stripe, elements, order.id]);
|
|
56
57
|
(0, react_3.useEffect)(() => {
|
|
@@ -73,7 +74,6 @@ function StripePaymentForm({ order, clientSecret, onPaymentSuccess, }) {
|
|
|
73
74
|
// Handle payment element changes
|
|
74
75
|
const handlePaymentElementChange = (event) => {
|
|
75
76
|
// Show address element only for card payments
|
|
76
|
-
console.log("@@stripe-web2-payment:payment-element-change:", JSON.stringify(event, null, 2));
|
|
77
77
|
setShowAddressElement(event.value.type === "card");
|
|
78
78
|
};
|
|
79
79
|
const handleSubmit = async (e) => {
|
|
@@ -85,7 +85,6 @@ function StripePaymentForm({ order, clientSecret, onPaymentSuccess, }) {
|
|
|
85
85
|
setLoading(true);
|
|
86
86
|
setMessage(null);
|
|
87
87
|
try {
|
|
88
|
-
console.log("@@stripe-web2-payment:confirming-payment:", JSON.stringify({ orderId: order.id }, null, 2));
|
|
89
88
|
const result = (await stripe.confirmPayment({
|
|
90
89
|
elements,
|
|
91
90
|
confirmParams: {
|
|
@@ -124,8 +123,6 @@ function StripePaymentForm({ order, clientSecret, onPaymentSuccess, }) {
|
|
|
124
123
|
const url = new URL(window.location.href);
|
|
125
124
|
const fromStripe = url.searchParams.get("fromStripe");
|
|
126
125
|
const paymentIntent = url.searchParams.get("payment_intent");
|
|
127
|
-
console.log("@@stripe-web2-payment:fromStripe:", fromStripe);
|
|
128
|
-
console.log("@@stripe-web2-payment:paymentIntent:", paymentIntent);
|
|
129
126
|
if (fromStripe && paymentIntent) {
|
|
130
127
|
// Close the modal as we're returning from 3DS
|
|
131
128
|
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";
|
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
17
|
exports.WebviewOnrampPayment = exports.WebviewOnrampOrderStatus = exports.TokenBalance = exports.OrderTokenAmount = exports.OrderToken = exports.OrderStatus = exports.OrderHistoryItem = exports.OrderHistory = exports.OrderDetails = exports.ChainTokenIcon = exports.AnySpendNFTButton = exports.AnySpendTournament = exports.AnySpendStakeB3 = exports.AnyspendSignatureMint = exports.AnySpendNFT = exports.AnySpendCustom = exports.AnySpendBuySpin = exports.AnySpendBondKit = exports.AnySpend = void 0;
|
|
4
18
|
// Components
|
|
@@ -10,6 +24,7 @@ var AnySpendBuySpin_1 = require("./AnySpendBuySpin");
|
|
|
10
24
|
Object.defineProperty(exports, "AnySpendBuySpin", { enumerable: true, get: function () { return AnySpendBuySpin_1.AnySpendBuySpin; } });
|
|
11
25
|
var AnySpendCustom_1 = require("./AnySpendCustom");
|
|
12
26
|
Object.defineProperty(exports, "AnySpendCustom", { enumerable: true, get: function () { return AnySpendCustom_1.AnySpendCustom; } });
|
|
27
|
+
__exportStar(require("./AnySpendFingerprintWrapper"), exports);
|
|
13
28
|
var AnySpendNFT_1 = require("./AnySpendNFT");
|
|
14
29
|
Object.defineProperty(exports, "AnySpendNFT", { enumerable: true, get: function () { return AnySpendNFT_1.AnySpendNFT; } });
|
|
15
30
|
var AnyspendSignatureMint_1 = require("./AnyspendSignatureMint");
|
|
@@ -9,5 +9,5 @@ interface WebviewOnrampPaymentProps {
|
|
|
9
9
|
onPaymentSuccess: (orderId: string) => void;
|
|
10
10
|
userId?: string;
|
|
11
11
|
}
|
|
12
|
-
export declare function WebviewOnrampPayment(
|
|
12
|
+
export declare function WebviewOnrampPayment(props: WebviewOnrampPaymentProps): import("react/jsx-runtime").JSX.Element;
|
|
13
13
|
export {};
|
|
@@ -15,7 +15,12 @@ const lucide_react_1 = require("lucide-react");
|
|
|
15
15
|
const react_2 = require("react");
|
|
16
16
|
const sonner_1 = require("sonner");
|
|
17
17
|
const viem_1 = require("viem");
|
|
18
|
+
const AnySpendFingerprintWrapper_1 = require("../AnySpendFingerprintWrapper");
|
|
18
19
|
const stripePromise = (0, stripe_js_1.loadStripe)(anyspend_1.STRIPE_CONFIG.publishableKey);
|
|
20
|
+
function WebviewOnrampPayment(props) {
|
|
21
|
+
const fingerprintConfig = (0, AnySpendFingerprintWrapper_1.getFingerprintConfig)();
|
|
22
|
+
return ((0, jsx_runtime_1.jsx)(AnySpendFingerprintWrapper_1.AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: (0, jsx_runtime_1.jsx)(WebviewOnrampPaymentInner, { ...props }) }));
|
|
23
|
+
}
|
|
19
24
|
// Stripe Payment Form Component
|
|
20
25
|
function StripePaymentForm({ order, onPaymentSuccess, }) {
|
|
21
26
|
const stripe = (0, react_stripe_js_1.useStripe)();
|
|
@@ -85,7 +90,7 @@ function StripePaymentForm({ order, onPaymentSuccess, }) {
|
|
|
85
90
|
},
|
|
86
91
|
} }) })), error && ((0, jsx_runtime_1.jsx)("div", { className: "mt-4 rounded-lg border border-red-200 bg-red-50 p-3 text-sm text-red-600", children: error })), (0, jsx_runtime_1.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 ? ((0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-center gap-2", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "h-5 w-5 animate-spin" }), (0, jsx_runtime_1.jsx)("span", { children: "Processing..." })] })) : ((0, jsx_runtime_1.jsx)("span", { children: "Complete Payment" })) })] }) }) }));
|
|
87
92
|
}
|
|
88
|
-
function
|
|
93
|
+
function WebviewOnrampPaymentInner({ srcAmountOnRamp, recipientAddress, destinationToken, anyspendQuote, onPaymentSuccess, userId, partnerId, }) {
|
|
89
94
|
const [stableAmountForGeo, setStableAmountForGeo] = (0, react_2.useState)(srcAmountOnRamp);
|
|
90
95
|
const hasInitialized = (0, react_2.useRef)(false);
|
|
91
96
|
const [createdOrder, setCreatedOrder] = (0, react_2.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;
|
|
@@ -4,6 +4,7 @@ exports.useAnyspendCreateOnrampOrder = useAnyspendCreateOnrampOrder;
|
|
|
4
4
|
const constants_1 = require("../../../anyspend/constants");
|
|
5
5
|
const anyspend_1 = require("../../../anyspend/services/anyspend");
|
|
6
6
|
const utils_1 = require("../../../anyspend/utils");
|
|
7
|
+
const fingerprintjs_pro_react_1 = require("@fingerprintjs/fingerprintjs-pro-react");
|
|
7
8
|
const react_query_1 = require("@tanstack/react-query");
|
|
8
9
|
const react_1 = require("react");
|
|
9
10
|
const viem_1 = require("viem");
|
|
@@ -13,6 +14,12 @@ const chains_1 = require("viem/chains");
|
|
|
13
14
|
* Specifically handles orders that involve fiat-to-crypto onramp functionality
|
|
14
15
|
*/
|
|
15
16
|
function useAnyspendCreateOnrampOrder({ onSuccess, onError } = {}) {
|
|
17
|
+
// Get fingerprint data
|
|
18
|
+
const { data: fpData } = (0, fingerprintjs_pro_react_1.useVisitorData)({ extendedResult: true }, { immediate: true });
|
|
19
|
+
const visitorData = fpData && {
|
|
20
|
+
requestId: fpData.requestId,
|
|
21
|
+
visitorId: fpData.visitorId,
|
|
22
|
+
};
|
|
16
23
|
const { mutate: createOrder, isPending } = (0, react_query_1.useMutation)({
|
|
17
24
|
mutationFn: async (params) => {
|
|
18
25
|
const { isMainnet, recipientAddress, orderType, dstChain, dstToken, srcFiatAmount, onramp, creatorAddress, expectedDstAmount, nft, tournament, payload, partnerId, } = params;
|
|
@@ -45,7 +52,9 @@ function useAnyspendCreateOnrampOrder({ onSuccess, onError } = {}) {
|
|
|
45
52
|
expectedDstAmount,
|
|
46
53
|
nft,
|
|
47
54
|
tournament,
|
|
48
|
-
payload
|
|
55
|
+
payload: {
|
|
56
|
+
...payload,
|
|
57
|
+
},
|
|
49
58
|
}),
|
|
50
59
|
onramp,
|
|
51
60
|
metadata: (0, utils_1.buildMetadata)(orderType, {
|
|
@@ -55,10 +64,13 @@ function useAnyspendCreateOnrampOrder({ onSuccess, onError } = {}) {
|
|
|
55
64
|
expectedDstAmount,
|
|
56
65
|
nft,
|
|
57
66
|
tournament,
|
|
58
|
-
payload
|
|
67
|
+
payload: {
|
|
68
|
+
...payload,
|
|
69
|
+
},
|
|
59
70
|
}),
|
|
60
71
|
creatorAddress: creatorAddress ? (0, utils_1.normalizeAddress)(creatorAddress) : undefined,
|
|
61
72
|
partnerId,
|
|
73
|
+
visitorData,
|
|
62
74
|
});
|
|
63
75
|
}
|
|
64
76
|
catch (error) {
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useAnyspendCreateOrder = useAnyspendCreateOrder;
|
|
4
4
|
const anyspend_1 = require("../../../anyspend/services/anyspend");
|
|
5
5
|
const utils_1 = require("../../../anyspend/utils");
|
|
6
|
+
const fingerprintjs_pro_react_1 = require("@fingerprintjs/fingerprintjs-pro-react");
|
|
6
7
|
const react_query_1 = require("@tanstack/react-query");
|
|
7
8
|
const react_1 = require("react");
|
|
8
9
|
/**
|
|
@@ -11,6 +12,12 @@ const react_1 = require("react");
|
|
|
11
12
|
* For onramp orders, use useAnyspendCreateOnrampOrder instead.
|
|
12
13
|
*/
|
|
13
14
|
function useAnyspendCreateOrder({ onSuccess, onError } = {}) {
|
|
15
|
+
// Get fingerprint data
|
|
16
|
+
const { data: fpData } = (0, fingerprintjs_pro_react_1.useVisitorData)({ extendedResult: true }, { immediate: true });
|
|
17
|
+
const visitorData = fpData && {
|
|
18
|
+
requestId: fpData.requestId,
|
|
19
|
+
visitorId: fpData.visitorId,
|
|
20
|
+
};
|
|
14
21
|
const { mutate: createOrder, isPending } = (0, react_query_1.useMutation)({
|
|
15
22
|
mutationFn: async (params) => {
|
|
16
23
|
const { isMainnet, recipientAddress, orderType, srcChain, dstChain, srcToken, dstToken, srcAmount, creatorAddress, } = params;
|
|
@@ -31,7 +38,9 @@ function useAnyspendCreateOrder({ onSuccess, onError } = {}) {
|
|
|
31
38
|
expectedDstAmount: params.expectedDstAmount,
|
|
32
39
|
nft: params.nft,
|
|
33
40
|
tournament: params.tournament,
|
|
34
|
-
payload:
|
|
41
|
+
payload: {
|
|
42
|
+
...params.payload,
|
|
43
|
+
},
|
|
35
44
|
}),
|
|
36
45
|
metadata: (0, utils_1.buildMetadata)(orderType, {
|
|
37
46
|
orderType,
|
|
@@ -40,9 +49,12 @@ function useAnyspendCreateOrder({ onSuccess, onError } = {}) {
|
|
|
40
49
|
expectedDstAmount: params.expectedDstAmount,
|
|
41
50
|
nft: params.nft,
|
|
42
51
|
tournament: params.tournament,
|
|
43
|
-
payload:
|
|
52
|
+
payload: {
|
|
53
|
+
...params.payload,
|
|
54
|
+
},
|
|
44
55
|
}),
|
|
45
56
|
creatorAddress: creatorAddress ? (0, utils_1.normalizeAddress)(creatorAddress) : undefined,
|
|
57
|
+
visitorData,
|
|
46
58
|
});
|
|
47
59
|
}
|
|
48
60
|
catch (error) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
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;
|
|
@@ -4,11 +4,11 @@ exports.useCoinbaseOnrampOptions = useCoinbaseOnrampOptions;
|
|
|
4
4
|
const anyspend_1 = require("../../../anyspend/services/anyspend");
|
|
5
5
|
const react_query_1 = require("@tanstack/react-query");
|
|
6
6
|
const react_1 = require("react");
|
|
7
|
-
function useCoinbaseOnrampOptions(isMainnet, country) {
|
|
7
|
+
function useCoinbaseOnrampOptions(isMainnet, country, visitorData, isLoadingVisitorData) {
|
|
8
8
|
const { data, isLoading, error, refetch } = (0, react_query_1.useQuery)({
|
|
9
|
-
queryKey: ["getCoinbaseOnrampOptions", isMainnet, country],
|
|
10
|
-
queryFn: () => anyspend_1.anyspendService.getCoinbaseOnrampOptions(isMainnet, country),
|
|
11
|
-
enabled: Boolean(country),
|
|
9
|
+
queryKey: ["getCoinbaseOnrampOptions", isMainnet, country, visitorData],
|
|
10
|
+
queryFn: () => anyspend_1.anyspendService.getCoinbaseOnrampOptions(isMainnet, country, visitorData),
|
|
11
|
+
enabled: Boolean(country) && !isLoadingVisitorData,
|
|
12
12
|
});
|
|
13
13
|
return (0, react_1.useMemo)(() => ({
|
|
14
14
|
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,15 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useGeoOnrampOptions = useGeoOnrampOptions;
|
|
4
|
+
const fingerprintjs_pro_react_1 = require("@fingerprintjs/fingerprintjs-pro-react");
|
|
4
5
|
const react_1 = require("react");
|
|
5
6
|
const useCoinbaseOnrampOptions_1 = require("./useCoinbaseOnrampOptions");
|
|
6
7
|
const useGetGeo_1 = require("./useGetGeo");
|
|
7
8
|
const useStripeSupport_1 = require("./useStripeSupport");
|
|
8
9
|
function useGeoOnrampOptions(isMainnet, srcFiatAmount) {
|
|
10
|
+
// Get fingerprint data
|
|
11
|
+
const { data: fpData, isLoading: isLoadingVisitorData } = (0, fingerprintjs_pro_react_1.useVisitorData)({ extendedResult: true }, { immediate: true });
|
|
12
|
+
const visitorData = fpData && {
|
|
13
|
+
requestId: fpData.requestId,
|
|
14
|
+
visitorId: fpData.visitorId,
|
|
15
|
+
};
|
|
9
16
|
// Use existing hooks
|
|
10
17
|
const { geoData, loading: isLoadingGeo, error: geoError } = (0, useGetGeo_1.useGetGeo)();
|
|
11
|
-
const { coinbaseOnrampOptions, isLoadingCoinbaseOnrampOptions, coinbaseOnrampOptionsError } = (0, useCoinbaseOnrampOptions_1.useCoinbaseOnrampOptions)(isMainnet, geoData?.country);
|
|
12
|
-
const { isStripeOnrampSupported, isStripeWeb2Supported, isLoadingStripeSupport, stripeSupportError } = (0, useStripeSupport_1.useStripeSupport)(isMainnet, geoData?.ip || "", srcFiatAmount);
|
|
18
|
+
const { coinbaseOnrampOptions, isLoadingCoinbaseOnrampOptions, coinbaseOnrampOptionsError } = (0, useCoinbaseOnrampOptions_1.useCoinbaseOnrampOptions)(isMainnet, geoData?.country, visitorData);
|
|
19
|
+
const { isStripeOnrampSupported, isStripeWeb2Supported, isLoadingStripeSupport, stripeSupportError } = (0, useStripeSupport_1.useStripeSupport)(isMainnet, geoData?.ip || "", srcFiatAmount, visitorData);
|
|
13
20
|
// Calculate available payment methods based on the amount
|
|
14
21
|
const coinbaseAvailablePaymentMethods = (0, react_1.useMemo)(() => {
|
|
15
22
|
if (!coinbaseOnrampOptions?.paymentCurrencies?.[0]?.limits || !srcFiatAmount)
|
|
@@ -30,7 +37,7 @@ function useGeoOnrampOptions(isMainnet, srcFiatAmount) {
|
|
|
30
37
|
isStripeOnrampSupported,
|
|
31
38
|
isStripeWeb2Supported,
|
|
32
39
|
isOnrampSupported: coinbaseAvailablePaymentMethods.length > 0 || isStripeOnrampSupported || isStripeWeb2Supported,
|
|
33
|
-
isLoading: isLoadingGeo || isLoadingCoinbaseOnrampOptions || isLoadingStripeSupport,
|
|
40
|
+
isLoading: isLoadingGeo || isLoadingCoinbaseOnrampOptions || isLoadingStripeSupport || isLoadingVisitorData,
|
|
34
41
|
isLoadingGeo,
|
|
35
42
|
isLoadingCoinbaseOnrampOptions,
|
|
36
43
|
isLoadingStripeSupport,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
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;
|
|
@@ -4,11 +4,11 @@ exports.useStripeSupport = useStripeSupport;
|
|
|
4
4
|
const anyspend_1 = require("../../../anyspend/services/anyspend");
|
|
5
5
|
const react_query_1 = require("@tanstack/react-query");
|
|
6
6
|
const react_1 = require("react");
|
|
7
|
-
function useStripeSupport(isMainnet, ipAddress, usdAmount) {
|
|
7
|
+
function useStripeSupport(isMainnet, ipAddress, usdAmount, visitorData, isLoadingVisitorData) {
|
|
8
8
|
const { data, isLoading, error, refetch } = (0, react_query_1.useQuery)({
|
|
9
|
-
queryKey: ["useStripeSupport", isMainnet, ipAddress, usdAmount],
|
|
10
|
-
queryFn: () => anyspend_1.anyspendService.checkStripeSupport(isMainnet, ipAddress, usdAmount),
|
|
11
|
-
enabled: !!ipAddress,
|
|
9
|
+
queryKey: ["useStripeSupport", isMainnet, ipAddress, usdAmount, visitorData?.requestId, visitorData?.visitorId],
|
|
10
|
+
queryFn: () => anyspend_1.anyspendService.checkStripeSupport(isMainnet, ipAddress, usdAmount, visitorData),
|
|
11
|
+
enabled: !!ipAddress && !isLoadingVisitorData,
|
|
12
12
|
});
|
|
13
13
|
return (0, react_1.useMemo)(() => ({
|
|
14
14
|
isStripeOnrampSupported: data?.stripeOnramp || false,
|
|
@@ -19,9 +19,6 @@ function StripeRedirectHandler() {
|
|
|
19
19
|
const fromStripe = url.searchParams.get("fromStripe");
|
|
20
20
|
const paymentIntent = url.searchParams.get("payment_intent");
|
|
21
21
|
const orderId = url.searchParams.get("orderId");
|
|
22
|
-
console.log("@@stripe-web2-payment:fromStripe:", fromStripe);
|
|
23
|
-
console.log("@@stripe-web2-payment:paymentIntent:", paymentIntent);
|
|
24
|
-
console.log("@@stripe-web2-payment:orderId:", orderId);
|
|
25
22
|
if (fromStripe && paymentIntent && orderId) {
|
|
26
23
|
// Re-open the modal with the order details
|
|
27
24
|
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
|
}>;
|
|
@@ -41,11 +41,13 @@ exports.anyspendService = {
|
|
|
41
41
|
return data;
|
|
42
42
|
},
|
|
43
43
|
// Order related
|
|
44
|
-
createOrder: async ({ isMainnet, recipientAddress, type, srcChain, dstChain, srcTokenAddress, dstTokenAddress, srcAmount, payload, onramp, metadata, creatorAddress, partnerId, }) => {
|
|
44
|
+
createOrder: async ({ isMainnet, recipientAddress, type, srcChain, dstChain, srcTokenAddress, dstTokenAddress, srcAmount, payload, onramp, metadata, creatorAddress, partnerId, visitorData, }) => {
|
|
45
45
|
const response = await fetch(`${isMainnet ? constants_1.ANYSPEND_MAINNET_BASE_URL : constants_1.ANYSPEND_TESTNET_BASE_URL}/orders`, {
|
|
46
46
|
method: "POST",
|
|
47
47
|
headers: {
|
|
48
48
|
"Content-Type": "application/json",
|
|
49
|
+
...(visitorData?.requestId && { "X-Fingerprint-Request-Id": visitorData.requestId }),
|
|
50
|
+
...(visitorData?.visitorId && { "X-Fingerprint-Visitor-Id": visitorData.visitorId }),
|
|
49
51
|
},
|
|
50
52
|
body: JSON.stringify({
|
|
51
53
|
recipientAddress,
|
|
@@ -83,20 +85,28 @@ exports.anyspendService = {
|
|
|
83
85
|
const data = await response.json();
|
|
84
86
|
return data;
|
|
85
87
|
},
|
|
86
|
-
getCoinbaseOnrampOptions: async (isMainnet, country) => {
|
|
88
|
+
getCoinbaseOnrampOptions: async (isMainnet, country, visitorData) => {
|
|
87
89
|
const params = new URLSearchParams({
|
|
88
90
|
country,
|
|
91
|
+
// include fingerprintId and requestId in the query params
|
|
92
|
+
...(visitorData?.requestId && { requestId: visitorData.requestId }),
|
|
93
|
+
...(visitorData?.visitorId && { fingerprintId: visitorData.visitorId }),
|
|
89
94
|
});
|
|
90
95
|
const response = await fetch(`${isMainnet ? constants_1.ANYSPEND_MAINNET_BASE_URL : constants_1.ANYSPEND_TESTNET_BASE_URL}/onramp/coinbase/options?${params.toString()}`);
|
|
91
96
|
const data = await response.json();
|
|
92
97
|
return data;
|
|
93
98
|
},
|
|
94
|
-
checkStripeSupport: async (isMainnet, ipAddress, usdAmount) => {
|
|
99
|
+
checkStripeSupport: async (isMainnet, ipAddress, usdAmount, visitorData) => {
|
|
95
100
|
const params = new URLSearchParams({
|
|
96
101
|
ipAddress,
|
|
97
102
|
usdAmount: usdAmount || "",
|
|
98
103
|
});
|
|
99
|
-
const response = await fetch(`${isMainnet ? constants_1.ANYSPEND_MAINNET_BASE_URL : constants_1.ANYSPEND_TESTNET_BASE_URL}/onramp/stripe/supported?${params.toString()}
|
|
104
|
+
const response = await fetch(`${isMainnet ? constants_1.ANYSPEND_MAINNET_BASE_URL : constants_1.ANYSPEND_TESTNET_BASE_URL}/onramp/stripe/supported?${params.toString()}`, {
|
|
105
|
+
headers: {
|
|
106
|
+
...(visitorData?.requestId && { "X-Fingerprint-Request-Id": visitorData.requestId }),
|
|
107
|
+
...(visitorData?.visitorId && { "X-Fingerprint-Visitor-Id": visitorData.visitorId }),
|
|
108
|
+
},
|
|
109
|
+
});
|
|
100
110
|
const data = await response.json();
|
|
101
111
|
(0, invariant_1.default)(response.status === 200, "Failed to check Stripe support");
|
|
102
112
|
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
|
+
}
|
|
@@ -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";
|