@b3dotfun/sdk 0.0.87-alpha.1 → 0.0.87
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 +0 -5
- package/dist/cjs/anyspend/react/components/AnySpend.js +49 -59
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.d.ts +1 -1
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.js +2 -1
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +12 -17
- package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.d.ts +0 -2
- package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.js +5 -12
- package/dist/cjs/anyspend/react/components/common/OrderStatus.js +2 -2
- package/dist/cjs/anyspend/react/components/index.d.ts +0 -2
- package/dist/cjs/anyspend/react/components/index.js +1 -3
- package/dist/cjs/anyspend/react/hooks/index.d.ts +0 -1
- package/dist/cjs/anyspend/react/hooks/index.js +0 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.d.ts +2 -2
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +11 -35
- package/dist/cjs/anyspend/utils/format.js +5 -28
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +0 -4
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +0 -5
- package/dist/esm/anyspend/react/components/AnySpend.js +49 -59
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.d.ts +1 -1
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.js +2 -1
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +12 -17
- package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.d.ts +0 -2
- package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.js +5 -12
- package/dist/esm/anyspend/react/components/common/OrderStatus.js +2 -2
- package/dist/esm/anyspend/react/components/index.d.ts +0 -2
- package/dist/esm/anyspend/react/components/index.js +0 -1
- package/dist/esm/anyspend/react/hooks/index.d.ts +0 -1
- package/dist/esm/anyspend/react/hooks/index.js +0 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.d.ts +2 -2
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +11 -35
- package/dist/esm/anyspend/utils/format.js +5 -28
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +0 -4
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/react/components/AnySpend.d.ts +0 -5
- package/dist/types/anyspend/react/components/AnySpendCustomExactIn.d.ts +1 -1
- package/dist/types/anyspend/react/components/common/OrderDetailsCollapsible.d.ts +0 -2
- package/dist/types/anyspend/react/components/index.d.ts +0 -2
- package/dist/types/anyspend/react/hooks/index.d.ts +0 -1
- package/dist/types/anyspend/react/hooks/useAnyspendFlow.d.ts +2 -2
- package/dist/types/global-account/react/stores/useModalStore.d.ts +0 -4
- package/package.json +1 -1
- package/src/anyspend/react/components/AnySpend.tsx +45 -68
- package/src/anyspend/react/components/AnySpendCustomExactIn.tsx +3 -2
- package/src/anyspend/react/components/common/OrderDetails.tsx +8 -26
- package/src/anyspend/react/components/common/OrderDetailsCollapsible.tsx +8 -20
- package/src/anyspend/react/components/common/OrderStatus.tsx +2 -2
- package/src/anyspend/react/components/index.ts +0 -2
- package/src/anyspend/react/hooks/index.ts +0 -1
- package/src/anyspend/react/hooks/useAnyspendFlow.ts +12 -37
- package/src/anyspend/utils/format.ts +5 -33
- package/src/global-account/react/stores/useModalStore.ts +0 -4
- package/src/styles/index.css +0 -2
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.d.ts +0 -122
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.js +0 -190
- package/dist/cjs/anyspend/react/components/QRDeposit.d.ts +0 -43
- package/dist/cjs/anyspend/react/components/QRDeposit.js +0 -146
- package/dist/cjs/anyspend/react/components/common/WarningText.d.ts +0 -32
- package/dist/cjs/anyspend/react/components/common/WarningText.js +0 -36
- package/dist/cjs/anyspend/react/components/icons/CreditCardIcon.d.ts +0 -6
- package/dist/cjs/anyspend/react/components/icons/CreditCardIcon.js +0 -6
- package/dist/cjs/anyspend/react/components/icons/QrCodeIcon.d.ts +0 -6
- package/dist/cjs/anyspend/react/components/icons/QrCodeIcon.js +0 -6
- package/dist/cjs/anyspend/react/hooks/useCreateDepositFirstOrder.d.ts +0 -24
- package/dist/cjs/anyspend/react/hooks/useCreateDepositFirstOrder.js +0 -86
- package/dist/esm/anyspend/react/components/AnySpendDeposit.d.ts +0 -122
- package/dist/esm/anyspend/react/components/AnySpendDeposit.js +0 -187
- package/dist/esm/anyspend/react/components/QRDeposit.d.ts +0 -43
- package/dist/esm/anyspend/react/components/QRDeposit.js +0 -143
- package/dist/esm/anyspend/react/components/common/WarningText.d.ts +0 -32
- package/dist/esm/anyspend/react/components/common/WarningText.js +0 -32
- package/dist/esm/anyspend/react/components/icons/CreditCardIcon.d.ts +0 -6
- package/dist/esm/anyspend/react/components/icons/CreditCardIcon.js +0 -2
- package/dist/esm/anyspend/react/components/icons/QrCodeIcon.d.ts +0 -6
- package/dist/esm/anyspend/react/components/icons/QrCodeIcon.js +0 -2
- package/dist/esm/anyspend/react/hooks/useCreateDepositFirstOrder.d.ts +0 -24
- package/dist/esm/anyspend/react/hooks/useCreateDepositFirstOrder.js +0 -83
- package/dist/types/anyspend/react/components/AnySpendDeposit.d.ts +0 -122
- package/dist/types/anyspend/react/components/QRDeposit.d.ts +0 -43
- package/dist/types/anyspend/react/components/common/WarningText.d.ts +0 -32
- package/dist/types/anyspend/react/components/icons/CreditCardIcon.d.ts +0 -6
- package/dist/types/anyspend/react/components/icons/QrCodeIcon.d.ts +0 -6
- package/dist/types/anyspend/react/hooks/useCreateDepositFirstOrder.d.ts +0 -24
- package/src/anyspend/react/components/AnySpendDeposit.tsx +0 -578
- package/src/anyspend/react/components/QRDeposit.tsx +0 -348
- package/src/anyspend/react/components/common/WarningText.tsx +0 -52
- package/src/anyspend/react/components/icons/CreditCardIcon.tsx +0 -25
- package/src/anyspend/react/components/icons/QrCodeIcon.tsx +0 -25
- package/src/anyspend/react/components/icons/credit-card.svg +0 -5
- package/src/anyspend/react/components/icons/qr-code.svg +0 -5
- package/src/anyspend/react/hooks/useCreateDepositFirstOrder.ts +0 -110
|
@@ -10,26 +10,19 @@ import { ChevronDown, Copy } from "lucide-react";
|
|
|
10
10
|
import { motion } from "motion/react";
|
|
11
11
|
import { memo, useState } from "react";
|
|
12
12
|
import { b3 } from "viem/chains";
|
|
13
|
-
export const OrderDetailsCollapsible = memo(function OrderDetailsCollapsible({ order, dstToken, tournament, nft, recipientName, formattedExpectedDstAmount, className, showTotal = false, totalAmount, points,
|
|
14
|
-
const [
|
|
15
|
-
// Use controlled mode if isOpen is provided, otherwise use internal state
|
|
16
|
-
const showOrderDetails = isOpen !== undefined ? isOpen : internalOpen;
|
|
17
|
-
const setShowOrderDetails = onOpenChange || setInternalOpen;
|
|
13
|
+
export const OrderDetailsCollapsible = memo(function OrderDetailsCollapsible({ order, dstToken, tournament, nft, recipientName, formattedExpectedDstAmount, className, showTotal = false, totalAmount, points, }) {
|
|
14
|
+
const [showOrderDetails, setShowOrderDetails] = useState(true);
|
|
18
15
|
// Calculate expected amount if not provided
|
|
19
16
|
const expectedDstAmount = order.type === "mint_nft" ||
|
|
20
17
|
order.type === "join_tournament" ||
|
|
21
18
|
order.type === "fund_tournament" ||
|
|
22
|
-
order.type === "custom"
|
|
23
|
-
order.type === "deposit_first"
|
|
19
|
+
order.type === "custom"
|
|
24
20
|
? "0"
|
|
25
21
|
: order.payload.expectedDstAmount.toString();
|
|
26
22
|
const finalFormattedExpectedDstAmount = formattedExpectedDstAmount || formatTokenAmount(BigInt(expectedDstAmount), dstToken.decimals);
|
|
27
23
|
return (_jsx("div", { className: cn("order-details-collapsible bg-as-surface-secondary border-as-border-secondary rounded-xl border px-4 py-2", className), children: showOrderDetails ? (_jsx(motion.div, { className: "order-details-expanded w-full", 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: _jsxs("div", { className: "order-details-content flex w-full flex-col items-center gap-3 whitespace-nowrap py-2 text-sm", children: [_jsxs("div", { className: "order-details-recipient-section flex w-full justify-between gap-4", children: [_jsx("div", { className: "order-details-recipient-label text-as-tertiarry", children: "Recipient" }), _jsxs("div", { className: "order-details-recipient-info flex flex-col items-end gap-1", children: [recipientName && (_jsx("div", { className: "order-details-recipient-name text-as-primary font-semibold", children: recipientName })), _jsx(CopyToClipboard, { text: order.recipientAddress, onCopy: () => {
|
|
28
24
|
toast.success("Copied recipient address to clipboard");
|
|
29
|
-
}, children: _jsxs("div", { className: "order-details-recipient-address text-as-primary flex items-center gap-2", children: [centerTruncate(order.recipientAddress, 10), _jsx(Copy, { className: "order-details-recipient-copy-icon text-as-primary/50 hover:text-as-primary h-4 w-4 cursor-pointer transition-all duration-200" })] }) })] })] }), _jsx("div", { className: "order-details-divider divider w-full" }), _jsxs("div", { className: "order-details-expected-section flex w-full items-
|
|
30
|
-
order.type === "deposit_first" ||
|
|
31
|
-
order.type === "mint_nft" ||
|
|
32
|
-
order.type === "hype_duel"
|
|
25
|
+
}, children: _jsxs("div", { className: "order-details-recipient-address text-as-primary flex items-center gap-2", children: [centerTruncate(order.recipientAddress, 10), _jsx(Copy, { className: "order-details-recipient-copy-icon text-as-primary/50 hover:text-as-primary h-4 w-4 cursor-pointer transition-all duration-200" })] }) })] })] }), _jsx("div", { className: "order-details-divider divider w-full" }), _jsxs("div", { className: "order-details-expected-section flex w-full items-center justify-between gap-2", children: [_jsx("div", { className: "order-details-expected-label text-as-tertiarry", children: order.type === "swap" || order.type === "mint_nft" || order.type === "hype_duel"
|
|
33
26
|
? "Expected to receive"
|
|
34
27
|
: order.type === "join_tournament"
|
|
35
28
|
? "Join tournament"
|
|
@@ -39,5 +32,5 @@ export const OrderDetailsCollapsible = memo(function OrderDetailsCollapsible({ o
|
|
|
39
32
|
? order.metadata.action
|
|
40
33
|
? capitalizeFirstLetter(order.metadata.action)
|
|
41
34
|
: "Contract execution"
|
|
42
|
-
: "" }), _jsxs("div", { className: "order-details-expected-value flex
|
|
35
|
+
: "" }), _jsxs("div", { className: "order-details-expected-value flex items-end gap-2", children: [order.type === "swap" ? (`~${finalFormattedExpectedDstAmount} ${dstToken.symbol}`) : order.type === "mint_nft" ? (_jsxs("div", { className: "order-details-nft-info flex items-center gap-2", children: [_jsx("img", { src: nft?.imageUrl, alt: nft?.name || "NFT", className: "order-details-nft-image h-5 w-5" }), _jsx("div", { className: "order-details-nft-name", children: nft?.name || "NFT" })] })) : order.type === "join_tournament" || order.type === "fund_tournament" ? (_jsxs("div", { className: "order-details-tournament-info flex items-center gap-2", children: [_jsx("img", { src: tournament?.imageUrl, alt: tournament?.name || "Tournament", className: "order-details-tournament-image h-5 w-5" }), _jsx("div", { className: "order-details-tournament-name", children: tournament?.name || "Tournament" })] })) : order.type === "hype_duel" ? (_jsx("div", { className: "order-details-hype-info flex items-center gap-2", children: _jsxs("div", { className: "order-details-hype-amount", children: [formatTokenAmount(BigInt(order.payload.expectedDstAmount), dstToken.decimals), " HYPE"] }) })) : null, _jsxs("div", { className: "order-details-chain-info text-as-primary/50 flex items-center gap-2", children: [_jsxs("span", { className: "order-details-chain-text", children: ["on ", order.dstChain !== b3.id && getChainName(order.dstChain)] }), _jsx("img", { src: ALL_CHAINS[order.dstChain].logoUrl, alt: getChainName(order.dstChain), className: cn("order-details-chain-logo h-3", order.dstChain !== b3.id && "w-3 rounded-full", order.dstChain === b3.id && "h-4") })] })] })] }), points !== undefined && points !== null && (_jsxs(_Fragment, { children: [_jsx("div", { className: "order-details-divider divider w-full" }), _jsxs("div", { className: "order-details-points-section flex w-full justify-between gap-4", children: [_jsx("div", { className: "order-details-points-label text-as-tertiarry", children: "Points" }), _jsxs("div", { className: "order-details-points-value text-as-brand font-semibold", children: ["+", formatNumber(points), " pts"] })] })] })), _jsx("div", { className: "order-details-divider divider w-full" }), _jsxs("div", { className: "order-details-id-total-section flex w-full justify-between gap-4", children: [_jsx("div", { className: "order-details-id-total-label text-as-tertiarry", children: showTotal ? "Total (included fee)" : "Order ID" }), _jsx("div", { className: "order-details-id-total-value text-as-primary overflow-hidden text-ellipsis whitespace-nowrap", children: showTotal && totalAmount ? totalAmount : order.id })] })] }) })) : (_jsxs("div", { className: "order-details-collapsed flex w-full items-center", children: [_jsx("div", { className: "order-details-collapsed-divider divider w-full" }), _jsx("button", { className: "order-details-collapsed-button whitespace-nowrap text-sm", onClick: () => setShowOrderDetails(true), children: "Order Details" }), _jsx(ChevronDown, { className: "order-details-collapsed-chevron text-as-primary mx-1 h-4 min-h-4 w-4 min-w-4" }), _jsx("div", { className: "order-details-collapsed-divider divider w-full" })] })) }));
|
|
43
36
|
});
|
|
@@ -5,7 +5,7 @@ import { Check, X } from "lucide-react";
|
|
|
5
5
|
import { memo } from "react";
|
|
6
6
|
import { StepProgress } from "./StepProgress.js";
|
|
7
7
|
export const OrderStatus = memo(function OrderStatus({ order, selectedCryptoPaymentMethod, }) {
|
|
8
|
-
const
|
|
8
|
+
const isComplete = order.status === "executed";
|
|
9
9
|
const { text, status: displayStatus, description } = getStatusDisplay(order);
|
|
10
10
|
const searchParams = useSearchParams();
|
|
11
11
|
const cryptoPaymentMethod = selectedCryptoPaymentMethod || searchParams.get("cryptoPaymentMethod");
|
|
@@ -35,5 +35,5 @@ export const OrderStatus = memo(function OrderStatus({ order, selectedCryptoPaym
|
|
|
35
35
|
if (selectedCryptoPaymentMethod === "transfer_crypto" && order.status === "scanning_deposit_transaction") {
|
|
36
36
|
return null;
|
|
37
37
|
}
|
|
38
|
-
return (_jsx("div", { className: "flex items-center justify-center gap-2", children:
|
|
38
|
+
return (_jsx("div", { className: "flex items-center justify-center gap-2", children: isComplete ? (_jsxs("div", { className: "flex flex-col items-center", children: [_jsx("div", { className: `bg-as-success-secondary relative flex h-10 w-10 items-center justify-center rounded-full`, children: _jsx(Check, { className: "text-as-content-icon-success h-6 w-6" }) }), _jsx("h2", { className: "text-as-primary mt-4 text-xl font-semibold", children: text }), _jsx("div", { className: "text-as-tertiarry mt-1 text-center", children: description })] })) : (_jsxs("div", { className: "flex flex-col items-center", children: [_jsx("div", { className: "bg-as-error-secondary flex h-10 w-10 items-center justify-center rounded-full text-base", children: _jsx(X, { className: "text-as-content-icon-error h-5 w-5" }) }), _jsx("div", { className: "font-sf-rounded text-as-content-primary mt-4 text-lg font-semibold", children: text }), _jsx("div", { className: "text-as-tertiarry text-center", style: { whiteSpace: "normal" }, children: description })] })) }));
|
|
39
39
|
});
|
|
@@ -4,8 +4,6 @@ export { AnySpendBuySpin } from "./AnySpendBuySpin";
|
|
|
4
4
|
export { AnySpendCollectorClubPurchase } from "./AnySpendCollectorClubPurchase";
|
|
5
5
|
export { AnySpendCustom } from "./AnySpendCustom";
|
|
6
6
|
export { AnySpendCustomExactIn } from "./AnySpendCustomExactIn";
|
|
7
|
-
export { AnySpendDeposit } from "./AnySpendDeposit";
|
|
8
|
-
export type { AnySpendDepositProps, ChainConfig, DepositContractConfig } from "./AnySpendDeposit";
|
|
9
7
|
export { AnySpendDepositHype, HYPE_TOKEN_DETAILS } from "./AnyspendDepositHype";
|
|
10
8
|
export * from "./AnySpendFingerprintWrapper";
|
|
11
9
|
export { AnySpendNFT } from "./AnySpendNFT";
|
|
@@ -5,7 +5,6 @@ export { AnySpendBuySpin } from "./AnySpendBuySpin.js";
|
|
|
5
5
|
export { AnySpendCollectorClubPurchase } from "./AnySpendCollectorClubPurchase.js";
|
|
6
6
|
export { AnySpendCustom } from "./AnySpendCustom.js";
|
|
7
7
|
export { AnySpendCustomExactIn } from "./AnySpendCustomExactIn.js";
|
|
8
|
-
export { AnySpendDeposit } from "./AnySpendDeposit.js";
|
|
9
8
|
export { AnySpendDepositHype, HYPE_TOKEN_DETAILS } from "./AnyspendDepositHype.js";
|
|
10
9
|
export * from "./AnySpendFingerprintWrapper.js";
|
|
11
10
|
export { AnySpendNFT } from "./AnySpendNFT.js";
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * from "./useAnyspendCreateOnrampOrder";
|
|
2
2
|
export * from "./useAnyspendCreateOrder";
|
|
3
|
-
export * from "./useCreateDepositFirstOrder";
|
|
4
3
|
export * from "./useAnyspendOrderAndTransactions";
|
|
5
4
|
export * from "./useAnyspendOrderHistory";
|
|
6
5
|
export * from "./useAnyspendQuote";
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * from "./useAnyspendCreateOnrampOrder.js";
|
|
2
2
|
export * from "./useAnyspendCreateOrder.js";
|
|
3
|
-
export * from "./useCreateDepositFirstOrder.js";
|
|
4
3
|
export * from "./useAnyspendOrderAndTransactions.js";
|
|
5
4
|
export * from "./useAnyspendOrderHistory.js";
|
|
6
5
|
export * from "./useAnyspendQuote.js";
|
|
@@ -24,9 +24,9 @@ interface UseAnyspendFlowProps {
|
|
|
24
24
|
destinationTokenChainId?: number;
|
|
25
25
|
slippage?: number;
|
|
26
26
|
disableUrlParamManagement?: boolean;
|
|
27
|
-
orderType?: "hype_duel" | "custom_exact_in"
|
|
27
|
+
orderType?: "hype_duel" | "custom_exact_in";
|
|
28
28
|
}
|
|
29
|
-
export declare function useAnyspendFlow({ paymentType, recipientAddress, loadOrder, onOrderSuccess, onTransactionSuccess, sourceTokenAddress, sourceTokenChainId, destinationTokenAddress, destinationTokenChainId, slippage, disableUrlParamManagement, orderType, }: UseAnyspendFlowProps): {
|
|
29
|
+
export declare function useAnyspendFlow({ paymentType, recipientAddress, loadOrder, isDepositMode, onOrderSuccess, onTransactionSuccess, sourceTokenAddress, sourceTokenChainId, destinationTokenAddress, destinationTokenChainId, slippage, disableUrlParamManagement, orderType, }: UseAnyspendFlowProps): {
|
|
30
30
|
activePanel: PanelView;
|
|
31
31
|
setActivePanel: import("react").Dispatch<import("react").SetStateAction<PanelView>>;
|
|
32
32
|
orderId: string | undefined;
|
|
@@ -24,7 +24,7 @@ export var PanelView;
|
|
|
24
24
|
PanelView[PanelView["FEE_DETAIL"] = 7] = "FEE_DETAIL";
|
|
25
25
|
})(PanelView || (PanelView = {}));
|
|
26
26
|
// This hook serves for order hype_duel and custom_exact_in
|
|
27
|
-
export function useAnyspendFlow({ paymentType = "crypto", recipientAddress, loadOrder, onOrderSuccess, onTransactionSuccess, sourceTokenAddress, sourceTokenChainId, destinationTokenAddress, destinationTokenChainId, slippage = 0, disableUrlParamManagement = false, orderType = "hype_duel", }) {
|
|
27
|
+
export function useAnyspendFlow({ paymentType = "crypto", recipientAddress, loadOrder, isDepositMode = false, onOrderSuccess, onTransactionSuccess, sourceTokenAddress, sourceTokenChainId, destinationTokenAddress, destinationTokenChainId, slippage = 0, disableUrlParamManagement = false, orderType = "hype_duel", }) {
|
|
28
28
|
const searchParams = useSearchParamsSSR();
|
|
29
29
|
const router = useRouter();
|
|
30
30
|
// Panel and order state
|
|
@@ -131,40 +131,16 @@ export function useAnyspendFlow({ paymentType = "crypto", recipientAddress, load
|
|
|
131
131
|
// For fiat payments, always use USDC decimals (6) regardless of selectedSrcToken
|
|
132
132
|
const effectiveDecimals = paymentType === "fiat" ? USDC_BASE.decimals : selectedSrcToken.decimals;
|
|
133
133
|
const activeInputAmountInWei = parseUnits(srcAmount.replace(/,/g, ""), effectiveDecimals).toString();
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
if (orderType === "swap") {
|
|
145
|
-
return {
|
|
146
|
-
...baseParams,
|
|
147
|
-
type: "swap",
|
|
148
|
-
tradeType: "EXACT_INPUT",
|
|
149
|
-
amount: activeInputAmountInWei,
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
else if (orderType === "hype_duel") {
|
|
153
|
-
return {
|
|
154
|
-
...baseParams,
|
|
155
|
-
type: "hype_duel",
|
|
156
|
-
amount: activeInputAmountInWei,
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
return {
|
|
161
|
-
...baseParams,
|
|
162
|
-
type: "custom_exact_in",
|
|
163
|
-
amount: activeInputAmountInWei,
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
})();
|
|
167
|
-
const { anyspendQuote, isLoadingAnyspendQuote, getAnyspendQuoteError } = useAnyspendQuote(quoteRequest);
|
|
134
|
+
const { anyspendQuote, isLoadingAnyspendQuote, getAnyspendQuoteError } = useAnyspendQuote({
|
|
135
|
+
srcChain: paymentType === "fiat" ? base.id : selectedSrcChainId,
|
|
136
|
+
dstChain: isDepositMode ? base.id : selectedDstChainId, // For deposits, always Base; for swaps, use selected destination
|
|
137
|
+
srcTokenAddress: paymentType === "fiat" ? USDC_BASE.address : selectedSrcToken.address,
|
|
138
|
+
dstTokenAddress: selectedDstToken.address,
|
|
139
|
+
type: orderType,
|
|
140
|
+
amount: activeInputAmountInWei,
|
|
141
|
+
recipientAddress: effectiveRecipientAddress,
|
|
142
|
+
onrampVendor: paymentType === "fiat" ? getOnrampVendor(selectedFiatPaymentMethod) : undefined,
|
|
143
|
+
});
|
|
168
144
|
// Get geo options for fiat
|
|
169
145
|
const { geoData, coinbaseAvailablePaymentMethods, stripeWeb2Support } = useGeoOnrampOptions(paymentType === "fiat" ? formatUnits(activeInputAmountInWei, USDC_BASE.decimals) : "0");
|
|
170
146
|
// Update destination amount when quote changes
|
|
@@ -1,22 +1,10 @@
|
|
|
1
|
-
import { formatTokenAmount } from "../../shared/utils/number.js";
|
|
2
1
|
export const getStatusDisplay = (order) => {
|
|
3
|
-
const srcToken = order.metadata?.srcToken;
|
|
4
|
-
const dstToken = order.metadata?.dstToken;
|
|
5
|
-
const formattedSrcAmount = srcToken ? formatTokenAmount(BigInt(order.srcAmount), srcToken.decimals) : undefined;
|
|
6
|
-
const actualDstAmount = order.settlement?.actualDstAmount;
|
|
7
|
-
const formattedActualDstAmount = actualDstAmount && dstToken ? formatTokenAmount(BigInt(actualDstAmount), dstToken.decimals) : undefined;
|
|
8
2
|
switch (order.status) {
|
|
9
|
-
case "scanning_deposit_transaction":
|
|
10
|
-
const depositText = formattedSrcAmount && srcToken
|
|
11
|
-
? `Awaiting ${formattedSrcAmount} ${srcToken.symbol}`
|
|
12
|
-
: order.onrampMetadata
|
|
13
|
-
? "Awaiting Payment"
|
|
14
|
-
: "Awaiting Deposit";
|
|
3
|
+
case "scanning_deposit_transaction":
|
|
15
4
|
return {
|
|
16
|
-
text:
|
|
5
|
+
text: order.onrampMetadata ? "Awaiting Payment" : "Awaiting Deposit",
|
|
17
6
|
status: "processing",
|
|
18
7
|
};
|
|
19
|
-
}
|
|
20
8
|
case "waiting_stripe_payment":
|
|
21
9
|
return {
|
|
22
10
|
text: "Awaiting Payment",
|
|
@@ -39,16 +27,15 @@ export const getStatusDisplay = (order) => {
|
|
|
39
27
|
description: "It will take approximately one minute to complete.",
|
|
40
28
|
};
|
|
41
29
|
case "executed": {
|
|
42
|
-
const receivedText = formattedActualDstAmount && dstToken ? `Received ${formattedActualDstAmount} ${dstToken.symbol}` : undefined;
|
|
43
30
|
const { text, description } = order.type === "swap"
|
|
44
|
-
? { text:
|
|
31
|
+
? { text: "Swap Complete", description: "Your swap has been completed successfully." }
|
|
45
32
|
: order.type === "mint_nft"
|
|
46
33
|
? { text: "NFT Minted", description: "Your NFT has been minted" }
|
|
47
34
|
: order.type === "join_tournament"
|
|
48
35
|
? { text: "Tournament Joined", description: "You have joined the tournament" }
|
|
49
36
|
: order.type === "fund_tournament"
|
|
50
37
|
? { text: "Tournament Funded", description: "You have funded the tournament" }
|
|
51
|
-
: { text:
|
|
38
|
+
: { text: "Order Complete", description: "Your order has been completed" };
|
|
52
39
|
return { text, status: "success", description };
|
|
53
40
|
}
|
|
54
41
|
case "refunding":
|
|
@@ -61,18 +48,8 @@ export const getStatusDisplay = (order) => {
|
|
|
61
48
|
status: "failure",
|
|
62
49
|
description: "This order has failed. Please try again or contact support.",
|
|
63
50
|
};
|
|
64
|
-
case "quoting_after_deposit": {
|
|
65
|
-
return {
|
|
66
|
-
text: "Quoting After Deposit",
|
|
67
|
-
status: "processing",
|
|
68
|
-
description: "Getting quote for the order",
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
51
|
default:
|
|
72
|
-
|
|
73
|
-
text: order.status,
|
|
74
|
-
status: "processing",
|
|
75
|
-
};
|
|
52
|
+
throw new Error("Invalid order status");
|
|
76
53
|
}
|
|
77
54
|
};
|
|
78
55
|
export const getErrorDisplay = (errorDetails) => {
|
|
@@ -144,10 +144,6 @@ export interface AnySpendModalProps extends BaseModalProps {
|
|
|
144
144
|
customUsdInputValues?: string[];
|
|
145
145
|
/** Client-provided reference ID for tracking orders */
|
|
146
146
|
clientReferenceId?: string;
|
|
147
|
-
/** Whether to hide the header */
|
|
148
|
-
hideHeader?: boolean;
|
|
149
|
-
/** When true, disables URL parameter management for swap configuration */
|
|
150
|
-
disableUrlParamManagement?: boolean;
|
|
151
147
|
}
|
|
152
148
|
/**
|
|
153
149
|
* Props for the AnySpend NFT modal
|