@b3dotfun/sdk 0.1.2-alpha.0 → 0.1.2-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/anyspend/react/components/AnySpend.d.ts +3 -0
- package/dist/cjs/anyspend/react/components/AnySpend.js +12 -6
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.d.ts +3 -0
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.js +10 -4
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.d.ts +4 -1
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.js +19 -4
- package/dist/cjs/anyspend/react/components/QRDeposit.d.ts +4 -1
- package/dist/cjs/anyspend/react/components/QRDeposit.js +12 -4
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.js +7 -5
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +4 -3
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.js +7 -6
- package/dist/cjs/anyspend/react/components/common/FeeDetailPanel.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/common/FeeDetailPanel.js +15 -6
- package/dist/cjs/anyspend/react/components/common/FiatPaymentMethod.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/common/FiatPaymentMethod.js +10 -6
- package/dist/cjs/anyspend/react/components/common/OrderDetails.d.ts +3 -0
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +7 -4
- package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.js +3 -2
- package/dist/cjs/anyspend/react/components/common/OrderHistory.js +2 -1
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.js +2 -2
- package/dist/cjs/anyspend/react/components/common/PanelOnrampPayment.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/common/PanelOnrampPayment.js +20 -7
- package/dist/cjs/anyspend/react/components/common/PointsDetailPanel.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/common/PointsDetailPanel.js +3 -2
- package/dist/cjs/anyspend/react/components/common/RecipientSelection.d.ts +6 -1
- package/dist/cjs/anyspend/react/components/common/RecipientSelection.js +5 -2
- package/dist/cjs/anyspend/react/components/common/TabSection.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/common/TabSection.js +16 -7
- package/dist/cjs/anyspend/react/components/common/TransferCryptoDetails.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/common/TransferCryptoDetails.js +3 -2
- package/dist/cjs/anyspend/react/components/common/WarningText.d.ts +8 -7
- package/dist/cjs/anyspend/react/components/common/WarningText.js +5 -6
- package/dist/cjs/anyspend/react/components/index.d.ts +1 -0
- package/dist/cjs/anyspend/react/components/types/classes.d.ts +390 -0
- package/dist/cjs/anyspend/react/components/types/classes.js +6 -0
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +3 -0
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +3 -0
- package/dist/esm/anyspend/react/components/AnySpend.js +12 -6
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.d.ts +3 -0
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.js +10 -4
- package/dist/esm/anyspend/react/components/AnySpendDeposit.d.ts +4 -1
- package/dist/esm/anyspend/react/components/AnySpendDeposit.js +19 -4
- package/dist/esm/anyspend/react/components/QRDeposit.d.ts +4 -1
- package/dist/esm/anyspend/react/components/QRDeposit.js +12 -4
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.d.ts +3 -1
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.js +7 -5
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.d.ts +3 -1
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +4 -3
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.d.ts +3 -1
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.js +7 -6
- package/dist/esm/anyspend/react/components/common/FeeDetailPanel.d.ts +3 -1
- package/dist/esm/anyspend/react/components/common/FeeDetailPanel.js +15 -6
- package/dist/esm/anyspend/react/components/common/FiatPaymentMethod.d.ts +3 -1
- package/dist/esm/anyspend/react/components/common/FiatPaymentMethod.js +10 -6
- package/dist/esm/anyspend/react/components/common/OrderDetails.d.ts +3 -0
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +7 -4
- package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.d.ts +2 -0
- package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.js +3 -2
- package/dist/esm/anyspend/react/components/common/OrderHistory.js +2 -1
- package/dist/esm/anyspend/react/components/common/PanelOnramp.d.ts +3 -1
- package/dist/esm/anyspend/react/components/common/PanelOnramp.js +2 -2
- package/dist/esm/anyspend/react/components/common/PanelOnrampPayment.d.ts +2 -0
- package/dist/esm/anyspend/react/components/common/PanelOnrampPayment.js +20 -7
- package/dist/esm/anyspend/react/components/common/PointsDetailPanel.d.ts +3 -1
- package/dist/esm/anyspend/react/components/common/PointsDetailPanel.js +3 -2
- package/dist/esm/anyspend/react/components/common/RecipientSelection.d.ts +6 -1
- package/dist/esm/anyspend/react/components/common/RecipientSelection.js +5 -2
- package/dist/esm/anyspend/react/components/common/TabSection.d.ts +3 -1
- package/dist/esm/anyspend/react/components/common/TabSection.js +16 -7
- package/dist/esm/anyspend/react/components/common/TransferCryptoDetails.d.ts +2 -0
- package/dist/esm/anyspend/react/components/common/TransferCryptoDetails.js +3 -2
- package/dist/esm/anyspend/react/components/common/WarningText.d.ts +8 -7
- package/dist/esm/anyspend/react/components/common/WarningText.js +5 -6
- package/dist/esm/anyspend/react/components/index.d.ts +1 -0
- package/dist/esm/anyspend/react/components/types/classes.d.ts +390 -0
- package/dist/esm/anyspend/react/components/types/classes.js +5 -0
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +3 -0
- package/dist/types/anyspend/react/components/AnySpend.d.ts +3 -0
- package/dist/types/anyspend/react/components/AnySpendCustomExactIn.d.ts +3 -0
- package/dist/types/anyspend/react/components/AnySpendDeposit.d.ts +4 -1
- package/dist/types/anyspend/react/components/QRDeposit.d.ts +4 -1
- package/dist/types/anyspend/react/components/common/CryptoPaySection.d.ts +3 -1
- package/dist/types/anyspend/react/components/common/CryptoPaymentMethod.d.ts +3 -1
- package/dist/types/anyspend/react/components/common/CryptoReceiveSection.d.ts +3 -1
- package/dist/types/anyspend/react/components/common/FeeDetailPanel.d.ts +3 -1
- package/dist/types/anyspend/react/components/common/FiatPaymentMethod.d.ts +3 -1
- package/dist/types/anyspend/react/components/common/OrderDetails.d.ts +3 -0
- package/dist/types/anyspend/react/components/common/OrderDetailsCollapsible.d.ts +2 -0
- package/dist/types/anyspend/react/components/common/PanelOnramp.d.ts +3 -1
- package/dist/types/anyspend/react/components/common/PanelOnrampPayment.d.ts +2 -0
- package/dist/types/anyspend/react/components/common/PointsDetailPanel.d.ts +3 -1
- package/dist/types/anyspend/react/components/common/RecipientSelection.d.ts +6 -1
- package/dist/types/anyspend/react/components/common/TabSection.d.ts +3 -1
- package/dist/types/anyspend/react/components/common/TransferCryptoDetails.d.ts +2 -0
- package/dist/types/anyspend/react/components/common/WarningText.d.ts +8 -7
- package/dist/types/anyspend/react/components/index.d.ts +1 -0
- package/dist/types/anyspend/react/components/types/classes.d.ts +390 -0
- package/dist/types/global-account/react/stores/useModalStore.d.ts +3 -0
- package/package.json +1 -1
- package/src/anyspend/react/components/AnySpend.tsx +41 -20
- package/src/anyspend/react/components/AnySpendCustomExactIn.tsx +31 -13
- package/src/anyspend/react/components/AnySpendDeposit.tsx +171 -52
- package/src/anyspend/react/components/QRDeposit.tsx +91 -35
- package/src/anyspend/react/components/common/CryptoPaySection.tsx +31 -19
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +14 -4
- package/src/anyspend/react/components/common/CryptoReceiveSection.tsx +43 -23
- package/src/anyspend/react/components/common/FeeDetailPanel.tsx +53 -32
- package/src/anyspend/react/components/common/FiatPaymentMethod.tsx +26 -13
- package/src/anyspend/react/components/common/OrderDetails.tsx +16 -3
- package/src/anyspend/react/components/common/OrderDetailsCollapsible.tsx +5 -1
- package/src/anyspend/react/components/common/OrderHistory.tsx +2 -1
- package/src/anyspend/react/components/common/PanelOnramp.tsx +4 -1
- package/src/anyspend/react/components/common/PanelOnrampPayment.tsx +118 -40
- package/src/anyspend/react/components/common/PointsDetailPanel.tsx +28 -14
- package/src/anyspend/react/components/common/RecipientSelection.tsx +20 -5
- package/src/anyspend/react/components/common/TabSection.tsx +21 -12
- package/src/anyspend/react/components/common/TransferCryptoDetails.tsx +12 -4
- package/src/anyspend/react/components/common/WarningText.tsx +10 -10
- package/src/anyspend/react/components/index.ts +16 -0
- package/src/anyspend/react/components/types/classes.ts +476 -0
- package/src/global-account/react/stores/useModalStore.ts +3 -0
|
@@ -27,7 +27,7 @@ export function AnySpendCustomExactIn(props) {
|
|
|
27
27
|
const fingerprintConfig = getFingerprintConfig();
|
|
28
28
|
return (_jsx(AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: _jsx(AnySpendCustomExactInInner, { ...props }) }));
|
|
29
29
|
}
|
|
30
|
-
function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddress, paymentType = "crypto", sourceTokenAddress, sourceTokenChainId, destinationToken, destinationChainId, onSuccess, onOpenCustomModal, mainFooter, onTokenSelect, customUsdInputValues, preferEoa, customExactInConfig, orderType = "custom_exact_in", minDestinationAmount, header, returnToHomeUrl, customRecipientLabel, returnHomeLabel, }) {
|
|
30
|
+
function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddress, paymentType = "crypto", sourceTokenAddress, sourceTokenChainId, destinationToken, destinationChainId, onSuccess, onOpenCustomModal, mainFooter, onTokenSelect, customUsdInputValues, preferEoa, customExactInConfig, orderType = "custom_exact_in", minDestinationAmount, header, returnToHomeUrl, customRecipientLabel, returnHomeLabel, classes, }) {
|
|
31
31
|
const actionLabel = customExactInConfig?.action ?? "Custom Execution";
|
|
32
32
|
const DESTINATION_TOKEN_DETAILS = {
|
|
33
33
|
SYMBOL: destinationToken.symbol ?? "TOKEN",
|
|
@@ -179,10 +179,15 @@ function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddres
|
|
|
179
179
|
}
|
|
180
180
|
};
|
|
181
181
|
const headerContent = header ? (header({ anyspendPrice: anyspendQuote, isLoadingAnyspendPrice: isLoadingAnyspendQuote })) : (_jsx("div", { className: "mb-4 flex flex-col items-center gap-3 text-center", children: _jsxs("div", { children: [_jsx("h1", { className: "text-as-primary text-xl font-bold", children: actionLabel }), _jsx("p", { className: "text-as-secondary text-sm", children: "Pay from any token to execute a custom exact-in transaction." })] }) }));
|
|
182
|
-
const mainView = (_jsxs("div", { className:
|
|
182
|
+
const mainView = (_jsxs("div", { className: classes?.container ||
|
|
183
|
+
"anyspend-custom-exact-in-container mx-auto flex w-[460px] max-w-full flex-col items-center gap-2", children: [headerContent, _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, isSrcInputDirty: isSrcInputDirty, setIsSrcInputDirty: setIsSrcInputDirty, selectedCryptoPaymentMethod: effectiveCryptoPaymentMethod, 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: selectedRecipientOrDefault, destinationToken: selectedDstToken, destinationChainId: selectedDstChainId, dstTokenSymbol: DESTINATION_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), onShowFeeDetail: () => setActivePanel(PanelView.FEE_DETAIL), customUsdInputValues: customUsdInputValues, customRecipientLabel: customRecipientLabel }) })), _jsx("div", { className: cn("relative -my-1 flex h-0 items-center justify-center", paymentType === "fiat" && "hidden"), children: _jsx(Button, { variant: "ghost", className: classes?.swapDirectionButton ||
|
|
184
|
+
"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, effectiveRecipientAddress: selectedRecipientOrDefault, recipientName: recipientName || undefined, customRecipientLabel: customRecipientLabel, onSelectRecipient: () => setActivePanel(PanelView.RECIPIENT_SELECTION), dstAmount: dstAmount, dstToken: selectedDstToken, dstTokenSymbol: DESTINATION_TOKEN_DETAILS.SYMBOL, dstTokenLogoURI: DESTINATION_TOKEN_DETAILS.LOGO_URI, selectedDstChainId: selectedDstChainId, setSelectedDstChainId: () => { }, setSelectedDstToken: () => { }, isSrcInputDirty: isSrcInputDirty, onChangeDstAmount: value => {
|
|
183
185
|
setIsSrcInputDirty(false);
|
|
184
186
|
setSrcAmount(value);
|
|
185
|
-
}, anyspendQuote: anyspendQuote, onShowPointsDetail: () => setActivePanel(PanelView.POINTS_DETAIL), onShowFeeDetail: () => setActivePanel(PanelView.FEE_DETAIL) }))] }) }), _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"), children: _jsx(ShinyButton, { accentColor: "hsl(var(--as-brand))", disabled: btnInfo.disable, onClick: onMainButtonClick, className:
|
|
187
|
+
}, anyspendQuote: anyspendQuote, onShowPointsDetail: () => setActivePanel(PanelView.POINTS_DETAIL), onShowFeeDetail: () => setActivePanel(PanelView.FEE_DETAIL) }))] }) }), _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"), children: _jsx(ShinyButton, { accentColor: "hsl(var(--as-brand))", disabled: btnInfo.disable, onClick: onMainButtonClick, className: (btnInfo.error && classes?.mainButtonError) ||
|
|
188
|
+
(btnInfo.disable && classes?.mainButtonDisabled) ||
|
|
189
|
+
classes?.mainButton ||
|
|
190
|
+
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: _jsxs("div", { className: "flex items-center justify-center gap-2", children: [btnInfo.loading && _jsx(Loader2, { className: "h-4 w-4 animate-spin" }), btnInfo.text] }) }) }), gasPriceData && !isLoadingGas && paymentType === "crypto" && (_jsx(GasIndicator, { gasPrice: gasPriceData, className: classes?.gasIndicator || "mt-2 w-full" })), mainFooter ? mainFooter : null] }));
|
|
186
191
|
const handleCryptoOrder = async () => {
|
|
187
192
|
try {
|
|
188
193
|
invariant(anyspendQuote, "Relay price is not found");
|
|
@@ -282,7 +287,8 @@ function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddres
|
|
|
282
287
|
: anyspendQuote.data.currencyIn?.amountUsd
|
|
283
288
|
? Number(anyspendQuote.data.currencyIn.amountUsd)
|
|
284
289
|
: undefined, onBack: () => setActivePanel(PanelView.MAIN) })) : null;
|
|
285
|
-
return (_jsx(StyleRoot, { children: _jsx("div", { className:
|
|
290
|
+
return (_jsx(StyleRoot, { children: _jsx("div", { className: classes?.root ||
|
|
291
|
+
cn("anyspend-container font-inter bg-as-surface-primary mx-auto w-full max-w-[460px] p-6", mode === "page" && "border-as-border-secondary overflow-hidden rounded-2xl border shadow-xl"), children: _jsx(TransitionPanel, { activeIndex: orderId
|
|
286
292
|
? oat
|
|
287
293
|
? PanelView.ORDER_DETAILS
|
|
288
294
|
: PanelView.LOADING
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { components } from "../../../anyspend/types/api";
|
|
2
2
|
import { GetQuoteResponse } from "../../../anyspend/types/api_req_res";
|
|
3
|
+
import type { AnySpendAllClasses } from "./types/classes";
|
|
3
4
|
export interface DepositContractConfig {
|
|
4
5
|
/** Custom function ABI JSON string */
|
|
5
6
|
functionAbi: string;
|
|
@@ -94,6 +95,8 @@ export interface AnySpendDepositProps {
|
|
|
94
95
|
* Defaults to false.
|
|
95
96
|
*/
|
|
96
97
|
isCustomDeposit?: boolean;
|
|
98
|
+
/** Custom class names for styling specific elements */
|
|
99
|
+
classes?: AnySpendAllClasses;
|
|
97
100
|
}
|
|
98
101
|
/**
|
|
99
102
|
* A flexible deposit component that wraps AnySpendCustomExactIn with optional chain selection.
|
|
@@ -130,4 +133,4 @@ export interface AnySpendDepositProps {
|
|
|
130
133
|
* onSuccess={(amount) => console.log(`Deposited ${amount}`)}
|
|
131
134
|
* />
|
|
132
135
|
*/
|
|
133
|
-
export declare function AnySpendDeposit({ loadOrder, mode, recipientAddress, paymentType: initialPaymentType, sourceTokenAddress, sourceTokenChainId: initialSourceChainId, destinationTokenAddress, destinationTokenChainId, onSuccess, onOpenCustomModal, mainFooter, onTokenSelect, customUsdInputValues, preferEoa, minDestinationAmount, header, orderType, depositContractConfig, showChainSelection, supportedChains, minPoolSize, topChainsCount, onClose, returnToHomeUrl, customRecipientLabel, returnHomeLabel, isCustomDeposit, }: AnySpendDepositProps): import("react/jsx-runtime").JSX.Element | null;
|
|
136
|
+
export declare function AnySpendDeposit({ loadOrder, mode, recipientAddress, paymentType: initialPaymentType, sourceTokenAddress, sourceTokenChainId: initialSourceChainId, destinationTokenAddress, destinationTokenChainId, onSuccess, onOpenCustomModal, mainFooter, onTokenSelect, customUsdInputValues, preferEoa, minDestinationAmount, header, orderType, depositContractConfig, showChainSelection, supportedChains, minPoolSize, topChainsCount, onClose, returnToHomeUrl, customRecipientLabel, returnHomeLabel, isCustomDeposit, classes, }: AnySpendDepositProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -94,7 +94,9 @@ function ChainIcon({ chainId, className }) {
|
|
|
94
94
|
* onSuccess={(amount) => console.log(`Deposited ${amount}`)}
|
|
95
95
|
* />
|
|
96
96
|
*/
|
|
97
|
-
export function AnySpendDeposit({ loadOrder, mode = "modal", recipientAddress, paymentType: initialPaymentType, sourceTokenAddress, sourceTokenChainId: initialSourceChainId, destinationTokenAddress, destinationTokenChainId, onSuccess, onOpenCustomModal, mainFooter, onTokenSelect, customUsdInputValues, preferEoa, minDestinationAmount, header, orderType, depositContractConfig, showChainSelection, supportedChains = DEFAULT_SUPPORTED_CHAINS, minPoolSize = DEFAULT_MIN_POOL_SIZE, topChainsCount = 3, onClose, returnToHomeUrl, customRecipientLabel, returnHomeLabel, isCustomDeposit = false, }) {
|
|
97
|
+
export function AnySpendDeposit({ loadOrder, mode = "modal", recipientAddress, paymentType: initialPaymentType, sourceTokenAddress, sourceTokenChainId: initialSourceChainId, destinationTokenAddress, destinationTokenChainId, onSuccess, onOpenCustomModal, mainFooter, onTokenSelect, customUsdInputValues, preferEoa, minDestinationAmount, header, orderType, depositContractConfig, showChainSelection, supportedChains = DEFAULT_SUPPORTED_CHAINS, minPoolSize = DEFAULT_MIN_POOL_SIZE, topChainsCount = 3, onClose, returnToHomeUrl, customRecipientLabel, returnHomeLabel, isCustomDeposit = false, classes, }) {
|
|
98
|
+
// Extract deposit-specific classes for convenience
|
|
99
|
+
const depositClasses = classes?.deposit;
|
|
98
100
|
const { connectedEOAWallet } = useAccountWallet();
|
|
99
101
|
const eoaAddress = connectedEOAWallet?.getAccount()?.address;
|
|
100
102
|
// Determine if we should show chain selection
|
|
@@ -184,12 +186,25 @@ export function AnySpendDeposit({ loadOrder, mode = "modal", recipientAddress, p
|
|
|
184
186
|
};
|
|
185
187
|
// Chain selection view
|
|
186
188
|
if (step === "select-chain") {
|
|
187
|
-
return (_jsxs("div", { className:
|
|
189
|
+
return (_jsxs("div", { className: depositClasses?.chainSelection ||
|
|
190
|
+
cn("anyspend-deposit anyspend-deposit-chain-selection font-inter bg-as-surface-primary relative mx-auto w-full max-w-[460px]", mode === "page" && "border-as-border-secondary overflow-hidden rounded-2xl border shadow-xl"), children: [onClose && (_jsx("button", { onClick: onClose, className: depositClasses?.closeButton ||
|
|
191
|
+
"anyspend-deposit-close-button text-as-secondary hover:text-as-primary absolute right-4 top-4 z-10", children: _jsx("svg", { className: "h-6 w-6", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) }) })), !isBalanceLoading && totalBalance > 0 && (_jsxs("div", { className: depositClasses?.balanceContainer || "anyspend-deposit-balance border-theme-border-secondary border-b p-5", children: [_jsx("p", { className: depositClasses?.balanceLabel || "anyspend-deposit-balance-label text-as-secondary text-sm", children: "Your Balance" }), _jsxs("p", { className: depositClasses?.balanceValue || "anyspend-deposit-balance-value text-as-primary text-3xl font-semibold", children: [formatDecimal(totalBalance), " ", _jsx("span", { className: "text-sm", children: "USD" })] })] })), _jsxs("div", { className: depositClasses?.optionsContainer || "anyspend-deposit-options flex flex-col gap-2 p-6", children: [isBalanceLoading && (_jsx("div", { className: depositClasses?.chainsSkeleton || "anyspend-deposit-chains-skeleton flex flex-col gap-2", children: [1, 2].map((_, i) => (_jsxs("div", { className: depositClasses?.skeletonItem ||
|
|
192
|
+
"border-border-primary flex items-center justify-between rounded-xl border p-4", children: [_jsxs("div", { className: "flex items-center gap-3", children: [_jsx(Skeleton, { className: "h-6 w-6 rounded-full" }), _jsxs("div", { className: "flex flex-col gap-1", children: [_jsx(Skeleton, { className: "h-4 w-32" }), _jsx(Skeleton, { className: "h-3 w-20" })] })] }), _jsx(Skeleton, { className: "h-5 w-5" })] }, i))) })), topChainsWithBalance.length > 0 && (_jsx("div", { className: depositClasses?.chainsContainer || "anyspend-deposit-chains flex flex-col gap-2", children: topChainsWithBalance.map(chain => (_jsxs("button", { onClick: () => handleSelectChain(chain.id), className: depositClasses?.chainButton ||
|
|
193
|
+
"anyspend-deposit-chain-button border-border-primary hover:border-as-brand hover:bg-as-surface-secondary flex w-full items-center justify-between rounded-xl border p-4 text-left shadow-sm transition-all", children: [_jsx("div", { className: depositClasses?.chainContent || "anyspend-deposit-chain-content", children: _jsxs("div", { className: depositClasses?.chainInfo || "anyspend-deposit-chain-info", children: [_jsxs("span", { className: depositClasses?.chainName ||
|
|
194
|
+
"anyspend-deposit-chain-name text-as-primary flex items-center gap-1.5 font-medium", children: ["Deposit from ", chain.name, _jsx(ChainIcon, { chainId: chain.id, className: depositClasses?.chainIcon || "h-5 w-5" })] }), _jsxs("p", { className: depositClasses?.chainBalance || "anyspend-deposit-chain-balance text-as-secondary text-xs", children: [formatUsd(chain.balance), " available"] })] }) }), _jsx(ChevronRight, { className: depositClasses?.chainChevron || "anyspend-deposit-chain-chevron text-as-secondary h-5 w-5" })] }, chain.id))) })), _jsxs("div", { className: depositClasses?.generalOptions || "anyspend-deposit-general-options flex flex-col gap-2", children: [_jsxs("button", { onClick: handleSelectCrypto, className: depositClasses?.cryptoButton ||
|
|
195
|
+
"anyspend-deposit-option-button anyspend-deposit-crypto-button border-border-primary hover:border-as-brand hover:bg-as-surface-secondary flex w-full items-center justify-between rounded-xl border p-4 text-left shadow-sm transition-all", children: [_jsx("div", { className: depositClasses?.optionContent || "anyspend-deposit-option-content", children: _jsxs("div", { className: depositClasses?.optionInfo || "anyspend-deposit-option-info", children: [_jsx("span", { className: depositClasses?.optionTitle || "anyspend-deposit-option-title text-as-primary font-medium", children: "Deposit Crypto" }), _jsx("p", { className: depositClasses?.optionDescription ||
|
|
196
|
+
"anyspend-deposit-option-description text-as-secondary text-xs", children: "Swap from any token on any chain" })] }) }), _jsx(ChevronRight, { className: depositClasses?.optionChevron || "anyspend-deposit-option-chevron text-as-secondary h-5 w-5" })] }), _jsxs("div", { className: depositClasses?.divider || "anyspend-deposit-divider flex items-center gap-3", children: [_jsx("div", { className: depositClasses?.dividerLine || "bg-as-stroke h-px flex-1" }), _jsx("span", { className: depositClasses?.dividerText || "anyspend-deposit-divider-text text-as-secondary text-sm", children: "More options" }), _jsx("div", { className: depositClasses?.dividerLine || "bg-as-stroke h-px flex-1" })] }), _jsxs("button", { onClick: handleSelectQrDeposit, className: depositClasses?.qrButton ||
|
|
197
|
+
"anyspend-deposit-option-button anyspend-deposit-qr-button border-border-primary hover:border-as-brand hover:bg-as-surface-secondary flex w-full items-center justify-between rounded-xl border p-4 text-left shadow-sm transition-all", children: [_jsxs("div", { className: depositClasses?.optionContent || "anyspend-deposit-option-content flex items-center gap-3", children: [_jsx(QrCodeIcon, { className: depositClasses?.optionIcon || "anyspend-deposit-option-icon h-10 w-10" }), _jsxs("div", { className: depositClasses?.optionInfo || "anyspend-deposit-option-info", children: [_jsx("span", { className: depositClasses?.optionTitle || "anyspend-deposit-option-title text-as-primary font-medium", children: "Deposit with QR Code" }), _jsx("p", { className: depositClasses?.optionDescription ||
|
|
198
|
+
"anyspend-deposit-option-description text-as-secondary text-xs", children: "Send tokens directly to deposit address" })] })] }), _jsx(ChevronRight, { className: depositClasses?.optionChevron || "anyspend-deposit-option-chevron text-as-secondary h-5 w-5" })] }), _jsxs("button", { onClick: handleSelectFiat, className: depositClasses?.fiatButton ||
|
|
199
|
+
"anyspend-deposit-option-button anyspend-deposit-fiat-button border-border-primary hover:border-as-brand hover:bg-as-surface-secondary flex w-full items-center justify-between rounded-xl border p-4 text-left transition-all", children: [_jsxs("div", { className: depositClasses?.optionContent || "anyspend-deposit-option-content flex items-center gap-3", children: [_jsx(CreditCardIcon, { className: depositClasses?.optionIcon || "anyspend-deposit-option-icon h-10 w-10" }), _jsxs("div", { className: depositClasses?.optionInfo || "anyspend-deposit-option-info", children: [_jsx("span", { className: depositClasses?.optionTitle || "anyspend-deposit-option-title text-as-primary font-medium", children: "Fund with Fiat" }), _jsx("p", { className: depositClasses?.optionDescription ||
|
|
200
|
+
"anyspend-deposit-option-description text-as-secondary text-xs", children: "Pay with card or bank transfer" })] })] }), _jsx(ChevronRight, { className: depositClasses?.optionChevron || "anyspend-deposit-option-chevron text-as-secondary h-5 w-5" })] })] }), _jsx(ChainWarningText, { chainId: destinationTokenChainId, classes: classes?.chainWarningText || { root: "mt-2" } })] })] }));
|
|
188
201
|
}
|
|
189
202
|
// QR Deposit view
|
|
190
203
|
if (step === "qr-deposit") {
|
|
191
|
-
return (_jsx(QRDeposit, { mode: mode, recipientAddress: recipientAddress, destinationToken: destinationToken, destinationChainId: destinationTokenChainId, depositContractConfig: depositContractConfig, onBack: handleBack, onClose: onClose ?? handleBack }));
|
|
204
|
+
return (_jsx(QRDeposit, { mode: mode, recipientAddress: recipientAddress, destinationToken: destinationToken, destinationChainId: destinationTokenChainId, depositContractConfig: depositContractConfig, onBack: handleBack, onClose: onClose ?? handleBack, classes: classes?.qrDeposit }));
|
|
192
205
|
}
|
|
193
206
|
// Deposit view
|
|
194
|
-
return (_jsxs("div", { className: "anyspend-deposit anyspend-deposit-form relative", children: [shouldShowChainSelection && (_jsxs("button", { onClick: handleBack, className:
|
|
207
|
+
return (_jsxs("div", { className: depositClasses?.form || "anyspend-deposit anyspend-deposit-form relative", children: [shouldShowChainSelection && (_jsxs("button", { onClick: handleBack, className: depositClasses?.backButton ||
|
|
208
|
+
"anyspend-deposit-back-button text-as-secondary hover:text-as-primary absolute left-4 top-4 z-10 flex items-center gap-1", children: [_jsx("svg", { className: depositClasses?.backIcon || "anyspend-deposit-back-icon h-5 w-5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M15 19l-7-7 7-7" }) }), _jsx("span", { className: depositClasses?.backText || "anyspend-deposit-back-text text-sm", children: "Back" })] })), onClose && (_jsx("button", { onClick: onClose, className: depositClasses?.closeButton ||
|
|
209
|
+
"anyspend-deposit-close-button text-as-secondary hover:text-as-primary absolute right-4 top-4 z-10", children: _jsx("svg", { className: "h-6 w-6", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) }) })), _jsx("div", { className: depositClasses?.formContent || cn("anyspend-deposit-form-content", shouldShowChainSelection && "pt-8"), children: isCustomDeposit ? (_jsx(AnySpendCustomExactIn, { loadOrder: loadOrder, mode: mode, recipientAddress: recipientAddress, paymentType: paymentType, sourceTokenAddress: sourceTokenAddress, sourceTokenChainId: selectedChainId, destinationToken: destinationToken, destinationChainId: destinationTokenChainId, orderType: effectiveOrderType, minDestinationAmount: minDestinationAmount, header: header ?? defaultHeader, onSuccess: onSuccess, onOpenCustomModal: onOpenCustomModal, mainFooter: mainFooter, onTokenSelect: onTokenSelect, customUsdInputValues: customUsdInputValues, preferEoa: preferEoa, customExactInConfig: depositContractConfig, returnToHomeUrl: returnToHomeUrl, customRecipientLabel: customRecipientLabel, returnHomeLabel: returnHomeLabel, classes: classes?.customExactIn }, selectedChainId)) : (_jsx(AnySpend, { loadOrder: loadOrder, mode: mode, defaultActiveTab: paymentType, recipientAddress: recipientAddress, sourceChainId: selectedChainId, destinationTokenAddress: destinationTokenAddress, destinationTokenChainId: destinationTokenChainId, onSuccess: txHash => onSuccess?.(txHash ?? ""), onTokenSelect: onTokenSelect, customUsdInputValues: customUsdInputValues, hideHeader: true, hideBottomNavigation: true, disableUrlParamManagement: true, returnToHomeUrl: returnToHomeUrl, customRecipientLabel: customRecipientLabel, returnHomeLabel: returnHomeLabel, classes: classes?.anySpend }, selectedChainId)) }), _jsx(ChainWarningText, { chainId: destinationTokenChainId, classes: classes?.chainWarningText || { root: "px-4 pb-4" } })] }));
|
|
195
210
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { components } from "../../../anyspend/types/api";
|
|
2
2
|
import { DepositContractConfig } from "./AnySpendDeposit";
|
|
3
|
+
import type { QRDepositClasses } from "./types/classes";
|
|
3
4
|
export interface QRDepositProps {
|
|
4
5
|
/** Display mode */
|
|
5
6
|
mode?: "modal" | "page";
|
|
@@ -25,6 +26,8 @@ export interface QRDepositProps {
|
|
|
25
26
|
onOrderCreated?: (orderId: string) => void;
|
|
26
27
|
/** Callback when deposit is completed */
|
|
27
28
|
onSuccess?: (txHash?: string) => void;
|
|
29
|
+
/** Custom classes for styling */
|
|
30
|
+
classes?: QRDepositClasses;
|
|
28
31
|
}
|
|
29
32
|
/**
|
|
30
33
|
* A component for displaying QR code deposit functionality.
|
|
@@ -40,4 +43,4 @@ export interface QRDepositProps {
|
|
|
40
43
|
* onSuccess={(txHash) => console.log("Deposit complete:", txHash)}
|
|
41
44
|
* />
|
|
42
45
|
*/
|
|
43
|
-
export declare function QRDeposit({ mode, recipientAddress, sourceToken: sourceTokenProp, sourceChainId: sourceChainIdProp, destinationToken, destinationChainId, creatorAddress, depositContractConfig, onBack, onClose, onOrderCreated, onSuccess, }: QRDepositProps): import("react/jsx-runtime").JSX.Element;
|
|
46
|
+
export declare function QRDeposit({ mode, recipientAddress, sourceToken: sourceTokenProp, sourceChainId: sourceChainIdProp, destinationToken, destinationChainId, creatorAddress, depositContractConfig, onBack, onClose, onOrderCreated, onSuccess, classes, }: QRDepositProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -38,7 +38,7 @@ const DEFAULT_ETH_ON_BASE = {
|
|
|
38
38
|
* onSuccess={(txHash) => console.log("Deposit complete:", txHash)}
|
|
39
39
|
* />
|
|
40
40
|
*/
|
|
41
|
-
export function QRDeposit({ mode = "modal", recipientAddress, sourceToken: sourceTokenProp, sourceChainId: sourceChainIdProp, destinationToken, destinationChainId, creatorAddress, depositContractConfig, onBack, onClose, onOrderCreated, onSuccess, }) {
|
|
41
|
+
export function QRDeposit({ mode = "modal", recipientAddress, sourceToken: sourceTokenProp, sourceChainId: sourceChainIdProp, destinationToken, destinationChainId, creatorAddress, depositContractConfig, onBack, onClose, onOrderCreated, onSuccess, classes, }) {
|
|
42
42
|
const [copied, setCopied] = useState(false);
|
|
43
43
|
const [orderId, setOrderId] = useState();
|
|
44
44
|
const [globalAddress, setGlobalAddress] = useState();
|
|
@@ -159,11 +159,19 @@ export function QRDeposit({ mode = "modal", recipientAddress, sourceToken: sourc
|
|
|
159
159
|
}
|
|
160
160
|
// Show order details if order has deposits or is being processed
|
|
161
161
|
if (oat?.data && oat.data.depositTxs && oat.data.depositTxs.length > 0) {
|
|
162
|
-
return (_jsx("div", { className:
|
|
162
|
+
return (_jsx("div", { className: classes?.orderDetailsContainer ||
|
|
163
|
+
cn("anyspend-container anyspend-qr-order-details font-inter bg-as-surface-primary mx-auto w-full max-w-[460px] p-6", mode === "page" && "border-as-border-secondary overflow-hidden rounded-2xl border shadow-xl"), children: _jsx("div", { className: classes?.orderDetailsContent || "anyspend-qr-order-details-content relative flex flex-col gap-4", children: _jsx(OrderDetails, { mode: mode, order: oat.data.order, depositTxs: oat.data.depositTxs, relayTxs: oat.data.relayTxs, executeTx: oat.data.executeTx, refundTxs: oat.data.refundTxs, onBack: handleBack }) }) }));
|
|
163
164
|
}
|
|
164
165
|
// Show loading state while creating order (but not if we already have an orderId or for pure transfers)
|
|
165
166
|
if (isCreatingOrder && !orderId && !isPureTransfer) {
|
|
166
|
-
return (_jsx("div", { className:
|
|
167
|
+
return (_jsx("div", { className: classes?.loadingContainer ||
|
|
168
|
+
cn("anyspend-container anyspend-qr-loading font-inter bg-as-surface-primary mx-auto w-full max-w-[460px] p-6", mode === "page" && "border-as-border-secondary overflow-hidden rounded-2xl border shadow-xl"), children: _jsxs("div", { className: classes?.loadingContent ||
|
|
169
|
+
"anyspend-qr-loading-content flex flex-col items-center justify-center gap-4 py-12", children: [_jsx(Loader2, { className: classes?.loadingSpinner || "anyspend-qr-loading-spinner text-as-brand h-8 w-8 animate-spin" }), _jsx("p", { className: classes?.loadingText || "anyspend-qr-loading-text text-as-secondary text-sm", children: "Creating deposit order..." })] }) }));
|
|
167
170
|
}
|
|
168
|
-
return (_jsx("div", { className:
|
|
171
|
+
return (_jsx("div", { className: classes?.container ||
|
|
172
|
+
cn("anyspend-container anyspend-qr-deposit font-inter bg-as-surface-primary mx-auto w-full max-w-[460px] p-6", mode === "page" && "border-as-border-secondary overflow-hidden rounded-2xl border shadow-xl"), children: _jsxs("div", { className: classes?.content || "anyspend-qr-deposit-content flex flex-col gap-4", children: [_jsxs("div", { className: classes?.header || "anyspend-qr-header flex items-center justify-between", children: [_jsx("button", { onClick: handleBack, className: classes?.backButton || "anyspend-qr-back-button text-as-secondary hover:text-as-primary", children: _jsx("svg", { className: "h-5 w-5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M15 19l-7-7 7-7" }) }) }), _jsx("h2", { className: classes?.title || "anyspend-qr-title text-as-primary text-base font-semibold", children: "Deposit" }), onClose ? (_jsx("button", { onClick: handleClose, className: classes?.closeButton || "anyspend-qr-close-button text-as-secondary hover:text-as-primary", children: _jsx("svg", { className: "h-5 w-5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) }) })) : (_jsx("div", { className: "w-5" }))] }), _jsxs("div", { className: classes?.tokenSelectorContainer || "anyspend-qr-token-selector flex flex-col gap-1.5", children: [_jsx("label", { className: classes?.tokenSelectorLabel || "anyspend-qr-token-label text-as-secondary text-sm", children: "Send" }), _jsx(TokenSelector, { chainIdsFilter: getAvailableChainIds("from"), context: "from", fromChainWalletVMSupported: true, isValidAddress: true, lockedChainIds: getAvailableChainIds("from"), multiWalletSupportEnabled: true, onAnalyticEvent: undefined, setToken: handleTokenSelect, supportedWalletVMs: ["evm"], token: undefined, trigger: _jsxs(Button, { variant: "outline", role: "combobox", className: classes?.tokenSelectorTrigger ||
|
|
173
|
+
"anyspend-qr-token-trigger border-as-stroke bg-as-surface-secondary flex h-auto w-full items-center justify-between gap-2 rounded-xl border px-3 py-2.5", children: [_jsxs("div", { className: "flex items-center gap-2", children: [sourceToken.metadata?.logoURI ? (_jsx(ChainTokenIcon, { chainUrl: ALL_CHAINS[sourceChainId]?.logoUrl, tokenUrl: sourceToken.metadata.logoURI, className: "h-8 min-h-8 w-8 min-w-8" })) : (_jsx("div", { className: "h-8 w-8 rounded-full bg-gray-700" })), _jsxs("div", { className: "flex flex-col items-start gap-0", children: [_jsx("div", { className: "text-as-primary font-semibold", children: sourceToken.symbol }), _jsx("div", { className: "text-as-primary/70 text-xs", children: ALL_CHAINS[sourceChainId]?.name ?? "Unknown" })] })] }), _jsx(ChevronsUpDown, { className: "h-4 w-4 shrink-0 opacity-70" })] }) })] }), _jsxs("div", { className: classes?.qrContent || "anyspend-qr-content border-as-stroke flex items-start gap-4 rounded-xl border p-4", children: [_jsxs("div", { className: classes?.qrCodeContainer || "anyspend-qr-code-container flex flex-col items-center gap-2", children: [_jsx("div", { className: classes?.qrCode || "anyspend-qr-code rounded-lg bg-white p-2", children: _jsx(QRCodeSVG, { value: displayAddress, size: 120, level: "M", marginSize: 0 }) }), _jsxs("span", { className: classes?.qrScanHint || "anyspend-qr-scan-hint text-as-secondary text-xs", children: ["SCAN WITH ", _jsx("span", { className: "inline-block", children: "\uD83E\uDD8A" })] })] }), _jsxs("div", { className: classes?.addressContainer || "anyspend-qr-address-container flex flex-1 flex-col gap-1", children: [_jsx("span", { className: classes?.addressLabel || "anyspend-qr-address-label text-as-secondary text-sm", children: "Deposit address:" }), _jsxs("div", { className: classes?.addressRow || "anyspend-qr-address-row flex items-start gap-1", children: [_jsx("span", { className: classes?.address || "anyspend-qr-address text-as-primary break-all font-mono text-sm leading-relaxed", children: displayAddress }), _jsx("button", { onClick: handleCopyAddress, className: classes?.addressCopyIcon ||
|
|
174
|
+
"anyspend-qr-copy-icon text-as-secondary hover:text-as-primary mt-0.5 shrink-0", children: copied ? _jsx(Check, { className: "h-4 w-4" }) : _jsx(Copy, { className: "h-4 w-4" }) })] })] })] }), _jsx(ChainWarningText, { chainId: destinationChainId }), _jsxs(WarningText, { children: ["Only send ", sourceToken.symbol, " on ", ALL_CHAINS[sourceChainId]?.name ?? "the specified chain", ". Other tokens will not be converted."] }), isPureTransfer && isWatchingTransfer && (_jsxs("div", { className: classes?.watchingIndicator ||
|
|
175
|
+
"anyspend-qr-watching flex items-center justify-center gap-2 rounded-lg bg-blue-500/10 p-3", children: [_jsx(Loader2, { className: "h-4 w-4 animate-spin text-blue-500" }), _jsx("span", { className: "text-sm text-blue-500", children: "Watching for incoming transfer..." })] })), _jsx("button", { onClick: handleCopyAddress, className: classes?.copyButton ||
|
|
176
|
+
"anyspend-qr-copy-button flex w-full items-center justify-center gap-2 rounded-xl bg-blue-500 py-3.5 font-medium text-white transition-all hover:bg-blue-600", children: "Copy deposit address" })] }) }));
|
|
169
177
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { components } from "../../../types/api";
|
|
2
|
+
import type { CryptoPaySectionClasses } from "../types/classes";
|
|
2
3
|
import { CryptoPaymentMethodType } from "./CryptoPaymentMethod";
|
|
3
4
|
interface CryptoPaySectionProps {
|
|
4
5
|
selectedSrcChainId: number;
|
|
@@ -16,6 +17,7 @@ interface CryptoPaySectionProps {
|
|
|
16
17
|
preventDefault: () => void;
|
|
17
18
|
}) => void;
|
|
18
19
|
onShowFeeDetail?: () => void;
|
|
20
|
+
classes?: CryptoPaySectionClasses;
|
|
19
21
|
}
|
|
20
|
-
export declare function CryptoPaySection({ selectedSrcChainId, setSelectedSrcChainId, selectedSrcToken, setSelectedSrcToken, srcAmount, setSrcAmount, isSrcInputDirty, setIsSrcInputDirty, selectedCryptoPaymentMethod, onSelectCryptoPaymentMethod, anyspendQuote, onTokenSelect, onShowFeeDetail, }: CryptoPaySectionProps): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export declare function CryptoPaySection({ selectedSrcChainId, setSelectedSrcChainId, selectedSrcToken, setSelectedSrcToken, srcAmount, setSrcAmount, isSrcInputDirty, setIsSrcInputDirty, selectedCryptoPaymentMethod, onSelectCryptoPaymentMethod, anyspendQuote, onTokenSelect, onShowFeeDetail, classes, }: CryptoPaySectionProps): import("react/jsx-runtime").JSX.Element;
|
|
21
23
|
export {};
|
|
@@ -8,7 +8,7 @@ import { useConnectedWalletDisplay } from "../../hooks/useConnectedWalletDisplay
|
|
|
8
8
|
import { CryptoPaymentMethodDisplay } from "./CryptoPaymentMethodDisplay.js";
|
|
9
9
|
import { OrderTokenAmount } from "./OrderTokenAmount.js";
|
|
10
10
|
import { TokenBalance } from "./TokenBalance.js";
|
|
11
|
-
export function CryptoPaySection({ selectedSrcChainId, setSelectedSrcChainId, selectedSrcToken, setSelectedSrcToken, srcAmount, setSrcAmount, isSrcInputDirty, setIsSrcInputDirty, selectedCryptoPaymentMethod, onSelectCryptoPaymentMethod, anyspendQuote, onTokenSelect, onShowFeeDetail, }) {
|
|
11
|
+
export function CryptoPaySection({ selectedSrcChainId, setSelectedSrcChainId, selectedSrcToken, setSelectedSrcToken, srcAmount, setSrcAmount, isSrcInputDirty, setIsSrcInputDirty, selectedCryptoPaymentMethod, onSelectCryptoPaymentMethod, anyspendQuote, onTokenSelect, onShowFeeDetail, classes, }) {
|
|
12
12
|
const { data: srcTokenMetadata } = useTokenData(selectedSrcToken?.chainId, selectedSrcToken?.address);
|
|
13
13
|
// Use custom hook to determine wallet address based on payment method
|
|
14
14
|
const { walletAddress } = useConnectedWalletDisplay(selectedCryptoPaymentMethod);
|
|
@@ -38,10 +38,12 @@ export function CryptoPaySection({ selectedSrcChainId, setSelectedSrcChainId, se
|
|
|
38
38
|
useEffect(() => {
|
|
39
39
|
appliedSrcMetadataRef.current = false;
|
|
40
40
|
}, [selectedSrcToken.address, selectedSrcToken.chainId]);
|
|
41
|
-
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:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
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: classes?.container ||
|
|
42
|
+
"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: [_jsxs("div", { className: classes?.label || "text-as-primary/50 flex h-7 items-center gap-1.5 text-sm", children: ["Pay", !isSrcInputDirty && anyspendQuote?.data?.fee && onShowFeeDetail && (_jsx("button", { onClick: onShowFeeDetail, className: "text-as-primary/40 hover:text-as-primary/60 transition-colors", children: _jsx(Info, { className: "h-4 w-4" }) }))] }), _jsx("button", { className: classes?.paymentMethodButton ||
|
|
43
|
+
"text-as-tertiarry flex h-7 items-center gap-2 text-sm transition-colors focus:!outline-none", onClick: onSelectCryptoPaymentMethod, children: _jsx(CryptoPaymentMethodDisplay, { paymentMethod: selectedCryptoPaymentMethod, connectedAddress: walletAddress, connectedName: connectedName }) })] }), _jsx("div", { className: classes?.inputContainer, children: _jsx(OrderTokenAmount, { address: walletAddress, walletAddress: walletAddress, context: "from", inputValue: srcAmount, onChangeInput: value => {
|
|
44
|
+
setIsSrcInputDirty(true);
|
|
45
|
+
setSrcAmount(value);
|
|
46
|
+
}, chainId: selectedSrcChainId, setChainId: setSelectedSrcChainId, token: selectedSrcToken, setToken: setSelectedSrcToken, onTokenSelect: onTokenSelect }) }), _jsxs("div", { className: classes?.balanceRow || "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, {
|
|
45
47
|
style: "currency",
|
|
46
48
|
fallback: "",
|
|
47
49
|
}) }), _jsx(TokenBalance, { token: selectedSrcToken, walletAddress: walletAddress, onChangeInput: value => {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CryptoPaymentMethodClasses } from "../types/classes";
|
|
1
2
|
export declare enum CryptoPaymentMethodType {
|
|
2
3
|
NONE = "none",
|
|
3
4
|
CONNECT_WALLET = "connect_wallet",
|
|
@@ -10,6 +11,7 @@ interface CryptoPaymentMethodProps {
|
|
|
10
11
|
isCreatingOrder: boolean;
|
|
11
12
|
onBack: () => void;
|
|
12
13
|
onSelectPaymentMethod: (method: CryptoPaymentMethodType) => void;
|
|
14
|
+
classes?: CryptoPaymentMethodClasses;
|
|
13
15
|
}
|
|
14
|
-
export declare function CryptoPaymentMethod({ selectedPaymentMethod, setSelectedPaymentMethod, isCreatingOrder, onBack, onSelectPaymentMethod, }: CryptoPaymentMethodProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export declare function CryptoPaymentMethod({ selectedPaymentMethod, setSelectedPaymentMethod, isCreatingOrder, onBack, onSelectPaymentMethod, classes, }: CryptoPaymentMethodProps): import("react/jsx-runtime").JSX.Element;
|
|
15
17
|
export {};
|
|
@@ -21,7 +21,7 @@ const recommendWallets = [
|
|
|
21
21
|
createWallet("me.rainbow"),
|
|
22
22
|
createWallet("io.rabby"),
|
|
23
23
|
];
|
|
24
|
-
export function CryptoPaymentMethod({ selectedPaymentMethod, setSelectedPaymentMethod, isCreatingOrder, onBack, onSelectPaymentMethod, }) {
|
|
24
|
+
export function CryptoPaymentMethod({ selectedPaymentMethod, setSelectedPaymentMethod, isCreatingOrder, onBack, onSelectPaymentMethod, classes, }) {
|
|
25
25
|
const { connectedEOAWallet, connectedSmartWallet } = useAccountWallet();
|
|
26
26
|
const { disconnect } = useDisconnect();
|
|
27
27
|
const { connect: openConnectModal } = useConnectModal();
|
|
@@ -72,11 +72,12 @@ export function CryptoPaymentMethod({ selectedPaymentMethod, setSelectedPaymentM
|
|
|
72
72
|
setClosable(true);
|
|
73
73
|
}
|
|
74
74
|
};
|
|
75
|
-
return (_jsx("div", { className: "crypto-payment-method mx-auto h-fit w-[460px] max-w-full px-5 pb-5 pt-5 sm:px-0 sm:pt-5", children: _jsxs("div", { className: cn("relative flex flex-col gap-10"), children: [_jsx("button", { onClick: onBack, className:
|
|
75
|
+
return (_jsx("div", { className: classes?.container || "crypto-payment-method mx-auto h-fit w-[460px] max-w-full px-5 pb-5 pt-5 sm:px-0 sm:pt-5", children: _jsxs("div", { className: cn("relative flex flex-col gap-10"), children: [_jsx("button", { onClick: onBack, className: classes?.backButton ||
|
|
76
|
+
"text-as-quaternary hover:text-as-primary absolute flex h-8 w-8 items-center justify-center rounded-lg transition-colors", children: _jsx(ChevronLeft, { className: "h-6 w-6" }) }), _jsx("div", { className: classes?.header || "flex items-center justify-around gap-4", children: _jsx("div", { className: "flex-1 text-center", children: _jsx("h2", { className: "text-as-primary text-lg font-semibold", children: "Select a payment method" }) }) }), process.env.NODE_ENV === "development" && (_jsxs("div", { className: "rounded-lg border border-yellow-500/50 bg-yellow-50 p-3 dark:bg-yellow-950/20", children: [_jsx("p", { className: "mb-2 text-xs font-semibold text-yellow-800 dark:text-yellow-300", children: "\uD83E\uDDEA Toast Test (Dev Only)" }), _jsxs("div", { className: "flex flex-wrap gap-2", children: [_jsx("button", { onClick: () => toast.success("Success! Transaction completed"), className: "rounded bg-green-600 px-2 py-1 text-xs font-medium text-white hover:bg-green-700", children: "Success" }), _jsx("button", { onClick: () => toast.error("Error! Transaction failed"), className: "rounded bg-red-600 px-2 py-1 text-xs font-medium text-white hover:bg-red-700", children: "Error" }), _jsx("button", { onClick: () => toast.info("Info: Processing your request..."), className: "rounded bg-blue-600 px-2 py-1 text-xs font-medium text-white hover:bg-blue-700", children: "Info" }), _jsx("button", { onClick: () => toast.warning("Warning: Low balance detected"), className: "rounded bg-yellow-600 px-2 py-1 text-xs font-medium text-white hover:bg-yellow-700", children: "Warning" }), _jsx("button", { onClick: () => {
|
|
76
77
|
toast.success("Multiple test 1");
|
|
77
78
|
setTimeout(() => toast.info("Multiple test 2"), 200);
|
|
78
79
|
setTimeout(() => toast.warning("Multiple test 3"), 400);
|
|
79
|
-
}, className: "rounded bg-purple-600 px-2 py-1 text-xs font-medium text-white hover:bg-purple-700", children: "Multiple" })] })] })), _jsxs("div", { className: "crypto-payment-methods flex flex-col gap-4", children: [(shouldShowConnectedEOA || globalAddress) && (_jsxs("div", { className: "installed-wallets", children: [_jsx("h3", { className: "text-as-primary/80 mb-3 text-sm font-medium", children: "Connected wallets" }), _jsxs("div", { className: "space-y-2", children: [shouldShowConnectedEOA && (_jsx("button", { onClick: () => {
|
|
80
|
+
}, className: "rounded bg-purple-600 px-2 py-1 text-xs font-medium text-white hover:bg-purple-700", children: "Multiple" })] })] })), _jsxs("div", { className: classes?.optionsList || "crypto-payment-methods flex flex-col gap-4", children: [(shouldShowConnectedEOA || globalAddress) && (_jsxs("div", { className: "installed-wallets", children: [_jsx("h3", { className: "text-as-primary/80 mb-3 text-sm font-medium", children: "Connected wallets" }), _jsxs("div", { className: "space-y-2", children: [shouldShowConnectedEOA && (_jsx("button", { onClick: () => {
|
|
80
81
|
setSelectedPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
81
82
|
onSelectPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
82
83
|
toast.success(`Selected ${eoaWalletInfo?.name || "wallet"}`);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { components } from "../../../types/api";
|
|
2
|
+
import type { CryptoReceiveSectionClasses } from "../types/classes";
|
|
2
3
|
interface CryptoReceiveSectionProps {
|
|
3
4
|
isDepositMode?: boolean;
|
|
4
5
|
isBuyMode?: boolean;
|
|
@@ -19,6 +20,7 @@ interface CryptoReceiveSectionProps {
|
|
|
19
20
|
dstTokenLogoURI?: string;
|
|
20
21
|
onShowPointsDetail?: () => void;
|
|
21
22
|
onShowFeeDetail?: () => void;
|
|
23
|
+
classes?: CryptoReceiveSectionClasses;
|
|
22
24
|
}
|
|
23
|
-
export declare function CryptoReceiveSection({ isDepositMode, isBuyMode, effectiveRecipientAddress, recipientName, customRecipientLabel, onSelectRecipient, dstAmount, dstToken, selectedDstChainId, setSelectedDstChainId, setSelectedDstToken, isSrcInputDirty, onChangeDstAmount, anyspendQuote, dstTokenSymbol, dstTokenLogoURI, onShowPointsDetail, onShowFeeDetail, }: CryptoReceiveSectionProps): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
export declare function CryptoReceiveSection({ isDepositMode, isBuyMode, effectiveRecipientAddress, recipientName, customRecipientLabel, onSelectRecipient, dstAmount, dstToken, selectedDstChainId, setSelectedDstChainId, setSelectedDstToken, isSrcInputDirty, onChangeDstAmount, anyspendQuote, dstTokenSymbol, dstTokenLogoURI, onShowPointsDetail, onShowFeeDetail, classes, }: CryptoReceiveSectionProps): import("react/jsx-runtime").JSX.Element;
|
|
24
26
|
export {};
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { ALL_CHAINS } from "../../../../anyspend/index.js";
|
|
3
3
|
import { formatUsername } from "../../../../shared/utils/index.js";
|
|
4
|
-
import { cn } from "../../../../shared/utils/cn.js";
|
|
5
4
|
import { shortenAddress } from "../../../../shared/utils/formatAddress.js";
|
|
6
5
|
import { formatDisplayNumber } from "../../../../shared/utils/number.js";
|
|
7
6
|
import { ChevronRight, Info } from "lucide-react";
|
|
8
7
|
import { motion } from "motion/react";
|
|
9
8
|
import { OrderTokenAmount } from "./OrderTokenAmount.js";
|
|
10
9
|
import { PointsBadge } from "./PointsBadge.js";
|
|
11
|
-
export function CryptoReceiveSection({ isDepositMode = false, isBuyMode = false, effectiveRecipientAddress, recipientName, customRecipientLabel, onSelectRecipient, dstAmount, dstToken, selectedDstChainId, setSelectedDstChainId, setSelectedDstToken, isSrcInputDirty, onChangeDstAmount, anyspendQuote, dstTokenSymbol, dstTokenLogoURI, onShowPointsDetail, onShowFeeDetail, }) {
|
|
12
|
-
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.1, ease: "easeInOut" }, className:
|
|
13
|
-
|
|
10
|
+
export function CryptoReceiveSection({ isDepositMode = false, isBuyMode = false, effectiveRecipientAddress, recipientName, customRecipientLabel, onSelectRecipient, dstAmount, dstToken, selectedDstChainId, setSelectedDstChainId, setSelectedDstToken, isSrcInputDirty, onChangeDstAmount, anyspendQuote, dstTokenSymbol, dstTokenLogoURI, onShowPointsDetail, onShowFeeDetail, classes, }) {
|
|
11
|
+
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.1, ease: "easeInOut" }, className: classes?.container ||
|
|
12
|
+
"receive-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 w-full items-center justify-between", children: [_jsxs("div", { className: classes?.label || "text-as-primary/50 flex h-7 items-center gap-1.5 text-sm", children: [isDepositMode ? "Deposit" : "Receive", isSrcInputDirty && anyspendQuote?.data?.fee && onShowFeeDetail && (_jsx("button", { onClick: onShowFeeDetail, className: "text-as-primary/40 hover:text-as-primary/60 transition-colors", children: _jsx(Info, { className: "h-4 w-4" }) }))] }), effectiveRecipientAddress ? (_jsx("button", { className: classes?.recipientButton || "text-as-tertiarry flex h-7 items-center gap-2 rounded-lg", onClick: onSelectRecipient, children: _jsxs(_Fragment, { children: [_jsx("span", { className: classes?.recipientValue || "text-as-tertiarry flex items-center gap-1 text-sm", children: customRecipientLabel ||
|
|
13
|
+
(recipientName ? formatUsername(recipientName) : shortenAddress(effectiveRecipientAddress || "")) }), _jsx(ChevronRight, { className: "h-4 w-4" })] }) })) : (_jsx("button", { className: classes?.recipientButton || "text-as-primary/70 flex items-center gap-1 rounded-lg", onClick: onSelectRecipient, children: _jsx("div", { className: "text-sm font-medium", children: "Select recipient" }) }))] }), isBuyMode || isDepositMode ? (
|
|
14
14
|
// Fixed destination token display for buy mode and deposit mode
|
|
15
|
-
_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:
|
|
15
|
+
_jsxs("div", { className: classes?.inputContainer || "flex items-center justify-between", children: [_jsx("div", { className: classes?.input || "text-as-primary text-2xl font-bold", children: dstAmount || "0" }), _jsxs("div", { className: classes?.tokenSelector ||
|
|
16
|
+
"bg-as-brand/10 border-as-brand/30 flex items-center gap-3 rounded-xl border px-4 py-3", children: [(dstTokenLogoURI || dstToken.metadata?.logoURI) && (_jsxs("div", { className: "relative", children: [_jsx("img", { src: dstTokenLogoURI || dstToken.metadata?.logoURI, alt: dstTokenSymbol || dstToken.symbol, className: classes?.tokenIcon || "h-8 w-8 rounded-full" }), ALL_CHAINS[dstToken.chainId]?.logoUrl && (_jsx("img", { src: ALL_CHAINS[dstToken.chainId].logoUrl, alt: "Chain", className: classes?.chainBadge || "absolute -bottom-1 -right-1 h-4 w-4 rounded-full border border-white" }))] })), _jsx("span", { className: classes?.tokenSymbol || "text-as-brand text-lg font-bold", children: dstTokenSymbol || dstToken.symbol })] })] })) : (
|
|
16
17
|
// Token selection for regular swap mode
|
|
17
|
-
_jsx(OrderTokenAmount, { address: effectiveRecipientAddress, context: "to", inputValue: dstAmount, onChangeInput: onChangeDstAmount || (() => { }), chainId: selectedDstChainId || dstToken.chainId, setChainId: setSelectedDstChainId || (() => { }), token: dstToken, setToken: setSelectedDstToken || (() => { }) })), _jsxs("div", { className: "text-as-primary/50 flex h-5 items-center justify-start gap-2 text-sm", children: [_jsxs("div", { className: "flex items-center gap-2", children: [formatDisplayNumber(anyspendQuote?.data?.currencyOut?.amountUsd, {
|
|
18
|
+
_jsx("div", { className: classes?.inputContainer, children: _jsx(OrderTokenAmount, { address: effectiveRecipientAddress, context: "to", inputValue: dstAmount, onChangeInput: onChangeDstAmount || (() => { }), chainId: selectedDstChainId || dstToken.chainId, setChainId: setSelectedDstChainId || (() => { }), token: dstToken, setToken: setSelectedDstToken || (() => { }) }) })), _jsxs("div", { className: classes?.feeRow || "text-as-primary/50 flex h-5 items-center justify-start gap-2 text-sm", children: [_jsxs("div", { className: "flex items-center gap-2", children: [formatDisplayNumber(anyspendQuote?.data?.currencyOut?.amountUsd, {
|
|
18
19
|
style: "currency",
|
|
19
20
|
fallback: "",
|
|
20
21
|
}), anyspendQuote?.data?.currencyIn?.amountUsd &&
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { components } from "../../../types/api";
|
|
2
|
+
import type { FeeDetailPanelClasses } from "../types/classes";
|
|
2
3
|
interface FeeDetailPanelProps {
|
|
3
4
|
fee: components["schemas"]["Fee"];
|
|
4
5
|
transactionAmountUsd?: number;
|
|
5
6
|
onBack: () => void;
|
|
7
|
+
classes?: FeeDetailPanelClasses;
|
|
6
8
|
}
|
|
7
|
-
export declare function FeeDetailPanel({ fee, transactionAmountUsd, onBack }: FeeDetailPanelProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare function FeeDetailPanel({ fee, transactionAmountUsd, onBack, classes }: FeeDetailPanelProps): import("react/jsx-runtime").JSX.Element;
|
|
8
10
|
export {};
|
|
@@ -22,7 +22,7 @@ const WHALE_DISCOUNT_TIERS = [
|
|
|
22
22
|
{ minAny: 500000, discountPercent: 75, label: "Tier 2: 500k $ANY" },
|
|
23
23
|
{ minAny: 1000000, discountPercent: 100, label: "Tier 3: 1M+ $ANY" },
|
|
24
24
|
];
|
|
25
|
-
export function FeeDetailPanel({ fee, transactionAmountUsd, onBack }) {
|
|
25
|
+
export function FeeDetailPanel({ fee, transactionAmountUsd, onBack, classes }) {
|
|
26
26
|
// Detect if this is a fiat onramp order (Stripe) vs regular crypto swap
|
|
27
27
|
// stripeweb2_fee = Stripe/fiat onramp (uses FIAT_FEE_TIERS)
|
|
28
28
|
// standard_fee = Regular crypto swap (uses CRYPTO_FEE_TIERS)
|
|
@@ -59,7 +59,7 @@ export function FeeDetailPanel({ fee, transactionAmountUsd, onBack }) {
|
|
|
59
59
|
// State for expanding tier lists
|
|
60
60
|
const [showAllFeeTiers, setShowAllFeeTiers] = useState(false);
|
|
61
61
|
const [showAllDiscountTiers, setShowAllDiscountTiers] = useState(false);
|
|
62
|
-
return (_jsx("div", { className: "mx-auto flex w-[460px] max-w-full flex-col items-center gap-3 px-5", children: _jsxs("div", { className: "flex w-full flex-col gap-3", children: [_jsx("div", { className: "text-center", children: _jsx("h3", { className: "text-as-primary text-lg font-bold", children: "Fee Breakdown" }) }), _jsxs("div", { className: "bg-as-surface-secondary border-as-border-secondary rounded-2xl border p-4", children: [_jsx("h4", { className: "text-as-primary mb-3 text-sm font-semibold", children: isStripeFee ? "Fiat Fee Schedule" : "Base Fee Schedule" }), _jsx("div", { className: "space-y-1.5", children: isStripeFee
|
|
62
|
+
return (_jsx("div", { className: classes?.container || "mx-auto flex w-[460px] max-w-full flex-col items-center gap-3 px-5", children: _jsxs("div", { className: "flex w-full flex-col gap-3", children: [_jsx("div", { className: "text-center", children: _jsx("h3", { className: classes?.title || "text-as-primary text-lg font-bold", children: "Fee Breakdown" }) }), _jsxs("div", { className: classes?.tierCard || "bg-as-surface-secondary border-as-border-secondary rounded-2xl border p-4", children: [_jsx("h4", { className: classes?.tierCardTitle || "text-as-primary mb-3 text-sm font-semibold", children: isStripeFee ? "Fiat Fee Schedule" : "Base Fee Schedule" }), _jsx("div", { className: "space-y-1.5", children: isStripeFee
|
|
63
63
|
? FIAT_FEE_TIERS.map((tier, idx) => {
|
|
64
64
|
const isCurrentTier = currentFiatTier?.label === tier.label;
|
|
65
65
|
const currentTierIndex = FIAT_FEE_TIERS.findIndex(t => t.label === currentFiatTier?.label);
|
|
@@ -67,7 +67,11 @@ export function FeeDetailPanel({ fee, transactionAmountUsd, onBack }) {
|
|
|
67
67
|
if (!showAllFeeTiers && currentTierIndex !== -1 && idx > currentTierIndex) {
|
|
68
68
|
return null;
|
|
69
69
|
}
|
|
70
|
-
return (_jsxs("div", { className: cn(
|
|
70
|
+
return (_jsxs("div", { className: cn(isCurrentTier
|
|
71
|
+
? classes?.tierRowActive ||
|
|
72
|
+
"bg-as-brand/10 text-as-brand flex items-center justify-between rounded-lg px-3 py-2.5 text-sm font-semibold transition-colors"
|
|
73
|
+
: classes?.tierRow ||
|
|
74
|
+
"text-as-primary/60 flex items-center justify-between rounded-lg px-3 py-2.5 text-sm transition-colors"), children: [_jsx("span", { className: classes?.tierLabel, children: tier.label }), _jsxs("span", { className: classes?.tierValue, children: ["Credit Card Fee + ", tier.fee] })] }, idx));
|
|
71
75
|
})
|
|
72
76
|
: CRYPTO_FEE_TIERS.map((tier, idx) => {
|
|
73
77
|
const isCurrentTier = currentCryptoTier?.label === tier.label;
|
|
@@ -76,7 +80,11 @@ export function FeeDetailPanel({ fee, transactionAmountUsd, onBack }) {
|
|
|
76
80
|
if (!showAllFeeTiers && currentTierIndex !== -1 && idx > currentTierIndex) {
|
|
77
81
|
return null;
|
|
78
82
|
}
|
|
79
|
-
return (_jsxs("div", { className: cn(
|
|
83
|
+
return (_jsxs("div", { className: cn(isCurrentTier
|
|
84
|
+
? classes?.tierRowActive ||
|
|
85
|
+
"bg-as-brand/10 text-as-brand flex items-center justify-between rounded-lg px-3 py-2.5 text-sm font-semibold transition-colors"
|
|
86
|
+
: classes?.tierRow ||
|
|
87
|
+
"text-as-primary/60 flex items-center justify-between rounded-lg px-3 py-2.5 text-sm transition-colors"), children: [_jsx("span", { className: classes?.tierLabel, children: tier.label }), _jsxs("span", { className: classes?.tierValue, children: [bpsToPercent(tier.bps), "%"] })] }, idx));
|
|
80
88
|
}) }), (() => {
|
|
81
89
|
const currentTierIndex = isStripeFee
|
|
82
90
|
? FIAT_FEE_TIERS.findIndex(t => t.label === currentFiatTier?.label)
|
|
@@ -84,7 +92,8 @@ export function FeeDetailPanel({ fee, transactionAmountUsd, onBack }) {
|
|
|
84
92
|
const totalTiers = isStripeFee ? FIAT_FEE_TIERS.length : CRYPTO_FEE_TIERS.length;
|
|
85
93
|
const hasMoreTiers = currentTierIndex !== -1 && currentTierIndex < totalTiers - 1;
|
|
86
94
|
if (hasMoreTiers) {
|
|
87
|
-
return (_jsxs("button", { onClick: () => setShowAllFeeTiers(!showAllFeeTiers), className:
|
|
95
|
+
return (_jsxs("button", { onClick: () => setShowAllFeeTiers(!showAllFeeTiers), className: classes?.expandButton ||
|
|
96
|
+
"text-as-primary/60 hover:text-as-primary mt-2 flex w-full items-center justify-center gap-1 text-xs transition-colors", children: [_jsx("span", { children: showAllFeeTiers ? "Show less" : "Show higher tiers" }), _jsx(ChevronDown, { className: cn("h-3.5 w-3.5 transition-transform", showAllFeeTiers && "rotate-180") })] }));
|
|
88
97
|
}
|
|
89
98
|
return null;
|
|
90
99
|
})()] }), !isStripeFee && (_jsxs("div", { className: "bg-as-surface-secondary border-as-border-secondary rounded-2xl border p-4", children: [_jsx("h4", { className: "text-as-primary mb-3 text-sm font-semibold", children: hasWhaleDiscount ? "Whale Discount Tiers" : hasPartnerDiscount ? "Partner Discount" : "Discount Tiers" }), _jsx("div", { className: "space-y-1.5", children: hasPartnerDiscount && !hasWhaleDiscount ? (_jsxs("div", { className: "flex items-center justify-between rounded-lg bg-green-500/10 px-3 py-2.5 text-sm font-semibold text-green-600", children: [_jsx("span", { children: "Partner Discount" }), _jsxs("span", { children: [partnerDiscountPercent, "% discount"] })] })) : (_jsxs(_Fragment, { children: [WHALE_DISCOUNT_TIERS.map((tier, idx) => {
|
|
@@ -109,5 +118,5 @@ export function FeeDetailPanel({ fee, transactionAmountUsd, onBack }) {
|
|
|
109
118
|
return (_jsxs("button", { onClick: () => setShowAllDiscountTiers(!showAllDiscountTiers), className: "text-as-primary/60 hover:text-as-primary mt-2 flex w-full items-center justify-center gap-1 text-xs transition-colors", children: [_jsx("span", { children: showAllDiscountTiers ? "Show less" : "Show all tiers" }), _jsx(ChevronDown, { className: cn("h-3.5 w-3.5 transition-transform", showAllDiscountTiers && "rotate-180") })] }));
|
|
110
119
|
}
|
|
111
120
|
return null;
|
|
112
|
-
})()] })) })] })), transactionAmountUsd && (_jsx("div", { className: "bg-as-surface-secondary border-as-border-secondary rounded-2xl border p-4", children: _jsxs("div", { className: "space-y-2 text-sm", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("span", { className: "text-as-secondary", children: "Transaction" }), _jsxs("span", { className: "text-as-primary font-semibold", children: ["$", transactionAmountUsd.toFixed(2)] })] }), isStripeFee && (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsxs("span", { className: "text-as-secondary", children: ["Credit Card Fee (", fee.stripeFeeBps ? `${bpsToPercent(fee.stripeFeeBps)}%` : "0%", " + $", fee.stripeFeeUsd?.toFixed(2) || "0.00", ")"] }), _jsxs("span", { className: "text-as-primary font-medium", children: ["$", ((transactionAmountUsd * (fee.stripeFeeBps || 0)) / 10000 + (fee.stripeFeeUsd || 0)).toFixed(2)] })] }), _jsxs("div", { className: "flex items-center justify-between", children: [_jsxs("span", { className: "text-as-secondary", children: ["AnySpend Fee (", fee.anyspendFeeBps ? `${bpsToPercent(fee.anyspendFeeBps)}%` : "0%", fee.anyspendFeeUsd && fee.anyspendFeeUsd > 0 ? ` + $${fee.anyspendFeeUsd.toFixed(2)}` : "", ")"] }), _jsxs("span", { className: "text-as-primary font-medium", children: ["$", ((transactionAmountUsd * (fee.anyspendFeeBps || 0)) / 10000 + (fee.anyspendFeeUsd || 0)).toFixed(2)] })] }), _jsx("div", { className: "border-as-border-secondary border-t pt-2", children: _jsxs("div", { className: "flex items-center justify-between", children: [_jsx("span", { className: "text-as-primary font-semibold", children: "Total Fee" }), _jsxs("span", { className: "text-as-brand font-semibold", children: ["$", ((transactionAmountUsd * (fee.finalFeeBps || 0)) / 10000 + (fee.finalFeeUsd || 0)).toFixed(2)] })] }) })] })), !isStripeFee && currentCryptoTier && (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsxs("span", { className: "text-as-secondary", children: ["Base Fee (", bpsToPercent(currentCryptoTier.bps), "%)"] }), _jsxs("span", { className: "text-as-primary font-medium", children: ["$", ((transactionAmountUsd * currentCryptoTier.bps) / 10000).toFixed(2)] })] }), hasWhaleDiscount && currentWhaleTier && (_jsxs("div", { className: "flex items-center justify-between", children: [_jsxs("span", { className: "text-green-600", children: ["Discount (", currentWhaleTier.discountPercent, "% off)"] }), _jsxs("span", { className: "font-medium text-green-600", children: ["-$", ((transactionAmountUsd * baseFee * currentWhaleTier.discountPercent) / 100 / 10000).toFixed(2)] })] })), hasPartnerDiscount && (_jsxs("div", { className: "flex items-center justify-between", children: [_jsxs("span", { className: "text-green-600", children: ["Partner Discount (", partnerDiscountPercent, "% off)"] }), _jsxs("span", { className: "font-medium text-green-600", children: ["-$", ((transactionAmountUsd * baseFee * partnerDiscountPercent) / 100 / 10000).toFixed(2)] })] })), _jsx("div", { className: "border-as-border-secondary border-t pt-2", children: _jsxs("div", { className: "flex items-center justify-between", children: [_jsx("span", { className: "text-as-primary font-semibold", children: "Total Fee" }), _jsxs("span", { className: "text-as-brand font-semibold", children: ["$", ((transactionAmountUsd * fee.finalFeeBps) / 10000).toFixed(2)] })] }) })] }))] }) })), _jsxs(ShinyButton, { accentColor: "hsl(var(--as-brand))", onClick: onBack, className: cn("as-main-button !bg-as-brand relative w-full"), textClassName: cn("text-white"), children: ["Back to ", isStripeFee ? "Payment" : "Swap"] })] }) }));
|
|
121
|
+
})()] })) })] })), transactionAmountUsd && (_jsx("div", { className: classes?.summaryCard || "bg-as-surface-secondary border-as-border-secondary rounded-2xl border p-4", children: _jsxs("div", { className: "space-y-2 text-sm", children: [_jsxs("div", { className: classes?.summaryRow || "flex items-center justify-between", children: [_jsx("span", { className: classes?.summaryLabel || "text-as-secondary", children: "Transaction" }), _jsxs("span", { className: classes?.summaryValue || "text-as-primary font-semibold", children: ["$", transactionAmountUsd.toFixed(2)] })] }), isStripeFee && (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsxs("span", { className: "text-as-secondary", children: ["Credit Card Fee (", fee.stripeFeeBps ? `${bpsToPercent(fee.stripeFeeBps)}%` : "0%", " + $", fee.stripeFeeUsd?.toFixed(2) || "0.00", ")"] }), _jsxs("span", { className: "text-as-primary font-medium", children: ["$", ((transactionAmountUsd * (fee.stripeFeeBps || 0)) / 10000 + (fee.stripeFeeUsd || 0)).toFixed(2)] })] }), _jsxs("div", { className: "flex items-center justify-between", children: [_jsxs("span", { className: "text-as-secondary", children: ["AnySpend Fee (", fee.anyspendFeeBps ? `${bpsToPercent(fee.anyspendFeeBps)}%` : "0%", fee.anyspendFeeUsd && fee.anyspendFeeUsd > 0 ? ` + $${fee.anyspendFeeUsd.toFixed(2)}` : "", ")"] }), _jsxs("span", { className: "text-as-primary font-medium", children: ["$", ((transactionAmountUsd * (fee.anyspendFeeBps || 0)) / 10000 + (fee.anyspendFeeUsd || 0)).toFixed(2)] })] }), _jsx("div", { className: classes?.summaryDivider || "border-as-border-secondary border-t pt-2", children: _jsxs("div", { className: classes?.totalRow || "flex items-center justify-between", children: [_jsx("span", { className: classes?.totalLabel || "text-as-primary font-semibold", children: "Total Fee" }), _jsxs("span", { className: classes?.totalValue || "text-as-brand font-semibold", children: ["$", ((transactionAmountUsd * (fee.finalFeeBps || 0)) / 10000 + (fee.finalFeeUsd || 0)).toFixed(2)] })] }) })] })), !isStripeFee && currentCryptoTier && (_jsxs(_Fragment, { children: [_jsxs("div", { className: classes?.summaryRow || "flex items-center justify-between", children: [_jsxs("span", { className: classes?.summaryLabel || "text-as-secondary", children: ["Base Fee (", bpsToPercent(currentCryptoTier.bps), "%)"] }), _jsxs("span", { className: classes?.summaryValue || "text-as-primary font-medium", children: ["$", ((transactionAmountUsd * currentCryptoTier.bps) / 10000).toFixed(2)] })] }), hasWhaleDiscount && currentWhaleTier && (_jsxs("div", { className: classes?.summaryRow || "flex items-center justify-between", children: [_jsxs("span", { className: "text-green-600", children: ["Discount (", currentWhaleTier.discountPercent, "% off)"] }), _jsxs("span", { className: "font-medium text-green-600", children: ["-$", ((transactionAmountUsd * baseFee * currentWhaleTier.discountPercent) / 100 / 10000).toFixed(2)] })] })), hasPartnerDiscount && (_jsxs("div", { className: classes?.summaryRow || "flex items-center justify-between", children: [_jsxs("span", { className: "text-green-600", children: ["Partner Discount (", partnerDiscountPercent, "% off)"] }), _jsxs("span", { className: "font-medium text-green-600", children: ["-$", ((transactionAmountUsd * baseFee * partnerDiscountPercent) / 100 / 10000).toFixed(2)] })] })), _jsx("div", { className: classes?.summaryDivider || "border-as-border-secondary border-t pt-2", children: _jsxs("div", { className: classes?.totalRow || "flex items-center justify-between", children: [_jsx("span", { className: classes?.totalLabel || "text-as-primary font-semibold", children: "Total Fee" }), _jsxs("span", { className: classes?.totalValue || "text-as-brand font-semibold", children: ["$", ((transactionAmountUsd * fee.finalFeeBps) / 10000).toFixed(2)] })] }) })] }))] }) })), _jsxs(ShinyButton, { accentColor: "hsl(var(--as-brand))", onClick: onBack, className: classes?.backButton || cn("as-main-button !bg-as-brand relative w-full"), textClassName: cn("text-white"), children: ["Back to ", isStripeFee ? "Payment" : "Swap"] })] }) }));
|
|
113
122
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { FiatPaymentMethodClasses } from "../types/classes";
|
|
1
2
|
export declare enum FiatPaymentMethod {
|
|
2
3
|
NONE = "none",
|
|
3
4
|
COINBASE_PAY = "coinbase_pay",
|
|
@@ -14,6 +15,7 @@ interface FiatPaymentMethodProps {
|
|
|
14
15
|
onBack: () => void;
|
|
15
16
|
onSelectPaymentMethod: (method: FiatPaymentMethod) => void;
|
|
16
17
|
srcAmountOnRamp: string;
|
|
18
|
+
classes?: FiatPaymentMethodClasses;
|
|
17
19
|
}
|
|
18
|
-
export declare function FiatPaymentMethodComponent({ selectedPaymentMethod, setSelectedPaymentMethod, onBack, onSelectPaymentMethod, srcAmountOnRamp, }: FiatPaymentMethodProps): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export declare function FiatPaymentMethodComponent({ selectedPaymentMethod, setSelectedPaymentMethod, onBack, onSelectPaymentMethod, srcAmountOnRamp, classes, }: FiatPaymentMethodProps): import("react/jsx-runtime").JSX.Element;
|
|
19
21
|
export {};
|
|
@@ -17,7 +17,7 @@ export const FIAT_PAYMENT_METHOD_DISPLAY = {
|
|
|
17
17
|
[FiatPaymentMethod.STRIPE_WEB2]: { icon: "S", label: "Pay with Card" },
|
|
18
18
|
[FiatPaymentMethod.NONE]: null,
|
|
19
19
|
};
|
|
20
|
-
export function FiatPaymentMethodComponent({ selectedPaymentMethod, setSelectedPaymentMethod, onBack, onSelectPaymentMethod, srcAmountOnRamp, }) {
|
|
20
|
+
export function FiatPaymentMethodComponent({ selectedPaymentMethod, setSelectedPaymentMethod, onBack, onSelectPaymentMethod, srcAmountOnRamp, classes, }) {
|
|
21
21
|
// Load geo-based onramp options like in PanelOnramp
|
|
22
22
|
const { coinbaseAvailablePaymentMethods, stripeOnrampSupport, stripeWeb2Support, isLoading: isLoadingGeoOnramp, } = useGeoOnrampOptions(srcAmountOnRamp);
|
|
23
23
|
// Helper function to get fees from API data
|
|
@@ -79,14 +79,18 @@ export function FiatPaymentMethodComponent({ selectedPaymentMethod, setSelectedP
|
|
|
79
79
|
}
|
|
80
80
|
// Show loading state while checking geo availability
|
|
81
81
|
if (isLoadingGeoOnramp) {
|
|
82
|
-
return (_jsx("div", { className: "fiat-payment-method mx-auto w-[460px] max-w-full p-5", children: _jsxs("div", { className: "flex flex-col gap-6", children: [_jsxs("div", { className: "flex items-center gap-4", children: [_jsx("button", { onClick: onBack, className:
|
|
82
|
+
return (_jsx("div", { className: classes?.container || "fiat-payment-method mx-auto w-[460px] max-w-full p-5", children: _jsxs("div", { className: "flex flex-col gap-6", children: [_jsxs("div", { className: classes?.header || "flex items-center gap-4", children: [_jsx("button", { onClick: onBack, className: classes?.backButton ||
|
|
83
|
+
"text-as-quaternary hover:text-as-primary flex h-8 w-8 items-center justify-center rounded-lg transition-colors", children: _jsx(ChevronLeft, { className: "h-6 w-6" }) }), _jsx("div", { className: "flex-1", children: _jsx("h2", { className: "text-as-primary text-lg font-semibold", children: "Choose payment method" }) })] }), _jsxs("div", { className: "flex items-center justify-center py-8", children: [_jsx(Loader2, { className: "h-6 w-6 animate-spin" }), _jsx("span", { className: "text-as-secondary ml-2 text-sm", children: "Loading payment methods..." })] })] }) }));
|
|
83
84
|
}
|
|
84
|
-
return (_jsx("div", { className: "fiat-payment-method mx-auto w-[460px] max-w-full p-5", children: _jsxs("div", { className: "flex flex-col gap-6", children: [_jsxs("div", { className: "flex items-center gap-4", children: [_jsx("button", { onClick: onBack, className:
|
|
85
|
+
return (_jsx("div", { className: classes?.container || "fiat-payment-method mx-auto w-[460px] max-w-full p-5", children: _jsxs("div", { className: "flex flex-col gap-6", children: [_jsxs("div", { className: classes?.header || "flex items-center gap-4", children: [_jsx("button", { onClick: onBack, className: classes?.backButton ||
|
|
86
|
+
"text-as-quaternary hover:text-as-primary flex h-8 w-8 items-center justify-center rounded-lg transition-colors", children: _jsx(ChevronLeft, { className: "h-6 w-6" }) }), _jsx("div", { className: "flex-1", children: _jsx("h2", { className: "text-as-primary text-lg font-semibold", children: "Choose payment method" }) })] }), _jsx("div", { className: classes?.optionsList || "flex flex-col gap-3", children: availablePaymentMethods.length === 0 ? (_jsx("div", { className: "fiat-payment-method-no-methods bg-as-surface-secondary border-as-border-secondary rounded-2xl border p-6 text-center", children: _jsx("p", { className: "text-as-secondary text-sm", children: "No payment methods available in your region for the selected amount." }) })) : (availablePaymentMethods.map(method => (_jsxs("button", { onClick: () => {
|
|
85
87
|
setSelectedPaymentMethod(method.id);
|
|
86
88
|
onSelectPaymentMethod(method.id);
|
|
87
|
-
}, className:
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
}, className: (selectedPaymentMethod === method.id && classes?.optionItemActive) ||
|
|
90
|
+
classes?.optionItem ||
|
|
91
|
+
cn("fiat-payment-method-item bg-as-surface-secondary border-as-border-secondary flex w-full items-center gap-4 rounded-2xl border p-4 transition-all duration-200", selectedPaymentMethod === method.id
|
|
92
|
+
? "border-as-brand bg-as-brand/10"
|
|
93
|
+
: "hover:border-as-brand/50 hover:bg-as-brand/5"), children: [_jsx("div", { className: "flex h-12 w-12 items-center justify-center rounded-full bg-blue-600 text-2xl text-white", children: method.id === FiatPaymentMethod.COINBASE_PAY
|
|
90
94
|
? "C"
|
|
91
95
|
: method.id === FiatPaymentMethod.STRIPE || method.id === FiatPaymentMethod.STRIPE_WEB2
|
|
92
96
|
? "S"
|