@b3dotfun/sdk 0.0.87 → 0.0.88-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/cjs/anyspend/react/components/AnySpend.d.ts +5 -0
- package/dist/cjs/anyspend/react/components/AnySpend.js +77 -73
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +0 -1
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.d.ts +1 -1
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.js +1 -2
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.d.ts +122 -0
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.js +190 -0
- package/dist/cjs/anyspend/react/components/QRDeposit.d.ts +43 -0
- package/dist/cjs/anyspend/react/components/QRDeposit.js +146 -0
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +17 -12
- package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.js +12 -5
- package/dist/cjs/anyspend/react/components/common/OrderStatus.js +2 -2
- package/dist/cjs/anyspend/react/components/common/WarningText.d.ts +32 -0
- package/dist/cjs/anyspend/react/components/common/WarningText.js +36 -0
- package/dist/cjs/anyspend/react/components/icons/CreditCardIcon.d.ts +6 -0
- package/dist/cjs/anyspend/react/components/icons/CreditCardIcon.js +6 -0
- package/dist/cjs/anyspend/react/components/icons/QrCodeIcon.d.ts +6 -0
- package/dist/cjs/anyspend/react/components/icons/QrCodeIcon.js +6 -0
- package/dist/cjs/anyspend/react/components/index.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/index.js +3 -1
- package/dist/cjs/anyspend/react/hooks/index.d.ts +1 -0
- package/dist/cjs/anyspend/react/hooks/index.js +1 -0
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.d.ts +2 -2
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +35 -11
- package/dist/cjs/anyspend/react/hooks/useCreateDepositFirstOrder.d.ts +24 -0
- package/dist/cjs/anyspend/react/hooks/useCreateDepositFirstOrder.js +86 -0
- package/dist/cjs/anyspend/react/hooks/useSigMint.d.ts +1 -1
- package/dist/cjs/anyspend/utils/format.js +28 -5
- package/dist/cjs/global-account/react/components/AvatarEditor/AvatarEditor.js +2 -1
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +17 -47
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.js +6 -7
- package/dist/cjs/global-account/react/components/B3Provider/types.d.ts +0 -5
- package/dist/cjs/global-account/react/components/B3Provider/types.js +4 -4
- package/dist/cjs/global-account/react/components/B3Provider/useB3.d.ts +1 -0
- package/dist/cjs/global-account/react/components/B3Provider/useB3.js +1 -0
- package/dist/cjs/global-account/react/components/B3Provider/useB3Account.d.ts +1 -0
- package/dist/cjs/global-account/react/components/B3Provider/useB3Account.js +10 -0
- package/dist/cjs/global-account/react/components/B3Provider/useB3Config.d.ts +9 -0
- package/dist/cjs/global-account/react/components/B3Provider/useB3Config.js +23 -0
- package/dist/cjs/global-account/react/components/LinkAccount/LinkAccount.js +1 -1
- package/dist/cjs/global-account/react/components/LinkAccount/LinkNewAccount.js +1 -2
- package/dist/cjs/global-account/react/components/ManageAccount/ProfileSection.js +2 -1
- package/dist/cjs/global-account/react/components/ManageAccount/SettingsProfileCard.js +2 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3.js +2 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +2 -1
- package/dist/cjs/global-account/react/components/index.d.ts +2 -0
- package/dist/cjs/global-account/react/components/index.js +7 -3
- package/dist/cjs/global-account/react/hooks/useAccountWallet.js +3 -2
- package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +1 -1
- package/dist/cjs/global-account/react/hooks/useAutoSelectWallet.d.ts +7 -0
- package/dist/cjs/global-account/react/hooks/useAutoSelectWallet.js +42 -0
- package/dist/cjs/global-account/react/hooks/useTurnkeyAuth.js +6 -4
- package/dist/cjs/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +2 -2
- package/dist/cjs/global-account/react/hooks/useUserQuery.d.ts +1 -1
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +4 -0
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +5 -0
- package/dist/esm/anyspend/react/components/AnySpend.js +77 -73
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +0 -1
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.d.ts +1 -1
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.js +1 -2
- package/dist/esm/anyspend/react/components/AnySpendDeposit.d.ts +122 -0
- package/dist/esm/anyspend/react/components/AnySpendDeposit.js +187 -0
- package/dist/esm/anyspend/react/components/QRDeposit.d.ts +43 -0
- package/dist/esm/anyspend/react/components/QRDeposit.js +143 -0
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +17 -12
- package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.d.ts +2 -0
- package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.js +12 -5
- package/dist/esm/anyspend/react/components/common/OrderStatus.js +2 -2
- package/dist/esm/anyspend/react/components/common/WarningText.d.ts +32 -0
- package/dist/esm/anyspend/react/components/common/WarningText.js +32 -0
- package/dist/esm/anyspend/react/components/icons/CreditCardIcon.d.ts +6 -0
- package/dist/esm/anyspend/react/components/icons/CreditCardIcon.js +2 -0
- package/dist/esm/anyspend/react/components/icons/QrCodeIcon.d.ts +6 -0
- package/dist/esm/anyspend/react/components/icons/QrCodeIcon.js +2 -0
- package/dist/esm/anyspend/react/components/index.d.ts +2 -0
- package/dist/esm/anyspend/react/components/index.js +1 -0
- package/dist/esm/anyspend/react/hooks/index.d.ts +1 -0
- package/dist/esm/anyspend/react/hooks/index.js +1 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.d.ts +2 -2
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +35 -11
- package/dist/esm/anyspend/react/hooks/useCreateDepositFirstOrder.d.ts +24 -0
- package/dist/esm/anyspend/react/hooks/useCreateDepositFirstOrder.js +83 -0
- package/dist/esm/anyspend/react/hooks/useSigMint.d.ts +1 -1
- package/dist/esm/anyspend/utils/format.js +28 -5
- package/dist/esm/global-account/react/components/AvatarEditor/AvatarEditor.js +3 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +21 -51
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.js +6 -7
- package/dist/esm/global-account/react/components/B3Provider/types.d.ts +0 -5
- package/dist/esm/global-account/react/components/B3Provider/types.js +4 -4
- package/dist/esm/global-account/react/components/B3Provider/useB3.d.ts +1 -0
- package/dist/esm/global-account/react/components/B3Provider/useB3.js +1 -0
- package/dist/esm/global-account/react/components/B3Provider/useB3Account.d.ts +1 -0
- package/dist/esm/global-account/react/components/B3Provider/useB3Account.js +6 -0
- package/dist/esm/global-account/react/components/B3Provider/useB3Config.d.ts +9 -0
- package/dist/esm/global-account/react/components/B3Provider/useB3Config.js +19 -0
- package/dist/esm/global-account/react/components/LinkAccount/LinkAccount.js +2 -2
- package/dist/esm/global-account/react/components/LinkAccount/LinkNewAccount.js +2 -3
- package/dist/esm/global-account/react/components/ManageAccount/ProfileSection.js +3 -2
- package/dist/esm/global-account/react/components/ManageAccount/SettingsProfileCard.js +3 -2
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3.js +3 -2
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +3 -2
- package/dist/esm/global-account/react/components/index.d.ts +2 -0
- package/dist/esm/global-account/react/components/index.js +2 -0
- package/dist/esm/global-account/react/hooks/useAccountWallet.js +4 -3
- package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +1 -1
- package/dist/esm/global-account/react/hooks/useAutoSelectWallet.d.ts +7 -0
- package/dist/esm/global-account/react/hooks/useAutoSelectWallet.js +39 -0
- package/dist/esm/global-account/react/hooks/useTurnkeyAuth.js +6 -4
- package/dist/esm/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +2 -2
- package/dist/esm/global-account/react/hooks/useUserQuery.d.ts +1 -1
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +4 -0
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/react/components/AnySpend.d.ts +5 -0
- package/dist/types/anyspend/react/components/AnySpendCustomExactIn.d.ts +1 -1
- package/dist/types/anyspend/react/components/AnySpendDeposit.d.ts +122 -0
- package/dist/types/anyspend/react/components/QRDeposit.d.ts +43 -0
- package/dist/types/anyspend/react/components/common/OrderDetailsCollapsible.d.ts +2 -0
- package/dist/types/anyspend/react/components/common/WarningText.d.ts +32 -0
- package/dist/types/anyspend/react/components/icons/CreditCardIcon.d.ts +6 -0
- package/dist/types/anyspend/react/components/icons/QrCodeIcon.d.ts +6 -0
- package/dist/types/anyspend/react/components/index.d.ts +2 -0
- package/dist/types/anyspend/react/hooks/index.d.ts +1 -0
- package/dist/types/anyspend/react/hooks/useAnyspendFlow.d.ts +2 -2
- package/dist/types/anyspend/react/hooks/useCreateDepositFirstOrder.d.ts +24 -0
- package/dist/types/anyspend/react/hooks/useSigMint.d.ts +1 -1
- package/dist/types/global-account/react/components/B3Provider/types.d.ts +0 -5
- package/dist/types/global-account/react/components/B3Provider/useB3.d.ts +1 -0
- package/dist/types/global-account/react/components/B3Provider/useB3Account.d.ts +1 -0
- package/dist/types/global-account/react/components/B3Provider/useB3Config.d.ts +9 -0
- package/dist/types/global-account/react/components/index.d.ts +2 -0
- package/dist/types/global-account/react/hooks/useAuthentication.d.ts +1 -1
- package/dist/types/global-account/react/hooks/useAutoSelectWallet.d.ts +7 -0
- package/dist/types/global-account/react/hooks/useUserQuery.d.ts +1 -1
- package/dist/types/global-account/react/stores/useModalStore.d.ts +4 -0
- package/package.json +1 -1
- package/src/anyspend/react/components/AnySpend.tsx +105 -85
- package/src/anyspend/react/components/AnySpendCustom.tsx +0 -2
- package/src/anyspend/react/components/AnySpendCustomExactIn.tsx +2 -3
- package/src/anyspend/react/components/AnySpendDeposit.tsx +570 -0
- package/src/anyspend/react/components/QRDeposit.tsx +348 -0
- package/src/anyspend/react/components/common/OrderDetails.tsx +26 -8
- package/src/anyspend/react/components/common/OrderDetailsCollapsible.tsx +20 -8
- package/src/anyspend/react/components/common/OrderStatus.tsx +2 -2
- package/src/anyspend/react/components/common/WarningText.tsx +52 -0
- package/src/anyspend/react/components/icons/CreditCardIcon.tsx +25 -0
- package/src/anyspend/react/components/icons/QrCodeIcon.tsx +25 -0
- package/src/anyspend/react/components/icons/credit-card.svg +5 -0
- package/src/anyspend/react/components/icons/qr-code.svg +5 -0
- package/src/anyspend/react/components/index.ts +2 -0
- package/src/anyspend/react/hooks/index.ts +1 -0
- package/src/anyspend/react/hooks/useAnyspendFlow.ts +37 -12
- package/src/anyspend/react/hooks/useCreateDepositFirstOrder.ts +110 -0
- package/src/anyspend/utils/format.ts +33 -5
- package/src/global-account/react/components/AvatarEditor/AvatarEditor.tsx +10 -2
- package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +6 -7
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +20 -71
- package/src/global-account/react/components/B3Provider/types.ts +8 -9
- package/src/global-account/react/components/B3Provider/useB3.ts +1 -0
- package/src/global-account/react/components/B3Provider/useB3Account.ts +7 -0
- package/src/global-account/react/components/B3Provider/useB3Config.ts +34 -0
- package/src/global-account/react/components/LinkAccount/LinkAccount.tsx +2 -2
- package/src/global-account/react/components/LinkAccount/LinkNewAccount.tsx +2 -3
- package/src/global-account/react/components/ManageAccount/ProfileSection.tsx +10 -2
- package/src/global-account/react/components/ManageAccount/SettingsProfileCard.tsx +3 -2
- package/src/global-account/react/components/SignInWithB3/SignInWithB3.tsx +2 -2
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +5 -2
- package/src/global-account/react/components/index.ts +2 -0
- package/src/global-account/react/hooks/useAccountWallet.tsx +4 -3
- package/src/global-account/react/hooks/useAutoSelectWallet.ts +51 -0
- package/src/global-account/react/hooks/useTurnkeyAuth.ts +7 -5
- package/src/global-account/react/hooks/useUnifiedChainSwitchAndExecute.ts +2 -2
- package/src/global-account/react/stores/useModalStore.ts +4 -0
- package/src/styles/index.css +2 -0
|
@@ -0,0 +1,187 @@
|
|
|
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" }) }) })), !isBalanceLoading && totalBalance > 0 && (_jsxs("div", { className: "anyspend-deposit-balance border-secondary border-b p-5", 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" })] })] })), _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: [1, 2].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
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
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;
|
|
@@ -0,0 +1,143 @@
|
|
|
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
|
+
}
|
|
@@ -31,6 +31,7 @@ function getOrderSuccessText({ order, tournament, formattedActualDstAmount, form
|
|
|
31
31
|
let actionText = "";
|
|
32
32
|
switch (order.type) {
|
|
33
33
|
case "swap":
|
|
34
|
+
case "deposit_first":
|
|
34
35
|
actionText = `sent ${formattedActualDstAmount || "--"} ${dstToken.symbol}`;
|
|
35
36
|
return `Successfully ${actionText} to ${recipient}`;
|
|
36
37
|
case "mint_nft":
|
|
@@ -152,6 +153,7 @@ export const OrderDetails = memo(function OrderDetails({ mode = "modal", order,
|
|
|
152
153
|
const { data: walletClient } = useWalletClient();
|
|
153
154
|
const [txHash, setTxHash] = useState();
|
|
154
155
|
const [showQRCode, setShowQRCode] = useState(false);
|
|
156
|
+
const [orderDetailsOpen, setOrderDetailsOpen] = useState(true);
|
|
155
157
|
const { isLoading: txLoading, isSuccess: txSuccess } = useWaitForTransactionReceipt({ hash: txHash });
|
|
156
158
|
const { switchChainAndExecuteWithEOA, switchChainAndExecute, isSwitchingOrExecuting } = useUnifiedChainSwitchAndExecute();
|
|
157
159
|
// Track if auto-payment was attempted to avoid re-triggering
|
|
@@ -320,7 +322,8 @@ export const OrderDetails = memo(function OrderDetails({ mode = "modal", order,
|
|
|
320
322
|
const expectedDstAmount = order.type === "mint_nft" ||
|
|
321
323
|
order.type === "join_tournament" ||
|
|
322
324
|
order.type === "fund_tournament" ||
|
|
323
|
-
order.type === "custom"
|
|
325
|
+
order.type === "custom" ||
|
|
326
|
+
order.type === "deposit_first"
|
|
324
327
|
? "0"
|
|
325
328
|
: order.payload.expectedDstAmount.toString();
|
|
326
329
|
const formattedExpectedDstAmount = formatTokenAmount(BigInt(expectedDstAmount), dstToken.decimals);
|
|
@@ -329,7 +332,7 @@ export const OrderDetails = memo(function OrderDetails({ mode = "modal", order,
|
|
|
329
332
|
? formatTokenAmount(BigInt(actualDstAmount), dstToken.decimals)
|
|
330
333
|
: undefined;
|
|
331
334
|
if (refundTxs.length > 0) {
|
|
332
|
-
return (_jsxs(_Fragment, { children: [_jsx(OrderStatus, { order: order, selectedCryptoPaymentMethod: effectiveCryptoPaymentMethod }), _jsx(OrderDetailsCollapsible, { order: order, dstToken: dstToken, tournament: tournament, nft: nft, recipientName: recipientName, formattedExpectedDstAmount: formattedExpectedDstAmount, points: points }), _jsx(Accordion, { type: "single", collapsible: true, className: "order-details-accordion w-full", children: _jsxs(AccordionItem, { value: "refund-details", className: "order-details-refund-item", children: [_jsx(AccordionTrigger, { className: "accordion-trigger", children: "Transaction Details" }), _jsx(AccordionContent, { className: "accordion-content pl-2", children: _jsxs("div", { className: "relative flex w-full flex-col gap-4", children: [_jsx("div", { className: "bg-as-surface-secondary absolute bottom-2 left-4 top-2 z-[5] w-2", children: _jsx(motion.div, { className: "bg-as-border-primary absolute left-[2px] top-0 z-10 w-[3px]", initial: { height: "0%" }, animate: { height: "100%" }, transition: { duration: 1.5, ease: "easeInOut" } }) }), depositTxs
|
|
335
|
+
return (_jsxs(_Fragment, { children: [_jsx(OrderStatus, { order: order, selectedCryptoPaymentMethod: effectiveCryptoPaymentMethod }), _jsx(OrderDetailsCollapsible, { order: order, dstToken: dstToken, tournament: tournament, nft: nft, recipientName: recipientName, formattedExpectedDstAmount: formattedExpectedDstAmount, points: points, isOpen: orderDetailsOpen, onOpenChange: setOrderDetailsOpen }), _jsx(Accordion, { type: "single", collapsible: true, className: "order-details-accordion w-full", children: _jsxs(AccordionItem, { value: "refund-details", className: "order-details-refund-item", children: [_jsx(AccordionTrigger, { className: "accordion-trigger", children: "Transaction Details" }), _jsx(AccordionContent, { className: "accordion-content pl-2", children: _jsxs("div", { className: "relative flex w-full flex-col gap-4", children: [_jsx("div", { className: "bg-as-surface-secondary absolute bottom-2 left-4 top-2 z-[5] w-2", children: _jsx(motion.div, { className: "bg-as-border-primary absolute left-[2px] top-0 z-10 w-[3px]", initial: { height: "0%" }, animate: { height: "100%" }, transition: { duration: 1.5, ease: "easeInOut" } }) }), depositTxs
|
|
333
336
|
? depositTxs.map(dTx => (_jsx(TransactionDetails, { title: order.onrampMetadata?.vendor === "stripe-web2"
|
|
334
337
|
? `Received payment`
|
|
335
338
|
: `Received ${formatTokenAmount(BigInt(dTx.amount), srcToken.decimals)} ${srcToken.symbol}`, chainId: order.srcChain, tx: dTx, isProcessing: false }, dTx.txHash)))
|
|
@@ -338,13 +341,13 @@ export const OrderDetails = memo(function OrderDetails({ mode = "modal", order,
|
|
|
338
341
|
: null] }) })] }) }), order.errorDetails && (_jsx("div", { className: "flex justify-center", children: _jsx("span", { className: "text-as-primary/50 text-center text-sm", style: { maxWidth: "40ch" }, children: getErrorDisplay(order.errorDetails) }) })), _jsx("button", { className: "order-close-button order-details-close-btn bg-as-brand flex w-full items-center justify-center gap-2 rounded-lg p-2 font-semibold text-white", onClick: mode === "page" ? handleBack : handleCloseModal, children: mode === "page" ? (_jsxs(_Fragment, { children: ["Return to Home ", _jsx(Home, { className: "ml-2 h-4 w-4" })] })) : ("Close") })] }));
|
|
339
342
|
}
|
|
340
343
|
if (executeTx) {
|
|
341
|
-
return (_jsxs(_Fragment, { children: [_jsx(OrderStatus, { order: order, selectedCryptoPaymentMethod: effectiveCryptoPaymentMethod }), _jsx(OrderDetailsCollapsible, { order: order, dstToken: dstToken, tournament: tournament, nft: nft, recipientName: recipientName, formattedExpectedDstAmount: formattedExpectedDstAmount, points: points }), _jsx(Accordion, { type: "single", collapsible: true, className: "order-details-accordion w-full", children: _jsxs(AccordionItem, { value: "execute-details", className: "order-details-execute-item", children: [_jsx(AccordionTrigger, { className: "accordion-trigger", children: "Transaction Details" }), _jsx(AccordionContent, { className: "accordion-content pl-2", children: _jsxs("div", { className: "relative flex w-full flex-col gap-4", children: [_jsx("div", { className: "bg-as-surface-secondary absolute bottom-2 left-4 top-2 z-[5] w-2", children: _jsx(motion.div, { className: "bg-as-border-primary absolute left-[2px] top-0 z-10 w-[3px]", initial: { height: "0%" }, animate: { height: "100%" }, transition: { duration: 1.5, ease: "easeInOut" } }) }), depositTxs
|
|
344
|
+
return (_jsxs(_Fragment, { children: [_jsx(OrderStatus, { order: order, selectedCryptoPaymentMethod: effectiveCryptoPaymentMethod }), _jsx(OrderDetailsCollapsible, { order: order, dstToken: dstToken, tournament: tournament, nft: nft, recipientName: recipientName, formattedExpectedDstAmount: formattedExpectedDstAmount, points: points, isOpen: orderDetailsOpen, onOpenChange: setOrderDetailsOpen }), _jsx(Accordion, { type: "single", collapsible: true, className: "order-details-accordion w-full", children: _jsxs(AccordionItem, { value: "execute-details", className: "order-details-execute-item", children: [_jsx(AccordionTrigger, { className: "accordion-trigger", children: "Transaction Details" }), _jsx(AccordionContent, { className: "accordion-content pl-2", children: _jsxs("div", { className: "relative flex w-full flex-col gap-4", children: [_jsx("div", { className: "bg-as-surface-secondary absolute bottom-2 left-4 top-2 z-[5] w-2", children: _jsx(motion.div, { className: "bg-as-border-primary absolute left-[2px] top-0 z-10 w-[3px]", initial: { height: "0%" }, animate: { height: "100%" }, transition: { duration: 1.5, ease: "easeInOut" } }) }), depositTxs
|
|
342
345
|
? depositTxs.map(dTxs => (_jsx(TransactionDetails, { title: order.onrampMetadata?.vendor === "stripe-web2"
|
|
343
346
|
? `Received payment`
|
|
344
347
|
: `Received ${formatTokenAmount(BigInt(dTxs.amount), srcToken.decimals)} ${srcToken.symbol}`, chainId: order.srcChain, tx: dTxs, isProcessing: false }, dTxs.txHash)))
|
|
345
348
|
: null, relayTxs
|
|
346
|
-
? relayTxs.map(relayTx => (_jsx(TransactionDetails, { title: "Processed
|
|
347
|
-
: null, _jsx(TransactionDetails, { title: order.type === "swap"
|
|
349
|
+
? relayTxs.map(relayTx => (_jsx(TransactionDetails, { title: "Processed Swap", chainId: relayTx.chain, tx: relayTx, delay: 0.5, isProcessing: false }, relayTx.txHash)))
|
|
350
|
+
: null, _jsx(TransactionDetails, { title: order.type === "swap" || order.type === "deposit_first"
|
|
348
351
|
? "Processed Swap"
|
|
349
352
|
: order.type === "mint_nft"
|
|
350
353
|
? "Minted NFT"
|
|
@@ -363,12 +366,14 @@ export const OrderDetails = memo(function OrderDetails({ mode = "modal", order,
|
|
|
363
366
|
}), _jsx(ExternalLink, { className: "ml-2 h-4 w-4" })] }) }) }), order.type === "join_tournament" && order.status === "executed" && (_jsxs(ShinyButton, { accentColor: "hsl(var(--as-brand))", textColor: "text-white", className: "flex w-full items-center gap-2", disabled: txLoading || isSwitchingOrExecuting, onClick: handleCloseModal, children: [_jsx("span", { className: "pl-4", children: "Continue to Tournament" }), _jsx(ChevronRight, { className: "h-4 w-4" })] })), order.status === "executed" && (_jsx("button", { className: "order-close-button order-details-close-btn bg-as-brand flex w-full items-center justify-center gap-2 rounded-lg p-2 font-semibold text-white", onClick: mode === "page" ? handleBack : handleCloseModal, children: mode === "page" ? (_jsxs(_Fragment, { children: ["Return to Home ", _jsx(Home, { className: "ml-2 h-4 w-4" })] })) : ("Close") }))] }));
|
|
364
367
|
}
|
|
365
368
|
if (relayTxs.length > 0 && relayTxs.every(tx => tx.status === "success")) {
|
|
366
|
-
return (_jsxs(_Fragment, { children: [_jsx(OrderStatus, { order: order, selectedCryptoPaymentMethod: effectiveCryptoPaymentMethod }), _jsx(OrderDetailsCollapsible, { order: order, dstToken: dstToken, tournament: tournament, nft: nft, recipientName: recipientName, formattedExpectedDstAmount: formattedExpectedDstAmount, points: points }), _jsx(Accordion, { type: "single", collapsible: true, className: "order-details-accordion w-full", children: _jsxs(AccordionItem, { value: "more-details", className: "order-details-more-item", children: [_jsx(AccordionTrigger, { className: "accordion-trigger", children: "More Details" }), _jsx(AccordionContent, { className: "accordion-content pl-2", children: _jsxs("div", { className: "relative flex w-full flex-col gap-4", children: [_jsx("div", { className: "bg-as-surface-secondary absolute bottom-2 left-4 top-2 z-[5] w-2", children: _jsx(motion.div, { className: "bg-as-border-primary absolute left-[2px] top-0 z-10 w-[3px]", initial: { height: "0%" }, animate: { height: "100%" }, transition: { duration: 1.5, ease: "easeInOut" } }) }), depositTxs
|
|
369
|
+
return (_jsxs(_Fragment, { children: [_jsx(OrderStatus, { order: order, selectedCryptoPaymentMethod: effectiveCryptoPaymentMethod }), _jsx(OrderDetailsCollapsible, { order: order, dstToken: dstToken, tournament: tournament, nft: nft, recipientName: recipientName, formattedExpectedDstAmount: formattedExpectedDstAmount, points: points, isOpen: orderDetailsOpen, onOpenChange: setOrderDetailsOpen }), _jsx(Accordion, { type: "single", collapsible: true, className: "order-details-accordion w-full", children: _jsxs(AccordionItem, { value: "more-details", className: "order-details-more-item", children: [_jsx(AccordionTrigger, { className: "accordion-trigger", children: "More Details" }), _jsx(AccordionContent, { className: "accordion-content pl-2", children: _jsxs("div", { className: "relative flex w-full flex-col gap-4", children: [_jsx("div", { className: "bg-as-surface-secondary absolute bottom-2 left-4 top-2 z-[5] w-2", children: _jsx(motion.div, { className: "bg-as-border-primary absolute left-[2px] top-0 z-10 w-[3px]", initial: { height: "0%" }, animate: { height: "100%" }, transition: { duration: 1.5, ease: "easeInOut" } }) }), depositTxs
|
|
367
370
|
? depositTxs.map(dTxs => (_jsx(TransactionDetails, { title: order.onrampMetadata?.vendor === "stripe-web2"
|
|
368
371
|
? `Received payment`
|
|
369
372
|
: `Received ${formatTokenAmount(BigInt(dTxs.amount), srcToken.decimals)} ${srcToken.symbol}`, chainId: order.srcChain, tx: dTxs, isProcessing: false }, dTxs.txHash)))
|
|
370
|
-
: null, relayTxs.map(relayTx => (_jsx(TransactionDetails, { title:
|
|
371
|
-
?
|
|
373
|
+
: null, relayTxs.map(relayTx => (_jsx(TransactionDetails, { title: relayTx.chain === order.srcChain
|
|
374
|
+
? `Process swap on ${getChainName(relayTx.chain)}`
|
|
375
|
+
: `Received on ${getChainName(relayTx.chain)}`, chainId: relayTx.chain, isProcessing: false, tx: relayTx, delay: 0.5 }, relayTx.txHash))), order.status === "executing" && (_jsx(TransactionDetails, { title: order.type === "swap" || order.type === "x402_swap" || order.type === "deposit_first"
|
|
376
|
+
? "Processing swap"
|
|
372
377
|
: order.type === "mint_nft"
|
|
373
378
|
? "Minting NFT"
|
|
374
379
|
: order.type === "join_tournament"
|
|
@@ -384,10 +389,10 @@ export const OrderDetails = memo(function OrderDetails({ mode = "modal", order,
|
|
|
384
389
|
// This boolean indicates that user finish payment, and waiting for the deposit to be confirmed. We get this from query params (waitingForDeposit=true)
|
|
385
390
|
const waitingForDeposit = new URLSearchParams(window.location.search).get("waitingForDeposit") === "true";
|
|
386
391
|
if (depositTxs?.length || waitingForDeposit) {
|
|
387
|
-
return (_jsxs(_Fragment, { children: [_jsx(OrderStatus, { order: order, selectedCryptoPaymentMethod: effectiveCryptoPaymentMethod }), _jsx(OrderDetailsCollapsible, { order: order, dstToken: dstToken, tournament: tournament, nft: nft, recipientName: recipientName, formattedExpectedDstAmount: formattedExpectedDstAmount, points: points }), _jsx(Accordion, { type: "single", collapsible: true, className: "order-details-accordion w-full", children: _jsxs(AccordionItem, { value: "deposit-details", className: "order-details-deposit-item", children: [_jsx(AccordionTrigger, { className: "accordion-trigger", children: "Transaction Details" }), _jsx(AccordionContent, { className: "accordion-content pl-2", children: _jsxs("div", { className: "relative flex w-full flex-col gap-6", children: [_jsx("div", { className: "bg-as-surface-secondary absolute bottom-2 left-4 top-2 z-[5] w-2", children: _jsx(motion.div, { className: "from-as-brand/50 absolute left-[2px] top-0 z-10 w-[3px] bg-gradient-to-b from-20% via-purple-500/50 via-80% to-transparent", initial: { height: "0%" }, animate: { height: "100%" }, transition: { duration: 1, ease: "easeInOut" } }) }), (depositTxs || []).map((dTxs, index) => (_jsx(TransactionDetails, { title: order.onrampMetadata?.vendor === "stripe-web2"
|
|
392
|
+
return (_jsxs(_Fragment, { children: [_jsx(OrderStatus, { order: order, selectedCryptoPaymentMethod: effectiveCryptoPaymentMethod }), _jsx(OrderDetailsCollapsible, { order: order, dstToken: dstToken, tournament: tournament, nft: nft, recipientName: recipientName, formattedExpectedDstAmount: formattedExpectedDstAmount, points: points, isOpen: orderDetailsOpen, onOpenChange: setOrderDetailsOpen }), _jsx(Accordion, { type: "single", collapsible: true, className: "order-details-accordion w-full", children: _jsxs(AccordionItem, { value: "deposit-details", className: "order-details-deposit-item", children: [_jsx(AccordionTrigger, { className: "accordion-trigger", children: "Transaction Details" }), _jsx(AccordionContent, { className: "accordion-content pl-2", children: _jsxs("div", { className: "relative flex w-full flex-col gap-6", children: [_jsx("div", { className: "bg-as-surface-secondary absolute bottom-2 left-4 top-2 z-[5] w-2", children: _jsx(motion.div, { className: "from-as-brand/50 absolute left-[2px] top-0 z-10 w-[3px] bg-gradient-to-b from-20% via-purple-500/50 via-80% to-transparent", initial: { height: "0%" }, animate: { height: "100%" }, transition: { duration: 1, ease: "easeInOut" } }) }), (depositTxs || []).map((dTxs, index) => (_jsx(TransactionDetails, { title: order.onrampMetadata?.vendor === "stripe-web2"
|
|
388
393
|
? `Received payment`
|
|
389
|
-
: `Received ${formatTokenAmount(BigInt(dTxs.amount), srcToken.decimals)} ${srcToken.symbol}`, chainId: order.srcChain, tx: dTxs, isProcessing: index < (depositTxs || []).length - 1 ? false : !depositEnoughAmount }, dTxs.txHash))), statusDisplay === "failure" ? (_jsx(TransactionDetails, { title: statusText, chainId: order.srcChain, tx: null, isProcessing: false, delay: 0.5 })) : depositEnoughAmount ? (_jsx(TransactionDetails, { title: order.type === "swap"
|
|
390
|
-
? "Processing
|
|
394
|
+
: `Received ${formatTokenAmount(BigInt(dTxs.amount), srcToken.decimals)} ${srcToken.symbol}`, chainId: order.srcChain, tx: dTxs, isProcessing: index < (depositTxs || []).length - 1 ? false : !depositEnoughAmount }, dTxs.txHash))), statusDisplay === "failure" ? (_jsx(TransactionDetails, { title: statusText, chainId: order.srcChain, tx: null, isProcessing: false, delay: 0.5 })) : depositEnoughAmount ? (_jsx(TransactionDetails, { title: order.type === "swap" || order.type === "deposit_first"
|
|
395
|
+
? "Processing swap"
|
|
391
396
|
: order.type === "mint_nft"
|
|
392
397
|
? "Minting NFT"
|
|
393
398
|
: order.type === "join_tournament"
|
|
@@ -411,7 +416,7 @@ export const OrderDetails = memo(function OrderDetails({ mode = "modal", order,
|
|
|
411
416
|
? centerTruncate(phantomWalletAddress, 6)
|
|
412
417
|
: centerTruncate(account?.address || "", 6)] })] }), _jsxs("div", { className: "flex w-full flex-col items-center gap-2", children: [_jsxs(ShinyButton, { accentColor: colorMode === "dark" ? "#ffffff" : "#000000", className: "flex w-5/6 items-center gap-2 sm:px-0", onClick: () => setShowQRCode(true), children: [_jsx("span", { className: "pl-4 text-lg md:text-sm", children: "Pay from a different wallet" }), _jsx(ChevronRight, { className: "h-4 w-4" })] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(WalletMetamask, { className: "h-5 w-5", variant: "branded" }), _jsx(WalletCoinbase, { className: "h-5 w-5", variant: "branded" }), _jsx(WalletPhantom, { className: "h-5 w-5", variant: "branded" }), _jsx(WalletTrust, { className: "h-5 w-5", variant: "branded" }), _jsx(WalletWalletConnect, { className: "h-5 w-5", variant: "branded" }), _jsx("span", { className: "label-style text-as-primary/30 text-xs", children: "& more" })] })] })] }) })) : (
|
|
413
418
|
// Default case - existing QR code flow
|
|
414
|
-
_jsx(motion.div, { initial: { opacity: 0, filter: "blur(10px)" }, animate: { opacity: 1, filter: "blur(0px)" }, transition: { duration: 0.5, ease: "easeInOut" }, className: "flex w-full items-center justify-evenly gap-4", children: _jsxs("div", { className: "order-details-qr-container mt-8 flex flex-col items-center rounded-lg bg-white p-6 pb-3", children: [_jsx(QRCodeSVG, { value: getPaymentUrl(order.globalAddress, BigInt(order.srcAmount), order.srcTokenAddress === ZERO_ADDRESS ? srcToken?.symbol || "ETH" : order.srcTokenAddress, order.srcChain, srcToken?.decimals), className: "order-details-qr-code max-w-[200px]" }), _jsxs("div", { className: "order-details-qr-wallets mt-3 flex items-center justify-center gap-2 text-sm", children: [_jsx("span", { className: "label-style text-as-brand/70 text-sm", children: "Scan with" }), _jsxs(TextLoop, { interval: 3, children: [_jsx(WalletMetamask, { className: "h-5 w-5", variant: "branded" }), _jsx(WalletCoinbase, { className: "h-5 w-5", variant: "branded" }), _jsx(WalletPhantom, { className: "h-5 w-5", variant: "branded" }), _jsx(WalletTrust, { className: "h-5 w-5", variant: "branded" })] })] })] }) }))] })) })), _jsxs("div", { className: "order-details-time-remaining flex w-full items-center justify-center gap-1 text-sm", children: [_jsx("div", { className: "text-as-primary/30 order-details-time-label", children: "Time remaining:" }), _jsx("div", { className: "text-as-primary order-details-time-value", children: depositEnoughAmount ? ("Received") : order.status === "expired" ? ("Expired") : (_jsx(TimeAgo, { date: new Date(order.expiredAt), live: true })) })] }), statusDisplay !== "processing" && (_jsx(OrderDetailsCollapsible, { order: order, dstToken: dstToken, tournament: tournament, nft: nft, recipientName: recipientName, formattedExpectedDstAmount: formattedExpectedDstAmount, points: points })), _jsxs("button", { className: "text-b3-primary-blue hover:text-b3-primary-blue/50 order-details-cancel-btn flex w-full items-center justify-center gap-2 underline", onClick: handleBack, children: [_jsx(RefreshCcw, { className: "ml-2 h-4 w-4" }), " Cancel and start over"] })] }));
|
|
419
|
+
_jsx(motion.div, { initial: { opacity: 0, filter: "blur(10px)" }, animate: { opacity: 1, filter: "blur(0px)" }, transition: { duration: 0.5, ease: "easeInOut" }, className: "flex w-full items-center justify-evenly gap-4", children: _jsxs("div", { className: "order-details-qr-container mt-8 flex flex-col items-center rounded-lg bg-white p-6 pb-3", children: [_jsx(QRCodeSVG, { value: getPaymentUrl(order.globalAddress, BigInt(order.srcAmount), order.srcTokenAddress === ZERO_ADDRESS ? srcToken?.symbol || "ETH" : order.srcTokenAddress, order.srcChain, srcToken?.decimals), className: "order-details-qr-code max-w-[200px]" }), _jsxs("div", { className: "order-details-qr-wallets mt-3 flex items-center justify-center gap-2 text-sm", children: [_jsx("span", { className: "label-style text-as-brand/70 text-sm", children: "Scan with" }), _jsxs(TextLoop, { interval: 3, children: [_jsx(WalletMetamask, { className: "h-5 w-5", variant: "branded" }), _jsx(WalletCoinbase, { className: "h-5 w-5", variant: "branded" }), _jsx(WalletPhantom, { className: "h-5 w-5", variant: "branded" }), _jsx(WalletTrust, { className: "h-5 w-5", variant: "branded" })] })] })] }) }))] })) })), _jsxs("div", { className: "order-details-time-remaining flex w-full items-center justify-center gap-1 text-sm", children: [_jsx("div", { className: "text-as-primary/30 order-details-time-label", children: "Time remaining:" }), _jsx("div", { className: "text-as-primary order-details-time-value", children: depositEnoughAmount ? ("Received") : order.status === "expired" ? ("Expired") : (_jsx(TimeAgo, { date: new Date(order.expiredAt), live: true })) })] }), statusDisplay !== "processing" && (_jsx(OrderDetailsCollapsible, { order: order, dstToken: dstToken, tournament: tournament, nft: nft, recipientName: recipientName, formattedExpectedDstAmount: formattedExpectedDstAmount, points: points, isOpen: orderDetailsOpen, onOpenChange: setOrderDetailsOpen })), _jsxs("button", { className: "text-b3-primary-blue hover:text-b3-primary-blue/50 order-details-cancel-btn flex w-full items-center justify-center gap-2 underline", onClick: handleBack, children: [_jsx(RefreshCcw, { className: "ml-2 h-4 w-4" }), " Cancel and start over"] })] }));
|
|
415
420
|
});
|
|
416
421
|
function TransactionDetails({ title, chainId, tx, isProcessing, delay, }) {
|
|
417
422
|
return (_jsxs("div", { className: "order-details-transaction-item relative flex w-full flex-1 items-center justify-between gap-4", children: [_jsxs("div", { className: "order-details-transaction-content flex grow items-center gap-4", children: [_jsx(motion.div, { className: "bg-as-surface-secondary relative h-10 w-10 rounded-full", children: isProcessing ? (_jsx(motion.div, { initial: { opacity: 0, scale: 0.3 }, animate: { opacity: 1, scale: 1 }, transition: { duration: 0.5, ease: "easeInOut", delay }, className: "border-as-border-secondary absolute z-10 m-2 flex h-6 w-6 items-center justify-center rounded-full border-2 shadow-lg backdrop-blur-sm", children: _jsx(Loader2, { className: "text-as-primary h-4 w-4 animate-spin" }) })) : (_jsx(motion.div, { initial: { opacity: 0, scale: 0.3 }, animate: { opacity: 1, scale: 1 }, transition: { duration: 0.5, ease: "easeOut", delay }, className: "bg-as-success-secondary absolute z-10 m-2 flex h-6 w-6 items-center justify-center rounded-full border border-white/30 shadow-lg backdrop-blur-sm", children: _jsx(CheckIcon, { className: "text-as-content-icon-success h-4 w-4" }) })) }), _jsx(motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { duration: 0.3, ease: "easeInOut", delay }, className: "shrink-0 text-base", children: isProcessing ? (_jsx(TextShimmer, { duration: 1, children: title })) : (_jsx("span", { className: "text-as-primary", children: title })) })] }), _jsx("div", { className: "flex flex-col gap-1", children: tx ? (_jsx(motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { duration: 0.3, ease: "easeInOut", delay: (delay || 0) + 0.3 }, className: "flex items-center gap-3", children: _jsx("a", { href: getExplorerTxUrl(chainId, tx.txHash), target: "_blank", children: _jsx("div", { className: "text-as-primary/30 font-mono text-xs", children: centerTruncate(tx?.txHash, 6) }) }) })) : null })] }));
|
|
@@ -14,6 +14,8 @@ interface OrderDetailsCollapsibleProps {
|
|
|
14
14
|
showTotal?: boolean;
|
|
15
15
|
totalAmount?: string;
|
|
16
16
|
points?: number;
|
|
17
|
+
isOpen?: boolean;
|
|
18
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
17
19
|
}
|
|
18
20
|
export declare const OrderDetailsCollapsible: import("react").NamedExoticComponent<OrderDetailsCollapsibleProps>;
|
|
19
21
|
export {};
|
|
@@ -10,19 +10,26 @@ 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 [
|
|
13
|
+
export const OrderDetailsCollapsible = memo(function OrderDetailsCollapsible({ order, dstToken, tournament, nft, recipientName, formattedExpectedDstAmount, className, showTotal = false, totalAmount, points, isOpen, onOpenChange, }) {
|
|
14
|
+
const [internalOpen, setInternalOpen] = useState(true);
|
|
15
|
+
// Use controlled mode if isOpen is provided, otherwise use internal state
|
|
16
|
+
const showOrderDetails = isOpen !== undefined ? isOpen : internalOpen;
|
|
17
|
+
const setShowOrderDetails = onOpenChange || setInternalOpen;
|
|
15
18
|
// Calculate expected amount if not provided
|
|
16
19
|
const expectedDstAmount = order.type === "mint_nft" ||
|
|
17
20
|
order.type === "join_tournament" ||
|
|
18
21
|
order.type === "fund_tournament" ||
|
|
19
|
-
order.type === "custom"
|
|
22
|
+
order.type === "custom" ||
|
|
23
|
+
order.type === "deposit_first"
|
|
20
24
|
? "0"
|
|
21
25
|
: order.payload.expectedDstAmount.toString();
|
|
22
26
|
const finalFormattedExpectedDstAmount = formattedExpectedDstAmount || formatTokenAmount(BigInt(expectedDstAmount), dstToken.decimals);
|
|
23
27
|
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: () => {
|
|
24
28
|
toast.success("Copied recipient address to clipboard");
|
|
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-
|
|
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-start justify-between gap-2", children: [_jsx("div", { className: "order-details-expected-label text-as-tertiarry shrink-0", children: order.type === "swap" ||
|
|
30
|
+
order.type === "deposit_first" ||
|
|
31
|
+
order.type === "mint_nft" ||
|
|
32
|
+
order.type === "hype_duel"
|
|
26
33
|
? "Expected to receive"
|
|
27
34
|
: order.type === "join_tournament"
|
|
28
35
|
? "Join tournament"
|
|
@@ -32,5 +39,5 @@ export const OrderDetailsCollapsible = memo(function OrderDetailsCollapsible({ o
|
|
|
32
39
|
? order.metadata.action
|
|
33
40
|
? capitalizeFirstLetter(order.metadata.action)
|
|
34
41
|
: "Contract execution"
|
|
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" })] })) }));
|
|
42
|
+
: "" }), _jsxs("div", { className: "order-details-expected-value flex flex-wrap items-center justify-end gap-2", children: [order.type === "swap" || order.type === "deposit_first" ? (_jsx("span", { className: "order-details-amount-text", children: `~${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" })] })) }));
|
|
36
43
|
});
|
|
@@ -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 showCheck = order.status === "executed" || order.status === "quoting_after_deposit";
|
|
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: showCheck ? (_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
|
});
|