@b3dotfun/sdk 0.0.40-alpha.14 → 0.0.40-alpha.15
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.d.ts +8 -0
- package/dist/cjs/anyspend/react/components/AnySpend.js +2 -2
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.d.ts +8 -0
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +2 -2
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.d.ts +4 -1
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.js +2 -2
- package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.d.ts +4 -1
- package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.js +23 -9
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +8 -0
- package/dist/esm/anyspend/react/components/AnySpend.js +2 -2
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.d.ts +8 -0
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +2 -2
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.d.ts +4 -1
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.js +2 -2
- package/dist/esm/anyspend/react/components/common/OrderTokenAmount.d.ts +4 -1
- package/dist/esm/anyspend/react/components/common/OrderTokenAmount.js +23 -9
- package/dist/types/anyspend/react/components/AnySpend.d.ts +8 -0
- package/dist/types/anyspend/react/components/AnyspendDepositHype.d.ts +8 -0
- package/dist/types/anyspend/react/components/common/CryptoPaySection.d.ts +4 -1
- package/dist/types/anyspend/react/components/common/OrderTokenAmount.d.ts +4 -1
- package/package.json +1 -1
- package/src/anyspend/react/components/AnySpend.tsx +8 -0
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +8 -0
- package/src/anyspend/react/components/common/CryptoPaySection.tsx +4 -0
- package/src/anyspend/react/components/common/OrderTokenAmount.tsx +28 -8
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { components } from "../../types/api";
|
|
1
2
|
export interface RecipientOption {
|
|
2
3
|
address: string;
|
|
3
4
|
icon?: string;
|
|
@@ -23,4 +24,11 @@ export declare function AnySpend(props: {
|
|
|
23
24
|
recipientAddress?: string;
|
|
24
25
|
loadOrder?: string;
|
|
25
26
|
hideTransactionHistoryButton?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Called when a token is selected. Call event.preventDefault() to prevent default token selection behavior.
|
|
29
|
+
* Useful for handling special cases like B3 token selection.
|
|
30
|
+
*/
|
|
31
|
+
onTokenSelect?: (token: components["schemas"]["Token"], event: {
|
|
32
|
+
preventDefault: () => void;
|
|
33
|
+
}) => void;
|
|
26
34
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -49,7 +49,7 @@ function AnySpend(props) {
|
|
|
49
49
|
const fingerprintConfig = (0, AnySpendFingerprintWrapper_1.getFingerprintConfig)();
|
|
50
50
|
return ((0, jsx_runtime_1.jsx)(AnySpendFingerprintWrapper_1.AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: (0, jsx_runtime_1.jsx)(AnySpendInner, { ...props }) }));
|
|
51
51
|
}
|
|
52
|
-
function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode = "modal", defaultActiveTab = "crypto", loadOrder, hideTransactionHistoryButton, recipientAddress: recipientAddressFromProps, }) {
|
|
52
|
+
function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode = "modal", defaultActiveTab = "crypto", loadOrder, hideTransactionHistoryButton, recipientAddress: recipientAddressFromProps, onTokenSelect, }) {
|
|
53
53
|
const searchParams = (0, react_2.useSearchParamsSSR)();
|
|
54
54
|
const router = (0, react_2.useRouter)();
|
|
55
55
|
// Determine if we're in "buy mode" based on whether destination token props are provided
|
|
@@ -665,7 +665,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
665
665
|
setActivePanel(PanelView.MAIN);
|
|
666
666
|
setSelectedCryptoPaymentMethod(CryptoPaymentMethod_1.CryptoPaymentMethodType.NONE); // Reset payment method when going back
|
|
667
667
|
} })) }) }));
|
|
668
|
-
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)(TabSection_1.TabSection, { activeTab: activeTab, setActiveTab: setActiveTab, setSelectedCryptoPaymentMethod: setSelectedCryptoPaymentMethod, setSelectedFiatPaymentMethod: setSelectedFiatPaymentMethod }), (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.jsx)(CryptoPaySection_1.CryptoPaySection, { selectedSrcChainId: selectedSrcChainId, setSelectedSrcChainId: setSelectedSrcChainId, selectedSrcToken: selectedSrcToken, setSelectedSrcToken: setSelectedSrcToken, srcAmount: srcAmount, setSrcAmount: setSrcAmount, setIsSrcInputDirty: setIsSrcInputDirty, selectedCryptoPaymentMethod: selectedCryptoPaymentMethod, onSelectCryptoPaymentMethod: () => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD), anyspendQuote: anyspendQuote })) : ((0, jsx_runtime_1.jsx)(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" }, children: (0, jsx_runtime_1.jsx)(PanelOnramp_1.PanelOnramp, { srcAmountOnRamp: srcAmountOnRamp, setSrcAmountOnRamp: setSrcAmountOnRamp, selectedPaymentMethod: selectedFiatPaymentMethod, setActivePanel: setActivePanel, _recipientAddress: recipientAddress, destinationToken: selectedDstToken, destinationChainId: selectedDstChainId, destinationAmount: dstAmount, onDestinationTokenChange: setSelectedDstToken, onDestinationChainChange: setSelectedDstChainId, fiatPaymentMethodIndex: PanelView.FIAT_PAYMENT_METHOD, recipientSelectionPanelIndex: PanelView.RECIPIENT_SELECTION, hideDstToken: isBuyMode, anyspendQuote: anyspendQuote, onShowPointsDetail: () => setActivePanel(PanelView.POINTS_DETAIL) }) })), (0, jsx_runtime_1.jsx)(react_2.Button, { variant: "ghost", className: (0, cn_1.cn)("border-as-stroke bg-as-surface-primary absolute left-1/2 top-1/2 z-10 h-10 w-10 -translate-x-1/2 -translate-y-1/2 rounded-xl border-2 sm:h-8 sm:w-8 sm:rounded-xl", isBuyMode && "top-[calc(50%+56px)] cursor-default", activeTab === "fiat" && "hidden"), onClick: () => {
|
|
668
|
+
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)(TabSection_1.TabSection, { activeTab: activeTab, setActiveTab: setActiveTab, setSelectedCryptoPaymentMethod: setSelectedCryptoPaymentMethod, setSelectedFiatPaymentMethod: setSelectedFiatPaymentMethod }), (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.jsx)(CryptoPaySection_1.CryptoPaySection, { selectedSrcChainId: selectedSrcChainId, setSelectedSrcChainId: setSelectedSrcChainId, selectedSrcToken: selectedSrcToken, setSelectedSrcToken: setSelectedSrcToken, srcAmount: srcAmount, setSrcAmount: setSrcAmount, setIsSrcInputDirty: setIsSrcInputDirty, selectedCryptoPaymentMethod: selectedCryptoPaymentMethod, onSelectCryptoPaymentMethod: () => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD), anyspendQuote: anyspendQuote, onTokenSelect: onTokenSelect })) : ((0, jsx_runtime_1.jsx)(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" }, children: (0, jsx_runtime_1.jsx)(PanelOnramp_1.PanelOnramp, { srcAmountOnRamp: srcAmountOnRamp, setSrcAmountOnRamp: setSrcAmountOnRamp, selectedPaymentMethod: selectedFiatPaymentMethod, setActivePanel: setActivePanel, _recipientAddress: recipientAddress, destinationToken: selectedDstToken, destinationChainId: selectedDstChainId, destinationAmount: dstAmount, onDestinationTokenChange: setSelectedDstToken, onDestinationChainChange: setSelectedDstChainId, fiatPaymentMethodIndex: PanelView.FIAT_PAYMENT_METHOD, recipientSelectionPanelIndex: PanelView.RECIPIENT_SELECTION, hideDstToken: isBuyMode, anyspendQuote: anyspendQuote, onShowPointsDetail: () => setActivePanel(PanelView.POINTS_DETAIL) }) })), (0, jsx_runtime_1.jsx)(react_2.Button, { variant: "ghost", className: (0, cn_1.cn)("border-as-stroke bg-as-surface-primary absolute left-1/2 top-1/2 z-10 h-10 w-10 -translate-x-1/2 -translate-y-1/2 rounded-xl border-2 sm:h-8 sm:w-8 sm:rounded-xl", isBuyMode && "top-[calc(50%+56px)] cursor-default", activeTab === "fiat" && "hidden"), onClick: () => {
|
|
669
669
|
if (activeTab === "fiat" || isBuyMode) {
|
|
670
670
|
return;
|
|
671
671
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { components } from "../../../anyspend/types/api";
|
|
1
2
|
export declare const HYPE_TOKEN_DETAILS: {
|
|
2
3
|
SYMBOL: string;
|
|
3
4
|
LOGO_URI: string;
|
|
@@ -11,5 +12,12 @@ export interface AnySpendDepositHypeProps {
|
|
|
11
12
|
sourceTokenChainId?: number;
|
|
12
13
|
onSuccess?: () => void;
|
|
13
14
|
mainFooter?: React.ReactNode;
|
|
15
|
+
/**
|
|
16
|
+
* Called when a token is selected. Call event.preventDefault() to prevent default token selection behavior.
|
|
17
|
+
* Useful for handling special cases like B3 token selection.
|
|
18
|
+
*/
|
|
19
|
+
onTokenSelect?: (token: components["schemas"]["Token"], event: {
|
|
20
|
+
preventDefault: () => void;
|
|
21
|
+
}) => void;
|
|
14
22
|
}
|
|
15
23
|
export declare function AnySpendDepositHype(props: AnySpendDepositHypeProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -35,7 +35,7 @@ function AnySpendDepositHype(props) {
|
|
|
35
35
|
const fingerprintConfig = (0, AnySpendFingerprintWrapper_1.getFingerprintConfig)();
|
|
36
36
|
return ((0, jsx_runtime_1.jsx)(AnySpendFingerprintWrapper_1.AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: (0, jsx_runtime_1.jsx)(AnySpendDepositHypeInner, { ...props }) }));
|
|
37
37
|
}
|
|
38
|
-
function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress, paymentType = "crypto", sourceTokenAddress, sourceTokenChainId, onSuccess, mainFooter, }) {
|
|
38
|
+
function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress, paymentType = "crypto", sourceTokenAddress, sourceTokenChainId, onSuccess, mainFooter, onTokenSelect, }) {
|
|
39
39
|
// Use shared flow hook
|
|
40
40
|
const { activePanel, setActivePanel, orderId, setOrderId, oat, selectedSrcChainId, setSelectedSrcChainId, selectedSrcToken, setSelectedSrcToken, srcAmount, setSrcAmount, dstAmount, setIsSrcInputDirty, selectedCryptoPaymentMethod, setSelectedCryptoPaymentMethod, selectedFiatPaymentMethod, setSelectedFiatPaymentMethod, selectedRecipientAddress, setSelectedRecipientAddress, recipientName, globalAddress, anyspendQuote, isLoadingAnyspendQuote, getAnyspendQuoteError, activeInputAmountInWei, geoData, coinbaseAvailablePaymentMethods, stripeWeb2Support, createOrder, isCreatingOrder, createOnrampOrder, isCreatingOnrampOrder, } = (0, useAnyspendFlow_1.useAnyspendFlow)({
|
|
41
41
|
paymentType,
|
|
@@ -119,7 +119,7 @@ function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress,
|
|
|
119
119
|
await handleFiatOrder();
|
|
120
120
|
}
|
|
121
121
|
};
|
|
122
|
-
const mainView = ((0, jsx_runtime_1.jsxs)("div", { className: "mx-auto flex w-[460px] max-w-full flex-col items-center gap-2", children: [(0, jsx_runtime_1.jsx)("div", { className: "mb-4 flex flex-col items-center gap-3 text-center", children: (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)("h1", { className: "text-as-primary text-xl font-bold", children: paymentType === "crypto" ? "Deposit Crypto" : "Fund with Fiat" }) }) }), (0, jsx_runtime_1.jsx)("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: (0, jsx_runtime_1.jsxs)("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: [paymentType === "crypto" ? ((0, jsx_runtime_1.jsx)(CryptoPaySection_1.CryptoPaySection, { selectedSrcChainId: selectedSrcChainId, setSelectedSrcChainId: setSelectedSrcChainId, selectedSrcToken: selectedSrcToken, setSelectedSrcToken: setSelectedSrcToken, srcAmount: srcAmount, setSrcAmount: setSrcAmount, setIsSrcInputDirty: setIsSrcInputDirty, selectedCryptoPaymentMethod: selectedCryptoPaymentMethod, onSelectCryptoPaymentMethod: () => setActivePanel(useAnyspendFlow_1.PanelView.CRYPTO_PAYMENT_METHOD), anyspendQuote: anyspendQuote })) : ((0, jsx_runtime_1.jsx)(react_2.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" }, children: (0, jsx_runtime_1.jsx)(PanelOnramp_1.PanelOnramp, { srcAmountOnRamp: srcAmount, setSrcAmountOnRamp: setSrcAmount, selectedPaymentMethod: selectedFiatPaymentMethod, setActivePanel: setActivePanel, _recipientAddress: recipientAddress, destinationToken: anyspend_1.B3_TOKEN, destinationChainId: chains_1.base.id, dstTokenSymbol: exports.HYPE_TOKEN_DETAILS.SYMBOL, hideDstToken: true, destinationAmount: dstAmount, onDestinationTokenChange: () => { }, onDestinationChainChange: () => { }, fiatPaymentMethodIndex: useAnyspendFlow_1.PanelView.FIAT_PAYMENT_METHOD, recipientSelectionPanelIndex: useAnyspendFlow_1.PanelView.RECIPIENT_SELECTION, anyspendQuote: anyspendQuote, onShowPointsDetail: () => setActivePanel(useAnyspendFlow_1.PanelView.POINTS_DETAIL) }) })), (0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)("relative -my-1 flex h-0 items-center justify-center", paymentType === "fiat" && "hidden"), children: (0, jsx_runtime_1.jsx)(react_1.Button, { variant: "ghost", className: (0, cn_1.cn)("swap-direction-button border-as-stroke bg-as-surface-primary z-10 h-10 w-10 cursor-default rounded-xl border-2 sm:h-8 sm:w-8 sm:rounded-xl"), 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" }) }) }) }), paymentType === "crypto" && ((0, jsx_runtime_1.jsx)(CryptoReceiveSection_1.CryptoReceiveSection, { isDepositMode: false, isBuyMode: true, selectedRecipientAddress: recipientAddress, recipientName: recipientName || undefined, onSelectRecipient: () => setActivePanel(useAnyspendFlow_1.PanelView.RECIPIENT_SELECTION), dstAmount: dstAmount, dstToken: anyspend_1.B3_TOKEN, dstTokenSymbol: exports.HYPE_TOKEN_DETAILS.SYMBOL, dstTokenLogoURI: exports.HYPE_TOKEN_DETAILS.LOGO_URI, selectedDstChainId: chains_1.base.id, setSelectedDstChainId: () => { }, setSelectedDstToken: () => { }, onChangeDstAmount: value => {
|
|
122
|
+
const mainView = ((0, jsx_runtime_1.jsxs)("div", { className: "mx-auto flex w-[460px] max-w-full flex-col items-center gap-2", children: [(0, jsx_runtime_1.jsx)("div", { className: "mb-4 flex flex-col items-center gap-3 text-center", children: (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)("h1", { className: "text-as-primary text-xl font-bold", children: paymentType === "crypto" ? "Deposit Crypto" : "Fund with Fiat" }) }) }), (0, jsx_runtime_1.jsx)("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: (0, jsx_runtime_1.jsxs)("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: [paymentType === "crypto" ? ((0, jsx_runtime_1.jsx)(CryptoPaySection_1.CryptoPaySection, { selectedSrcChainId: selectedSrcChainId, setSelectedSrcChainId: setSelectedSrcChainId, selectedSrcToken: selectedSrcToken, setSelectedSrcToken: setSelectedSrcToken, srcAmount: srcAmount, setSrcAmount: setSrcAmount, setIsSrcInputDirty: setIsSrcInputDirty, selectedCryptoPaymentMethod: selectedCryptoPaymentMethod, onSelectCryptoPaymentMethod: () => setActivePanel(useAnyspendFlow_1.PanelView.CRYPTO_PAYMENT_METHOD), anyspendQuote: anyspendQuote, onTokenSelect: onTokenSelect })) : ((0, jsx_runtime_1.jsx)(react_2.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" }, children: (0, jsx_runtime_1.jsx)(PanelOnramp_1.PanelOnramp, { srcAmountOnRamp: srcAmount, setSrcAmountOnRamp: setSrcAmount, selectedPaymentMethod: selectedFiatPaymentMethod, setActivePanel: setActivePanel, _recipientAddress: recipientAddress, destinationToken: anyspend_1.B3_TOKEN, destinationChainId: chains_1.base.id, dstTokenSymbol: exports.HYPE_TOKEN_DETAILS.SYMBOL, hideDstToken: true, destinationAmount: dstAmount, onDestinationTokenChange: () => { }, onDestinationChainChange: () => { }, fiatPaymentMethodIndex: useAnyspendFlow_1.PanelView.FIAT_PAYMENT_METHOD, recipientSelectionPanelIndex: useAnyspendFlow_1.PanelView.RECIPIENT_SELECTION, anyspendQuote: anyspendQuote, onShowPointsDetail: () => setActivePanel(useAnyspendFlow_1.PanelView.POINTS_DETAIL) }) })), (0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)("relative -my-1 flex h-0 items-center justify-center", paymentType === "fiat" && "hidden"), children: (0, jsx_runtime_1.jsx)(react_1.Button, { variant: "ghost", className: (0, cn_1.cn)("swap-direction-button border-as-stroke bg-as-surface-primary z-10 h-10 w-10 cursor-default rounded-xl border-2 sm:h-8 sm:w-8 sm:rounded-xl"), 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" }) }) }) }), paymentType === "crypto" && ((0, jsx_runtime_1.jsx)(CryptoReceiveSection_1.CryptoReceiveSection, { isDepositMode: false, isBuyMode: true, selectedRecipientAddress: recipientAddress, recipientName: recipientName || undefined, onSelectRecipient: () => setActivePanel(useAnyspendFlow_1.PanelView.RECIPIENT_SELECTION), dstAmount: dstAmount, dstToken: anyspend_1.B3_TOKEN, dstTokenSymbol: exports.HYPE_TOKEN_DETAILS.SYMBOL, dstTokenLogoURI: exports.HYPE_TOKEN_DETAILS.LOGO_URI, selectedDstChainId: chains_1.base.id, setSelectedDstChainId: () => { }, setSelectedDstToken: () => { }, onChangeDstAmount: value => {
|
|
123
123
|
setIsSrcInputDirty(false);
|
|
124
124
|
setSrcAmount(value);
|
|
125
125
|
}, anyspendQuote: anyspendQuote, onShowPointsDetail: () => setActivePanel(useAnyspendFlow_1.PanelView.POINTS_DETAIL) }))] }) }), (0, jsx_runtime_1.jsx)(ErrorSection_1.ErrorSection, { error: getAnyspendQuoteError }), (0, jsx_runtime_1.jsx)(react_2.motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: (0, cn_1.cn)("mt-4 flex w-full max-w-[460px] flex-col gap-2", getAnyspendQuoteError && "mt-0"), children: (0, jsx_runtime_1.jsx)(react_1.ShinyButton, { accentColor: "hsl(var(--as-brand))", disabled: btnInfo.disable, onClick: onMainButtonClick, className: (0, cn_1.cn)("as-main-button relative w-full", btnInfo.error ? "!bg-as-red" : btnInfo.disable ? "!bg-as-on-surface-2" : "!bg-as-brand"), textClassName: (0, cn_1.cn)(btnInfo.error ? "text-white" : btnInfo.disable ? "text-as-secondary" : "text-white"), children: btnInfo.text }) }), mainFooter ? mainFooter : null] }));
|
|
@@ -11,6 +11,9 @@ interface CryptoPaySectionProps {
|
|
|
11
11
|
selectedCryptoPaymentMethod: CryptoPaymentMethodType;
|
|
12
12
|
onSelectCryptoPaymentMethod: () => void;
|
|
13
13
|
anyspendQuote?: any;
|
|
14
|
+
onTokenSelect?: (token: components["schemas"]["Token"], event: {
|
|
15
|
+
preventDefault: () => void;
|
|
16
|
+
}) => void;
|
|
14
17
|
}
|
|
15
|
-
export declare function CryptoPaySection({ selectedSrcChainId, setSelectedSrcChainId, selectedSrcToken, setSelectedSrcToken, srcAmount, setSrcAmount, setIsSrcInputDirty, selectedCryptoPaymentMethod, onSelectCryptoPaymentMethod, anyspendQuote, }: CryptoPaySectionProps): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export declare function CryptoPaySection({ selectedSrcChainId, setSelectedSrcChainId, selectedSrcToken, setSelectedSrcToken, srcAmount, setSrcAmount, setIsSrcInputDirty, selectedCryptoPaymentMethod, onSelectCryptoPaymentMethod, anyspendQuote, onTokenSelect, }: CryptoPaySectionProps): import("react/jsx-runtime").JSX.Element;
|
|
16
19
|
export {};
|
|
@@ -12,7 +12,7 @@ const react_3 = require("react");
|
|
|
12
12
|
const CryptoPaymentMethod_1 = require("./CryptoPaymentMethod");
|
|
13
13
|
const OrderTokenAmount_1 = require("./OrderTokenAmount");
|
|
14
14
|
const TokenBalance_1 = require("./TokenBalance");
|
|
15
|
-
function CryptoPaySection({ selectedSrcChainId, setSelectedSrcChainId, selectedSrcToken, setSelectedSrcToken, srcAmount, setSrcAmount, setIsSrcInputDirty, selectedCryptoPaymentMethod, onSelectCryptoPaymentMethod, anyspendQuote, }) {
|
|
15
|
+
function CryptoPaySection({ selectedSrcChainId, setSelectedSrcChainId, selectedSrcToken, setSelectedSrcToken, srcAmount, setSrcAmount, setIsSrcInputDirty, selectedCryptoPaymentMethod, onSelectCryptoPaymentMethod, anyspendQuote, onTokenSelect, }) {
|
|
16
16
|
const { connectedSmartWallet, connectedEOAWallet } = (0, react_1.useAccountWallet)();
|
|
17
17
|
const { data: srcTokenMetadata } = (0, react_1.useTokenData)(selectedSrcToken?.chainId, selectedSrcToken?.address);
|
|
18
18
|
// Determine which address to use based on payment method
|
|
@@ -48,7 +48,7 @@ function CryptoPaySection({ selectedSrcChainId, setSelectedSrcChainId, selectedS
|
|
|
48
48
|
return ((0, jsx_runtime_1.jsxs)(react_2.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: "pay-section 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 focus:!outline-none", onClick: onSelectCryptoPaymentMethod, children: selectedCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.CONNECT_WALLET ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [walletAddress ? ((0, jsx_runtime_1.jsx)("div", { className: "flex items-center gap-1", children: connectedName ? (0, utils_1.formatUsername)(connectedName) : (0, formatAddress_1.shortenAddress)(walletAddress || "") })) : ("Connect wallet"), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] })) : selectedCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.GLOBAL_WALLET ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Global Account", (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: walletAddress, context: "from", inputValue: srcAmount, onChangeInput: value => {
|
|
49
49
|
setIsSrcInputDirty(true);
|
|
50
50
|
setSrcAmount(value);
|
|
51
|
-
}, 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, {
|
|
51
|
+
}, chainId: selectedSrcChainId, setChainId: setSelectedSrcChainId, token: selectedSrcToken, setToken: setSelectedSrcToken, onTokenSelect: onTokenSelect }), (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, {
|
|
52
52
|
style: "currency",
|
|
53
53
|
fallback: "",
|
|
54
54
|
}) }), (0, jsx_runtime_1.jsx)(TokenBalance_1.TokenBalance, { token: selectedSrcToken, walletAddress: walletAddress, onChangeInput: value => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { components } from "../../../../anyspend/types/api";
|
|
2
|
-
export declare function OrderTokenAmount({ disabled, inputValue, onChangeInput, context, address, chainId, setChainId, token, setToken, hideTokenSelect, canEditAmount, className, innerClassName, amountClassName, tokenSelectClassName, }: {
|
|
2
|
+
export declare function OrderTokenAmount({ disabled, inputValue, onChangeInput, context, address, chainId, setChainId, token, setToken, hideTokenSelect, canEditAmount, className, innerClassName, amountClassName, tokenSelectClassName, onTokenSelect, }: {
|
|
3
3
|
disabled?: boolean;
|
|
4
4
|
inputValue: string;
|
|
5
5
|
onChangeInput: (value: string) => void;
|
|
@@ -15,4 +15,7 @@ export declare function OrderTokenAmount({ disabled, inputValue, onChangeInput,
|
|
|
15
15
|
innerClassName?: string;
|
|
16
16
|
amountClassName?: string;
|
|
17
17
|
tokenSelectClassName?: string;
|
|
18
|
+
onTokenSelect?: (token: components["schemas"]["Token"], event: {
|
|
19
|
+
preventDefault: () => void;
|
|
20
|
+
}) => void;
|
|
18
21
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -11,7 +11,7 @@ const react_2 = require("../../../../global-account/react");
|
|
|
11
11
|
const utils_1 = require("../../../../shared/utils");
|
|
12
12
|
const relay_kit_ui_1 = require("@reservoir0x/relay-kit-ui");
|
|
13
13
|
const ChainTokenIcon_1 = require("./ChainTokenIcon");
|
|
14
|
-
function OrderTokenAmount({ disabled, inputValue, onChangeInput, context, address, chainId, setChainId, token, setToken, hideTokenSelect = false, canEditAmount = true, className, innerClassName, amountClassName, tokenSelectClassName, }) {
|
|
14
|
+
function OrderTokenAmount({ disabled, inputValue, onChangeInput, context, address, chainId, setChainId, token, setToken, hideTokenSelect = false, canEditAmount = true, className, innerClassName, amountClassName, tokenSelectClassName, onTokenSelect, }) {
|
|
15
15
|
// Track previous token to detect changes
|
|
16
16
|
const prevTokenRef = (0, react_1.useRef)(token.address);
|
|
17
17
|
(0, react_1.useEffect)(() => {
|
|
@@ -28,19 +28,33 @@ function OrderTokenAmount({ disabled, inputValue, onChangeInput, context, addres
|
|
|
28
28
|
}
|
|
29
29
|
}, [token.address, chainId, context, onChangeInput]);
|
|
30
30
|
const handleTokenSelect = (newToken) => {
|
|
31
|
-
|
|
32
|
-
prevTokenRef.current = "changing"; // Temporary value to force effect
|
|
33
|
-
// Set the chain ID first
|
|
34
|
-
setChainId(newToken.chainId);
|
|
35
|
-
// Then set the new token
|
|
36
|
-
setToken({
|
|
31
|
+
const token = {
|
|
37
32
|
address: newToken.address,
|
|
38
|
-
chainId: newToken.chainId,
|
|
33
|
+
chainId: newToken.chainId,
|
|
39
34
|
decimals: newToken.decimals,
|
|
40
35
|
metadata: { logoURI: newToken.logoURI },
|
|
41
36
|
name: newToken.name,
|
|
42
37
|
symbol: newToken.symbol,
|
|
43
|
-
}
|
|
38
|
+
};
|
|
39
|
+
// Call the onTokenSelect callback if provided
|
|
40
|
+
if (onTokenSelect) {
|
|
41
|
+
let isDefaultPrevented = false;
|
|
42
|
+
const event = {
|
|
43
|
+
preventDefault: () => {
|
|
44
|
+
isDefaultPrevented = true;
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
onTokenSelect(token, event);
|
|
48
|
+
if (isDefaultPrevented) {
|
|
49
|
+
return; // Early return if callback prevented default behavior
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// Mark that we're about to change tokens
|
|
53
|
+
prevTokenRef.current = "changing"; // Temporary value to force effect
|
|
54
|
+
// Set the chain ID first
|
|
55
|
+
setChainId(newToken.chainId);
|
|
56
|
+
// Then set the new token
|
|
57
|
+
setToken(token);
|
|
44
58
|
// If this is the source token, reset the amount immediately
|
|
45
59
|
if (context === "from") {
|
|
46
60
|
onChangeInput("0.01");
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { components } from "../../types/api";
|
|
1
2
|
export interface RecipientOption {
|
|
2
3
|
address: string;
|
|
3
4
|
icon?: string;
|
|
@@ -23,4 +24,11 @@ export declare function AnySpend(props: {
|
|
|
23
24
|
recipientAddress?: string;
|
|
24
25
|
loadOrder?: string;
|
|
25
26
|
hideTransactionHistoryButton?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Called when a token is selected. Call event.preventDefault() to prevent default token selection behavior.
|
|
29
|
+
* Useful for handling special cases like B3 token selection.
|
|
30
|
+
*/
|
|
31
|
+
onTokenSelect?: (token: components["schemas"]["Token"], event: {
|
|
32
|
+
preventDefault: () => void;
|
|
33
|
+
}) => void;
|
|
26
34
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -42,7 +42,7 @@ export function AnySpend(props) {
|
|
|
42
42
|
const fingerprintConfig = getFingerprintConfig();
|
|
43
43
|
return (_jsx(AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: _jsx(AnySpendInner, { ...props }) }));
|
|
44
44
|
}
|
|
45
|
-
function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode = "modal", defaultActiveTab = "crypto", loadOrder, hideTransactionHistoryButton, recipientAddress: recipientAddressFromProps, }) {
|
|
45
|
+
function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode = "modal", defaultActiveTab = "crypto", loadOrder, hideTransactionHistoryButton, recipientAddress: recipientAddressFromProps, onTokenSelect, }) {
|
|
46
46
|
const searchParams = useSearchParamsSSR();
|
|
47
47
|
const router = useRouter();
|
|
48
48
|
// Determine if we're in "buy mode" based on whether destination token props are provided
|
|
@@ -658,7 +658,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
658
658
|
setActivePanel(PanelView.MAIN);
|
|
659
659
|
setSelectedCryptoPaymentMethod(CryptoPaymentMethodType.NONE); // Reset payment method when going back
|
|
660
660
|
} })) }) }));
|
|
661
|
-
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(TabSection, { activeTab: activeTab, setActiveTab: setActiveTab, setSelectedCryptoPaymentMethod: setSelectedCryptoPaymentMethod, setSelectedFiatPaymentMethod: setSelectedFiatPaymentMethod }), _jsxs("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: [activeTab === "crypto" ? (_jsx(CryptoPaySection, { selectedSrcChainId: selectedSrcChainId, setSelectedSrcChainId: setSelectedSrcChainId, selectedSrcToken: selectedSrcToken, setSelectedSrcToken: setSelectedSrcToken, srcAmount: srcAmount, setSrcAmount: setSrcAmount, setIsSrcInputDirty: setIsSrcInputDirty, selectedCryptoPaymentMethod: selectedCryptoPaymentMethod, onSelectCryptoPaymentMethod: () => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD), anyspendQuote: anyspendQuote })) : (_jsx(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" }, children: _jsx(PanelOnramp, { srcAmountOnRamp: srcAmountOnRamp, setSrcAmountOnRamp: setSrcAmountOnRamp, selectedPaymentMethod: selectedFiatPaymentMethod, setActivePanel: setActivePanel, _recipientAddress: recipientAddress, destinationToken: selectedDstToken, destinationChainId: selectedDstChainId, destinationAmount: dstAmount, onDestinationTokenChange: setSelectedDstToken, onDestinationChainChange: setSelectedDstChainId, fiatPaymentMethodIndex: PanelView.FIAT_PAYMENT_METHOD, recipientSelectionPanelIndex: PanelView.RECIPIENT_SELECTION, hideDstToken: isBuyMode, anyspendQuote: anyspendQuote, onShowPointsDetail: () => setActivePanel(PanelView.POINTS_DETAIL) }) })), _jsx(Button, { variant: "ghost", className: cn("border-as-stroke bg-as-surface-primary absolute left-1/2 top-1/2 z-10 h-10 w-10 -translate-x-1/2 -translate-y-1/2 rounded-xl border-2 sm:h-8 sm:w-8 sm:rounded-xl", isBuyMode && "top-[calc(50%+56px)] cursor-default", activeTab === "fiat" && "hidden"), onClick: () => {
|
|
661
|
+
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(TabSection, { activeTab: activeTab, setActiveTab: setActiveTab, setSelectedCryptoPaymentMethod: setSelectedCryptoPaymentMethod, setSelectedFiatPaymentMethod: setSelectedFiatPaymentMethod }), _jsxs("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: [activeTab === "crypto" ? (_jsx(CryptoPaySection, { selectedSrcChainId: selectedSrcChainId, setSelectedSrcChainId: setSelectedSrcChainId, selectedSrcToken: selectedSrcToken, setSelectedSrcToken: setSelectedSrcToken, srcAmount: srcAmount, setSrcAmount: setSrcAmount, setIsSrcInputDirty: setIsSrcInputDirty, selectedCryptoPaymentMethod: selectedCryptoPaymentMethod, onSelectCryptoPaymentMethod: () => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD), anyspendQuote: anyspendQuote, onTokenSelect: onTokenSelect })) : (_jsx(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" }, children: _jsx(PanelOnramp, { srcAmountOnRamp: srcAmountOnRamp, setSrcAmountOnRamp: setSrcAmountOnRamp, selectedPaymentMethod: selectedFiatPaymentMethod, setActivePanel: setActivePanel, _recipientAddress: recipientAddress, destinationToken: selectedDstToken, destinationChainId: selectedDstChainId, destinationAmount: dstAmount, onDestinationTokenChange: setSelectedDstToken, onDestinationChainChange: setSelectedDstChainId, fiatPaymentMethodIndex: PanelView.FIAT_PAYMENT_METHOD, recipientSelectionPanelIndex: PanelView.RECIPIENT_SELECTION, hideDstToken: isBuyMode, anyspendQuote: anyspendQuote, onShowPointsDetail: () => setActivePanel(PanelView.POINTS_DETAIL) }) })), _jsx(Button, { variant: "ghost", className: cn("border-as-stroke bg-as-surface-primary absolute left-1/2 top-1/2 z-10 h-10 w-10 -translate-x-1/2 -translate-y-1/2 rounded-xl border-2 sm:h-8 sm:w-8 sm:rounded-xl", isBuyMode && "top-[calc(50%+56px)] cursor-default", activeTab === "fiat" && "hidden"), onClick: () => {
|
|
662
662
|
if (activeTab === "fiat" || isBuyMode) {
|
|
663
663
|
return;
|
|
664
664
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { components } from "../../../anyspend/types/api";
|
|
1
2
|
export declare const HYPE_TOKEN_DETAILS: {
|
|
2
3
|
SYMBOL: string;
|
|
3
4
|
LOGO_URI: string;
|
|
@@ -11,5 +12,12 @@ export interface AnySpendDepositHypeProps {
|
|
|
11
12
|
sourceTokenChainId?: number;
|
|
12
13
|
onSuccess?: () => void;
|
|
13
14
|
mainFooter?: React.ReactNode;
|
|
15
|
+
/**
|
|
16
|
+
* Called when a token is selected. Call event.preventDefault() to prevent default token selection behavior.
|
|
17
|
+
* Useful for handling special cases like B3 token selection.
|
|
18
|
+
*/
|
|
19
|
+
onTokenSelect?: (token: components["schemas"]["Token"], event: {
|
|
20
|
+
preventDefault: () => void;
|
|
21
|
+
}) => void;
|
|
14
22
|
}
|
|
15
23
|
export declare function AnySpendDepositHype(props: AnySpendDepositHypeProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -28,7 +28,7 @@ export function AnySpendDepositHype(props) {
|
|
|
28
28
|
const fingerprintConfig = getFingerprintConfig();
|
|
29
29
|
return (_jsx(AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: _jsx(AnySpendDepositHypeInner, { ...props }) }));
|
|
30
30
|
}
|
|
31
|
-
function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress, paymentType = "crypto", sourceTokenAddress, sourceTokenChainId, onSuccess, mainFooter, }) {
|
|
31
|
+
function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress, paymentType = "crypto", sourceTokenAddress, sourceTokenChainId, onSuccess, mainFooter, onTokenSelect, }) {
|
|
32
32
|
// Use shared flow hook
|
|
33
33
|
const { activePanel, setActivePanel, orderId, setOrderId, oat, selectedSrcChainId, setSelectedSrcChainId, selectedSrcToken, setSelectedSrcToken, srcAmount, setSrcAmount, dstAmount, setIsSrcInputDirty, selectedCryptoPaymentMethod, setSelectedCryptoPaymentMethod, selectedFiatPaymentMethod, setSelectedFiatPaymentMethod, selectedRecipientAddress, setSelectedRecipientAddress, recipientName, globalAddress, anyspendQuote, isLoadingAnyspendQuote, getAnyspendQuoteError, activeInputAmountInWei, geoData, coinbaseAvailablePaymentMethods, stripeWeb2Support, createOrder, isCreatingOrder, createOnrampOrder, isCreatingOnrampOrder, } = useAnyspendFlow({
|
|
34
34
|
paymentType,
|
|
@@ -112,7 +112,7 @@ function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress,
|
|
|
112
112
|
await handleFiatOrder();
|
|
113
113
|
}
|
|
114
114
|
};
|
|
115
|
-
const mainView = (_jsxs("div", { className: "mx-auto flex w-[460px] max-w-full flex-col items-center gap-2", children: [_jsx("div", { className: "mb-4 flex flex-col items-center gap-3 text-center", children: _jsx("div", { children: _jsx("h1", { className: "text-as-primary text-xl font-bold", children: paymentType === "crypto" ? "Deposit Crypto" : "Fund with Fiat" }) }) }), _jsx("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: _jsxs("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: [paymentType === "crypto" ? (_jsx(CryptoPaySection, { selectedSrcChainId: selectedSrcChainId, setSelectedSrcChainId: setSelectedSrcChainId, selectedSrcToken: selectedSrcToken, setSelectedSrcToken: setSelectedSrcToken, srcAmount: srcAmount, setSrcAmount: setSrcAmount, setIsSrcInputDirty: setIsSrcInputDirty, selectedCryptoPaymentMethod: selectedCryptoPaymentMethod, onSelectCryptoPaymentMethod: () => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD), anyspendQuote: anyspendQuote })) : (_jsx(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" }, children: _jsx(PanelOnramp, { srcAmountOnRamp: srcAmount, setSrcAmountOnRamp: setSrcAmount, selectedPaymentMethod: selectedFiatPaymentMethod, setActivePanel: setActivePanel, _recipientAddress: recipientAddress, destinationToken: B3_TOKEN, destinationChainId: base.id, dstTokenSymbol: HYPE_TOKEN_DETAILS.SYMBOL, hideDstToken: true, destinationAmount: dstAmount, onDestinationTokenChange: () => { }, onDestinationChainChange: () => { }, fiatPaymentMethodIndex: PanelView.FIAT_PAYMENT_METHOD, recipientSelectionPanelIndex: PanelView.RECIPIENT_SELECTION, anyspendQuote: anyspendQuote, onShowPointsDetail: () => setActivePanel(PanelView.POINTS_DETAIL) }) })), _jsx("div", { className: cn("relative -my-1 flex h-0 items-center justify-center", paymentType === "fiat" && "hidden"), children: _jsx(Button, { variant: "ghost", className: cn("swap-direction-button border-as-stroke bg-as-surface-primary z-10 h-10 w-10 cursor-default rounded-xl border-2 sm:h-8 sm:w-8 sm:rounded-xl"), children: _jsx("div", { className: "relative flex items-center justify-center transition-opacity", children: _jsx(ArrowDown, { className: "text-as-primary/50 h-5 w-5" }) }) }) }), paymentType === "crypto" && (_jsx(CryptoReceiveSection, { isDepositMode: false, isBuyMode: true, selectedRecipientAddress: recipientAddress, recipientName: recipientName || undefined, onSelectRecipient: () => setActivePanel(PanelView.RECIPIENT_SELECTION), dstAmount: dstAmount, dstToken: B3_TOKEN, dstTokenSymbol: HYPE_TOKEN_DETAILS.SYMBOL, dstTokenLogoURI: HYPE_TOKEN_DETAILS.LOGO_URI, selectedDstChainId: base.id, setSelectedDstChainId: () => { }, setSelectedDstToken: () => { }, onChangeDstAmount: value => {
|
|
115
|
+
const mainView = (_jsxs("div", { className: "mx-auto flex w-[460px] max-w-full flex-col items-center gap-2", children: [_jsx("div", { className: "mb-4 flex flex-col items-center gap-3 text-center", children: _jsx("div", { children: _jsx("h1", { className: "text-as-primary text-xl font-bold", children: paymentType === "crypto" ? "Deposit Crypto" : "Fund with Fiat" }) }) }), _jsx("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: _jsxs("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: [paymentType === "crypto" ? (_jsx(CryptoPaySection, { selectedSrcChainId: selectedSrcChainId, setSelectedSrcChainId: setSelectedSrcChainId, selectedSrcToken: selectedSrcToken, setSelectedSrcToken: setSelectedSrcToken, srcAmount: srcAmount, setSrcAmount: setSrcAmount, setIsSrcInputDirty: setIsSrcInputDirty, selectedCryptoPaymentMethod: selectedCryptoPaymentMethod, onSelectCryptoPaymentMethod: () => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD), anyspendQuote: anyspendQuote, onTokenSelect: onTokenSelect })) : (_jsx(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" }, children: _jsx(PanelOnramp, { srcAmountOnRamp: srcAmount, setSrcAmountOnRamp: setSrcAmount, selectedPaymentMethod: selectedFiatPaymentMethod, setActivePanel: setActivePanel, _recipientAddress: recipientAddress, destinationToken: B3_TOKEN, destinationChainId: base.id, dstTokenSymbol: HYPE_TOKEN_DETAILS.SYMBOL, hideDstToken: true, destinationAmount: dstAmount, onDestinationTokenChange: () => { }, onDestinationChainChange: () => { }, fiatPaymentMethodIndex: PanelView.FIAT_PAYMENT_METHOD, recipientSelectionPanelIndex: PanelView.RECIPIENT_SELECTION, anyspendQuote: anyspendQuote, onShowPointsDetail: () => setActivePanel(PanelView.POINTS_DETAIL) }) })), _jsx("div", { className: cn("relative -my-1 flex h-0 items-center justify-center", paymentType === "fiat" && "hidden"), children: _jsx(Button, { variant: "ghost", className: cn("swap-direction-button border-as-stroke bg-as-surface-primary z-10 h-10 w-10 cursor-default rounded-xl border-2 sm:h-8 sm:w-8 sm:rounded-xl"), children: _jsx("div", { className: "relative flex items-center justify-center transition-opacity", children: _jsx(ArrowDown, { className: "text-as-primary/50 h-5 w-5" }) }) }) }), paymentType === "crypto" && (_jsx(CryptoReceiveSection, { isDepositMode: false, isBuyMode: true, selectedRecipientAddress: recipientAddress, recipientName: recipientName || undefined, onSelectRecipient: () => setActivePanel(PanelView.RECIPIENT_SELECTION), dstAmount: dstAmount, dstToken: B3_TOKEN, dstTokenSymbol: HYPE_TOKEN_DETAILS.SYMBOL, dstTokenLogoURI: HYPE_TOKEN_DETAILS.LOGO_URI, selectedDstChainId: base.id, setSelectedDstChainId: () => { }, setSelectedDstToken: () => { }, onChangeDstAmount: value => {
|
|
116
116
|
setIsSrcInputDirty(false);
|
|
117
117
|
setSrcAmount(value);
|
|
118
118
|
}, anyspendQuote: anyspendQuote, onShowPointsDetail: () => setActivePanel(PanelView.POINTS_DETAIL) }))] }) }), _jsx(ErrorSection, { error: getAnyspendQuoteError }), _jsx(motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: cn("mt-4 flex w-full max-w-[460px] flex-col gap-2", getAnyspendQuoteError && "mt-0"), children: _jsx(ShinyButton, { accentColor: "hsl(var(--as-brand))", disabled: btnInfo.disable, onClick: onMainButtonClick, className: cn("as-main-button relative w-full", btnInfo.error ? "!bg-as-red" : btnInfo.disable ? "!bg-as-on-surface-2" : "!bg-as-brand"), textClassName: cn(btnInfo.error ? "text-white" : btnInfo.disable ? "text-as-secondary" : "text-white"), children: btnInfo.text }) }), mainFooter ? mainFooter : null] }));
|
|
@@ -11,6 +11,9 @@ interface CryptoPaySectionProps {
|
|
|
11
11
|
selectedCryptoPaymentMethod: CryptoPaymentMethodType;
|
|
12
12
|
onSelectCryptoPaymentMethod: () => void;
|
|
13
13
|
anyspendQuote?: any;
|
|
14
|
+
onTokenSelect?: (token: components["schemas"]["Token"], event: {
|
|
15
|
+
preventDefault: () => void;
|
|
16
|
+
}) => void;
|
|
14
17
|
}
|
|
15
|
-
export declare function CryptoPaySection({ selectedSrcChainId, setSelectedSrcChainId, selectedSrcToken, setSelectedSrcToken, srcAmount, setSrcAmount, setIsSrcInputDirty, selectedCryptoPaymentMethod, onSelectCryptoPaymentMethod, anyspendQuote, }: CryptoPaySectionProps): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export declare function CryptoPaySection({ selectedSrcChainId, setSelectedSrcChainId, selectedSrcToken, setSelectedSrcToken, srcAmount, setSrcAmount, setIsSrcInputDirty, selectedCryptoPaymentMethod, onSelectCryptoPaymentMethod, anyspendQuote, onTokenSelect, }: CryptoPaySectionProps): import("react/jsx-runtime").JSX.Element;
|
|
16
19
|
export {};
|
|
@@ -9,7 +9,7 @@ import { useEffect, useRef } from "react";
|
|
|
9
9
|
import { CryptoPaymentMethodType } from "./CryptoPaymentMethod.js";
|
|
10
10
|
import { OrderTokenAmount } from "./OrderTokenAmount.js";
|
|
11
11
|
import { TokenBalance } from "./TokenBalance.js";
|
|
12
|
-
export function CryptoPaySection({ selectedSrcChainId, setSelectedSrcChainId, selectedSrcToken, setSelectedSrcToken, srcAmount, setSrcAmount, setIsSrcInputDirty, selectedCryptoPaymentMethod, onSelectCryptoPaymentMethod, anyspendQuote, }) {
|
|
12
|
+
export function CryptoPaySection({ selectedSrcChainId, setSelectedSrcChainId, selectedSrcToken, setSelectedSrcToken, srcAmount, setSrcAmount, setIsSrcInputDirty, selectedCryptoPaymentMethod, onSelectCryptoPaymentMethod, anyspendQuote, onTokenSelect, }) {
|
|
13
13
|
const { connectedSmartWallet, connectedEOAWallet } = useAccountWallet();
|
|
14
14
|
const { data: srcTokenMetadata } = useTokenData(selectedSrcToken?.chainId, selectedSrcToken?.address);
|
|
15
15
|
// Determine which address to use based on payment method
|
|
@@ -45,7 +45,7 @@ export function CryptoPaySection({ selectedSrcChainId, setSelectedSrcChainId, se
|
|
|
45
45
|
return (_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: "pay-section 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 focus:!outline-none", onClick: onSelectCryptoPaymentMethod, children: selectedCryptoPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET ? (_jsxs(_Fragment, { children: [walletAddress ? (_jsx("div", { className: "flex items-center gap-1", children: connectedName ? formatUsername(connectedName) : shortenAddress(walletAddress || "") })) : ("Connect wallet"), _jsx(ChevronRight, { className: "h-4 w-4" })] })) : selectedCryptoPaymentMethod === CryptoPaymentMethodType.GLOBAL_WALLET ? (_jsxs(_Fragment, { children: ["Global Account", _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: walletAddress, context: "from", inputValue: srcAmount, onChangeInput: value => {
|
|
46
46
|
setIsSrcInputDirty(true);
|
|
47
47
|
setSrcAmount(value);
|
|
48
|
-
}, 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, {
|
|
48
|
+
}, chainId: selectedSrcChainId, setChainId: setSelectedSrcChainId, token: selectedSrcToken, setToken: setSelectedSrcToken, onTokenSelect: onTokenSelect }), _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, {
|
|
49
49
|
style: "currency",
|
|
50
50
|
fallback: "",
|
|
51
51
|
}) }), _jsx(TokenBalance, { token: selectedSrcToken, walletAddress: walletAddress, onChangeInput: value => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { components } from "../../../../anyspend/types/api";
|
|
2
|
-
export declare function OrderTokenAmount({ disabled, inputValue, onChangeInput, context, address, chainId, setChainId, token, setToken, hideTokenSelect, canEditAmount, className, innerClassName, amountClassName, tokenSelectClassName, }: {
|
|
2
|
+
export declare function OrderTokenAmount({ disabled, inputValue, onChangeInput, context, address, chainId, setChainId, token, setToken, hideTokenSelect, canEditAmount, className, innerClassName, amountClassName, tokenSelectClassName, onTokenSelect, }: {
|
|
3
3
|
disabled?: boolean;
|
|
4
4
|
inputValue: string;
|
|
5
5
|
onChangeInput: (value: string) => void;
|
|
@@ -15,4 +15,7 @@ export declare function OrderTokenAmount({ disabled, inputValue, onChangeInput,
|
|
|
15
15
|
innerClassName?: string;
|
|
16
16
|
amountClassName?: string;
|
|
17
17
|
tokenSelectClassName?: string;
|
|
18
|
+
onTokenSelect?: (token: components["schemas"]["Token"], event: {
|
|
19
|
+
preventDefault: () => void;
|
|
20
|
+
}) => void;
|
|
18
21
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -8,7 +8,7 @@ import { Button } from "../../../../global-account/react/index.js";
|
|
|
8
8
|
import { cn } from "../../../../shared/utils/index.js";
|
|
9
9
|
import { TokenSelector } from "@reservoir0x/relay-kit-ui";
|
|
10
10
|
import { ChainTokenIcon } from "./ChainTokenIcon.js";
|
|
11
|
-
export function OrderTokenAmount({ disabled, inputValue, onChangeInput, context, address, chainId, setChainId, token, setToken, hideTokenSelect = false, canEditAmount = true, className, innerClassName, amountClassName, tokenSelectClassName, }) {
|
|
11
|
+
export function OrderTokenAmount({ disabled, inputValue, onChangeInput, context, address, chainId, setChainId, token, setToken, hideTokenSelect = false, canEditAmount = true, className, innerClassName, amountClassName, tokenSelectClassName, onTokenSelect, }) {
|
|
12
12
|
// Track previous token to detect changes
|
|
13
13
|
const prevTokenRef = useRef(token.address);
|
|
14
14
|
useEffect(() => {
|
|
@@ -25,19 +25,33 @@ export function OrderTokenAmount({ disabled, inputValue, onChangeInput, context,
|
|
|
25
25
|
}
|
|
26
26
|
}, [token.address, chainId, context, onChangeInput]);
|
|
27
27
|
const handleTokenSelect = (newToken) => {
|
|
28
|
-
|
|
29
|
-
prevTokenRef.current = "changing"; // Temporary value to force effect
|
|
30
|
-
// Set the chain ID first
|
|
31
|
-
setChainId(newToken.chainId);
|
|
32
|
-
// Then set the new token
|
|
33
|
-
setToken({
|
|
28
|
+
const token = {
|
|
34
29
|
address: newToken.address,
|
|
35
|
-
chainId: newToken.chainId,
|
|
30
|
+
chainId: newToken.chainId,
|
|
36
31
|
decimals: newToken.decimals,
|
|
37
32
|
metadata: { logoURI: newToken.logoURI },
|
|
38
33
|
name: newToken.name,
|
|
39
34
|
symbol: newToken.symbol,
|
|
40
|
-
}
|
|
35
|
+
};
|
|
36
|
+
// Call the onTokenSelect callback if provided
|
|
37
|
+
if (onTokenSelect) {
|
|
38
|
+
let isDefaultPrevented = false;
|
|
39
|
+
const event = {
|
|
40
|
+
preventDefault: () => {
|
|
41
|
+
isDefaultPrevented = true;
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
onTokenSelect(token, event);
|
|
45
|
+
if (isDefaultPrevented) {
|
|
46
|
+
return; // Early return if callback prevented default behavior
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// Mark that we're about to change tokens
|
|
50
|
+
prevTokenRef.current = "changing"; // Temporary value to force effect
|
|
51
|
+
// Set the chain ID first
|
|
52
|
+
setChainId(newToken.chainId);
|
|
53
|
+
// Then set the new token
|
|
54
|
+
setToken(token);
|
|
41
55
|
// If this is the source token, reset the amount immediately
|
|
42
56
|
if (context === "from") {
|
|
43
57
|
onChangeInput("0.01");
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { components } from "../../types/api";
|
|
1
2
|
export interface RecipientOption {
|
|
2
3
|
address: string;
|
|
3
4
|
icon?: string;
|
|
@@ -23,4 +24,11 @@ export declare function AnySpend(props: {
|
|
|
23
24
|
recipientAddress?: string;
|
|
24
25
|
loadOrder?: string;
|
|
25
26
|
hideTransactionHistoryButton?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Called when a token is selected. Call event.preventDefault() to prevent default token selection behavior.
|
|
29
|
+
* Useful for handling special cases like B3 token selection.
|
|
30
|
+
*/
|
|
31
|
+
onTokenSelect?: (token: components["schemas"]["Token"], event: {
|
|
32
|
+
preventDefault: () => void;
|
|
33
|
+
}) => void;
|
|
26
34
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
1
2
|
export declare const HYPE_TOKEN_DETAILS: {
|
|
2
3
|
SYMBOL: string;
|
|
3
4
|
LOGO_URI: string;
|
|
@@ -11,5 +12,12 @@ export interface AnySpendDepositHypeProps {
|
|
|
11
12
|
sourceTokenChainId?: number;
|
|
12
13
|
onSuccess?: () => void;
|
|
13
14
|
mainFooter?: React.ReactNode;
|
|
15
|
+
/**
|
|
16
|
+
* Called when a token is selected. Call event.preventDefault() to prevent default token selection behavior.
|
|
17
|
+
* Useful for handling special cases like B3 token selection.
|
|
18
|
+
*/
|
|
19
|
+
onTokenSelect?: (token: components["schemas"]["Token"], event: {
|
|
20
|
+
preventDefault: () => void;
|
|
21
|
+
}) => void;
|
|
14
22
|
}
|
|
15
23
|
export declare function AnySpendDepositHype(props: AnySpendDepositHypeProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -11,6 +11,9 @@ interface CryptoPaySectionProps {
|
|
|
11
11
|
selectedCryptoPaymentMethod: CryptoPaymentMethodType;
|
|
12
12
|
onSelectCryptoPaymentMethod: () => void;
|
|
13
13
|
anyspendQuote?: any;
|
|
14
|
+
onTokenSelect?: (token: components["schemas"]["Token"], event: {
|
|
15
|
+
preventDefault: () => void;
|
|
16
|
+
}) => void;
|
|
14
17
|
}
|
|
15
|
-
export declare function CryptoPaySection({ selectedSrcChainId, setSelectedSrcChainId, selectedSrcToken, setSelectedSrcToken, srcAmount, setSrcAmount, setIsSrcInputDirty, selectedCryptoPaymentMethod, onSelectCryptoPaymentMethod, anyspendQuote, }: CryptoPaySectionProps): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export declare function CryptoPaySection({ selectedSrcChainId, setSelectedSrcChainId, selectedSrcToken, setSelectedSrcToken, srcAmount, setSrcAmount, setIsSrcInputDirty, selectedCryptoPaymentMethod, onSelectCryptoPaymentMethod, anyspendQuote, onTokenSelect, }: CryptoPaySectionProps): import("react/jsx-runtime").JSX.Element;
|
|
16
19
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
2
|
-
export declare function OrderTokenAmount({ disabled, inputValue, onChangeInput, context, address, chainId, setChainId, token, setToken, hideTokenSelect, canEditAmount, className, innerClassName, amountClassName, tokenSelectClassName, }: {
|
|
2
|
+
export declare function OrderTokenAmount({ disabled, inputValue, onChangeInput, context, address, chainId, setChainId, token, setToken, hideTokenSelect, canEditAmount, className, innerClassName, amountClassName, tokenSelectClassName, onTokenSelect, }: {
|
|
3
3
|
disabled?: boolean;
|
|
4
4
|
inputValue: string;
|
|
5
5
|
onChangeInput: (value: string) => void;
|
|
@@ -15,4 +15,7 @@ export declare function OrderTokenAmount({ disabled, inputValue, onChangeInput,
|
|
|
15
15
|
innerClassName?: string;
|
|
16
16
|
amountClassName?: string;
|
|
17
17
|
tokenSelectClassName?: string;
|
|
18
|
+
onTokenSelect?: (token: components["schemas"]["Token"], event: {
|
|
19
|
+
preventDefault: () => void;
|
|
20
|
+
}) => void;
|
|
18
21
|
}): import("react/jsx-runtime").JSX.Element;
|
package/package.json
CHANGED
|
@@ -73,6 +73,11 @@ export function AnySpend(props: {
|
|
|
73
73
|
recipientAddress?: string;
|
|
74
74
|
loadOrder?: string;
|
|
75
75
|
hideTransactionHistoryButton?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Called when a token is selected. Call event.preventDefault() to prevent default token selection behavior.
|
|
78
|
+
* Useful for handling special cases like B3 token selection.
|
|
79
|
+
*/
|
|
80
|
+
onTokenSelect?: (token: components["schemas"]["Token"], event: { preventDefault: () => void }) => void;
|
|
76
81
|
}) {
|
|
77
82
|
const fingerprintConfig = getFingerprintConfig();
|
|
78
83
|
|
|
@@ -91,6 +96,7 @@ function AnySpendInner({
|
|
|
91
96
|
loadOrder,
|
|
92
97
|
hideTransactionHistoryButton,
|
|
93
98
|
recipientAddress: recipientAddressFromProps,
|
|
99
|
+
onTokenSelect,
|
|
94
100
|
}: {
|
|
95
101
|
destinationTokenAddress?: string;
|
|
96
102
|
destinationTokenChainId?: number;
|
|
@@ -99,6 +105,7 @@ function AnySpendInner({
|
|
|
99
105
|
loadOrder?: string;
|
|
100
106
|
hideTransactionHistoryButton?: boolean;
|
|
101
107
|
recipientAddress?: string;
|
|
108
|
+
onTokenSelect?: (token: components["schemas"]["Token"], event: { preventDefault: () => void }) => void;
|
|
102
109
|
}) {
|
|
103
110
|
const searchParams = useSearchParamsSSR();
|
|
104
111
|
const router = useRouter();
|
|
@@ -871,6 +878,7 @@ function AnySpendInner({
|
|
|
871
878
|
selectedCryptoPaymentMethod={selectedCryptoPaymentMethod}
|
|
872
879
|
onSelectCryptoPaymentMethod={() => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD)}
|
|
873
880
|
anyspendQuote={anyspendQuote}
|
|
881
|
+
onTokenSelect={onTokenSelect}
|
|
874
882
|
/>
|
|
875
883
|
) : (
|
|
876
884
|
<motion.div
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { B3_TOKEN } from "@b3dotfun/sdk/anyspend";
|
|
2
|
+
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
2
3
|
import { Button, ShinyButton, StyleRoot, TransitionPanel } from "@b3dotfun/sdk/global-account/react";
|
|
3
4
|
import { cn } from "@b3dotfun/sdk/shared/utils/cn";
|
|
4
5
|
import invariant from "invariant";
|
|
@@ -36,6 +37,11 @@ export interface AnySpendDepositHypeProps {
|
|
|
36
37
|
sourceTokenChainId?: number;
|
|
37
38
|
onSuccess?: () => void;
|
|
38
39
|
mainFooter?: React.ReactNode;
|
|
40
|
+
/**
|
|
41
|
+
* Called when a token is selected. Call event.preventDefault() to prevent default token selection behavior.
|
|
42
|
+
* Useful for handling special cases like B3 token selection.
|
|
43
|
+
*/
|
|
44
|
+
onTokenSelect?: (token: components["schemas"]["Token"], event: { preventDefault: () => void }) => void;
|
|
39
45
|
}
|
|
40
46
|
|
|
41
47
|
export function AnySpendDepositHype(props: AnySpendDepositHypeProps) {
|
|
@@ -57,6 +63,7 @@ function AnySpendDepositHypeInner({
|
|
|
57
63
|
sourceTokenChainId,
|
|
58
64
|
onSuccess,
|
|
59
65
|
mainFooter,
|
|
66
|
+
onTokenSelect,
|
|
60
67
|
}: AnySpendDepositHypeProps) {
|
|
61
68
|
// Use shared flow hook
|
|
62
69
|
const {
|
|
@@ -202,6 +209,7 @@ function AnySpendDepositHypeInner({
|
|
|
202
209
|
selectedCryptoPaymentMethod={selectedCryptoPaymentMethod}
|
|
203
210
|
onSelectCryptoPaymentMethod={() => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD)}
|
|
204
211
|
anyspendQuote={anyspendQuote}
|
|
212
|
+
onTokenSelect={onTokenSelect}
|
|
205
213
|
/>
|
|
206
214
|
) : (
|
|
207
215
|
<motion.div
|
|
@@ -24,6 +24,8 @@ interface CryptoPaySectionProps {
|
|
|
24
24
|
onSelectCryptoPaymentMethod: () => void;
|
|
25
25
|
// Quote data
|
|
26
26
|
anyspendQuote?: any;
|
|
27
|
+
// Token selection callback
|
|
28
|
+
onTokenSelect?: (token: components["schemas"]["Token"], event: { preventDefault: () => void }) => void;
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
export function CryptoPaySection({
|
|
@@ -37,6 +39,7 @@ export function CryptoPaySection({
|
|
|
37
39
|
selectedCryptoPaymentMethod,
|
|
38
40
|
onSelectCryptoPaymentMethod,
|
|
39
41
|
anyspendQuote,
|
|
42
|
+
onTokenSelect,
|
|
40
43
|
}: CryptoPaySectionProps) {
|
|
41
44
|
const { connectedSmartWallet, connectedEOAWallet } = useAccountWallet();
|
|
42
45
|
const { data: srcTokenMetadata } = useTokenData(selectedSrcToken?.chainId, selectedSrcToken?.address);
|
|
@@ -132,6 +135,7 @@ export function CryptoPaySection({
|
|
|
132
135
|
setChainId={setSelectedSrcChainId}
|
|
133
136
|
token={selectedSrcToken}
|
|
134
137
|
setToken={setSelectedSrcToken}
|
|
138
|
+
onTokenSelect={onTokenSelect}
|
|
135
139
|
/>
|
|
136
140
|
<div className="flex items-center justify-between">
|
|
137
141
|
<div className="text-as-primary/50 flex h-5 items-center text-sm">
|
|
@@ -27,6 +27,7 @@ export function OrderTokenAmount({
|
|
|
27
27
|
innerClassName,
|
|
28
28
|
amountClassName,
|
|
29
29
|
tokenSelectClassName,
|
|
30
|
+
onTokenSelect,
|
|
30
31
|
}: {
|
|
31
32
|
disabled?: boolean;
|
|
32
33
|
inputValue: string;
|
|
@@ -43,6 +44,7 @@ export function OrderTokenAmount({
|
|
|
43
44
|
innerClassName?: string;
|
|
44
45
|
amountClassName?: string;
|
|
45
46
|
tokenSelectClassName?: string;
|
|
47
|
+
onTokenSelect?: (token: components["schemas"]["Token"], event: { preventDefault: () => void }) => void;
|
|
46
48
|
}) {
|
|
47
49
|
// Track previous token to detect changes
|
|
48
50
|
const prevTokenRef = useRef<string>(token.address);
|
|
@@ -64,6 +66,31 @@ export function OrderTokenAmount({
|
|
|
64
66
|
}, [token.address, chainId, context, onChangeInput]);
|
|
65
67
|
|
|
66
68
|
const handleTokenSelect = (newToken: any) => {
|
|
69
|
+
const token: components["schemas"]["Token"] = {
|
|
70
|
+
address: newToken.address,
|
|
71
|
+
chainId: newToken.chainId,
|
|
72
|
+
decimals: newToken.decimals,
|
|
73
|
+
metadata: { logoURI: newToken.logoURI },
|
|
74
|
+
name: newToken.name,
|
|
75
|
+
symbol: newToken.symbol,
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// Call the onTokenSelect callback if provided
|
|
79
|
+
if (onTokenSelect) {
|
|
80
|
+
let isDefaultPrevented = false;
|
|
81
|
+
const event = {
|
|
82
|
+
preventDefault: () => {
|
|
83
|
+
isDefaultPrevented = true;
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
onTokenSelect(token, event);
|
|
88
|
+
|
|
89
|
+
if (isDefaultPrevented) {
|
|
90
|
+
return; // Early return if callback prevented default behavior
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
67
94
|
// Mark that we're about to change tokens
|
|
68
95
|
prevTokenRef.current = "changing"; // Temporary value to force effect
|
|
69
96
|
|
|
@@ -71,14 +98,7 @@ export function OrderTokenAmount({
|
|
|
71
98
|
setChainId(newToken.chainId);
|
|
72
99
|
|
|
73
100
|
// Then set the new token
|
|
74
|
-
setToken(
|
|
75
|
-
address: newToken.address,
|
|
76
|
-
chainId: newToken.chainId, // Use the new chain ID
|
|
77
|
-
decimals: newToken.decimals,
|
|
78
|
-
metadata: { logoURI: newToken.logoURI },
|
|
79
|
-
name: newToken.name,
|
|
80
|
-
symbol: newToken.symbol,
|
|
81
|
-
});
|
|
101
|
+
setToken(token);
|
|
82
102
|
|
|
83
103
|
// If this is the source token, reset the amount immediately
|
|
84
104
|
if (context === "from") {
|