@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.
Files changed (90) hide show
  1. package/dist/cjs/anyspend/react/components/AnySpend.d.ts +0 -5
  2. package/dist/cjs/anyspend/react/components/AnySpend.js +49 -59
  3. package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.d.ts +1 -1
  4. package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.js +2 -1
  5. package/dist/cjs/anyspend/react/components/common/OrderDetails.js +12 -17
  6. package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.d.ts +0 -2
  7. package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.js +5 -12
  8. package/dist/cjs/anyspend/react/components/common/OrderStatus.js +2 -2
  9. package/dist/cjs/anyspend/react/components/index.d.ts +0 -2
  10. package/dist/cjs/anyspend/react/components/index.js +1 -3
  11. package/dist/cjs/anyspend/react/hooks/index.d.ts +0 -1
  12. package/dist/cjs/anyspend/react/hooks/index.js +0 -1
  13. package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.d.ts +2 -2
  14. package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +11 -35
  15. package/dist/cjs/anyspend/utils/format.js +5 -28
  16. package/dist/cjs/global-account/react/stores/useModalStore.d.ts +0 -4
  17. package/dist/esm/anyspend/react/components/AnySpend.d.ts +0 -5
  18. package/dist/esm/anyspend/react/components/AnySpend.js +49 -59
  19. package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.d.ts +1 -1
  20. package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.js +2 -1
  21. package/dist/esm/anyspend/react/components/common/OrderDetails.js +12 -17
  22. package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.d.ts +0 -2
  23. package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.js +5 -12
  24. package/dist/esm/anyspend/react/components/common/OrderStatus.js +2 -2
  25. package/dist/esm/anyspend/react/components/index.d.ts +0 -2
  26. package/dist/esm/anyspend/react/components/index.js +0 -1
  27. package/dist/esm/anyspend/react/hooks/index.d.ts +0 -1
  28. package/dist/esm/anyspend/react/hooks/index.js +0 -1
  29. package/dist/esm/anyspend/react/hooks/useAnyspendFlow.d.ts +2 -2
  30. package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +11 -35
  31. package/dist/esm/anyspend/utils/format.js +5 -28
  32. package/dist/esm/global-account/react/stores/useModalStore.d.ts +0 -4
  33. package/dist/styles/index.css +1 -1
  34. package/dist/types/anyspend/react/components/AnySpend.d.ts +0 -5
  35. package/dist/types/anyspend/react/components/AnySpendCustomExactIn.d.ts +1 -1
  36. package/dist/types/anyspend/react/components/common/OrderDetailsCollapsible.d.ts +0 -2
  37. package/dist/types/anyspend/react/components/index.d.ts +0 -2
  38. package/dist/types/anyspend/react/hooks/index.d.ts +0 -1
  39. package/dist/types/anyspend/react/hooks/useAnyspendFlow.d.ts +2 -2
  40. package/dist/types/global-account/react/stores/useModalStore.d.ts +0 -4
  41. package/package.json +1 -1
  42. package/src/anyspend/react/components/AnySpend.tsx +45 -68
  43. package/src/anyspend/react/components/AnySpendCustomExactIn.tsx +3 -2
  44. package/src/anyspend/react/components/common/OrderDetails.tsx +8 -26
  45. package/src/anyspend/react/components/common/OrderDetailsCollapsible.tsx +8 -20
  46. package/src/anyspend/react/components/common/OrderStatus.tsx +2 -2
  47. package/src/anyspend/react/components/index.ts +0 -2
  48. package/src/anyspend/react/hooks/index.ts +0 -1
  49. package/src/anyspend/react/hooks/useAnyspendFlow.ts +12 -37
  50. package/src/anyspend/utils/format.ts +5 -33
  51. package/src/global-account/react/stores/useModalStore.ts +0 -4
  52. package/src/styles/index.css +0 -2
  53. package/dist/cjs/anyspend/react/components/AnySpendDeposit.d.ts +0 -122
  54. package/dist/cjs/anyspend/react/components/AnySpendDeposit.js +0 -190
  55. package/dist/cjs/anyspend/react/components/QRDeposit.d.ts +0 -43
  56. package/dist/cjs/anyspend/react/components/QRDeposit.js +0 -146
  57. package/dist/cjs/anyspend/react/components/common/WarningText.d.ts +0 -32
  58. package/dist/cjs/anyspend/react/components/common/WarningText.js +0 -36
  59. package/dist/cjs/anyspend/react/components/icons/CreditCardIcon.d.ts +0 -6
  60. package/dist/cjs/anyspend/react/components/icons/CreditCardIcon.js +0 -6
  61. package/dist/cjs/anyspend/react/components/icons/QrCodeIcon.d.ts +0 -6
  62. package/dist/cjs/anyspend/react/components/icons/QrCodeIcon.js +0 -6
  63. package/dist/cjs/anyspend/react/hooks/useCreateDepositFirstOrder.d.ts +0 -24
  64. package/dist/cjs/anyspend/react/hooks/useCreateDepositFirstOrder.js +0 -86
  65. package/dist/esm/anyspend/react/components/AnySpendDeposit.d.ts +0 -122
  66. package/dist/esm/anyspend/react/components/AnySpendDeposit.js +0 -187
  67. package/dist/esm/anyspend/react/components/QRDeposit.d.ts +0 -43
  68. package/dist/esm/anyspend/react/components/QRDeposit.js +0 -143
  69. package/dist/esm/anyspend/react/components/common/WarningText.d.ts +0 -32
  70. package/dist/esm/anyspend/react/components/common/WarningText.js +0 -32
  71. package/dist/esm/anyspend/react/components/icons/CreditCardIcon.d.ts +0 -6
  72. package/dist/esm/anyspend/react/components/icons/CreditCardIcon.js +0 -2
  73. package/dist/esm/anyspend/react/components/icons/QrCodeIcon.d.ts +0 -6
  74. package/dist/esm/anyspend/react/components/icons/QrCodeIcon.js +0 -2
  75. package/dist/esm/anyspend/react/hooks/useCreateDepositFirstOrder.d.ts +0 -24
  76. package/dist/esm/anyspend/react/hooks/useCreateDepositFirstOrder.js +0 -83
  77. package/dist/types/anyspend/react/components/AnySpendDeposit.d.ts +0 -122
  78. package/dist/types/anyspend/react/components/QRDeposit.d.ts +0 -43
  79. package/dist/types/anyspend/react/components/common/WarningText.d.ts +0 -32
  80. package/dist/types/anyspend/react/components/icons/CreditCardIcon.d.ts +0 -6
  81. package/dist/types/anyspend/react/components/icons/QrCodeIcon.d.ts +0 -6
  82. package/dist/types/anyspend/react/hooks/useCreateDepositFirstOrder.d.ts +0 -24
  83. package/src/anyspend/react/components/AnySpendDeposit.tsx +0 -578
  84. package/src/anyspend/react/components/QRDeposit.tsx +0 -348
  85. package/src/anyspend/react/components/common/WarningText.tsx +0 -52
  86. package/src/anyspend/react/components/icons/CreditCardIcon.tsx +0 -25
  87. package/src/anyspend/react/components/icons/QrCodeIcon.tsx +0 -25
  88. package/src/anyspend/react/components/icons/credit-card.svg +0 -5
  89. package/src/anyspend/react/components/icons/qr-code.svg +0 -5
  90. package/src/anyspend/react/hooks/useCreateDepositFirstOrder.ts +0 -110
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.QrCodeIcon = void 0;
4
- const jsx_runtime_1 = require("react/jsx-runtime");
5
- const QrCodeIcon = ({ className }) => ((0, jsx_runtime_1.jsxs)("svg", { width: "40", height: "40", viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: className, children: [(0, jsx_runtime_1.jsx)("path", { d: "M8 0.5H32C36.1421 0.5 39.5 3.85786 39.5 8V32C39.5 36.1421 36.1421 39.5 32 39.5H8C3.85786 39.5 0.5 36.1421 0.5 32V8C0.5 3.85786 3.85786 0.5 8 0.5Z", fill: "#F4F4F5" }), (0, jsx_runtime_1.jsx)("path", { d: "M8 0.5H32C36.1421 0.5 39.5 3.85786 39.5 8V32C39.5 36.1421 36.1421 39.5 32 39.5H8C3.85786 39.5 0.5 36.1421 0.5 32V8C0.5 3.85786 3.85786 0.5 8 0.5Z", stroke: "#E4E4E7" }), (0, jsx_runtime_1.jsx)("path", { d: "M15 20H20V25M11.01 20H11M16.01 25H16M20.01 29H20M29.01 20H29M11 25H12.5M23.5 20H25.5M11 29H16M20 10V16M25.6 29H27.4C27.9601 29 28.2401 29 28.454 28.891C28.6422 28.7951 28.7951 28.6422 28.891 28.454C29 28.2401 29 27.9601 29 27.4V25.6C29 25.0399 29 24.7599 28.891 24.546C28.7951 24.3578 28.6422 24.2049 28.454 24.109C28.2401 24 27.9601 24 27.4 24H25.6C25.0399 24 24.7599 24 24.546 24.109C24.3578 24.2049 24.2049 24.3578 24.109 24.546C24 24.7599 24 25.0399 24 25.6V27.4C24 27.9601 24 28.2401 24.109 28.454C24.2049 28.6422 24.3578 28.7951 24.546 28.891C24.7599 29 25.0399 29 25.6 29ZM25.6 16H27.4C27.9601 16 28.2401 16 28.454 15.891C28.6422 15.7951 28.7951 15.6422 28.891 15.454C29 15.2401 29 14.9601 29 14.4V12.6C29 12.0399 29 11.7599 28.891 11.546C28.7951 11.3578 28.6422 11.2049 28.454 11.109C28.2401 11 27.9601 11 27.4 11H25.6C25.0399 11 24.7599 11 24.546 11.109C24.3578 11.2049 24.2049 11.3578 24.109 11.546C24 11.7599 24 12.0399 24 12.6V14.4C24 14.9601 24 15.2401 24.109 15.454C24.2049 15.6422 24.3578 15.7951 24.546 15.891C24.7599 16 25.0399 16 25.6 16ZM12.6 16H14.4C14.9601 16 15.2401 16 15.454 15.891C15.6422 15.7951 15.7951 15.6422 15.891 15.454C16 15.2401 16 14.9601 16 14.4V12.6C16 12.0399 16 11.7599 15.891 11.546C15.7951 11.3578 15.6422 11.2049 15.454 11.109C15.2401 11 14.9601 11 14.4 11H12.6C12.0399 11 11.7599 11 11.546 11.109C11.3578 11.2049 11.2049 11.3578 11.109 11.546C11 11.7599 11 12.0399 11 12.6V14.4C11 14.9601 11 15.2401 11.109 15.454C11.2049 15.6422 11.3578 15.7951 11.546 15.891C11.7599 16 12.0399 16 12.6 16Z", stroke: "#51525C", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })] }));
6
- exports.QrCodeIcon = QrCodeIcon;
@@ -1,24 +0,0 @@
1
- import { components } from "../../../anyspend/types/api";
2
- import { DepositContractConfig } from "../components/AnySpendDeposit";
3
- export type CreateDepositFirstOrderParams = {
4
- recipientAddress: string;
5
- srcChain: number;
6
- dstChain: number;
7
- srcToken: components["schemas"]["Token"];
8
- dstToken: components["schemas"]["Token"];
9
- creatorAddress?: string;
10
- /** Optional contract config for custom execution after deposit */
11
- contractConfig?: DepositContractConfig;
12
- };
13
- export type UseCreateDepositFirstOrderProps = {
14
- onSuccess?: (data: any) => void;
15
- onError?: (error: Error) => void;
16
- };
17
- /**
18
- * Hook for creating deposit_first orders in the Anyspend protocol.
19
- * This order type doesn't require srcAmount - the user deposits tokens after the order is created.
20
- */
21
- export declare function useCreateDepositFirstOrder({ onSuccess, onError }?: UseCreateDepositFirstOrderProps): {
22
- createOrder: import("@tanstack/react-query").UseMutateFunction<any, Error, CreateDepositFirstOrderParams, unknown>;
23
- isCreatingOrder: boolean;
24
- };
@@ -1,86 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useCreateDepositFirstOrder = useCreateDepositFirstOrder;
4
- const anyspend_1 = require("../../../anyspend/services/anyspend");
5
- const utils_1 = require("../../../anyspend/utils");
6
- const react_1 = require("../../../global-account/react");
7
- const fingerprintjs_pro_react_1 = require("@fingerprintjs/fingerprintjs-pro-react");
8
- const react_query_1 = require("@tanstack/react-query");
9
- const react_2 = require("react");
10
- /**
11
- * Hook for creating deposit_first orders in the Anyspend protocol.
12
- * This order type doesn't require srcAmount - the user deposits tokens after the order is created.
13
- */
14
- function useCreateDepositFirstOrder({ onSuccess, onError } = {}) {
15
- const { partnerId } = (0, react_1.useB3)();
16
- const { data: fpData } = (0, fingerprintjs_pro_react_1.useVisitorData)({ extendedResult: true }, { immediate: true });
17
- const visitorData = fpData && {
18
- requestId: fpData.requestId,
19
- visitorId: fpData.visitorId,
20
- };
21
- const { mutate: createOrder, isPending } = (0, react_query_1.useMutation)({
22
- mutationFn: async (params) => {
23
- const { recipientAddress, srcChain, dstChain, srcToken, dstToken, creatorAddress, contractConfig } = params;
24
- // Build payload based on whether we have a contract config
25
- const payload = contractConfig
26
- ? {
27
- functionAbi: contractConfig.functionAbi,
28
- functionName: contractConfig.functionName,
29
- functionArgs: contractConfig.functionArgs,
30
- to: (0, utils_1.normalizeAddress)(contractConfig.to),
31
- spenderAddress: contractConfig.spenderAddress ? (0, utils_1.normalizeAddress)(contractConfig.spenderAddress) : undefined,
32
- action: contractConfig.action,
33
- }
34
- : {};
35
- try {
36
- return await anyspend_1.anyspendService.createOrder({
37
- recipientAddress: (0, utils_1.normalizeAddress)(recipientAddress),
38
- type: "deposit_first",
39
- srcChain,
40
- dstChain,
41
- srcTokenAddress: (0, utils_1.normalizeAddress)(srcToken.address),
42
- dstTokenAddress: (0, utils_1.normalizeAddress)(dstToken.address),
43
- srcAmount: "", // Not required for deposit_first
44
- payload,
45
- metadata: {
46
- srcToken: {
47
- chainId: srcToken.chainId,
48
- address: srcToken.address,
49
- symbol: srcToken.symbol,
50
- name: srcToken.name,
51
- decimals: srcToken.decimals,
52
- metadata: srcToken.metadata || {},
53
- },
54
- dstToken: {
55
- chainId: dstToken.chainId,
56
- address: dstToken.address,
57
- symbol: dstToken.symbol,
58
- name: dstToken.name,
59
- decimals: dstToken.decimals,
60
- metadata: dstToken.metadata || {},
61
- },
62
- },
63
- creatorAddress: creatorAddress ? (0, utils_1.normalizeAddress)(creatorAddress) : undefined,
64
- partnerId,
65
- visitorData,
66
- });
67
- }
68
- catch (error) {
69
- if (error?.data) {
70
- throw error.data;
71
- }
72
- throw error;
73
- }
74
- },
75
- onSuccess: (data) => {
76
- onSuccess?.(data);
77
- },
78
- onError: (error) => {
79
- onError?.(error);
80
- },
81
- });
82
- return (0, react_2.useMemo)(() => ({
83
- createOrder,
84
- isCreatingOrder: isPending,
85
- }), [createOrder, isPending]);
86
- }
@@ -1,122 +0,0 @@
1
- import { components } from "../../../anyspend/types/api";
2
- import { GetQuoteResponse } from "../../../anyspend/types/api_req_res";
3
- export interface DepositContractConfig {
4
- /** Custom function ABI JSON string */
5
- functionAbi: string;
6
- /** The function name to call */
7
- functionName: string;
8
- /** Custom function arguments. Use "{{amount_out}}" for the deposit amount placeholder */
9
- functionArgs: string[];
10
- /** The contract address to deposit to */
11
- to: string;
12
- /** Optional spender address if different from contract address */
13
- spenderAddress?: string;
14
- /** Custom action label */
15
- action?: string;
16
- }
17
- export interface ChainConfig {
18
- /** Chain ID */
19
- id: number;
20
- /** Display name */
21
- name: string;
22
- /** Optional icon URL */
23
- iconUrl?: string;
24
- }
25
- export interface AnySpendDepositProps {
26
- /** Order ID to load an existing order */
27
- loadOrder?: string;
28
- /** Display mode */
29
- mode?: "modal" | "page";
30
- /** The recipient address for the deposit */
31
- recipientAddress: string;
32
- /** Payment type - crypto or fiat. If not set, shows chain selection first */
33
- paymentType?: "crypto" | "fiat";
34
- /** Source token address to pre-select */
35
- sourceTokenAddress?: string;
36
- /** Source chain ID to pre-select. If not provided, shows chain selection */
37
- sourceTokenChainId?: number;
38
- /** The destination token to receive */
39
- destinationToken: components["schemas"]["Token"];
40
- /** The destination chain ID */
41
- destinationChainId: number;
42
- /** Callback when deposit succeeds */
43
- onSuccess?: (amount: string) => void;
44
- /** Callback for opening a custom modal (e.g., for special token handling) */
45
- onOpenCustomModal?: () => void;
46
- /** Custom footer content */
47
- mainFooter?: React.ReactNode;
48
- /** Called when a token is selected. Call event.preventDefault() to prevent default behavior */
49
- onTokenSelect?: (token: components["schemas"]["Token"], event: {
50
- preventDefault: () => void;
51
- }) => void;
52
- /** Custom USD input value presets for fiat payment */
53
- customUsdInputValues?: string[];
54
- /** Whether to prefer using connected EOA wallet */
55
- preferEoa?: boolean;
56
- /** Minimum destination amount required */
57
- minDestinationAmount?: number;
58
- /** Custom header component */
59
- header?: ({ anyspendPrice, isLoadingAnyspendPrice, }: {
60
- anyspendPrice: GetQuoteResponse | undefined;
61
- isLoadingAnyspendPrice: boolean;
62
- }) => React.JSX.Element;
63
- /** Order type for the deposit */
64
- orderType?: "hype_duel" | "custom_exact_in" | "swap";
65
- /** Custom action label displayed on buttons */
66
- actionLabel?: string;
67
- /** Configuration for depositing to a custom contract.
68
- * If provided, creates a custom_exact_in order that calls the contract.
69
- * If not provided, creates a simple hype_duel order for direct deposits.
70
- */
71
- depositContractConfig?: DepositContractConfig;
72
- /** Whether to show chain selection step. Defaults to true if sourceTokenChainId is not provided */
73
- showChainSelection?: boolean;
74
- /** Custom list of supported chains. If not provided, uses default chains */
75
- supportedChains?: ChainConfig[];
76
- /** Minimum pool size for filtering tokens (default: 1,000,000) */
77
- minPoolSize?: number;
78
- /** Custom title for chain selection step */
79
- chainSelectionTitle?: string;
80
- /** Custom description for chain selection step */
81
- chainSelectionDescription?: string;
82
- /** Number of top chains to show (default: 3) */
83
- topChainsCount?: number;
84
- /** Callback when close button is clicked */
85
- onClose?: () => void;
86
- }
87
- /**
88
- * A flexible deposit component that wraps AnySpendCustomExactIn with optional chain selection.
89
- *
90
- * @example
91
- * // Simple deposit with chain selection
92
- * <AnySpendDeposit
93
- * recipientAddress={userAddress}
94
- * destinationToken={myToken}
95
- * destinationChainId={base.id}
96
- * onSuccess={(amount) => console.log(`Deposited ${amount}`)}
97
- * />
98
- *
99
- * @example
100
- * // Skip chain selection by providing sourceTokenChainId
101
- * <AnySpendDeposit
102
- * recipientAddress={userAddress}
103
- * destinationToken={myToken}
104
- * destinationChainId={base.id}
105
- * sourceTokenChainId={base.id}
106
- * onSuccess={(amount) => console.log(`Deposited ${amount}`)}
107
- * />
108
- *
109
- * @example
110
- * // Deposit with custom contract
111
- * <AnySpendDeposit
112
- * recipientAddress={userAddress}
113
- * destinationToken={myToken}
114
- * destinationChainId={base.id}
115
- * depositContractConfig={{
116
- * contractAddress: "0x...",
117
- * functionName: "depositFor",
118
- * }}
119
- * onSuccess={(amount) => console.log(`Deposited ${amount}`)}
120
- * />
121
- */
122
- export declare function AnySpendDeposit({ loadOrder, mode, recipientAddress, paymentType: initialPaymentType, sourceTokenAddress, sourceTokenChainId: initialSourceChainId, destinationToken, destinationChainId, onSuccess, onOpenCustomModal, mainFooter, onTokenSelect, customUsdInputValues, preferEoa, minDestinationAmount, header, orderType, depositContractConfig, showChainSelection, supportedChains, minPoolSize, topChainsCount, onClose, }: AnySpendDepositProps): import("react/jsx-runtime").JSX.Element | null;
@@ -1,187 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { HYPERLIQUID_CHAIN_ID } from "../../../anyspend/index.js";
3
- import { Skeleton, useAccountWallet, useSimBalance } from "../../../global-account/react/index.js";
4
- import { cn } from "../../../shared/utils/cn.js";
5
- import { NetworkArbitrumOne, NetworkBase, NetworkBinanceSmartChain, NetworkEthereum, NetworkOptimism, NetworkPolygonPos, } from "@web3icons/react";
6
- import { ChevronRight } from "lucide-react";
7
- import { useMemo, useState } from "react";
8
- import { AnySpend } from "./AnySpend.js";
9
- import { AnySpendCustomExactIn } from "./AnySpendCustomExactIn.js";
10
- import { ChainWarningText } from "./common/WarningText.js";
11
- import { CreditCardIcon } from "./icons/CreditCardIcon.js";
12
- import { QrCodeIcon } from "./icons/QrCodeIcon.js";
13
- import { QRDeposit } from "./QRDeposit.js";
14
- // Default supported chains
15
- const DEFAULT_SUPPORTED_CHAINS = [
16
- { id: 8453, name: "Base" },
17
- { id: 1, name: "Ethereum" },
18
- { id: 42161, name: "Arbitrum" },
19
- { id: 10, name: "Optimism" },
20
- { id: 137, name: "Polygon" },
21
- { id: 56, name: "BNB Chain" },
22
- ];
23
- // Minimum pool size to filter out low liquidity tokens
24
- const DEFAULT_MIN_POOL_SIZE = 1000000;
25
- function formatUsd(value) {
26
- return new Intl.NumberFormat("en-US", {
27
- style: "currency",
28
- currency: "USD",
29
- minimumFractionDigits: 0,
30
- maximumFractionDigits: value >= 100 ? 0 : 2,
31
- }).format(value);
32
- }
33
- function formatDecimal(value) {
34
- return new Intl.NumberFormat("en-US", {
35
- style: "decimal",
36
- minimumFractionDigits: 0,
37
- maximumFractionDigits: value >= 100 ? 0 : 2,
38
- }).format(value);
39
- }
40
- // Chain icon component
41
- function ChainIcon({ chainId, className }) {
42
- const iconProps = {
43
- variant: "branded",
44
- className: cn("anyspend-deposit-chain-icon", className),
45
- };
46
- switch (chainId) {
47
- case 1:
48
- return _jsx(NetworkEthereum, { ...iconProps });
49
- case 8453:
50
- return _jsx(NetworkBase, { ...iconProps });
51
- case 137:
52
- return _jsx(NetworkPolygonPos, { ...iconProps });
53
- case 42161:
54
- return _jsx(NetworkArbitrumOne, { ...iconProps });
55
- case 10:
56
- return _jsx(NetworkOptimism, { ...iconProps });
57
- case 56:
58
- return _jsx(NetworkBinanceSmartChain, { ...iconProps });
59
- default:
60
- return null;
61
- }
62
- }
63
- /**
64
- * A flexible deposit component that wraps AnySpendCustomExactIn with optional chain selection.
65
- *
66
- * @example
67
- * // Simple deposit with chain selection
68
- * <AnySpendDeposit
69
- * recipientAddress={userAddress}
70
- * destinationToken={myToken}
71
- * destinationChainId={base.id}
72
- * onSuccess={(amount) => console.log(`Deposited ${amount}`)}
73
- * />
74
- *
75
- * @example
76
- * // Skip chain selection by providing sourceTokenChainId
77
- * <AnySpendDeposit
78
- * recipientAddress={userAddress}
79
- * destinationToken={myToken}
80
- * destinationChainId={base.id}
81
- * sourceTokenChainId={base.id}
82
- * onSuccess={(amount) => console.log(`Deposited ${amount}`)}
83
- * />
84
- *
85
- * @example
86
- * // Deposit with custom contract
87
- * <AnySpendDeposit
88
- * recipientAddress={userAddress}
89
- * destinationToken={myToken}
90
- * destinationChainId={base.id}
91
- * depositContractConfig={{
92
- * contractAddress: "0x...",
93
- * functionName: "depositFor",
94
- * }}
95
- * onSuccess={(amount) => console.log(`Deposited ${amount}`)}
96
- * />
97
- */
98
- export function AnySpendDeposit({ loadOrder, mode = "modal", recipientAddress, paymentType: initialPaymentType, sourceTokenAddress, sourceTokenChainId: initialSourceChainId, destinationToken, destinationChainId, onSuccess, onOpenCustomModal, mainFooter, onTokenSelect, customUsdInputValues, preferEoa, minDestinationAmount, header, orderType, depositContractConfig, showChainSelection, supportedChains = DEFAULT_SUPPORTED_CHAINS, minPoolSize = DEFAULT_MIN_POOL_SIZE, topChainsCount = 3, onClose, }) {
99
- const { connectedEOAWallet } = useAccountWallet();
100
- const eoaAddress = connectedEOAWallet?.getAccount()?.address;
101
- // Determine if we should show chain selection
102
- const shouldShowChainSelection = showChainSelection ?? (!initialSourceChainId && !initialPaymentType);
103
- const [step, setStep] = useState(shouldShowChainSelection ? "select-chain" : "deposit");
104
- const [selectedChainId, setSelectedChainId] = useState(initialSourceChainId);
105
- const [paymentType, setPaymentType] = useState(initialPaymentType ?? "crypto");
106
- // Fetch balances for EOA wallet
107
- const { data: balanceData, isLoading: isBalanceLoading } = useSimBalance(shouldShowChainSelection ? eoaAddress : undefined, supportedChains.map(c => c.id));
108
- // Group balances by chain and calculate total USD value per chain
109
- const chainBalances = useMemo(() => {
110
- if (!balanceData?.balances)
111
- return {};
112
- const filteredBalances = balanceData.balances.filter(token => token.address === "native" || (token.pool_size && token.pool_size > minPoolSize));
113
- return filteredBalances.reduce((acc, token) => {
114
- const chainId = token.chain_id;
115
- if (!acc[chainId]) {
116
- acc[chainId] = {
117
- chainId,
118
- chainName: token.chain,
119
- totalUsdValue: 0,
120
- tokenCount: 0,
121
- };
122
- }
123
- acc[chainId].totalUsdValue += token.value_usd || 0;
124
- acc[chainId].tokenCount += 1;
125
- return acc;
126
- }, {});
127
- }, [balanceData, minPoolSize]);
128
- // Sort chains by USD value (highest first)
129
- const sortedChains = useMemo(() => {
130
- return supportedChains
131
- .map(chain => ({
132
- ...chain,
133
- balance: chainBalances[chain.id]?.totalUsdValue || 0,
134
- tokenCount: chainBalances[chain.id]?.tokenCount || 0,
135
- }))
136
- .sort((a, b) => b.balance - a.balance);
137
- }, [supportedChains, chainBalances]);
138
- // Get top chains with balance
139
- const topChainsWithBalance = useMemo(() => {
140
- return sortedChains.filter(chain => chain.balance > 0).slice(0, topChainsCount);
141
- }, [sortedChains, topChainsCount]);
142
- // Calculate total balance across all chains
143
- const totalBalance = useMemo(() => {
144
- return Object.values(chainBalances).reduce((sum, chain) => sum + chain.totalUsdValue, 0);
145
- }, [chainBalances]);
146
- if (!recipientAddress)
147
- return null;
148
- const tokenSymbol = destinationToken.symbol ?? "TOKEN";
149
- // Determine order type based on config
150
- const effectiveOrderType = orderType ?? (depositContractConfig ? "custom_exact_in" : "swap");
151
- // Default header if not provided
152
- const defaultHeader = () => (_jsx("div", { className: "anyspend-deposit-header mb-4 flex flex-col items-center gap-3 text-center", children: _jsx("div", { children: _jsx("h1", { className: "anyspend-deposit-title text-as-primary text-xl font-bold", children: paymentType === "crypto" ? `Deposit ${tokenSymbol}` : "Fund with Fiat" }) }) }));
153
- const handleSelectChain = (chainId) => {
154
- setSelectedChainId(chainId);
155
- setPaymentType("crypto");
156
- setStep("deposit");
157
- };
158
- const handleSelectCrypto = () => {
159
- setPaymentType("crypto");
160
- setSelectedChainId(undefined);
161
- setStep("deposit");
162
- };
163
- const handleSelectFiat = () => {
164
- setPaymentType("fiat");
165
- setSelectedChainId(undefined);
166
- setStep("deposit");
167
- };
168
- const handleBack = () => {
169
- setStep("select-chain");
170
- setSelectedChainId(undefined);
171
- };
172
- const handleSelectQrDeposit = () => {
173
- setStep("qr-deposit");
174
- };
175
- // Chain selection view
176
- if (step === "select-chain") {
177
- return (_jsxs("div", { className: 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: "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" }) }) })), _jsxs("div", { className: "anyspend-deposit-balance-header border-secondary border-b p-5", children: [!isBalanceLoading && totalBalance > 0 && (_jsxs("div", { className: "anyspend-deposit-balance", children: [_jsx("p", { className: "anyspend-deposit-balance-label text-as-secondary text-sm", children: "Your Balance" }), _jsxs("p", { className: "anyspend-deposit-balance-value text-as-primary text-3xl font-semibold", children: [formatDecimal(totalBalance), " ", _jsx("span", { className: "text-sm", children: "USD" })] })] })), isBalanceLoading && (_jsxs("div", { className: "anyspend-deposit-balance-skeleton", children: [_jsx(Skeleton, { className: "mb-2 h-4 w-24" }), _jsx(Skeleton, { className: "h-8 w-32" })] }))] }), _jsxs("div", { className: "anyspend-deposit-options flex flex-col gap-2 p-6", children: [isBalanceLoading && (_jsx("div", { className: "anyspend-deposit-chains-skeleton flex flex-col gap-2", children: [...Array(topChainsCount)].map((_, i) => (_jsxs("div", { className: "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: "anyspend-deposit-chains flex flex-col gap-2", children: topChainsWithBalance.map(chain => (_jsxs("button", { onClick: () => handleSelectChain(chain.id), className: "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: "anyspend-deposit-chain-content", children: _jsxs("div", { className: "anyspend-deposit-chain-info", children: [_jsxs("span", { className: "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: "h-5 w-5" })] }), _jsxs("p", { className: "anyspend-deposit-chain-balance text-as-secondary text-xs", children: [formatUsd(chain.balance), " available"] })] }) }), _jsx(ChevronRight, { className: "anyspend-deposit-chain-chevron text-as-secondary h-5 w-5" })] }, chain.id))) })), _jsxs("div", { className: "anyspend-deposit-general-options flex flex-col gap-2", children: [_jsxs("button", { onClick: handleSelectCrypto, className: "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: "anyspend-deposit-option-content", children: _jsxs("div", { className: "anyspend-deposit-option-info", children: [_jsx("span", { className: "anyspend-deposit-option-title text-as-primary font-medium", children: "Deposit Crypto" }), _jsx("p", { className: "anyspend-deposit-option-description text-as-secondary text-xs", children: "Swap from any token on any chain" })] }) }), _jsx(ChevronRight, { className: "anyspend-deposit-option-chevron text-as-secondary h-5 w-5" })] }), _jsxs("div", { className: "anyspend-deposit-divider flex items-center gap-3", children: [_jsx("div", { className: "bg-as-stroke h-px flex-1" }), _jsx("span", { className: "anyspend-deposit-divider-text text-as-secondary text-sm", children: "More options" }), _jsx("div", { className: "bg-as-stroke h-px flex-1" })] }), _jsxs("button", { onClick: handleSelectQrDeposit, className: "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: "anyspend-deposit-option-content flex items-center gap-3", children: [_jsx(QrCodeIcon, { className: "anyspend-deposit-option-icon h-10 w-10" }), _jsxs("div", { className: "anyspend-deposit-option-info", children: [_jsx("span", { className: "anyspend-deposit-option-title text-as-primary font-medium", children: "Deposit with QR Code" }), _jsx("p", { className: "anyspend-deposit-option-description text-as-secondary text-xs", children: "Send tokens directly to deposit address" })] })] }), _jsx(ChevronRight, { className: "anyspend-deposit-option-chevron text-as-secondary h-5 w-5" })] }), _jsxs("button", { onClick: handleSelectFiat, className: "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: "anyspend-deposit-option-content flex items-center gap-3", children: [_jsx(CreditCardIcon, { className: "anyspend-deposit-option-icon h-10 w-10" }), _jsxs("div", { className: "anyspend-deposit-option-info", children: [_jsx("span", { className: "anyspend-deposit-option-title text-as-primary font-medium", children: "Fund with Fiat" }), _jsx("p", { className: "anyspend-deposit-option-description text-as-secondary text-xs", children: "Pay with card or bank transfer" })] })] }), _jsx(ChevronRight, { className: "anyspend-deposit-option-chevron text-as-secondary h-5 w-5" })] })] }), _jsx(ChainWarningText, { chainId: destinationChainId, className: "mt-2" })] })] }));
178
- }
179
- // QR Deposit view
180
- if (step === "qr-deposit") {
181
- return (_jsx(QRDeposit, { mode: mode, recipientAddress: recipientAddress, destinationToken: destinationToken, destinationChainId: destinationChainId, depositContractConfig: depositContractConfig, onBack: handleBack, onClose: onClose ?? handleBack }));
182
- }
183
- // Check if destination is Hyperliquid
184
- const isHyperliquidDeposit = destinationChainId === HYPERLIQUID_CHAIN_ID;
185
- // Deposit view
186
- return (_jsxs("div", { className: "anyspend-deposit anyspend-deposit-form relative", children: [shouldShowChainSelection && (_jsxs("button", { onClick: handleBack, className: "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: "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: "anyspend-deposit-back-text text-sm", children: "Back" })] })), onClose && (_jsx("button", { onClick: onClose, className: "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: cn("anyspend-deposit-form-content", shouldShowChainSelection && "pt-8"), children: isHyperliquidDeposit ? (_jsx(AnySpend, { loadOrder: loadOrder, mode: mode, defaultActiveTab: paymentType, recipientAddress: recipientAddress, sourceChainId: selectedChainId, destinationTokenAddress: destinationToken.address, destinationTokenChainId: destinationChainId, onSuccess: txHash => onSuccess?.(txHash ?? ""), onTokenSelect: onTokenSelect, customUsdInputValues: customUsdInputValues, hideHeader: true, hideBottomNavigation: true, disableUrlParamManagement: true })) : (_jsx(AnySpendCustomExactIn, { loadOrder: loadOrder, mode: mode, recipientAddress: recipientAddress, paymentType: paymentType, sourceTokenAddress: sourceTokenAddress, sourceTokenChainId: selectedChainId, destinationToken: destinationToken, destinationChainId: destinationChainId, orderType: effectiveOrderType, minDestinationAmount: minDestinationAmount, header: header ?? defaultHeader, onSuccess: onSuccess, onOpenCustomModal: onOpenCustomModal, mainFooter: mainFooter, onTokenSelect: onTokenSelect, customUsdInputValues: customUsdInputValues, preferEoa: preferEoa, customExactInConfig: depositContractConfig })) }), _jsx(ChainWarningText, { chainId: destinationChainId, className: "px-4 pb-4" })] }));
187
- }
@@ -1,43 +0,0 @@
1
- import { components } from "../../../anyspend/types/api";
2
- import { DepositContractConfig } from "./AnySpendDeposit";
3
- export interface QRDepositProps {
4
- /** Display mode */
5
- mode?: "modal" | "page";
6
- /** The recipient address (user's wallet) */
7
- recipientAddress: string;
8
- /** The source token to deposit (defaults to ETH on Base) */
9
- sourceToken?: components["schemas"]["Token"];
10
- /** The source chain ID (defaults to Base) */
11
- sourceChainId?: number;
12
- /** The destination token to receive */
13
- destinationToken: components["schemas"]["Token"];
14
- /** The destination chain ID */
15
- destinationChainId: number;
16
- /** Creator address (optional) */
17
- creatorAddress?: string;
18
- /** Contract config for custom execution after deposit */
19
- depositContractConfig?: DepositContractConfig;
20
- /** Callback when back button is clicked */
21
- onBack?: () => void;
22
- /** Callback when close button is clicked */
23
- onClose?: () => void;
24
- /** Callback when order is created successfully */
25
- onOrderCreated?: (orderId: string) => void;
26
- /** Callback when deposit is completed */
27
- onSuccess?: (txHash?: string) => void;
28
- }
29
- /**
30
- * A component for displaying QR code deposit functionality.
31
- * Creates a deposit_first order on mount and shows a QR code that can be scanned to deposit tokens.
32
- * Users can change the source token/chain using the TokenSelector.
33
- *
34
- * @example
35
- * <QRDeposit
36
- * recipientAddress={userAddress}
37
- * destinationToken={usdcArbitrumToken}
38
- * destinationChainId={42161}
39
- * onBack={() => setStep("select-chain")}
40
- * onSuccess={(txHash) => console.log("Deposit complete:", txHash)}
41
- * />
42
- */
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;
@@ -1,143 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { ALL_CHAINS, getAvailableChainIds } from "../../../anyspend/index.js";
3
- import { Button, toast } from "../../../global-account/react/index.js";
4
- import { cn } from "../../../shared/utils/cn.js";
5
- import { TokenSelector } from "@relayprotocol/relay-kit-ui";
6
- import { Check, ChevronsUpDown, Copy, Loader2 } from "lucide-react";
7
- import { QRCodeSVG } from "qrcode.react";
8
- import { useEffect, useRef, useState } from "react";
9
- import { useAnyspendOrderAndTransactions } from "../hooks/useAnyspendOrderAndTransactions.js";
10
- import { useCreateDepositFirstOrder } from "../hooks/useCreateDepositFirstOrder.js";
11
- import { ChainTokenIcon } from "./common/ChainTokenIcon.js";
12
- import { OrderDetails } from "./common/OrderDetails.js";
13
- import { ChainWarningText, WarningText } from "./common/WarningText.js";
14
- // Default source token: ETH on Base
15
- const DEFAULT_ETH_ON_BASE = {
16
- chainId: 8453,
17
- address: "0x0000000000000000000000000000000000000000",
18
- symbol: "ETH",
19
- name: "Ethereum",
20
- decimals: 18,
21
- metadata: {
22
- logoURI: "https://assets.relay.link/icons/1/light.png",
23
- },
24
- };
25
- /**
26
- * A component for displaying QR code deposit functionality.
27
- * Creates a deposit_first order on mount and shows a QR code that can be scanned to deposit tokens.
28
- * Users can change the source token/chain using the TokenSelector.
29
- *
30
- * @example
31
- * <QRDeposit
32
- * recipientAddress={userAddress}
33
- * destinationToken={usdcArbitrumToken}
34
- * destinationChainId={42161}
35
- * onBack={() => setStep("select-chain")}
36
- * onSuccess={(txHash) => console.log("Deposit complete:", txHash)}
37
- * />
38
- */
39
- export function QRDeposit({ mode = "modal", recipientAddress, sourceToken: sourceTokenProp, sourceChainId: sourceChainIdProp, destinationToken, destinationChainId, creatorAddress, depositContractConfig, onBack, onClose, onOrderCreated, onSuccess, }) {
40
- const [copied, setCopied] = useState(false);
41
- const [orderId, setOrderId] = useState();
42
- const [globalAddress, setGlobalAddress] = useState();
43
- const orderCreatedRef = useRef(false);
44
- const onSuccessCalled = useRef(false);
45
- // Source token/chain as state (can be changed by user)
46
- const [sourceChainId, setSourceChainId] = useState(sourceChainIdProp ?? 8453);
47
- const [sourceToken, setSourceToken] = useState(sourceTokenProp ?? DEFAULT_ETH_ON_BASE);
48
- // Handle token selection from TokenSelector
49
- const handleTokenSelect = (newToken) => {
50
- const token = {
51
- address: newToken.address,
52
- chainId: newToken.chainId,
53
- decimals: newToken.decimals,
54
- metadata: { logoURI: newToken.logoURI },
55
- name: newToken.name,
56
- symbol: newToken.symbol,
57
- };
58
- // Reset order state when token changes
59
- setOrderId(undefined);
60
- setGlobalAddress(undefined);
61
- orderCreatedRef.current = false;
62
- // Update token and chain
63
- setSourceChainId(newToken.chainId);
64
- setSourceToken(token);
65
- };
66
- // Create order hook
67
- const { createOrder, isCreatingOrder } = useCreateDepositFirstOrder({
68
- onSuccess: data => {
69
- const newOrderId = data.data.id;
70
- const newGlobalAddress = data.data.globalAddress;
71
- setOrderId(newOrderId);
72
- setGlobalAddress(newGlobalAddress);
73
- onOrderCreated?.(newOrderId);
74
- },
75
- onError: error => {
76
- console.error("Failed to create deposit order:", error);
77
- toast.error("Failed to create deposit order: " + error.message);
78
- },
79
- });
80
- // Fetch order status
81
- const { orderAndTransactions: oat } = useAnyspendOrderAndTransactions(orderId);
82
- // Create order on mount
83
- useEffect(() => {
84
- if (orderCreatedRef.current)
85
- return;
86
- orderCreatedRef.current = true;
87
- createOrder({
88
- recipientAddress,
89
- srcChain: sourceChainId,
90
- dstChain: destinationChainId,
91
- srcToken: sourceToken,
92
- dstToken: destinationToken,
93
- creatorAddress,
94
- contractConfig: depositContractConfig,
95
- });
96
- }, [
97
- recipientAddress,
98
- sourceChainId,
99
- destinationChainId,
100
- sourceToken,
101
- destinationToken,
102
- creatorAddress,
103
- depositContractConfig,
104
- createOrder,
105
- ]);
106
- // Call onSuccess when order is executed
107
- useEffect(() => {
108
- if (oat?.data?.order.status === "executed" && !onSuccessCalled.current) {
109
- const txHash = oat?.data?.executeTx?.txHash;
110
- onSuccess?.(txHash);
111
- onSuccessCalled.current = true;
112
- }
113
- }, [oat?.data?.order.status, oat?.data?.executeTx?.txHash, onSuccess]);
114
- // Reset onSuccess flag when orderId changes
115
- useEffect(() => {
116
- onSuccessCalled.current = false;
117
- }, [orderId]);
118
- const displayAddress = globalAddress || recipientAddress;
119
- const handleCopyAddress = async () => {
120
- if (displayAddress) {
121
- await navigator.clipboard.writeText(displayAddress);
122
- setCopied(true);
123
- setTimeout(() => setCopied(false), 2000);
124
- }
125
- };
126
- const handleBack = () => {
127
- setCopied(false);
128
- onBack?.();
129
- };
130
- const handleClose = () => {
131
- setCopied(false);
132
- onClose?.();
133
- };
134
- // Show order details if order has deposits or is being processed
135
- if (oat?.data && oat.data.depositTxs && oat.data.depositTxs.length > 0) {
136
- return (_jsx("div", { className: 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: "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 }) }) }));
137
- }
138
- // Show loading state while creating order (but not if we already have an orderId)
139
- if (isCreatingOrder && !orderId) {
140
- return (_jsx("div", { className: 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: "anyspend-qr-loading-content flex flex-col items-center justify-center gap-4 py-12", children: [_jsx(Loader2, { className: "anyspend-qr-loading-spinner text-as-brand h-8 w-8 animate-spin" }), _jsx("p", { className: "anyspend-qr-loading-text text-as-secondary text-sm", children: "Creating deposit order..." })] }) }));
141
- }
142
- return (_jsx("div", { className: 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: "anyspend-qr-deposit-content flex flex-col gap-4", children: [_jsxs("div", { className: "anyspend-qr-header flex items-center justify-between", children: [_jsx("button", { onClick: handleBack, className: "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: "anyspend-qr-title text-as-primary text-base font-semibold", children: "Deposit" }), onClose ? (_jsx("button", { onClick: handleClose, className: "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: "anyspend-qr-token-selector flex flex-col gap-1.5", children: [_jsx("label", { className: "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: "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: "anyspend-qr-content border-as-stroke flex items-start gap-4 rounded-xl border p-4", children: [_jsxs("div", { className: "anyspend-qr-code-container flex flex-col items-center gap-2", children: [_jsx("div", { className: "anyspend-qr-code rounded-lg bg-white p-2", children: _jsx(QRCodeSVG, { value: displayAddress, size: 120, level: "M", marginSize: 0 }) }), _jsxs("span", { className: "anyspend-qr-scan-hint text-as-secondary text-xs", children: ["SCAN WITH ", _jsx("span", { className: "inline-block", children: "\uD83E\uDD8A" })] })] }), _jsxs("div", { className: "anyspend-qr-address-container flex flex-1 flex-col gap-1", children: [_jsx("span", { className: "anyspend-qr-address-label text-as-secondary text-sm", children: "Deposit address:" }), _jsxs("div", { className: "anyspend-qr-address-row flex items-start gap-1", children: [_jsx("span", { className: "anyspend-qr-address text-as-primary break-all font-mono text-sm leading-relaxed", children: displayAddress }), _jsx("button", { onClick: handleCopyAddress, className: "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."] }), _jsx("button", { onClick: handleCopyAddress, className: "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" })] }) }));
143
- }