@b3dotfun/sdk 0.0.20-alpha.0 → 0.0.20-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.
- package/dist/cjs/anyspend/react/components/AnySpend.js +18 -14
- package/dist/cjs/anyspend/react/components/AnySpendFingerprintWrapper.d.ts +1 -1
- package/dist/cjs/anyspend/react/components/AnySpendFingerprintWrapper.js +2 -5
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +42 -95
- package/dist/cjs/global-account/react/hooks/index.d.ts +1 -1
- package/dist/esm/anyspend/react/components/AnySpend.js +19 -15
- package/dist/esm/anyspend/react/components/AnySpendFingerprintWrapper.d.ts +1 -1
- package/dist/esm/anyspend/react/components/AnySpendFingerprintWrapper.js +2 -5
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +45 -98
- package/dist/esm/global-account/react/hooks/index.d.ts +1 -1
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/react/components/AnySpendFingerprintWrapper.d.ts +1 -1
- package/dist/types/global-account/react/hooks/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/anyspend/react/components/AnySpend.tsx +57 -22
- package/src/anyspend/react/components/AnySpendFingerprintWrapper.tsx +4 -8
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +61 -96
- package/src/global-account/react/hooks/index.ts +1 -1
|
@@ -18,9 +18,9 @@ const lucide_react_1 = require("lucide-react");
|
|
|
18
18
|
const react_3 = require("motion/react");
|
|
19
19
|
const react_4 = require("react");
|
|
20
20
|
const sonner_1 = require("sonner");
|
|
21
|
+
const react_5 = require("thirdweb/react");
|
|
21
22
|
const viem_1 = require("viem");
|
|
22
23
|
const chains_1 = require("viem/chains");
|
|
23
|
-
const wagmi_1 = require("wagmi");
|
|
24
24
|
const AnySpendFingerprintWrapper_1 = require("./AnySpendFingerprintWrapper");
|
|
25
25
|
const CryptoPaymentMethod_1 = require("./common/CryptoPaymentMethod");
|
|
26
26
|
const FiatPaymentMethod_1 = require("./common/FiatPaymentMethod");
|
|
@@ -51,7 +51,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
51
51
|
const searchParams = (0, react_2.useSearchParamsSSR)();
|
|
52
52
|
const router = (0, react_2.useRouter)();
|
|
53
53
|
// Get wagmi account state for wallet connection
|
|
54
|
-
const
|
|
54
|
+
const connectedWallets = (0, react_5.useConnectedWallets)();
|
|
55
55
|
// Determine if we're in "buy mode" based on whether destination token props are provided
|
|
56
56
|
const isBuyMode = !!(destinationTokenAddress && destinationTokenChainId);
|
|
57
57
|
// Add refs to track URL state
|
|
@@ -343,6 +343,9 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
343
343
|
amount: srcAmountOnrampInWei,
|
|
344
344
|
onrampVendor: getOnrampVendor(selectedFiatPaymentMethod),
|
|
345
345
|
});
|
|
346
|
+
const connectedAddress = globalAddress || connectedWallets?.[0]?.getAccount()?.address;
|
|
347
|
+
const connectedProfile = (0, react_2.useProfile)({ address: connectedAddress });
|
|
348
|
+
const connectedName = connectedProfile.data?.name?.replace(/\.b3\.fun/g, "");
|
|
346
349
|
const recipientProfile = (0, react_2.useProfile)({ address: recipientAddress });
|
|
347
350
|
const recipientName = recipientProfile.data?.name?.replace(/\.b3\.fun/g, "");
|
|
348
351
|
// Load custom recipients from local storage on mount
|
|
@@ -807,7 +810,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
807
810
|
setActiveTab("fiat");
|
|
808
811
|
setSelectedPaymentMethod(CryptoPaymentMethod_1.PaymentMethod.NONE); // Reset crypto payment method when switching to fiat
|
|
809
812
|
setSelectedFiatPaymentMethod(FiatPaymentMethod_1.FiatPaymentMethod.NONE); // Reset fiat payment method when switching to fiat
|
|
810
|
-
}, children: "Pay with Fiat" })] }) }), (0, jsx_runtime_1.jsxs)("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: [activeTab === "crypto" ? ((0, jsx_runtime_1.jsxs)(react_3.motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "bg-as-surface-secondary border-as-border-secondary relative flex w-full flex-col gap-2 rounded-2xl border p-4 sm:p-6", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary/50 flex h-7 items-center text-sm", children: "Pay" }), (0, jsx_runtime_1.jsx)("button", { className: "text-as-
|
|
813
|
+
}, children: "Pay with Fiat" })] }) }), (0, jsx_runtime_1.jsxs)("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: [activeTab === "crypto" ? ((0, jsx_runtime_1.jsxs)(react_3.motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "bg-as-surface-secondary border-as-border-secondary relative flex w-full flex-col gap-2 rounded-2xl border p-4 sm:p-6", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary/50 flex h-7 items-center text-sm", children: "Pay" }), (0, jsx_runtime_1.jsx)("button", { className: "text-as-tertiarry flex h-7 items-center gap-2 text-sm transition-colors", onClick: () => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD), children: selectedPaymentMethod === CryptoPaymentMethod_1.PaymentMethod.CONNECT_WALLET ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [connectedAddress ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [globalWallet?.meta?.icon && ((0, jsx_runtime_1.jsx)("img", { src: globalWallet.meta.icon, alt: "Connected Wallet", className: "bg-as-primary h-6 w-6 rounded-full" })), (0, jsx_runtime_1.jsx)("span", { className: "text-as-tertiarry", children: connectedName || (0, formatAddress_1.shortenAddress)(connectedAddress || "") })] })) : ("Connect wallet"), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] })) : selectedPaymentMethod === CryptoPaymentMethod_1.PaymentMethod.TRANSFER_CRYPTO ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Transfer crypto", (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Select payment method", (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] })) })] }), (0, jsx_runtime_1.jsx)(OrderTokenAmount_1.OrderTokenAmount, { address: globalAddress, context: "from", inputValue: srcAmount, onChangeInput: value => {
|
|
811
814
|
setIsSrcInputDirty(true);
|
|
812
815
|
setSrcAmount(value);
|
|
813
816
|
}, chainId: selectedSrcChainId, setChainId: setSelectedSrcChainId, token: selectedSrcToken, setToken: setSelectedSrcToken }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary/50 flex h-5 items-center text-sm", children: (0, number_1.formatDisplayNumber)(anyspendQuote?.data?.currencyIn?.amountUsd, { style: "currency", fallback: "" }) }), (0, jsx_runtime_1.jsx)(TokenBalance_1.TokenBalance, { token: selectedSrcToken, walletAddress: globalAddress, onChangeInput: value => {
|
|
@@ -832,7 +835,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
832
835
|
const tempDstAmount = dstAmount;
|
|
833
836
|
setSrcAmount(tempDstAmount);
|
|
834
837
|
setDstAmount(tempSrcAmount);
|
|
835
|
-
}, children: (0, jsx_runtime_1.jsx)("div", { className: "relative flex items-center justify-center transition-opacity", children: (0, jsx_runtime_1.jsx)(lucide_react_1.ArrowDown, { className: "text-as-primary/50 h-5 w-5" }) }) }), activeTab !== "fiat" && ((0, jsx_runtime_1.jsxs)(react_3.motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, className: "bg-as-surface-secondary border-as-border-secondary relative flex w-full flex-col gap-2 rounded-2xl border p-4 sm:p-6", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex w-full items-center justify-between", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary/50 flex h-7 items-center text-sm", children: "Receive" }), recipientAddress ? ((0, jsx_runtime_1.jsxs)("button", { className: (0, cn_1.cn)("text-as-
|
|
838
|
+
}, children: (0, jsx_runtime_1.jsx)("div", { className: "relative flex items-center justify-center transition-opacity", children: (0, jsx_runtime_1.jsx)(lucide_react_1.ArrowDown, { className: "text-as-primary/50 h-5 w-5" }) }) }), activeTab !== "fiat" && ((0, jsx_runtime_1.jsxs)(react_3.motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, className: "bg-as-surface-secondary border-as-border-secondary relative flex w-full flex-col gap-2 rounded-2xl border p-4 sm:p-6", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex w-full items-center justify-between", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary/50 flex h-7 items-center text-sm", children: "Receive" }), recipientAddress ? ((0, jsx_runtime_1.jsxs)("button", { className: (0, cn_1.cn)("text-as-tertiarry flex h-7 items-center gap-2 rounded-lg"), onClick: () => setActivePanel(PanelView.RECIPIENT_SELECTION), children: [globalAddress && recipientAddress === globalAddress && globalWallet?.meta?.icon ? ((0, jsx_runtime_1.jsx)("img", { src: globalWallet?.meta?.icon, alt: "Current wallet", className: "bg-as-primary h-6 w-6 rounded-full" })) : ((0, jsx_runtime_1.jsx)("div", { className: "flex h-6 w-6 items-center justify-center rounded-full bg-orange-500 text-xs text-white", children: "\uD83E\uDD8A" })), (0, jsx_runtime_1.jsx)("div", { className: "text-sm", children: recipientName ? recipientName : (0, formatAddress_1.shortenAddress)(recipientAddress) }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] })) : ((0, jsx_runtime_1.jsxs)("button", { className: "text-as-primary/70 flex items-center gap-1 rounded-lg", onClick: () => setActivePanel(PanelView.RECIPIENT_SELECTION), children: [(0, jsx_runtime_1.jsx)("div", { className: "text-sm font-medium", children: "Select recipient" }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronsUpDown, { className: "h-3 w-3" })] }))] }), isBuyMode ? (
|
|
836
839
|
// Fixed destination token display in buy mode
|
|
837
840
|
(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary text-2xl font-bold", children: dstAmount || "0" }), (0, jsx_runtime_1.jsxs)("div", { className: "bg-as-brand/10 border-as-brand/30 flex items-center gap-3 rounded-xl border px-4 py-3", children: [selectedDstToken.metadata?.logoURI && ((0, jsx_runtime_1.jsx)("img", { src: selectedDstToken.metadata.logoURI, alt: selectedDstToken.symbol, className: "h-8 w-8 rounded-full" })), (0, jsx_runtime_1.jsx)("span", { className: "text-as-brand text-lg font-bold", children: selectedDstToken.symbol })] })] })) : ((0, jsx_runtime_1.jsx)(OrderTokenAmount_1.OrderTokenAmount, { address: recipientAddress, context: "to", inputValue: dstAmount, onChangeInput: value => {
|
|
838
841
|
setIsSrcInputDirty(false);
|
|
@@ -891,26 +894,27 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
891
894
|
setActivePanel(PanelView.MAIN); // Go back to main panel to show updated pricing
|
|
892
895
|
}, srcAmountOnRamp: srcAmountOnRamp, isMainnet: isMainnet }));
|
|
893
896
|
// Add tabs to the main component when no order is loaded
|
|
894
|
-
return ((0, jsx_runtime_1.jsx)(react_2.StyleRoot, { children: (0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)("mx-auto w-full max-w-[460px]", mode === "page" &&
|
|
897
|
+
return ((0, jsx_runtime_1.jsx)(react_2.StyleRoot, { children: (0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)("mx-auto w-full max-w-[460px]", mode === "page" &&
|
|
898
|
+
"bg-as-surface-primary border-as-border-secondary overflow-hidden rounded-2xl border shadow-xl"), children: (0, jsx_runtime_1.jsx)(react_2.TransitionPanel, { activeIndex: orderId
|
|
895
899
|
? oat
|
|
896
900
|
? PanelView.ORDER_DETAILS
|
|
897
901
|
: PanelView.LOADING
|
|
898
902
|
: activePanel === PanelView.ORDER_DETAILS
|
|
899
903
|
? PanelView.MAIN
|
|
900
|
-
: activePanel, className: (0, cn_1.cn)("
|
|
904
|
+
: activePanel, className: (0, cn_1.cn)("rounded-2xl", {
|
|
901
905
|
"mt-0": mode === "modal",
|
|
902
906
|
}), variants: {
|
|
903
907
|
enter: { x: 300, opacity: 0 },
|
|
904
908
|
center: { x: 0, opacity: 1 },
|
|
905
909
|
exit: { x: -300, opacity: 0 },
|
|
906
910
|
}, transition: { type: "spring", stiffness: 300, damping: 30 }, children: [
|
|
907
|
-
(0, jsx_runtime_1.jsx)("div", { children: mainView }, "main-view"),
|
|
908
|
-
(0, jsx_runtime_1.jsx)("div", { children: historyView }, "history-view"),
|
|
909
|
-
(0, jsx_runtime_1.jsx)("div", { children: orderDetailsView }, "order-details-view"),
|
|
910
|
-
(0, jsx_runtime_1.jsx)("div", { children: OrderDetails_1.OrderDetailsLoadingView }, "loading-view"),
|
|
911
|
-
(0, jsx_runtime_1.jsx)("div", { children: onrampPaymentView }, "fiat-payment-view"),
|
|
912
|
-
(0, jsx_runtime_1.jsx)("div", { children: recipientSelectionView }, "recipient-selection-view"),
|
|
913
|
-
(0, jsx_runtime_1.jsx)("div", { children: cryptoPaymentMethodView }, "crypto-payment-method-view"),
|
|
914
|
-
(0, jsx_runtime_1.jsx)("div", { children: fiatPaymentMethodView }, "fiat-payment-method-view"),
|
|
911
|
+
(0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)(mode === "page" && "p-6"), children: mainView }, "main-view"),
|
|
912
|
+
(0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)(mode === "page" && "p-6"), children: historyView }, "history-view"),
|
|
913
|
+
(0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)(mode === "page" && "p-6"), children: orderDetailsView }, "order-details-view"),
|
|
914
|
+
(0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)(mode === "page" && "p-6"), children: OrderDetails_1.OrderDetailsLoadingView }, "loading-view"),
|
|
915
|
+
(0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)(mode === "page" && "p-6"), children: onrampPaymentView }, "fiat-payment-view"),
|
|
916
|
+
(0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)(mode === "page" && "p-6"), children: recipientSelectionView }, "recipient-selection-view"),
|
|
917
|
+
(0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)(mode === "page" && "p-6"), children: cryptoPaymentMethodView }, "crypto-payment-method-view"),
|
|
918
|
+
(0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)(mode === "page" && "p-6"), children: fiatPaymentMethodView }, "fiat-payment-method-view"),
|
|
915
919
|
] }) }) }));
|
|
916
920
|
}
|
|
@@ -13,5 +13,5 @@ interface AnySpendFingerprintWrapperProps {
|
|
|
13
13
|
* This prevents unnecessary fingerprinting of users who don't interact with AnySpend.
|
|
14
14
|
*/
|
|
15
15
|
export declare function AnySpendFingerprintWrapper({ children, fingerprint }: AnySpendFingerprintWrapperProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
-
export declare function getFingerprintConfig(): FingerprintConfig
|
|
16
|
+
export declare function getFingerprintConfig(): FingerprintConfig;
|
|
17
17
|
export {};
|
|
@@ -26,14 +26,11 @@ function AnySpendFingerprintWrapper({ children, fingerprint }) {
|
|
|
26
26
|
: undefined,
|
|
27
27
|
}, children: children }));
|
|
28
28
|
}
|
|
29
|
+
const defaultApiKey = "80EnsS6POsxPAR9xGxmN";
|
|
29
30
|
// Helper function to get fingerprint config from environment variables
|
|
30
31
|
function getFingerprintConfig() {
|
|
31
|
-
const apiKey = process.env.NEXT_PUBLIC_FINGERPRINT_API_KEY;
|
|
32
|
-
if (!apiKey) {
|
|
33
|
-
return undefined;
|
|
34
|
-
}
|
|
35
32
|
return {
|
|
36
|
-
apiKey,
|
|
33
|
+
apiKey: process.env.NEXT_PUBLIC_FINGERPRINT_API_KEY || defaultApiKey,
|
|
37
34
|
endpoint: process.env.NEXT_PUBLIC_FINGERPRINT_ENDPOINT,
|
|
38
35
|
scriptUrlPattern: process.env.NEXT_PUBLIC_FINGERPRINT_SCRIPT_URL,
|
|
39
36
|
};
|
|
@@ -5,12 +5,16 @@ exports.PaymentMethod = void 0;
|
|
|
5
5
|
exports.CryptoPaymentMethod = CryptoPaymentMethod;
|
|
6
6
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
7
|
const react_1 = require("../../../../global-account/react");
|
|
8
|
+
const b3Chain_1 = require("../../../../shared/constants/chains/b3Chain");
|
|
8
9
|
const cn_1 = require("../../../../shared/utils/cn");
|
|
9
10
|
const formatAddress_1 = require("../../../../shared/utils/formatAddress");
|
|
11
|
+
const thirdweb_1 = require("../../../../shared/utils/thirdweb");
|
|
10
12
|
const lucide_react_1 = require("lucide-react");
|
|
11
13
|
const react_2 = require("react");
|
|
14
|
+
const react_dom_1 = require("react-dom");
|
|
12
15
|
const sonner_1 = require("sonner");
|
|
13
16
|
const react_3 = require("thirdweb/react");
|
|
17
|
+
const wallets_1 = require("thirdweb/wallets");
|
|
14
18
|
const wagmi_1 = require("wagmi");
|
|
15
19
|
var PaymentMethod;
|
|
16
20
|
(function (PaymentMethod) {
|
|
@@ -19,100 +23,43 @@ var PaymentMethod;
|
|
|
19
23
|
PaymentMethod["TRANSFER_CRYPTO"] = "transfer_crypto";
|
|
20
24
|
})(PaymentMethod || (exports.PaymentMethod = PaymentMethod = {}));
|
|
21
25
|
function CryptoPaymentMethod({ selectedPaymentMethod, setSelectedPaymentMethod, isCreatingOrder, onBack, onSelectPaymentMethod, }) {
|
|
22
|
-
const {
|
|
23
|
-
const wagmiAccount = (0, wagmi_1.useAccount)();
|
|
24
|
-
const { address: globalAddress, connectedEOAWallet, isActiveEOAWallet, wallet: globalWallet } = (0, react_1.useAccountWallet)();
|
|
26
|
+
const { address: globalAddress, wallet: globalWallet } = (0, react_1.useAccountWallet)();
|
|
25
27
|
const { disconnect } = (0, wagmi_1.useDisconnect)();
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
(0,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
sonner_1.toast.error(`Failed to connect wallet: ${connectError.message}`);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}, [connectError, globalAddress, wagmiAccount.address, setSelectedPaymentMethod, onSelectPaymentMethod]);
|
|
70
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: "mx-auto w-[460px] max-w-full", children: (0, jsx_runtime_1.jsxs)("div", { className: (0, cn_1.cn)("relative flex flex-col gap-10"), children: [(0, jsx_runtime_1.jsx)("button", { onClick: onBack, className: "text-as-quaternary hover:text-as-primary absolute flex h-8 w-8 items-center justify-center rounded-lg transition-colors", children: (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronLeft, { className: "h-6 w-6" }) }), (0, jsx_runtime_1.jsx)("div", { className: "flex items-center justify-around gap-4", children: (0, jsx_runtime_1.jsx)("div", { className: "flex-1 text-center", children: (0, jsx_runtime_1.jsx)("h2", { className: "text-as-primary text-lg font-semibold", children: "Choose payment method" }) }) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-3", children: [!globalAddress ? (
|
|
71
|
-
// Not connected - show single connect button
|
|
72
|
-
(0, jsx_runtime_1.jsxs)("button", { onClick: () => {
|
|
73
|
-
// Prevent connecting if already connecting or if there's already a connection
|
|
74
|
-
if (isConnecting)
|
|
75
|
-
return;
|
|
76
|
-
try {
|
|
77
|
-
// Check if wagmi already has a connection
|
|
78
|
-
if (wagmiAccount.isConnected && wagmiAccount.address) {
|
|
79
|
-
// Already connected via wagmi, just proceed with selection
|
|
80
|
-
console.log("Wagmi already connected, proceeding with selection");
|
|
81
|
-
setSelectedPaymentMethod(PaymentMethod.CONNECT_WALLET);
|
|
82
|
-
onSelectPaymentMethod(PaymentMethod.CONNECT_WALLET);
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
// Check if global address exists (b3 account system)
|
|
86
|
-
if (globalAddress) {
|
|
87
|
-
// Already connected via global account, just proceed with selection
|
|
88
|
-
console.log("Global address already exists, proceeding with selection");
|
|
89
|
-
setSelectedPaymentMethod(PaymentMethod.CONNECT_WALLET);
|
|
90
|
-
onSelectPaymentMethod(PaymentMethod.CONNECT_WALLET);
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
// Use the first available connector or a preferred one
|
|
94
|
-
const preferredConnector = connectors.find(c => c.name.toLowerCase().includes("metamask")) || connectors[0];
|
|
95
|
-
if (preferredConnector) {
|
|
96
|
-
connect({ connector: preferredConnector });
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
catch (error) {
|
|
100
|
-
console.error("Connection error:", error);
|
|
101
|
-
sonner_1.toast.error("Failed to connect wallet. Please try again.");
|
|
102
|
-
}
|
|
103
|
-
}, disabled: isConnecting, className: "bg-as-surface-primary border-as-border-secondary hover:border-as-secondary/80 group flex w-full items-center justify-between gap-4 rounded-xl border px-4 py-3.5 transition-all duration-200 hover:shadow-md disabled:cursor-not-allowed disabled:opacity-50", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-3", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex h-8 w-8 items-center justify-center rounded-full bg-blue-100", children: (0, jsx_runtime_1.jsx)(lucide_react_1.Wallet, { className: "h-4 w-4 text-blue-600" }) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-start text-left", children: [(0, jsx_runtime_1.jsx)("h4", { className: "text-as-primary font-semibold", children: "Connect wallet" }), (0, jsx_runtime_1.jsx)("p", { className: "text-as-primary/60 text-sm", children: "Connect your wallet to continue" })] })] }), isConnecting ? ((0, jsx_runtime_1.jsx)("div", { className: "border-as-primary/20 border-t-as-primary h-5 w-5 animate-spin rounded-full border-2" })) : ((0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRightCircle, { className: "text-as-primary/40 group-hover:text-as-primary/60 h-5 w-5 transition-colors" }))] })) : (
|
|
104
|
-
// Connected - show wallet info
|
|
105
|
-
(0, jsx_runtime_1.jsx)("div", { className: "bg-as-surface-primary border-as-border-secondary rounded-xl border", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between p-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-3", children: [globalWallet?.meta?.icon ? ((0, jsx_runtime_1.jsx)("img", { src: globalWallet.meta.icon, alt: "Connected Wallet", className: "h-8 w-8 rounded-full" })) : ((0, jsx_runtime_1.jsx)("div", { className: "flex h-8 w-8 items-center justify-center rounded-full bg-green-100", children: (0, jsx_runtime_1.jsx)(lucide_react_1.Wallet, { className: "h-4 w-4 text-green-600" }) })), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-primary font-semibold", children: "Connected Wallet" }), (0, jsx_runtime_1.jsx)("span", { className: "text-as-primary/60 text-sm", children: (0, formatAddress_1.shortenAddress)(globalAddress) })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2", children: [(0, jsx_runtime_1.jsx)("button", { onClick: () => {
|
|
106
|
-
setSelectedPaymentMethod(PaymentMethod.CONNECT_WALLET);
|
|
107
|
-
onSelectPaymentMethod(PaymentMethod.CONNECT_WALLET);
|
|
108
|
-
}, className: "bg-as-brand hover:bg-as-brand/90 rounded-lg px-3 py-1.5 text-sm font-medium text-white transition-colors", children: "Use Wallet" }), (0, jsx_runtime_1.jsx)("button", { onClick: () => {
|
|
109
|
-
disconnect();
|
|
110
|
-
sonner_1.toast.success("Wallet disconnected");
|
|
111
|
-
if (selectedPaymentMethod === PaymentMethod.CONNECT_WALLET) {
|
|
112
|
-
setSelectedPaymentMethod(PaymentMethod.NONE);
|
|
113
|
-
}
|
|
114
|
-
}, className: "text-as-primary/60 hover:text-as-primary/80 rounded-lg p-1.5 transition-colors", children: (0, jsx_runtime_1.jsx)(lucide_react_1.X, { className: "h-4 w-4" }) })] })] }) })), (0, jsx_runtime_1.jsxs)("button", { onClick: () => {
|
|
115
|
-
setSelectedPaymentMethod(PaymentMethod.TRANSFER_CRYPTO);
|
|
116
|
-
onSelectPaymentMethod(PaymentMethod.TRANSFER_CRYPTO);
|
|
117
|
-
}, disabled: isCreatingOrder, className: "bg-as-surface-primary border-as-border-secondary hover:border-as-secondary/80 group flex w-full items-center justify-between gap-4 rounded-xl border px-4 py-3.5 transition-all duration-200 hover:shadow-md", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex flex-col items-start text-left", children: (0, jsx_runtime_1.jsx)("h4", { className: "text-as-primary font-semibold", children: "Transfer crypto" }) }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRightCircle, { className: "text-as-primary/40 group-hover:text-as-primary/60 h-5 w-5 transition-colors" })] })] })] }) }));
|
|
28
|
+
const [showWalletModal, setShowWalletModal] = (0, react_2.useState)(false);
|
|
29
|
+
// Define available wallets for the modal
|
|
30
|
+
const availableWallets = [
|
|
31
|
+
(0, wallets_1.createWallet)("io.metamask"),
|
|
32
|
+
// createWallet("com.coinbase.wallet"),
|
|
33
|
+
(0, wallets_1.createWallet)("me.rainbow"),
|
|
34
|
+
(0, wallets_1.createWallet)("walletConnect"),
|
|
35
|
+
(0, wallets_1.createWallet)("io.rabby"),
|
|
36
|
+
(0, wallets_1.createWallet)("app.phantom"),
|
|
37
|
+
];
|
|
38
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "mx-auto h-fit w-[460px] max-w-full", children: [(0, jsx_runtime_1.jsxs)("div", { className: (0, cn_1.cn)("relative flex flex-col gap-10"), children: [(0, jsx_runtime_1.jsx)("button", { onClick: onBack, className: "text-as-quaternary hover:text-as-primary absolute flex h-8 w-8 items-center justify-center rounded-lg transition-colors", children: (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronLeft, { className: "h-6 w-6" }) }), (0, jsx_runtime_1.jsx)("div", { className: "flex items-center justify-around gap-4", children: (0, jsx_runtime_1.jsx)("div", { className: "flex-1 text-center", children: (0, jsx_runtime_1.jsx)("h2", { className: "text-as-primary text-lg font-semibold", children: "Choose payment method" }) }) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-3", children: [!globalAddress ? (
|
|
39
|
+
// Not connected - show single connect button
|
|
40
|
+
(0, jsx_runtime_1.jsxs)("button", { onClick: () => setShowWalletModal(true), className: "bg-as-surface-primary border-as-border-secondary hover:border-as-secondary/80 group flex w-full items-center justify-between gap-4 rounded-xl border px-4 py-3.5 transition-all duration-200 hover:shadow-md", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-3", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex h-8 w-8 items-center justify-center rounded-full bg-blue-100", children: (0, jsx_runtime_1.jsx)(lucide_react_1.Wallet, { className: "h-4 w-4 text-blue-600" }) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-start text-left", children: [(0, jsx_runtime_1.jsx)("h4", { className: "text-as-primary font-semibold", children: "Connect wallet" }), (0, jsx_runtime_1.jsx)("p", { className: "text-as-primary/60 text-sm", children: "Choose from multiple wallet options" })] })] }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRightCircle, { className: "text-as-primary/40 group-hover:text-as-primary/60 h-5 w-5 transition-colors" })] })) : (
|
|
41
|
+
// Connected - show wallet info
|
|
42
|
+
(0, jsx_runtime_1.jsx)("div", { className: "bg-as-surface-primary border-as-border-secondary rounded-xl border", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between p-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-3", children: [globalWallet?.meta?.icon ? ((0, jsx_runtime_1.jsx)("img", { src: globalWallet.meta.icon, alt: "Connected Wallet", className: "h-8 w-8 rounded-full" })) : ((0, jsx_runtime_1.jsx)("div", { className: "flex h-8 w-8 items-center justify-center rounded-full bg-green-100", children: (0, jsx_runtime_1.jsx)(lucide_react_1.Wallet, { className: "h-4 w-4 text-green-600" }) })), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-primary font-semibold", children: "Connected Wallet" }), (0, jsx_runtime_1.jsx)("span", { className: "text-as-primary/60 text-sm", children: (0, formatAddress_1.shortenAddress)(globalAddress) })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2", children: [(0, jsx_runtime_1.jsx)("button", { onClick: () => {
|
|
43
|
+
setSelectedPaymentMethod(PaymentMethod.CONNECT_WALLET);
|
|
44
|
+
onSelectPaymentMethod(PaymentMethod.CONNECT_WALLET);
|
|
45
|
+
}, className: "bg-as-brand hover:bg-as-brand/90 rounded-lg px-3 py-1.5 text-sm font-medium text-white transition-colors", children: "Use Wallet" }), (0, jsx_runtime_1.jsx)("button", { onClick: async () => {
|
|
46
|
+
disconnect();
|
|
47
|
+
sonner_1.toast.success("Wallet disconnected");
|
|
48
|
+
if (selectedPaymentMethod === PaymentMethod.CONNECT_WALLET) {
|
|
49
|
+
setSelectedPaymentMethod(PaymentMethod.NONE);
|
|
50
|
+
}
|
|
51
|
+
}, className: "text-as-primary/60 hover:text-as-primary/80 rounded-lg p-1.5 transition-colors", children: (0, jsx_runtime_1.jsx)(lucide_react_1.X, { className: "h-4 w-4" }) })] })] }) })), (0, jsx_runtime_1.jsxs)("button", { onClick: () => {
|
|
52
|
+
setSelectedPaymentMethod(PaymentMethod.TRANSFER_CRYPTO);
|
|
53
|
+
onSelectPaymentMethod(PaymentMethod.TRANSFER_CRYPTO);
|
|
54
|
+
}, disabled: isCreatingOrder, className: "bg-as-surface-primary border-as-border-secondary hover:border-as-secondary/80 group flex w-full items-center justify-between gap-4 rounded-xl border px-4 py-3.5 transition-all duration-200 hover:shadow-md", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex flex-col items-start text-left", children: (0, jsx_runtime_1.jsx)("h4", { className: "text-as-primary font-semibold", children: "Transfer crypto" }) }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRightCircle, { className: "text-as-primary/40 group-hover:text-as-primary/60 h-5 w-5 transition-colors" })] })] })] }), showWalletModal &&
|
|
55
|
+
(0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)("div", { className: "pointer-events-auto fixed inset-0 z-[9999] flex items-center justify-center bg-black/50", children: (0, jsx_runtime_1.jsxs)("div", { className: "max-h-[80vh] w-[400px] max-w-[90vw] overflow-auto rounded-xl bg-white p-6 dark:bg-gray-900", children: [(0, jsx_runtime_1.jsxs)("div", { className: "mb-4 flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("h3", { className: "text-lg font-semibold text-gray-900 dark:text-white", children: "Connect Wallet" }), (0, jsx_runtime_1.jsx)("button", { onClick: () => setShowWalletModal(false), className: "text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200", children: (0, jsx_runtime_1.jsx)(lucide_react_1.X, { className: "h-5 w-5" }) })] }), (0, jsx_runtime_1.jsx)(react_3.ConnectEmbed, { client: thirdweb_1.client, chain: b3Chain_1.thirdwebB3Mainnet, wallets: availableWallets, showThirdwebBranding: false, theme: (0, react_3.lightTheme)(), onConnect: async (wallet) => {
|
|
56
|
+
console.log("Wallet connected:", wallet);
|
|
57
|
+
// setShowWalletModal(false);
|
|
58
|
+
setSelectedPaymentMethod(PaymentMethod.CONNECT_WALLET);
|
|
59
|
+
onSelectPaymentMethod(PaymentMethod.CONNECT_WALLET);
|
|
60
|
+
setShowWalletModal(false);
|
|
61
|
+
}, style: {
|
|
62
|
+
width: "100%",
|
|
63
|
+
minHeight: "300px",
|
|
64
|
+
} })] }) }), typeof window !== "undefined" ? document.getElementById("b3-root") || document.body : document.body)] }));
|
|
118
65
|
}
|
|
@@ -18,7 +18,7 @@ export { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect";
|
|
|
18
18
|
export { useMediaQuery } from "./useMediaQuery";
|
|
19
19
|
export { useNativeBalance, useNativeBalanceFromRPC } from "./useNativeBalance";
|
|
20
20
|
export { useOneBalance } from "./useOneBalance";
|
|
21
|
-
export { useProfile, useProfilePreference, type
|
|
21
|
+
export { useProfile, useProfilePreference, type CombinedProfile, type PreferenceRequestBody, type Profile, } from "./useProfile";
|
|
22
22
|
export { useQueryB3 } from "./useQueryB3";
|
|
23
23
|
export { useQueryBSMNT } from "./useQueryBSMNT";
|
|
24
24
|
export { useRemoveSessionKey } from "./useRemoveSessionKey";
|
|
@@ -7,13 +7,13 @@ 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";
|
|
9
9
|
import invariant from "invariant";
|
|
10
|
-
import { ArrowDown, ChevronLeft, ChevronRightCircle, ChevronsUpDown, CircleAlert, HistoryIcon } from "lucide-react";
|
|
10
|
+
import { ArrowDown, ChevronLeft, ChevronRight, ChevronRightCircle, ChevronsUpDown, CircleAlert, HistoryIcon, } from "lucide-react";
|
|
11
11
|
import { motion } from "motion/react";
|
|
12
12
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
13
13
|
import { toast } from "sonner";
|
|
14
|
+
import { useConnectedWallets } from "thirdweb/react";
|
|
14
15
|
import { parseUnits } from "viem";
|
|
15
16
|
import { b3Sepolia, base, mainnet, sepolia } from "viem/chains";
|
|
16
|
-
import { useAccount } from "wagmi";
|
|
17
17
|
import { AnySpendFingerprintWrapper, getFingerprintConfig } from "./AnySpendFingerprintWrapper.js";
|
|
18
18
|
import { CryptoPaymentMethod, PaymentMethod } from "./common/CryptoPaymentMethod.js";
|
|
19
19
|
import { FiatPaymentMethod, FiatPaymentMethodComponent } from "./common/FiatPaymentMethod.js";
|
|
@@ -44,7 +44,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
44
44
|
const searchParams = useSearchParamsSSR();
|
|
45
45
|
const router = useRouter();
|
|
46
46
|
// Get wagmi account state for wallet connection
|
|
47
|
-
const
|
|
47
|
+
const connectedWallets = useConnectedWallets();
|
|
48
48
|
// Determine if we're in "buy mode" based on whether destination token props are provided
|
|
49
49
|
const isBuyMode = !!(destinationTokenAddress && destinationTokenChainId);
|
|
50
50
|
// Add refs to track URL state
|
|
@@ -336,6 +336,9 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
336
336
|
amount: srcAmountOnrampInWei,
|
|
337
337
|
onrampVendor: getOnrampVendor(selectedFiatPaymentMethod),
|
|
338
338
|
});
|
|
339
|
+
const connectedAddress = globalAddress || connectedWallets?.[0]?.getAccount()?.address;
|
|
340
|
+
const connectedProfile = useProfile({ address: connectedAddress });
|
|
341
|
+
const connectedName = connectedProfile.data?.name?.replace(/\.b3\.fun/g, "");
|
|
339
342
|
const recipientProfile = useProfile({ address: recipientAddress });
|
|
340
343
|
const recipientName = recipientProfile.data?.name?.replace(/\.b3\.fun/g, "");
|
|
341
344
|
// Load custom recipients from local storage on mount
|
|
@@ -800,7 +803,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
800
803
|
setActiveTab("fiat");
|
|
801
804
|
setSelectedPaymentMethod(PaymentMethod.NONE); // Reset crypto payment method when switching to fiat
|
|
802
805
|
setSelectedFiatPaymentMethod(FiatPaymentMethod.NONE); // Reset fiat payment method when switching to fiat
|
|
803
|
-
}, children: "Pay with Fiat" })] }) }), _jsxs("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: [activeTab === "crypto" ? (_jsxs(motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "bg-as-surface-secondary border-as-border-secondary relative flex w-full flex-col gap-2 rounded-2xl border p-4 sm:p-6", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("div", { className: "text-as-primary/50 flex h-7 items-center text-sm", children: "Pay" }), _jsx("button", { className: "text-as-
|
|
806
|
+
}, children: "Pay with Fiat" })] }) }), _jsxs("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: [activeTab === "crypto" ? (_jsxs(motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "bg-as-surface-secondary border-as-border-secondary relative flex w-full flex-col gap-2 rounded-2xl border p-4 sm:p-6", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("div", { className: "text-as-primary/50 flex h-7 items-center text-sm", children: "Pay" }), _jsx("button", { className: "text-as-tertiarry flex h-7 items-center gap-2 text-sm transition-colors", onClick: () => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD), children: selectedPaymentMethod === PaymentMethod.CONNECT_WALLET ? (_jsxs(_Fragment, { children: [connectedAddress ? (_jsxs(_Fragment, { children: [globalWallet?.meta?.icon && (_jsx("img", { src: globalWallet.meta.icon, alt: "Connected Wallet", className: "bg-as-primary h-6 w-6 rounded-full" })), _jsx("span", { className: "text-as-tertiarry", children: connectedName || shortenAddress(connectedAddress || "") })] })) : ("Connect wallet"), _jsx(ChevronRight, { className: "h-4 w-4" })] })) : selectedPaymentMethod === PaymentMethod.TRANSFER_CRYPTO ? (_jsxs(_Fragment, { children: ["Transfer crypto", _jsx(ChevronRight, { className: "h-4 w-4" })] })) : (_jsxs(_Fragment, { children: ["Select payment method", _jsx(ChevronRight, { className: "h-4 w-4" })] })) })] }), _jsx(OrderTokenAmount, { address: globalAddress, context: "from", inputValue: srcAmount, onChangeInput: value => {
|
|
804
807
|
setIsSrcInputDirty(true);
|
|
805
808
|
setSrcAmount(value);
|
|
806
809
|
}, chainId: selectedSrcChainId, setChainId: setSelectedSrcChainId, token: selectedSrcToken, setToken: setSelectedSrcToken }), _jsxs("div", { className: "flex items-center justify-between", children: [_jsx("div", { className: "text-as-primary/50 flex h-5 items-center text-sm", children: formatDisplayNumber(anyspendQuote?.data?.currencyIn?.amountUsd, { style: "currency", fallback: "" }) }), _jsx(TokenBalance, { token: selectedSrcToken, walletAddress: globalAddress, onChangeInput: value => {
|
|
@@ -825,7 +828,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
825
828
|
const tempDstAmount = dstAmount;
|
|
826
829
|
setSrcAmount(tempDstAmount);
|
|
827
830
|
setDstAmount(tempSrcAmount);
|
|
828
|
-
}, children: _jsx("div", { className: "relative flex items-center justify-center transition-opacity", children: _jsx(ArrowDown, { className: "text-as-primary/50 h-5 w-5" }) }) }), activeTab !== "fiat" && (_jsxs(motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, className: "bg-as-surface-secondary border-as-border-secondary relative flex w-full flex-col gap-2 rounded-2xl border p-4 sm:p-6", children: [_jsxs("div", { className: "flex w-full items-center justify-between", children: [_jsx("div", { className: "text-as-primary/50 flex h-7 items-center text-sm", children: "Receive" }), recipientAddress ? (_jsxs("button", { className: cn("text-as-
|
|
831
|
+
}, children: _jsx("div", { className: "relative flex items-center justify-center transition-opacity", children: _jsx(ArrowDown, { className: "text-as-primary/50 h-5 w-5" }) }) }), activeTab !== "fiat" && (_jsxs(motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, className: "bg-as-surface-secondary border-as-border-secondary relative flex w-full flex-col gap-2 rounded-2xl border p-4 sm:p-6", children: [_jsxs("div", { className: "flex w-full items-center justify-between", children: [_jsx("div", { className: "text-as-primary/50 flex h-7 items-center text-sm", children: "Receive" }), recipientAddress ? (_jsxs("button", { className: cn("text-as-tertiarry flex h-7 items-center gap-2 rounded-lg"), onClick: () => setActivePanel(PanelView.RECIPIENT_SELECTION), children: [globalAddress && recipientAddress === globalAddress && globalWallet?.meta?.icon ? (_jsx("img", { src: globalWallet?.meta?.icon, alt: "Current wallet", className: "bg-as-primary h-6 w-6 rounded-full" })) : (_jsx("div", { className: "flex h-6 w-6 items-center justify-center rounded-full bg-orange-500 text-xs text-white", children: "\uD83E\uDD8A" })), _jsx("div", { className: "text-sm", children: recipientName ? recipientName : shortenAddress(recipientAddress) }), _jsx(ChevronRight, { className: "h-4 w-4" })] })) : (_jsxs("button", { className: "text-as-primary/70 flex items-center gap-1 rounded-lg", onClick: () => setActivePanel(PanelView.RECIPIENT_SELECTION), children: [_jsx("div", { className: "text-sm font-medium", children: "Select recipient" }), _jsx(ChevronsUpDown, { className: "h-3 w-3" })] }))] }), isBuyMode ? (
|
|
829
832
|
// Fixed destination token display in buy mode
|
|
830
833
|
_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("div", { className: "text-as-primary text-2xl font-bold", children: dstAmount || "0" }), _jsxs("div", { className: "bg-as-brand/10 border-as-brand/30 flex items-center gap-3 rounded-xl border px-4 py-3", children: [selectedDstToken.metadata?.logoURI && (_jsx("img", { src: selectedDstToken.metadata.logoURI, alt: selectedDstToken.symbol, className: "h-8 w-8 rounded-full" })), _jsx("span", { className: "text-as-brand text-lg font-bold", children: selectedDstToken.symbol })] })] })) : (_jsx(OrderTokenAmount, { address: recipientAddress, context: "to", inputValue: dstAmount, onChangeInput: value => {
|
|
831
834
|
setIsSrcInputDirty(false);
|
|
@@ -884,26 +887,27 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
884
887
|
setActivePanel(PanelView.MAIN); // Go back to main panel to show updated pricing
|
|
885
888
|
}, srcAmountOnRamp: srcAmountOnRamp, isMainnet: isMainnet }));
|
|
886
889
|
// Add tabs to the main component when no order is loaded
|
|
887
|
-
return (_jsx(StyleRoot, { children: _jsx("div", { className: cn("mx-auto w-full max-w-[460px]", mode === "page" &&
|
|
890
|
+
return (_jsx(StyleRoot, { children: _jsx("div", { className: cn("mx-auto w-full max-w-[460px]", mode === "page" &&
|
|
891
|
+
"bg-as-surface-primary border-as-border-secondary overflow-hidden rounded-2xl border shadow-xl"), children: _jsx(TransitionPanel, { activeIndex: orderId
|
|
888
892
|
? oat
|
|
889
893
|
? PanelView.ORDER_DETAILS
|
|
890
894
|
: PanelView.LOADING
|
|
891
895
|
: activePanel === PanelView.ORDER_DETAILS
|
|
892
896
|
? PanelView.MAIN
|
|
893
|
-
: activePanel, className: cn("
|
|
897
|
+
: activePanel, className: cn("rounded-2xl", {
|
|
894
898
|
"mt-0": mode === "modal",
|
|
895
899
|
}), variants: {
|
|
896
900
|
enter: { x: 300, opacity: 0 },
|
|
897
901
|
center: { x: 0, opacity: 1 },
|
|
898
902
|
exit: { x: -300, opacity: 0 },
|
|
899
903
|
}, transition: { type: "spring", stiffness: 300, damping: 30 }, children: [
|
|
900
|
-
_jsx("div", { children: mainView }, "main-view"),
|
|
901
|
-
_jsx("div", { children: historyView }, "history-view"),
|
|
902
|
-
_jsx("div", { children: orderDetailsView }, "order-details-view"),
|
|
903
|
-
_jsx("div", { children: OrderDetailsLoadingView }, "loading-view"),
|
|
904
|
-
_jsx("div", { children: onrampPaymentView }, "fiat-payment-view"),
|
|
905
|
-
_jsx("div", { children: recipientSelectionView }, "recipient-selection-view"),
|
|
906
|
-
_jsx("div", { children: cryptoPaymentMethodView }, "crypto-payment-method-view"),
|
|
907
|
-
_jsx("div", { children: fiatPaymentMethodView }, "fiat-payment-method-view"),
|
|
904
|
+
_jsx("div", { className: cn(mode === "page" && "p-6"), children: mainView }, "main-view"),
|
|
905
|
+
_jsx("div", { className: cn(mode === "page" && "p-6"), children: historyView }, "history-view"),
|
|
906
|
+
_jsx("div", { className: cn(mode === "page" && "p-6"), children: orderDetailsView }, "order-details-view"),
|
|
907
|
+
_jsx("div", { className: cn(mode === "page" && "p-6"), children: OrderDetailsLoadingView }, "loading-view"),
|
|
908
|
+
_jsx("div", { className: cn(mode === "page" && "p-6"), children: onrampPaymentView }, "fiat-payment-view"),
|
|
909
|
+
_jsx("div", { className: cn(mode === "page" && "p-6"), children: recipientSelectionView }, "recipient-selection-view"),
|
|
910
|
+
_jsx("div", { className: cn(mode === "page" && "p-6"), children: cryptoPaymentMethodView }, "crypto-payment-method-view"),
|
|
911
|
+
_jsx("div", { className: cn(mode === "page" && "p-6"), children: fiatPaymentMethodView }, "fiat-payment-method-view"),
|
|
908
912
|
] }) }) }));
|
|
909
913
|
}
|
|
@@ -13,5 +13,5 @@ interface AnySpendFingerprintWrapperProps {
|
|
|
13
13
|
* This prevents unnecessary fingerprinting of users who don't interact with AnySpend.
|
|
14
14
|
*/
|
|
15
15
|
export declare function AnySpendFingerprintWrapper({ children, fingerprint }: AnySpendFingerprintWrapperProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
-
export declare function getFingerprintConfig(): FingerprintConfig
|
|
16
|
+
export declare function getFingerprintConfig(): FingerprintConfig;
|
|
17
17
|
export {};
|
|
@@ -22,14 +22,11 @@ export function AnySpendFingerprintWrapper({ children, fingerprint }) {
|
|
|
22
22
|
: undefined,
|
|
23
23
|
}, children: children }));
|
|
24
24
|
}
|
|
25
|
+
const defaultApiKey = "80EnsS6POsxPAR9xGxmN";
|
|
25
26
|
// Helper function to get fingerprint config from environment variables
|
|
26
27
|
export function getFingerprintConfig() {
|
|
27
|
-
const apiKey = process.env.NEXT_PUBLIC_FINGERPRINT_API_KEY;
|
|
28
|
-
if (!apiKey) {
|
|
29
|
-
return undefined;
|
|
30
|
-
}
|
|
31
28
|
return {
|
|
32
|
-
apiKey,
|
|
29
|
+
apiKey: process.env.NEXT_PUBLIC_FINGERPRINT_API_KEY || defaultApiKey,
|
|
33
30
|
endpoint: process.env.NEXT_PUBLIC_FINGERPRINT_ENDPOINT,
|
|
34
31
|
scriptUrlPattern: process.env.NEXT_PUBLIC_FINGERPRINT_SCRIPT_URL,
|
|
35
32
|
};
|