@b3dotfun/sdk 0.0.20 → 0.0.21-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/README.md +28 -0
- package/dist/cjs/anyspend/index.native.d.ts +0 -2
- package/dist/cjs/anyspend/index.native.js +0 -4
- package/dist/cjs/anyspend/react/components/AnySpend.d.ts +3 -3
- package/dist/cjs/anyspend/react/components/AnySpend.js +43 -55
- 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/AnySpendFingerprintWrapper.d.ts +1 -1
- package/dist/cjs/anyspend/react/components/AnySpendFingerprintWrapper.js +2 -5
- 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 +50 -102
- package/dist/cjs/anyspend/react/components/common/FiatPaymentMethod.js +1 -1
- package/dist/cjs/anyspend/react/components/common/OrderDetails.d.ts +2 -2
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +7 -9
- package/dist/cjs/anyspend/react/components/common/OrderStatus.js +2 -2
- package/dist/cjs/anyspend/react/components/common/PaymentStripeWeb2.js +1 -3
- 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/common/TransferCryptoDetails.js +1 -1
- 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/anyspend/react/hooks/useSigMint.d.ts +5 -5
- package/dist/cjs/anyspend/react/index.d.ts +1 -1
- package/dist/cjs/anyspend/react/index.js +1 -1
- package/dist/cjs/anyspend/react/providers/index.d.ts +2 -0
- package/dist/cjs/anyspend/react/providers/index.js +18 -0
- package/dist/cjs/anyspend/types/api.d.ts +35 -56
- package/dist/cjs/anyspend/utils/chain.d.ts +1 -1
- package/dist/cjs/anyspend/utils/chain.js +122 -15
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +5 -1
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +2 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +2 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +3 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +4 -1
- package/dist/cjs/global-account/react/hooks/index.d.ts +1 -1
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +4 -1
- package/dist/cjs/global-account/react/hooks/useProfile.d.ts +2 -1
- package/dist/cjs/global-account/react/hooks/useProfile.js +9 -7
- package/dist/cjs/shared/constants/index.js +5 -3
- package/dist/cjs/shared/utils/formatUsername.d.ts +1 -1
- package/dist/cjs/shared/utils/formatUsername.js +3 -1
- package/dist/esm/anyspend/index.native.d.ts +0 -2
- package/dist/esm/anyspend/index.native.js +0 -4
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +3 -3
- package/dist/esm/anyspend/react/components/AnySpend.js +46 -58
- 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/AnySpendFingerprintWrapper.d.ts +1 -1
- package/dist/esm/anyspend/react/components/AnySpendFingerprintWrapper.js +2 -5
- 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 +52 -104
- package/dist/esm/anyspend/react/components/common/FiatPaymentMethod.js +1 -1
- package/dist/esm/anyspend/react/components/common/OrderDetails.d.ts +2 -2
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +8 -10
- package/dist/esm/anyspend/react/components/common/OrderStatus.js +2 -2
- package/dist/esm/anyspend/react/components/common/PaymentStripeWeb2.js +1 -3
- 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/common/TransferCryptoDetails.js +1 -1
- 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/anyspend/react/hooks/useSigMint.d.ts +5 -5
- package/dist/esm/anyspend/react/index.d.ts +1 -1
- package/dist/esm/anyspend/react/index.js +1 -1
- package/dist/esm/anyspend/react/providers/index.d.ts +2 -0
- package/dist/esm/anyspend/react/providers/index.js +2 -0
- package/dist/esm/anyspend/types/api.d.ts +35 -56
- package/dist/esm/anyspend/utils/chain.d.ts +1 -1
- package/dist/esm/anyspend/utils/chain.js +122 -15
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +5 -1
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +2 -2
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +2 -0
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +2 -2
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +4 -1
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +4 -1
- package/dist/esm/global-account/react/hooks/index.d.ts +1 -1
- package/dist/esm/global-account/react/hooks/useAuthentication.js +4 -1
- package/dist/esm/global-account/react/hooks/useProfile.d.ts +2 -1
- package/dist/esm/global-account/react/hooks/useProfile.js +9 -7
- package/dist/esm/shared/constants/index.js +5 -3
- 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/index.native.d.ts +0 -2
- package/dist/types/anyspend/react/components/AnySpend.d.ts +3 -3
- package/dist/types/anyspend/react/components/AnySpendCustom.d.ts +1 -1
- package/dist/types/anyspend/react/components/AnySpendFingerprintWrapper.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/anyspend/react/hooks/useSigMint.d.ts +5 -5
- package/dist/types/anyspend/react/index.d.ts +1 -1
- package/dist/types/anyspend/react/providers/index.d.ts +2 -0
- package/dist/types/anyspend/types/api.d.ts +35 -56
- package/dist/types/anyspend/utils/chain.d.ts +1 -1
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +5 -1
- package/dist/types/global-account/react/hooks/index.d.ts +1 -1
- package/dist/types/global-account/react/hooks/useProfile.d.ts +2 -1
- package/dist/types/shared/utils/formatUsername.d.ts +1 -1
- package/package.json +2 -2
- package/src/anyspend/index.native.ts +0 -6
- package/src/anyspend/react/components/AnySpend.tsx +110 -134
- package/src/anyspend/react/components/AnySpendCustom.tsx +488 -196
- package/src/anyspend/react/components/AnySpendFingerprintWrapper.tsx +4 -8
- 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 +76 -108
- package/src/anyspend/react/components/common/FiatPaymentMethod.tsx +1 -1
- package/src/anyspend/react/components/common/OrderDetails.tsx +12 -13
- package/src/anyspend/react/components/common/OrderStatus.tsx +2 -2
- package/src/anyspend/react/components/common/PaymentStripeWeb2.tsx +1 -3
- 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/common/TransferCryptoDetails.tsx +1 -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/anyspend/react/index.ts +1 -1
- package/src/anyspend/react/providers/index.ts +2 -0
- package/src/anyspend/types/api.ts +37 -58
- package/src/anyspend/utils/chain.ts +126 -18
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +6 -1
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +2 -0
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Privy.tsx +2 -2
- package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +4 -1
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +4 -1
- package/src/global-account/react/hooks/index.ts +1 -1
- package/src/global-account/react/hooks/useAuthentication.ts +4 -2
- package/src/global-account/react/hooks/useProfile.ts +10 -5
- package/src/shared/constants/index.ts +5 -3
- package/src/shared/utils/formatUsername.ts +3 -2
|
@@ -15,12 +15,12 @@ export declare enum PanelView {
|
|
|
15
15
|
FIAT_PAYMENT_METHOD = 7
|
|
16
16
|
}
|
|
17
17
|
export declare function AnySpend(props: {
|
|
18
|
-
destinationTokenAddress?: string;
|
|
19
|
-
destinationTokenChainId?: number;
|
|
20
18
|
isMainnet?: boolean;
|
|
21
19
|
mode?: "page" | "modal";
|
|
22
20
|
defaultActiveTab?: "crypto" | "fiat";
|
|
21
|
+
destinationTokenAddress?: string;
|
|
22
|
+
destinationTokenChainId?: number;
|
|
23
|
+
recipientAddress?: string;
|
|
23
24
|
loadOrder?: string;
|
|
24
25
|
hideTransactionHistoryButton?: boolean;
|
|
25
|
-
recipientAddress?: string;
|
|
26
26
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { getDefaultToken, USDC_BASE } from "../../../anyspend/index.js";
|
|
4
|
-
import { useAnyspendCreateOnrampOrder, useAnyspendCreateOrder, useAnyspendOrderAndTransactions, useAnyspendQuote, useGeoOnrampOptions, } from "../../../anyspend/react/index.js";
|
|
4
|
+
import { useAnyspendCreateOnrampOrder, useAnyspendCreateOrder, useAnyspendOrderAndTransactions, useAnyspendQuote, useConnectedUserProfile, useGeoOnrampOptions, } from "../../../anyspend/react/index.js";
|
|
5
5
|
import { Button, ShinyButton, StyleRoot, TransitionPanel, useAccountWallet, useProfile, useRouter, useSearchParamsSSR, useTokenData, useTokenFromUrl, } from "../../../global-account/react/index.js";
|
|
6
|
+
import { formatUsername } from "../../../shared/utils/index.js";
|
|
6
7
|
import { cn } from "../../../shared/utils/cn.js";
|
|
7
8
|
import { shortenAddress } from "../../../shared/utils/formatAddress.js";
|
|
8
9
|
import { formatDisplayNumber, formatTokenAmount } from "../../../shared/utils/number.js";
|
|
9
10
|
import invariant from "invariant";
|
|
10
|
-
import { ArrowDown,
|
|
11
|
+
import { ArrowDown, ChevronRight, ChevronRightCircle, CircleAlert, HistoryIcon } from "lucide-react";
|
|
11
12
|
import { motion } from "motion/react";
|
|
12
13
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
13
14
|
import { toast } from "sonner";
|
|
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
|
-
import { CryptoPaymentMethod,
|
|
18
|
+
import { CryptoPaymentMethod, CryptoPaymentMethodType } from "./common/CryptoPaymentMethod.js";
|
|
19
19
|
import { FiatPaymentMethod, FiatPaymentMethodComponent } from "./common/FiatPaymentMethod.js";
|
|
20
20
|
import { OrderDetails, OrderDetailsLoadingView } from "./common/OrderDetails.js";
|
|
21
21
|
import { OrderHistory } from "./common/OrderHistory.js";
|
|
@@ -23,6 +23,7 @@ import { OrderStatus } from "./common/OrderStatus.js";
|
|
|
23
23
|
import { OrderTokenAmount } from "./common/OrderTokenAmount.js";
|
|
24
24
|
import { PanelOnramp } from "./common/PanelOnramp.js";
|
|
25
25
|
import { PanelOnrampPayment } from "./common/PanelOnrampPayment.js";
|
|
26
|
+
import { RecipientSelection } from "./common/RecipientSelection.js";
|
|
26
27
|
import { TokenBalance } from "./common/TokenBalance.js";
|
|
27
28
|
export var PanelView;
|
|
28
29
|
(function (PanelView) {
|
|
@@ -43,8 +44,6 @@ export function AnySpend(props) {
|
|
|
43
44
|
function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMainnet = true, mode = "modal", defaultActiveTab = "crypto", loadOrder, hideTransactionHistoryButton, recipientAddress: recipientAddressFromProps, }) {
|
|
44
45
|
const searchParams = useSearchParamsSSR();
|
|
45
46
|
const router = useRouter();
|
|
46
|
-
// Get wagmi account state for wallet connection
|
|
47
|
-
const wagmiAccount = useAccount();
|
|
48
47
|
// Determine if we're in "buy mode" based on whether destination token props are provided
|
|
49
48
|
const isBuyMode = !!(destinationTokenAddress && destinationTokenChainId);
|
|
50
49
|
// Add refs to track URL state
|
|
@@ -57,7 +56,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
57
56
|
const [activePanel, setActivePanel] = useState(loadOrder ? PanelView.ORDER_DETAILS : PanelView.MAIN);
|
|
58
57
|
const [customRecipients, setCustomRecipients] = useState([]);
|
|
59
58
|
// Add state for selected payment method
|
|
60
|
-
const [
|
|
59
|
+
const [selectedCryptoPaymentMethod, setSelectedCryptoPaymentMethod] = useState(CryptoPaymentMethodType.NONE);
|
|
61
60
|
// Add state for selected fiat payment method
|
|
62
61
|
const [selectedFiatPaymentMethod, setSelectedFiatPaymentMethod] = useState(FiatPaymentMethod.NONE);
|
|
63
62
|
// const [newRecipientAddress, setNewRecipientAddress] = useState("");
|
|
@@ -336,8 +335,9 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
336
335
|
amount: srcAmountOnrampInWei,
|
|
337
336
|
onrampVendor: getOnrampVendor(selectedFiatPaymentMethod),
|
|
338
337
|
});
|
|
338
|
+
const { address: connectedAddress, name: connectedName, profile: connectedProfile } = useConnectedUserProfile();
|
|
339
339
|
const recipientProfile = useProfile({ address: recipientAddress });
|
|
340
|
-
const recipientName = recipientProfile.data?.name
|
|
340
|
+
const recipientName = formatUsername(recipientProfile.data?.name ?? "");
|
|
341
341
|
// Load custom recipients from local storage on mount
|
|
342
342
|
useEffect(() => {
|
|
343
343
|
try {
|
|
@@ -503,13 +503,13 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
503
503
|
// setNewRecipientAddress("");
|
|
504
504
|
setActivePanel(PanelView.ORDER_DETAILS);
|
|
505
505
|
// Debug: Check payment method before setting URL
|
|
506
|
-
console.log("Creating order -
|
|
506
|
+
console.log("Creating order - selectedCryptoPaymentMethod:", selectedCryptoPaymentMethod);
|
|
507
507
|
// Add orderId and payment method to URL for persistence
|
|
508
508
|
const params = new URLSearchParams(searchParams.toString()); // Preserve existing params
|
|
509
509
|
params.set("orderId", orderId);
|
|
510
|
-
if (
|
|
511
|
-
console.log("Setting
|
|
512
|
-
params.set("
|
|
510
|
+
if (selectedCryptoPaymentMethod !== CryptoPaymentMethodType.NONE) {
|
|
511
|
+
console.log("Setting cryptoPaymentMethod in URL:", selectedCryptoPaymentMethod);
|
|
512
|
+
params.set("cryptoPaymentMethod", selectedCryptoPaymentMethod);
|
|
513
513
|
}
|
|
514
514
|
else {
|
|
515
515
|
console.log("Payment method is NONE, not setting in URL");
|
|
@@ -553,14 +553,14 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
553
553
|
return { text: "Get rate error", disable: true, error: true };
|
|
554
554
|
if (activeTab === "crypto") {
|
|
555
555
|
// If no payment method selected, show "Choose payment method"
|
|
556
|
-
if (
|
|
556
|
+
if (selectedCryptoPaymentMethod === CryptoPaymentMethodType.NONE) {
|
|
557
557
|
return { text: "Choose payment method", disable: false, error: false };
|
|
558
558
|
}
|
|
559
559
|
// If payment method selected, show appropriate action
|
|
560
|
-
if (
|
|
560
|
+
if (selectedCryptoPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET) {
|
|
561
561
|
return { text: "Swap", disable: false, error: false };
|
|
562
562
|
}
|
|
563
|
-
if (
|
|
563
|
+
if (selectedCryptoPaymentMethod === CryptoPaymentMethodType.TRANSFER_CRYPTO) {
|
|
564
564
|
return { text: "Continue to payment", disable: false, error: false };
|
|
565
565
|
}
|
|
566
566
|
}
|
|
@@ -581,7 +581,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
581
581
|
isCreatingOnrampOrder,
|
|
582
582
|
anyspendQuote,
|
|
583
583
|
activeTab,
|
|
584
|
-
|
|
584
|
+
selectedCryptoPaymentMethod,
|
|
585
585
|
selectedFiatPaymentMethod,
|
|
586
586
|
]);
|
|
587
587
|
// Handle main button click
|
|
@@ -607,16 +607,16 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
607
607
|
}
|
|
608
608
|
if (activeTab === "crypto") {
|
|
609
609
|
// If no payment method selected, show payment method selection
|
|
610
|
-
if (
|
|
610
|
+
if (selectedCryptoPaymentMethod === CryptoPaymentMethodType.NONE) {
|
|
611
611
|
console.log("No payment method selected, showing selection panel");
|
|
612
612
|
setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD);
|
|
613
613
|
return;
|
|
614
614
|
}
|
|
615
615
|
// If payment method is selected, create order with payment method info
|
|
616
|
-
if (
|
|
617
|
-
|
|
618
|
-
console.log("Creating crypto order with payment method:",
|
|
619
|
-
await handleCryptoSwap(
|
|
616
|
+
if (selectedCryptoPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET ||
|
|
617
|
+
selectedCryptoPaymentMethod === CryptoPaymentMethodType.TRANSFER_CRYPTO) {
|
|
618
|
+
console.log("Creating crypto order with payment method:", selectedCryptoPaymentMethod);
|
|
619
|
+
await handleCryptoSwap(selectedCryptoPaymentMethod);
|
|
620
620
|
return;
|
|
621
621
|
}
|
|
622
622
|
}
|
|
@@ -642,7 +642,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
642
642
|
invariant(recipientAddress, "Recipient address is not found");
|
|
643
643
|
// Debug: Check payment method values
|
|
644
644
|
console.log("handleCryptoSwap - method parameter:", method);
|
|
645
|
-
console.log("handleCryptoSwap -
|
|
645
|
+
console.log("handleCryptoSwap - selectedCryptoPaymentMethod state:", selectedCryptoPaymentMethod);
|
|
646
646
|
const srcAmountBigInt = parseUnits(srcAmount.replace(/,/g, ""), selectedSrcToken.decimals);
|
|
647
647
|
createOrder({
|
|
648
648
|
isMainnet,
|
|
@@ -790,17 +790,17 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
790
790
|
const orderDetailsView = (_jsx("div", { className: "mx-auto w-[460px] max-w-full", children: _jsx("div", { className: "relative flex flex-col gap-4", children: oat && (_jsxs(_Fragment, { children: [_jsx(OrderStatus, { order: oat.data.order }), _jsx(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: () => {
|
|
791
791
|
setOrderId(undefined);
|
|
792
792
|
setActivePanel(PanelView.MAIN);
|
|
793
|
-
|
|
793
|
+
setSelectedCryptoPaymentMethod(CryptoPaymentMethodType.NONE); // Reset payment method when going back
|
|
794
794
|
} })] })) }) }));
|
|
795
795
|
const mainView = (_jsxs("div", { className: "mx-auto flex w-[460px] max-w-full flex-col items-center gap-2", children: [isBuyMode && (_jsxs("div", { className: "mb-4 flex flex-col items-center gap-3 text-center", children: [selectedDstToken.metadata?.logoURI && (_jsx("div", { className: "relative", children: _jsx("img", { src: selectedDstToken.metadata.logoURI, alt: selectedDstToken.symbol, className: "border-as-stroke h-12 w-12 rounded-full border-2 shadow-md" }) })), _jsx("div", { children: _jsxs("h1", { className: "text-as-primary text-xl font-bold", children: ["Buy ", selectedDstToken.symbol] }) })] })), _jsx("div", { className: "w-full", children: _jsxs("div", { className: "bg-as-surface-secondary relative mb-4 grid h-10 grid-cols-2 rounded-xl", children: [_jsx("div", { className: 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" } }), _jsx("button", { className: 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: () => {
|
|
796
796
|
setActiveTab("crypto");
|
|
797
|
-
|
|
797
|
+
setSelectedCryptoPaymentMethod(CryptoPaymentMethodType.NONE); // Reset payment method when switching to crypto
|
|
798
798
|
setSelectedFiatPaymentMethod(FiatPaymentMethod.NONE); // Reset fiat payment method when switching to crypto
|
|
799
799
|
}, children: "Pay with crypto" }), _jsx("button", { className: 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: () => {
|
|
800
800
|
setActiveTab("fiat");
|
|
801
|
-
|
|
801
|
+
setSelectedCryptoPaymentMethod(CryptoPaymentMethodType.NONE); // Reset crypto payment method when switching to fiat
|
|
802
802
|
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-
|
|
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-tertiarry flex h-7 items-center gap-2 text-sm transition-colors", onClick: () => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD), children: selectedCryptoPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET ? (_jsxs(_Fragment, { children: [connectedAddress ? (_jsxs(_Fragment, { children: [recipientProfile && (_jsx("img", { src: recipientProfile.data?.avatar || "", alt: recipientProfile.data?.name || "", className: "bg-b3-react-foreground size-7 rounded-full object-cover opacity-100" })), _jsxs("div", { className: "flex items-center gap-1", children: [recipientName && _jsx("span", { children: recipientName }), _jsx("span", { children: shortenAddress(recipientAddress || "") })] })] })) : ("Connect wallet"), _jsx(ChevronRight, { className: "h-4 w-4" })] })) : selectedCryptoPaymentMethod === CryptoPaymentMethodType.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
804
|
setIsSrcInputDirty(true);
|
|
805
805
|
setSrcAmount(value);
|
|
806
806
|
}, 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 +825,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
825
825
|
const tempDstAmount = dstAmount;
|
|
826
826
|
setSrcAmount(tempDstAmount);
|
|
827
827
|
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 ? (
|
|
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 ? (_jsx("button", { className: cn("text-as-tertiarry flex h-7 items-center gap-2 rounded-lg"), onClick: () => setActivePanel(PanelView.RECIPIENT_SELECTION), children: _jsxs(_Fragment, { children: [connectedAddress ? (_jsxs(_Fragment, { children: [connectedProfile?.data?.avatar && (_jsx("img", { src: connectedProfile.data?.avatar || "", alt: "Connected Wallet", className: "bg-as-primary h-6 w-6 rounded-full" })), _jsxs("span", { className: "text-as-tertiarry flex items-center gap-1 text-sm", children: [connectedName && _jsx("span", { children: formatUsername(connectedName) }), _jsx("span", { children: shortenAddress(connectedAddress || "") })] })] })) : ("Connect wallet"), _jsx(ChevronRight, { className: "h-4 w-4" })] }) })) : (_jsx("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" }) }))] }), isBuyMode ? (
|
|
829
829
|
// Fixed destination token display in buy mode
|
|
830
830
|
_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
831
|
setIsSrcInputDirty(false);
|
|
@@ -853,30 +853,17 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
853
853
|
if (activeTab === "fiat") {
|
|
854
854
|
params.set("paymentMethod", "fiat");
|
|
855
855
|
}
|
|
856
|
-
else if (
|
|
857
|
-
params.set("paymentMethod",
|
|
856
|
+
else if (selectedCryptoPaymentMethod !== CryptoPaymentMethodType.NONE) {
|
|
857
|
+
params.set("paymentMethod", selectedCryptoPaymentMethod);
|
|
858
858
|
}
|
|
859
859
|
router.push(`${window.location.pathname}?${params.toString()}`);
|
|
860
860
|
}, onBack: () => setActivePanel(PanelView.MAIN), recipientEnsName: globalWallet?.ensName, recipientImageUrl: globalWallet?.meta?.icon }));
|
|
861
|
-
const recipientSelectionView = (_jsx(
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
const text = await navigator.clipboard.readText();
|
|
868
|
-
setRecipientAddress(text);
|
|
869
|
-
}
|
|
870
|
-
catch (err) {
|
|
871
|
-
console.error("Failed to read clipboard:", err);
|
|
872
|
-
}
|
|
873
|
-
}, className: "text-as-primary/70 hover:text-as-primary hover:bg-as-surface-primary h-full px-4 font-semibold transition-colors", children: "Paste" }) })] }), _jsx("button", { onClick: () => {
|
|
874
|
-
if (recipientAddress) {
|
|
875
|
-
setActivePanel(PanelView.MAIN);
|
|
876
|
-
}
|
|
877
|
-
}, 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" })] })] }) }));
|
|
878
|
-
const cryptoPaymentMethodView = (_jsx(CryptoPaymentMethod, { globalAddress: globalAddress, globalWallet: globalWallet, selectedPaymentMethod: selectedPaymentMethod, setSelectedPaymentMethod: setSelectedPaymentMethod, isCreatingOrder: isCreatingOrder, onBack: () => setActivePanel(PanelView.MAIN), onSelectPaymentMethod: (method) => {
|
|
879
|
-
setSelectedPaymentMethod(method);
|
|
861
|
+
const recipientSelectionView = (_jsx(RecipientSelection, { initialValue: recipientAddress || "", onBack: () => setActivePanel(PanelView.MAIN), onConfirm: address => {
|
|
862
|
+
setRecipientAddress(address);
|
|
863
|
+
setActivePanel(PanelView.MAIN);
|
|
864
|
+
} }));
|
|
865
|
+
const cryptoPaymentMethodView = (_jsx(CryptoPaymentMethod, { globalAddress: globalAddress, globalWallet: globalWallet, selectedPaymentMethod: selectedCryptoPaymentMethod, setSelectedPaymentMethod: setSelectedCryptoPaymentMethod, isCreatingOrder: isCreatingOrder, onBack: () => setActivePanel(PanelView.MAIN), onSelectPaymentMethod: (method) => {
|
|
866
|
+
setSelectedCryptoPaymentMethod(method);
|
|
880
867
|
setActivePanel(PanelView.MAIN);
|
|
881
868
|
} }));
|
|
882
869
|
const fiatPaymentMethodView = (_jsx(FiatPaymentMethodComponent, { selectedPaymentMethod: selectedFiatPaymentMethod, setSelectedPaymentMethod: setSelectedFiatPaymentMethod, onBack: () => setActivePanel(PanelView.MAIN), onSelectPaymentMethod: (method) => {
|
|
@@ -884,26 +871,27 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
884
871
|
setActivePanel(PanelView.MAIN); // Go back to main panel to show updated pricing
|
|
885
872
|
}, srcAmountOnRamp: srcAmountOnRamp, isMainnet: isMainnet }));
|
|
886
873
|
// 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" &&
|
|
874
|
+
return (_jsx(StyleRoot, { children: _jsx("div", { className: cn("mx-auto w-full max-w-[460px]", mode === "page" &&
|
|
875
|
+
"bg-as-surface-primary border-as-border-secondary overflow-hidden rounded-2xl border shadow-xl"), children: _jsx(TransitionPanel, { activeIndex: orderId
|
|
888
876
|
? oat
|
|
889
877
|
? PanelView.ORDER_DETAILS
|
|
890
878
|
: PanelView.LOADING
|
|
891
879
|
: activePanel === PanelView.ORDER_DETAILS
|
|
892
880
|
? PanelView.MAIN
|
|
893
|
-
: activePanel, className: cn("
|
|
881
|
+
: activePanel, className: cn("rounded-2xl", {
|
|
894
882
|
"mt-0": mode === "modal",
|
|
895
883
|
}), variants: {
|
|
896
884
|
enter: { x: 300, opacity: 0 },
|
|
897
885
|
center: { x: 0, opacity: 1 },
|
|
898
886
|
exit: { x: -300, opacity: 0 },
|
|
899
887
|
}, 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"),
|
|
888
|
+
_jsx("div", { className: cn(mode === "page" && "p-6"), children: mainView }, "main-view"),
|
|
889
|
+
_jsx("div", { className: cn(mode === "page" && "p-6"), children: historyView }, "history-view"),
|
|
890
|
+
_jsx("div", { className: cn(mode === "page" && "p-6"), children: orderDetailsView }, "order-details-view"),
|
|
891
|
+
_jsx("div", { className: cn(mode === "page" && "p-6"), children: OrderDetailsLoadingView }, "loading-view"),
|
|
892
|
+
_jsx("div", { className: cn(mode === "page" && "p-6"), children: onrampPaymentView }, "fiat-payment-view"),
|
|
893
|
+
_jsx("div", { className: cn(mode === "page" && "p-6"), children: recipientSelectionView }, "recipient-selection-view"),
|
|
894
|
+
_jsx("div", { className: cn(mode === "page" && "p-6"), children: cryptoPaymentMethodView }, "crypto-payment-method-view"),
|
|
895
|
+
_jsx("div", { className: cn(mode === "page" && "p-6"), children: fiatPaymentMethodView }, "fiat-payment-method-view"),
|
|
908
896
|
] }) }) }));
|
|
909
897
|
}
|
|
@@ -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";
|