@b3dotfun/sdk 0.0.20-alpha.8 → 0.0.20-alpha.9
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 +32 -48
- package/dist/cjs/anyspend/react/components/AnySpendCustom.d.ts +1 -1
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +159 -84
- package/dist/cjs/anyspend/react/components/AnySpendNFT.js +1 -1
- package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.js +1 -1
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.d.ts +4 -4
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +19 -18
- package/dist/cjs/anyspend/react/components/common/OrderDetails.d.ts +2 -2
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +6 -8
- package/dist/cjs/anyspend/react/components/common/OrderStatus.js +2 -2
- package/dist/cjs/anyspend/react/components/common/RecipientSelection.d.ts +42 -0
- package/dist/cjs/anyspend/react/components/common/RecipientSelection.example.d.ts +7 -0
- package/dist/cjs/anyspend/react/components/common/RecipientSelection.example.js +27 -0
- package/dist/cjs/anyspend/react/components/common/RecipientSelection.js +36 -0
- package/dist/cjs/anyspend/react/components/index.d.ts +1 -0
- package/dist/cjs/anyspend/react/components/index.js +3 -1
- package/dist/cjs/anyspend/react/hooks/index.d.ts +1 -0
- package/dist/cjs/anyspend/react/hooks/index.js +1 -0
- package/dist/cjs/anyspend/react/hooks/useConnectedUserProfile.d.ts +12 -0
- package/dist/cjs/anyspend/react/hooks/useConnectedUserProfile.js +25 -0
- package/dist/cjs/shared/utils/formatUsername.d.ts +1 -1
- package/dist/cjs/shared/utils/formatUsername.js +3 -1
- package/dist/esm/anyspend/react/components/AnySpend.js +35 -51
- package/dist/esm/anyspend/react/components/AnySpendCustom.d.ts +1 -1
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +163 -88
- package/dist/esm/anyspend/react/components/AnySpendNFT.js +1 -1
- package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.js +1 -1
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.d.ts +4 -4
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +19 -18
- package/dist/esm/anyspend/react/components/common/OrderDetails.d.ts +2 -2
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +7 -9
- package/dist/esm/anyspend/react/components/common/OrderStatus.js +2 -2
- package/dist/esm/anyspend/react/components/common/RecipientSelection.d.ts +42 -0
- package/dist/esm/anyspend/react/components/common/RecipientSelection.example.d.ts +7 -0
- package/dist/esm/anyspend/react/components/common/RecipientSelection.example.js +22 -0
- package/dist/esm/anyspend/react/components/common/RecipientSelection.js +33 -0
- 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/hooks/index.d.ts +1 -0
- package/dist/esm/anyspend/react/hooks/index.js +1 -0
- package/dist/esm/anyspend/react/hooks/useConnectedUserProfile.d.ts +12 -0
- package/dist/esm/anyspend/react/hooks/useConnectedUserProfile.js +22 -0
- package/dist/esm/shared/utils/formatUsername.d.ts +1 -1
- package/dist/esm/shared/utils/formatUsername.js +3 -1
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/react/components/AnySpendCustom.d.ts +1 -1
- package/dist/types/anyspend/react/components/common/CryptoPaymentMethod.d.ts +4 -4
- package/dist/types/anyspend/react/components/common/OrderDetails.d.ts +2 -2
- package/dist/types/anyspend/react/components/common/RecipientSelection.d.ts +42 -0
- package/dist/types/anyspend/react/components/common/RecipientSelection.example.d.ts +7 -0
- package/dist/types/anyspend/react/components/index.d.ts +1 -0
- package/dist/types/anyspend/react/hooks/index.d.ts +1 -0
- package/dist/types/anyspend/react/hooks/useConnectedUserProfile.d.ts +12 -0
- package/dist/types/shared/utils/formatUsername.d.ts +1 -1
- package/package.json +1 -1
- package/src/anyspend/react/components/AnySpend.tsx +72 -131
- package/src/anyspend/react/components/AnySpendCustom.tsx +488 -196
- package/src/anyspend/react/components/AnySpendNFT.tsx +1 -1
- package/src/anyspend/react/components/common/ConnectWalletPayment.tsx +1 -1
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +19 -16
- package/src/anyspend/react/components/common/OrderDetails.tsx +10 -12
- package/src/anyspend/react/components/common/OrderStatus.tsx +2 -2
- package/src/anyspend/react/components/common/RecipientSelection.example.tsx +52 -0
- package/src/anyspend/react/components/common/RecipientSelection.tsx +146 -0
- package/src/anyspend/react/components/index.ts +1 -0
- package/src/anyspend/react/hooks/index.ts +1 -0
- package/src/anyspend/react/hooks/useConnectedUserProfile.ts +26 -0
- package/src/shared/utils/formatUsername.ts +3 -2
|
@@ -10,6 +10,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
10
10
|
const anyspend_1 = require("../../../anyspend");
|
|
11
11
|
const react_1 = require("../../../anyspend/react");
|
|
12
12
|
const react_2 = require("../../../global-account/react");
|
|
13
|
+
const utils_1 = require("../../../shared/utils");
|
|
13
14
|
const cn_1 = require("../../../shared/utils/cn");
|
|
14
15
|
const formatAddress_1 = require("../../../shared/utils/formatAddress");
|
|
15
16
|
const number_1 = require("../../../shared/utils/number");
|
|
@@ -18,7 +19,6 @@ const lucide_react_1 = require("lucide-react");
|
|
|
18
19
|
const react_3 = require("motion/react");
|
|
19
20
|
const react_4 = require("react");
|
|
20
21
|
const sonner_1 = require("sonner");
|
|
21
|
-
const react_5 = require("thirdweb/react");
|
|
22
22
|
const viem_1 = require("viem");
|
|
23
23
|
const chains_1 = require("viem/chains");
|
|
24
24
|
const AnySpendFingerprintWrapper_1 = require("./AnySpendFingerprintWrapper");
|
|
@@ -30,6 +30,7 @@ const OrderStatus_1 = require("./common/OrderStatus");
|
|
|
30
30
|
const OrderTokenAmount_1 = require("./common/OrderTokenAmount");
|
|
31
31
|
const PanelOnramp_1 = require("./common/PanelOnramp");
|
|
32
32
|
const PanelOnrampPayment_1 = require("./common/PanelOnrampPayment");
|
|
33
|
+
const RecipientSelection_1 = require("./common/RecipientSelection");
|
|
33
34
|
const TokenBalance_1 = require("./common/TokenBalance");
|
|
34
35
|
var PanelView;
|
|
35
36
|
(function (PanelView) {
|
|
@@ -50,8 +51,6 @@ function AnySpend(props) {
|
|
|
50
51
|
function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMainnet = true, mode = "modal", defaultActiveTab = "crypto", loadOrder, hideTransactionHistoryButton, recipientAddress: recipientAddressFromProps, }) {
|
|
51
52
|
const searchParams = (0, react_2.useSearchParamsSSR)();
|
|
52
53
|
const router = (0, react_2.useRouter)();
|
|
53
|
-
// Get wagmi account state for wallet connection
|
|
54
|
-
const connectedWallets = (0, react_5.useConnectedWallets)();
|
|
55
54
|
// Determine if we're in "buy mode" based on whether destination token props are provided
|
|
56
55
|
const isBuyMode = !!(destinationTokenAddress && destinationTokenChainId);
|
|
57
56
|
// Add refs to track URL state
|
|
@@ -64,7 +63,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
64
63
|
const [activePanel, setActivePanel] = (0, react_4.useState)(loadOrder ? PanelView.ORDER_DETAILS : PanelView.MAIN);
|
|
65
64
|
const [customRecipients, setCustomRecipients] = (0, react_4.useState)([]);
|
|
66
65
|
// Add state for selected payment method
|
|
67
|
-
const [
|
|
66
|
+
const [selectedCryptoPaymentMethod, setSelectedCryptoPaymentMethod] = (0, react_4.useState)(CryptoPaymentMethod_1.CryptoPaymentMethodType.NONE);
|
|
68
67
|
// Add state for selected fiat payment method
|
|
69
68
|
const [selectedFiatPaymentMethod, setSelectedFiatPaymentMethod] = (0, react_4.useState)(FiatPaymentMethod_1.FiatPaymentMethod.NONE);
|
|
70
69
|
// const [newRecipientAddress, setNewRecipientAddress] = useState("");
|
|
@@ -343,11 +342,9 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
343
342
|
amount: srcAmountOnrampInWei,
|
|
344
343
|
onrampVendor: getOnrampVendor(selectedFiatPaymentMethod),
|
|
345
344
|
});
|
|
346
|
-
const connectedAddress
|
|
347
|
-
const connectedProfile = (0, react_2.useProfile)({ address: connectedAddress });
|
|
348
|
-
const connectedName = connectedProfile.data?.name?.replace(/\.b3\.fun/g, "");
|
|
345
|
+
const { address: connectedAddress, name: connectedName, profile: connectedProfile } = (0, react_1.useConnectedUserProfile)();
|
|
349
346
|
const recipientProfile = (0, react_2.useProfile)({ address: recipientAddress });
|
|
350
|
-
const recipientName = recipientProfile.data?.name
|
|
347
|
+
const recipientName = (0, utils_1.formatUsername)(recipientProfile.data?.name ?? "");
|
|
351
348
|
// Load custom recipients from local storage on mount
|
|
352
349
|
(0, react_4.useEffect)(() => {
|
|
353
350
|
try {
|
|
@@ -513,13 +510,13 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
513
510
|
// setNewRecipientAddress("");
|
|
514
511
|
setActivePanel(PanelView.ORDER_DETAILS);
|
|
515
512
|
// Debug: Check payment method before setting URL
|
|
516
|
-
console.log("Creating order -
|
|
513
|
+
console.log("Creating order - selectedCryptoPaymentMethod:", selectedCryptoPaymentMethod);
|
|
517
514
|
// Add orderId and payment method to URL for persistence
|
|
518
515
|
const params = new URLSearchParams(searchParams.toString()); // Preserve existing params
|
|
519
516
|
params.set("orderId", orderId);
|
|
520
|
-
if (
|
|
521
|
-
console.log("Setting
|
|
522
|
-
params.set("
|
|
517
|
+
if (selectedCryptoPaymentMethod !== CryptoPaymentMethod_1.CryptoPaymentMethodType.NONE) {
|
|
518
|
+
console.log("Setting cryptoPaymentMethod in URL:", selectedCryptoPaymentMethod);
|
|
519
|
+
params.set("cryptoPaymentMethod", selectedCryptoPaymentMethod);
|
|
523
520
|
}
|
|
524
521
|
else {
|
|
525
522
|
console.log("Payment method is NONE, not setting in URL");
|
|
@@ -563,14 +560,14 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
563
560
|
return { text: "Get rate error", disable: true, error: true };
|
|
564
561
|
if (activeTab === "crypto") {
|
|
565
562
|
// If no payment method selected, show "Choose payment method"
|
|
566
|
-
if (
|
|
563
|
+
if (selectedCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.NONE) {
|
|
567
564
|
return { text: "Choose payment method", disable: false, error: false };
|
|
568
565
|
}
|
|
569
566
|
// If payment method selected, show appropriate action
|
|
570
|
-
if (
|
|
567
|
+
if (selectedCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.CONNECT_WALLET) {
|
|
571
568
|
return { text: "Swap", disable: false, error: false };
|
|
572
569
|
}
|
|
573
|
-
if (
|
|
570
|
+
if (selectedCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.TRANSFER_CRYPTO) {
|
|
574
571
|
return { text: "Continue to payment", disable: false, error: false };
|
|
575
572
|
}
|
|
576
573
|
}
|
|
@@ -591,7 +588,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
591
588
|
isCreatingOnrampOrder,
|
|
592
589
|
anyspendQuote,
|
|
593
590
|
activeTab,
|
|
594
|
-
|
|
591
|
+
selectedCryptoPaymentMethod,
|
|
595
592
|
selectedFiatPaymentMethod,
|
|
596
593
|
]);
|
|
597
594
|
// Handle main button click
|
|
@@ -617,16 +614,16 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
617
614
|
}
|
|
618
615
|
if (activeTab === "crypto") {
|
|
619
616
|
// If no payment method selected, show payment method selection
|
|
620
|
-
if (
|
|
617
|
+
if (selectedCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.NONE) {
|
|
621
618
|
console.log("No payment method selected, showing selection panel");
|
|
622
619
|
setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD);
|
|
623
620
|
return;
|
|
624
621
|
}
|
|
625
622
|
// If payment method is selected, create order with payment method info
|
|
626
|
-
if (
|
|
627
|
-
|
|
628
|
-
console.log("Creating crypto order with payment method:",
|
|
629
|
-
await handleCryptoSwap(
|
|
623
|
+
if (selectedCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.CONNECT_WALLET ||
|
|
624
|
+
selectedCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.TRANSFER_CRYPTO) {
|
|
625
|
+
console.log("Creating crypto order with payment method:", selectedCryptoPaymentMethod);
|
|
626
|
+
await handleCryptoSwap(selectedCryptoPaymentMethod);
|
|
630
627
|
return;
|
|
631
628
|
}
|
|
632
629
|
}
|
|
@@ -652,7 +649,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
652
649
|
(0, invariant_1.default)(recipientAddress, "Recipient address is not found");
|
|
653
650
|
// Debug: Check payment method values
|
|
654
651
|
console.log("handleCryptoSwap - method parameter:", method);
|
|
655
|
-
console.log("handleCryptoSwap -
|
|
652
|
+
console.log("handleCryptoSwap - selectedCryptoPaymentMethod state:", selectedCryptoPaymentMethod);
|
|
656
653
|
const srcAmountBigInt = (0, viem_1.parseUnits)(srcAmount.replace(/,/g, ""), selectedSrcToken.decimals);
|
|
657
654
|
createOrder({
|
|
658
655
|
isMainnet,
|
|
@@ -800,17 +797,17 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
800
797
|
const orderDetailsView = ((0, jsx_runtime_1.jsx)("div", { className: "mx-auto w-[460px] max-w-full", children: (0, jsx_runtime_1.jsx)("div", { className: "relative flex flex-col gap-4", children: oat && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(OrderStatus_1.OrderStatus, { order: oat.data.order }), (0, jsx_runtime_1.jsx)(OrderDetails_1.OrderDetails, { isMainnet: isMainnet, mode: mode, order: oat.data.order, depositTxs: oat.data.depositTxs, relayTx: oat.data.relayTx, executeTx: oat.data.executeTx, refundTxs: oat.data.refundTxs, onBack: () => {
|
|
801
798
|
setOrderId(undefined);
|
|
802
799
|
setActivePanel(PanelView.MAIN);
|
|
803
|
-
|
|
800
|
+
setSelectedCryptoPaymentMethod(CryptoPaymentMethod_1.CryptoPaymentMethodType.NONE); // Reset payment method when going back
|
|
804
801
|
} })] })) }) }));
|
|
805
802
|
const mainView = ((0, jsx_runtime_1.jsxs)("div", { className: "mx-auto flex w-[460px] max-w-full flex-col items-center gap-2", children: [isBuyMode && ((0, jsx_runtime_1.jsxs)("div", { className: "mb-4 flex flex-col items-center gap-3 text-center", children: [selectedDstToken.metadata?.logoURI && ((0, jsx_runtime_1.jsx)("div", { className: "relative", children: (0, jsx_runtime_1.jsx)("img", { src: selectedDstToken.metadata.logoURI, alt: selectedDstToken.symbol, className: "border-as-stroke h-12 w-12 rounded-full border-2 shadow-md" }) })), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsxs)("h1", { className: "text-as-primary text-xl font-bold", children: ["Buy ", selectedDstToken.symbol] }) })] })), (0, jsx_runtime_1.jsx)("div", { className: "w-full", children: (0, jsx_runtime_1.jsxs)("div", { className: "bg-as-surface-secondary relative mb-4 grid h-10 grid-cols-2 rounded-xl", children: [(0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)("bg-as-brand absolute bottom-0 left-0 top-0 z-0 rounded-xl transition-transform duration-100", "h-full w-1/2", activeTab === "fiat" ? "translate-x-full" : "translate-x-0"), style: { willChange: "transform" } }), (0, jsx_runtime_1.jsx)("button", { className: (0, cn_1.cn)("relative z-10 h-full w-full rounded-xl px-3 text-sm font-medium transition-colors duration-100", activeTab === "crypto" ? "text-white" : "text-as-primary/70 hover:bg-as-on-surface-2 bg-transparent"), onClick: () => {
|
|
806
803
|
setActiveTab("crypto");
|
|
807
|
-
|
|
804
|
+
setSelectedCryptoPaymentMethod(CryptoPaymentMethod_1.CryptoPaymentMethodType.NONE); // Reset payment method when switching to crypto
|
|
808
805
|
setSelectedFiatPaymentMethod(FiatPaymentMethod_1.FiatPaymentMethod.NONE); // Reset fiat payment method when switching to crypto
|
|
809
806
|
}, children: "Pay with crypto" }), (0, jsx_runtime_1.jsx)("button", { className: (0, cn_1.cn)("relative z-10 h-full w-full rounded-xl px-3 text-sm font-medium transition-colors duration-100", activeTab === "fiat" ? "text-white" : "text-as-primary/70 hover:bg-as-on-surface-2 bg-transparent"), onClick: () => {
|
|
810
807
|
setActiveTab("fiat");
|
|
811
|
-
|
|
808
|
+
setSelectedCryptoPaymentMethod(CryptoPaymentMethod_1.CryptoPaymentMethodType.NONE); // Reset crypto payment method when switching to fiat
|
|
812
809
|
setSelectedFiatPaymentMethod(FiatPaymentMethod_1.FiatPaymentMethod.NONE); // Reset fiat payment method when switching to fiat
|
|
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:
|
|
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-tertiarry flex h-7 items-center gap-2 text-sm transition-colors", onClick: () => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD), children: selectedCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.CONNECT_WALLET ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [connectedAddress ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [recipientProfile && ((0, jsx_runtime_1.jsx)("img", { src: recipientProfile.data?.avatar || "", alt: recipientProfile.data?.name || "", className: "bg-b3-react-foreground size-7 rounded-full object-cover opacity-100" })), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-1", children: [recipientName && (0, jsx_runtime_1.jsx)("span", { children: recipientName }), (0, jsx_runtime_1.jsx)("span", { children: (0, formatAddress_1.shortenAddress)(recipientAddress || "") })] })] })) : ("Connect wallet"), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] })) : selectedCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.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 => {
|
|
814
811
|
setIsSrcInputDirty(true);
|
|
815
812
|
setSrcAmount(value);
|
|
816
813
|
}, 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 => {
|
|
@@ -835,7 +832,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
835
832
|
const tempDstAmount = dstAmount;
|
|
836
833
|
setSrcAmount(tempDstAmount);
|
|
837
834
|
setDstAmount(tempSrcAmount);
|
|
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.
|
|
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.jsx)("button", { className: (0, cn_1.cn)("text-as-tertiarry flex h-7 items-center gap-2 rounded-lg"), onClick: () => setActivePanel(PanelView.RECIPIENT_SELECTION), children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [connectedAddress ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [connectedProfile?.data?.avatar && ((0, jsx_runtime_1.jsx)("img", { src: connectedProfile.data?.avatar || "", alt: "Connected Wallet", className: "bg-as-primary h-6 w-6 rounded-full" })), (0, jsx_runtime_1.jsxs)("span", { className: "text-as-tertiarry flex items-center gap-1 text-sm", children: [connectedName && (0, jsx_runtime_1.jsx)("span", { children: (0, utils_1.formatUsername)(connectedName) }), (0, jsx_runtime_1.jsx)("span", { children: (0, formatAddress_1.shortenAddress)(connectedAddress || "") })] })] })) : ("Connect wallet"), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] }) })) : ((0, jsx_runtime_1.jsx)("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" }) }))] }), isBuyMode ? (
|
|
839
836
|
// Fixed destination token display in buy mode
|
|
840
837
|
(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 => {
|
|
841
838
|
setIsSrcInputDirty(false);
|
|
@@ -863,30 +860,17 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
863
860
|
if (activeTab === "fiat") {
|
|
864
861
|
params.set("paymentMethod", "fiat");
|
|
865
862
|
}
|
|
866
|
-
else if (
|
|
867
|
-
params.set("paymentMethod",
|
|
863
|
+
else if (selectedCryptoPaymentMethod !== CryptoPaymentMethod_1.CryptoPaymentMethodType.NONE) {
|
|
864
|
+
params.set("paymentMethod", selectedCryptoPaymentMethod);
|
|
868
865
|
}
|
|
869
866
|
router.push(`${window.location.pathname}?${params.toString()}`);
|
|
870
867
|
}, onBack: () => setActivePanel(PanelView.MAIN), recipientEnsName: globalWallet?.ensName, recipientImageUrl: globalWallet?.meta?.icon }));
|
|
871
|
-
const recipientSelectionView = ((0, jsx_runtime_1.jsx)(
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
const text = await navigator.clipboard.readText();
|
|
878
|
-
setRecipientAddress(text);
|
|
879
|
-
}
|
|
880
|
-
catch (err) {
|
|
881
|
-
console.error("Failed to read clipboard:", err);
|
|
882
|
-
}
|
|
883
|
-
}, className: "text-as-primary/70 hover:text-as-primary hover:bg-as-surface-primary h-full px-4 font-semibold transition-colors", children: "Paste" }) })] }), (0, jsx_runtime_1.jsx)("button", { onClick: () => {
|
|
884
|
-
if (recipientAddress) {
|
|
885
|
-
setActivePanel(PanelView.MAIN);
|
|
886
|
-
}
|
|
887
|
-
}, disabled: !recipientAddress, className: "bg-as-brand hover:bg-as-brand/90 disabled:bg-as-on-surface-2 disabled:text-as-secondary h-12 w-full rounded-xl font-medium text-white transition-colors disabled:cursor-not-allowed", children: "Confirm recipient address" })] })] }) }));
|
|
888
|
-
const cryptoPaymentMethodView = ((0, jsx_runtime_1.jsx)(CryptoPaymentMethod_1.CryptoPaymentMethod, { globalAddress: globalAddress, globalWallet: globalWallet, selectedPaymentMethod: selectedPaymentMethod, setSelectedPaymentMethod: setSelectedPaymentMethod, isCreatingOrder: isCreatingOrder, onBack: () => setActivePanel(PanelView.MAIN), onSelectPaymentMethod: (method) => {
|
|
889
|
-
setSelectedPaymentMethod(method);
|
|
868
|
+
const recipientSelectionView = ((0, jsx_runtime_1.jsx)(RecipientSelection_1.RecipientSelection, { initialValue: recipientAddress || "", onBack: () => setActivePanel(PanelView.MAIN), onConfirm: address => {
|
|
869
|
+
setRecipientAddress(address);
|
|
870
|
+
setActivePanel(PanelView.MAIN);
|
|
871
|
+
} }));
|
|
872
|
+
const cryptoPaymentMethodView = ((0, jsx_runtime_1.jsx)(CryptoPaymentMethod_1.CryptoPaymentMethod, { globalAddress: globalAddress, globalWallet: globalWallet, selectedPaymentMethod: selectedCryptoPaymentMethod, setSelectedPaymentMethod: setSelectedCryptoPaymentMethod, isCreatingOrder: isCreatingOrder, onBack: () => setActivePanel(PanelView.MAIN), onSelectPaymentMethod: (method) => {
|
|
873
|
+
setSelectedCryptoPaymentMethod(method);
|
|
890
874
|
setActivePanel(PanelView.MAIN);
|
|
891
875
|
} }));
|
|
892
876
|
const fiatPaymentMethodView = ((0, jsx_runtime_1.jsx)(FiatPaymentMethod_1.FiatPaymentMethodComponent, { selectedPaymentMethod: selectedFiatPaymentMethod, setSelectedPaymentMethod: setSelectedFiatPaymentMethod, onBack: () => setActivePanel(PanelView.MAIN), onSelectPaymentMethod: (method) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { components } from "../../../anyspend/types/api";
|
|
2
2
|
import { GetQuoteResponse } from "../../../anyspend/types/api_req_res";
|
|
3
3
|
import React from "react";
|
|
4
|
-
export declare function AnySpendCustom(
|
|
4
|
+
export declare function AnySpendCustom(props: {
|
|
5
5
|
isMainnet?: boolean;
|
|
6
6
|
loadOrder?: string;
|
|
7
7
|
mode?: "modal" | "page";
|