@b3dotfun/sdk 0.0.87 → 0.0.88
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 +578 -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,190 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AnySpendDeposit = AnySpendDeposit;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const anyspend_1 = require("../../../anyspend");
|
|
6
|
+
const react_1 = require("../../../global-account/react");
|
|
7
|
+
const cn_1 = require("../../../shared/utils/cn");
|
|
8
|
+
const react_2 = require("@web3icons/react");
|
|
9
|
+
const lucide_react_1 = require("lucide-react");
|
|
10
|
+
const react_3 = require("react");
|
|
11
|
+
const AnySpend_1 = require("./AnySpend");
|
|
12
|
+
const AnySpendCustomExactIn_1 = require("./AnySpendCustomExactIn");
|
|
13
|
+
const WarningText_1 = require("./common/WarningText");
|
|
14
|
+
const CreditCardIcon_1 = require("./icons/CreditCardIcon");
|
|
15
|
+
const QrCodeIcon_1 = require("./icons/QrCodeIcon");
|
|
16
|
+
const QRDeposit_1 = require("./QRDeposit");
|
|
17
|
+
// Default supported chains
|
|
18
|
+
const DEFAULT_SUPPORTED_CHAINS = [
|
|
19
|
+
{ id: 8453, name: "Base" },
|
|
20
|
+
{ id: 1, name: "Ethereum" },
|
|
21
|
+
{ id: 42161, name: "Arbitrum" },
|
|
22
|
+
{ id: 10, name: "Optimism" },
|
|
23
|
+
{ id: 137, name: "Polygon" },
|
|
24
|
+
{ id: 56, name: "BNB Chain" },
|
|
25
|
+
];
|
|
26
|
+
// Minimum pool size to filter out low liquidity tokens
|
|
27
|
+
const DEFAULT_MIN_POOL_SIZE = 1000000;
|
|
28
|
+
function formatUsd(value) {
|
|
29
|
+
return new Intl.NumberFormat("en-US", {
|
|
30
|
+
style: "currency",
|
|
31
|
+
currency: "USD",
|
|
32
|
+
minimumFractionDigits: 0,
|
|
33
|
+
maximumFractionDigits: value >= 100 ? 0 : 2,
|
|
34
|
+
}).format(value);
|
|
35
|
+
}
|
|
36
|
+
function formatDecimal(value) {
|
|
37
|
+
return new Intl.NumberFormat("en-US", {
|
|
38
|
+
style: "decimal",
|
|
39
|
+
minimumFractionDigits: 0,
|
|
40
|
+
maximumFractionDigits: value >= 100 ? 0 : 2,
|
|
41
|
+
}).format(value);
|
|
42
|
+
}
|
|
43
|
+
// Chain icon component
|
|
44
|
+
function ChainIcon({ chainId, className }) {
|
|
45
|
+
const iconProps = {
|
|
46
|
+
variant: "branded",
|
|
47
|
+
className: (0, cn_1.cn)("anyspend-deposit-chain-icon", className),
|
|
48
|
+
};
|
|
49
|
+
switch (chainId) {
|
|
50
|
+
case 1:
|
|
51
|
+
return (0, jsx_runtime_1.jsx)(react_2.NetworkEthereum, { ...iconProps });
|
|
52
|
+
case 8453:
|
|
53
|
+
return (0, jsx_runtime_1.jsx)(react_2.NetworkBase, { ...iconProps });
|
|
54
|
+
case 137:
|
|
55
|
+
return (0, jsx_runtime_1.jsx)(react_2.NetworkPolygonPos, { ...iconProps });
|
|
56
|
+
case 42161:
|
|
57
|
+
return (0, jsx_runtime_1.jsx)(react_2.NetworkArbitrumOne, { ...iconProps });
|
|
58
|
+
case 10:
|
|
59
|
+
return (0, jsx_runtime_1.jsx)(react_2.NetworkOptimism, { ...iconProps });
|
|
60
|
+
case 56:
|
|
61
|
+
return (0, jsx_runtime_1.jsx)(react_2.NetworkBinanceSmartChain, { ...iconProps });
|
|
62
|
+
default:
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* A flexible deposit component that wraps AnySpendCustomExactIn with optional chain selection.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* // Simple deposit with chain selection
|
|
71
|
+
* <AnySpendDeposit
|
|
72
|
+
* recipientAddress={userAddress}
|
|
73
|
+
* destinationToken={myToken}
|
|
74
|
+
* destinationChainId={base.id}
|
|
75
|
+
* onSuccess={(amount) => console.log(`Deposited ${amount}`)}
|
|
76
|
+
* />
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* // Skip chain selection by providing sourceTokenChainId
|
|
80
|
+
* <AnySpendDeposit
|
|
81
|
+
* recipientAddress={userAddress}
|
|
82
|
+
* destinationToken={myToken}
|
|
83
|
+
* destinationChainId={base.id}
|
|
84
|
+
* sourceTokenChainId={base.id}
|
|
85
|
+
* onSuccess={(amount) => console.log(`Deposited ${amount}`)}
|
|
86
|
+
* />
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* // Deposit with custom contract
|
|
90
|
+
* <AnySpendDeposit
|
|
91
|
+
* recipientAddress={userAddress}
|
|
92
|
+
* destinationToken={myToken}
|
|
93
|
+
* destinationChainId={base.id}
|
|
94
|
+
* depositContractConfig={{
|
|
95
|
+
* contractAddress: "0x...",
|
|
96
|
+
* functionName: "depositFor",
|
|
97
|
+
* }}
|
|
98
|
+
* onSuccess={(amount) => console.log(`Deposited ${amount}`)}
|
|
99
|
+
* />
|
|
100
|
+
*/
|
|
101
|
+
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, }) {
|
|
102
|
+
const { connectedEOAWallet } = (0, react_1.useAccountWallet)();
|
|
103
|
+
const eoaAddress = connectedEOAWallet?.getAccount()?.address;
|
|
104
|
+
// Determine if we should show chain selection
|
|
105
|
+
const shouldShowChainSelection = showChainSelection ?? (!initialSourceChainId && !initialPaymentType);
|
|
106
|
+
const [step, setStep] = (0, react_3.useState)(shouldShowChainSelection ? "select-chain" : "deposit");
|
|
107
|
+
const [selectedChainId, setSelectedChainId] = (0, react_3.useState)(initialSourceChainId);
|
|
108
|
+
const [paymentType, setPaymentType] = (0, react_3.useState)(initialPaymentType ?? "crypto");
|
|
109
|
+
// Fetch balances for EOA wallet
|
|
110
|
+
const { data: balanceData, isLoading: isBalanceLoading } = (0, react_1.useSimBalance)(shouldShowChainSelection ? eoaAddress : undefined, supportedChains.map(c => c.id));
|
|
111
|
+
// Group balances by chain and calculate total USD value per chain
|
|
112
|
+
const chainBalances = (0, react_3.useMemo)(() => {
|
|
113
|
+
if (!balanceData?.balances)
|
|
114
|
+
return {};
|
|
115
|
+
const filteredBalances = balanceData.balances.filter(token => token.address === "native" || (token.pool_size && token.pool_size > minPoolSize));
|
|
116
|
+
return filteredBalances.reduce((acc, token) => {
|
|
117
|
+
const chainId = token.chain_id;
|
|
118
|
+
if (!acc[chainId]) {
|
|
119
|
+
acc[chainId] = {
|
|
120
|
+
chainId,
|
|
121
|
+
chainName: token.chain,
|
|
122
|
+
totalUsdValue: 0,
|
|
123
|
+
tokenCount: 0,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
acc[chainId].totalUsdValue += token.value_usd || 0;
|
|
127
|
+
acc[chainId].tokenCount += 1;
|
|
128
|
+
return acc;
|
|
129
|
+
}, {});
|
|
130
|
+
}, [balanceData, minPoolSize]);
|
|
131
|
+
// Sort chains by USD value (highest first)
|
|
132
|
+
const sortedChains = (0, react_3.useMemo)(() => {
|
|
133
|
+
return supportedChains
|
|
134
|
+
.map(chain => ({
|
|
135
|
+
...chain,
|
|
136
|
+
balance: chainBalances[chain.id]?.totalUsdValue || 0,
|
|
137
|
+
tokenCount: chainBalances[chain.id]?.tokenCount || 0,
|
|
138
|
+
}))
|
|
139
|
+
.sort((a, b) => b.balance - a.balance);
|
|
140
|
+
}, [supportedChains, chainBalances]);
|
|
141
|
+
// Get top chains with balance
|
|
142
|
+
const topChainsWithBalance = (0, react_3.useMemo)(() => {
|
|
143
|
+
return sortedChains.filter(chain => chain.balance > 0).slice(0, topChainsCount);
|
|
144
|
+
}, [sortedChains, topChainsCount]);
|
|
145
|
+
// Calculate total balance across all chains
|
|
146
|
+
const totalBalance = (0, react_3.useMemo)(() => {
|
|
147
|
+
return Object.values(chainBalances).reduce((sum, chain) => sum + chain.totalUsdValue, 0);
|
|
148
|
+
}, [chainBalances]);
|
|
149
|
+
if (!recipientAddress)
|
|
150
|
+
return null;
|
|
151
|
+
const tokenSymbol = destinationToken.symbol ?? "TOKEN";
|
|
152
|
+
// Determine order type based on config
|
|
153
|
+
const effectiveOrderType = orderType ?? (depositContractConfig ? "custom_exact_in" : "swap");
|
|
154
|
+
// Default header if not provided
|
|
155
|
+
const defaultHeader = () => ((0, jsx_runtime_1.jsx)("div", { className: "anyspend-deposit-header mb-4 flex flex-col items-center gap-3 text-center", children: (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)("h1", { className: "anyspend-deposit-title text-as-primary text-xl font-bold", children: paymentType === "crypto" ? `Deposit ${tokenSymbol}` : "Fund with Fiat" }) }) }));
|
|
156
|
+
const handleSelectChain = (chainId) => {
|
|
157
|
+
setSelectedChainId(chainId);
|
|
158
|
+
setPaymentType("crypto");
|
|
159
|
+
setStep("deposit");
|
|
160
|
+
};
|
|
161
|
+
const handleSelectCrypto = () => {
|
|
162
|
+
setPaymentType("crypto");
|
|
163
|
+
setSelectedChainId(undefined);
|
|
164
|
+
setStep("deposit");
|
|
165
|
+
};
|
|
166
|
+
const handleSelectFiat = () => {
|
|
167
|
+
setPaymentType("fiat");
|
|
168
|
+
setSelectedChainId(undefined);
|
|
169
|
+
setStep("deposit");
|
|
170
|
+
};
|
|
171
|
+
const handleBack = () => {
|
|
172
|
+
setStep("select-chain");
|
|
173
|
+
setSelectedChainId(undefined);
|
|
174
|
+
};
|
|
175
|
+
const handleSelectQrDeposit = () => {
|
|
176
|
+
setStep("qr-deposit");
|
|
177
|
+
};
|
|
178
|
+
// Chain selection view
|
|
179
|
+
if (step === "select-chain") {
|
|
180
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, cn_1.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 && ((0, jsx_runtime_1.jsx)("button", { onClick: onClose, className: "anyspend-deposit-close-button text-as-secondary hover:text-as-primary absolute right-4 top-4 z-10", children: (0, jsx_runtime_1.jsx)("svg", { className: "h-6 w-6", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: (0, jsx_runtime_1.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) }) })), (0, jsx_runtime_1.jsxs)("div", { className: "anyspend-deposit-balance-header border-secondary border-b p-5", children: [!isBalanceLoading && totalBalance > 0 && ((0, jsx_runtime_1.jsxs)("div", { className: "anyspend-deposit-balance", children: [(0, jsx_runtime_1.jsx)("p", { className: "anyspend-deposit-balance-label text-as-secondary text-sm", children: "Your Balance" }), (0, jsx_runtime_1.jsxs)("p", { className: "anyspend-deposit-balance-value text-as-primary text-3xl font-semibold", children: [formatDecimal(totalBalance), " ", (0, jsx_runtime_1.jsx)("span", { className: "text-sm", children: "USD" })] })] })), isBalanceLoading && ((0, jsx_runtime_1.jsxs)("div", { className: "anyspend-deposit-balance-skeleton", children: [(0, jsx_runtime_1.jsx)(react_1.Skeleton, { className: "mb-2 h-4 w-24" }), (0, jsx_runtime_1.jsx)(react_1.Skeleton, { className: "h-8 w-32" })] }))] }), (0, jsx_runtime_1.jsxs)("div", { className: "anyspend-deposit-options flex flex-col gap-2 p-6", children: [isBalanceLoading && ((0, jsx_runtime_1.jsx)("div", { className: "anyspend-deposit-chains-skeleton flex flex-col gap-2", children: [...Array(topChainsCount)].map((_, i) => ((0, jsx_runtime_1.jsxs)("div", { className: "border-border-primary flex items-center justify-between rounded-xl border p-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-3", children: [(0, jsx_runtime_1.jsx)(react_1.Skeleton, { className: "h-6 w-6 rounded-full" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-1", children: [(0, jsx_runtime_1.jsx)(react_1.Skeleton, { className: "h-4 w-32" }), (0, jsx_runtime_1.jsx)(react_1.Skeleton, { className: "h-3 w-20" })] })] }), (0, jsx_runtime_1.jsx)(react_1.Skeleton, { className: "h-5 w-5" })] }, i))) })), topChainsWithBalance.length > 0 && ((0, jsx_runtime_1.jsx)("div", { className: "anyspend-deposit-chains flex flex-col gap-2", children: topChainsWithBalance.map(chain => ((0, jsx_runtime_1.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: [(0, jsx_runtime_1.jsx)("div", { className: "anyspend-deposit-chain-content", children: (0, jsx_runtime_1.jsxs)("div", { className: "anyspend-deposit-chain-info", children: [(0, jsx_runtime_1.jsxs)("span", { className: "anyspend-deposit-chain-name text-as-primary flex items-center gap-1.5 font-medium", children: ["Deposit from ", chain.name, (0, jsx_runtime_1.jsx)(ChainIcon, { chainId: chain.id, className: "h-5 w-5" })] }), (0, jsx_runtime_1.jsxs)("p", { className: "anyspend-deposit-chain-balance text-as-secondary text-xs", children: [formatUsd(chain.balance), " available"] })] }) }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "anyspend-deposit-chain-chevron text-as-secondary h-5 w-5" })] }, chain.id))) })), (0, jsx_runtime_1.jsxs)("div", { className: "anyspend-deposit-general-options flex flex-col gap-2", children: [(0, jsx_runtime_1.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: [(0, jsx_runtime_1.jsx)("div", { className: "anyspend-deposit-option-content", children: (0, jsx_runtime_1.jsxs)("div", { className: "anyspend-deposit-option-info", children: [(0, jsx_runtime_1.jsx)("span", { className: "anyspend-deposit-option-title text-as-primary font-medium", children: "Deposit Crypto" }), (0, jsx_runtime_1.jsx)("p", { className: "anyspend-deposit-option-description text-as-secondary text-xs", children: "Swap from any token on any chain" })] }) }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "anyspend-deposit-option-chevron text-as-secondary h-5 w-5" })] }), (0, jsx_runtime_1.jsxs)("div", { className: "anyspend-deposit-divider flex items-center gap-3", children: [(0, jsx_runtime_1.jsx)("div", { className: "bg-as-stroke h-px flex-1" }), (0, jsx_runtime_1.jsx)("span", { className: "anyspend-deposit-divider-text text-as-secondary text-sm", children: "More options" }), (0, jsx_runtime_1.jsx)("div", { className: "bg-as-stroke h-px flex-1" })] }), (0, jsx_runtime_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: [(0, jsx_runtime_1.jsxs)("div", { className: "anyspend-deposit-option-content flex items-center gap-3", children: [(0, jsx_runtime_1.jsx)(QrCodeIcon_1.QrCodeIcon, { className: "anyspend-deposit-option-icon h-10 w-10" }), (0, jsx_runtime_1.jsxs)("div", { className: "anyspend-deposit-option-info", children: [(0, jsx_runtime_1.jsx)("span", { className: "anyspend-deposit-option-title text-as-primary font-medium", children: "Deposit with QR Code" }), (0, jsx_runtime_1.jsx)("p", { className: "anyspend-deposit-option-description text-as-secondary text-xs", children: "Send tokens directly to deposit address" })] })] }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "anyspend-deposit-option-chevron text-as-secondary h-5 w-5" })] }), (0, jsx_runtime_1.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: [(0, jsx_runtime_1.jsxs)("div", { className: "anyspend-deposit-option-content flex items-center gap-3", children: [(0, jsx_runtime_1.jsx)(CreditCardIcon_1.CreditCardIcon, { className: "anyspend-deposit-option-icon h-10 w-10" }), (0, jsx_runtime_1.jsxs)("div", { className: "anyspend-deposit-option-info", children: [(0, jsx_runtime_1.jsx)("span", { className: "anyspend-deposit-option-title text-as-primary font-medium", children: "Fund with Fiat" }), (0, jsx_runtime_1.jsx)("p", { className: "anyspend-deposit-option-description text-as-secondary text-xs", children: "Pay with card or bank transfer" })] })] }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "anyspend-deposit-option-chevron text-as-secondary h-5 w-5" })] })] }), (0, jsx_runtime_1.jsx)(WarningText_1.ChainWarningText, { chainId: destinationChainId, className: "mt-2" })] })] }));
|
|
181
|
+
}
|
|
182
|
+
// QR Deposit view
|
|
183
|
+
if (step === "qr-deposit") {
|
|
184
|
+
return ((0, jsx_runtime_1.jsx)(QRDeposit_1.QRDeposit, { mode: mode, recipientAddress: recipientAddress, destinationToken: destinationToken, destinationChainId: destinationChainId, depositContractConfig: depositContractConfig, onBack: handleBack, onClose: onClose ?? handleBack }));
|
|
185
|
+
}
|
|
186
|
+
// Check if destination is Hyperliquid
|
|
187
|
+
const isHyperliquidDeposit = destinationChainId === anyspend_1.HYPERLIQUID_CHAIN_ID;
|
|
188
|
+
// Deposit view
|
|
189
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "anyspend-deposit anyspend-deposit-form relative", children: [shouldShowChainSelection && ((0, jsx_runtime_1.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: [(0, jsx_runtime_1.jsx)("svg", { className: "anyspend-deposit-back-icon h-5 w-5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: (0, jsx_runtime_1.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M15 19l-7-7 7-7" }) }), (0, jsx_runtime_1.jsx)("span", { className: "anyspend-deposit-back-text text-sm", children: "Back" })] })), onClose && ((0, jsx_runtime_1.jsx)("button", { onClick: onClose, className: "anyspend-deposit-close-button text-as-secondary hover:text-as-primary absolute right-4 top-4 z-10", children: (0, jsx_runtime_1.jsx)("svg", { className: "h-6 w-6", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: (0, jsx_runtime_1.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) }) })), (0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)("anyspend-deposit-form-content", shouldShowChainSelection && "pt-8"), children: isHyperliquidDeposit ? ((0, jsx_runtime_1.jsx)(AnySpend_1.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 })) : ((0, jsx_runtime_1.jsx)(AnySpendCustomExactIn_1.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 })) }), (0, jsx_runtime_1.jsx)(WarningText_1.ChainWarningText, { chainId: destinationChainId, className: "px-4 pb-4" })] }));
|
|
190
|
+
}
|
|
@@ -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,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QRDeposit = QRDeposit;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const anyspend_1 = require("../../../anyspend");
|
|
6
|
+
const react_1 = require("../../../global-account/react");
|
|
7
|
+
const cn_1 = require("../../../shared/utils/cn");
|
|
8
|
+
const relay_kit_ui_1 = require("@relayprotocol/relay-kit-ui");
|
|
9
|
+
const lucide_react_1 = require("lucide-react");
|
|
10
|
+
const qrcode_react_1 = require("qrcode.react");
|
|
11
|
+
const react_2 = require("react");
|
|
12
|
+
const useAnyspendOrderAndTransactions_1 = require("../hooks/useAnyspendOrderAndTransactions");
|
|
13
|
+
const useCreateDepositFirstOrder_1 = require("../hooks/useCreateDepositFirstOrder");
|
|
14
|
+
const ChainTokenIcon_1 = require("./common/ChainTokenIcon");
|
|
15
|
+
const OrderDetails_1 = require("./common/OrderDetails");
|
|
16
|
+
const WarningText_1 = require("./common/WarningText");
|
|
17
|
+
// Default source token: ETH on Base
|
|
18
|
+
const DEFAULT_ETH_ON_BASE = {
|
|
19
|
+
chainId: 8453,
|
|
20
|
+
address: "0x0000000000000000000000000000000000000000",
|
|
21
|
+
symbol: "ETH",
|
|
22
|
+
name: "Ethereum",
|
|
23
|
+
decimals: 18,
|
|
24
|
+
metadata: {
|
|
25
|
+
logoURI: "https://assets.relay.link/icons/1/light.png",
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* A component for displaying QR code deposit functionality.
|
|
30
|
+
* Creates a deposit_first order on mount and shows a QR code that can be scanned to deposit tokens.
|
|
31
|
+
* Users can change the source token/chain using the TokenSelector.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* <QRDeposit
|
|
35
|
+
* recipientAddress={userAddress}
|
|
36
|
+
* destinationToken={usdcArbitrumToken}
|
|
37
|
+
* destinationChainId={42161}
|
|
38
|
+
* onBack={() => setStep("select-chain")}
|
|
39
|
+
* onSuccess={(txHash) => console.log("Deposit complete:", txHash)}
|
|
40
|
+
* />
|
|
41
|
+
*/
|
|
42
|
+
function QRDeposit({ mode = "modal", recipientAddress, sourceToken: sourceTokenProp, sourceChainId: sourceChainIdProp, destinationToken, destinationChainId, creatorAddress, depositContractConfig, onBack, onClose, onOrderCreated, onSuccess, }) {
|
|
43
|
+
const [copied, setCopied] = (0, react_2.useState)(false);
|
|
44
|
+
const [orderId, setOrderId] = (0, react_2.useState)();
|
|
45
|
+
const [globalAddress, setGlobalAddress] = (0, react_2.useState)();
|
|
46
|
+
const orderCreatedRef = (0, react_2.useRef)(false);
|
|
47
|
+
const onSuccessCalled = (0, react_2.useRef)(false);
|
|
48
|
+
// Source token/chain as state (can be changed by user)
|
|
49
|
+
const [sourceChainId, setSourceChainId] = (0, react_2.useState)(sourceChainIdProp ?? 8453);
|
|
50
|
+
const [sourceToken, setSourceToken] = (0, react_2.useState)(sourceTokenProp ?? DEFAULT_ETH_ON_BASE);
|
|
51
|
+
// Handle token selection from TokenSelector
|
|
52
|
+
const handleTokenSelect = (newToken) => {
|
|
53
|
+
const token = {
|
|
54
|
+
address: newToken.address,
|
|
55
|
+
chainId: newToken.chainId,
|
|
56
|
+
decimals: newToken.decimals,
|
|
57
|
+
metadata: { logoURI: newToken.logoURI },
|
|
58
|
+
name: newToken.name,
|
|
59
|
+
symbol: newToken.symbol,
|
|
60
|
+
};
|
|
61
|
+
// Reset order state when token changes
|
|
62
|
+
setOrderId(undefined);
|
|
63
|
+
setGlobalAddress(undefined);
|
|
64
|
+
orderCreatedRef.current = false;
|
|
65
|
+
// Update token and chain
|
|
66
|
+
setSourceChainId(newToken.chainId);
|
|
67
|
+
setSourceToken(token);
|
|
68
|
+
};
|
|
69
|
+
// Create order hook
|
|
70
|
+
const { createOrder, isCreatingOrder } = (0, useCreateDepositFirstOrder_1.useCreateDepositFirstOrder)({
|
|
71
|
+
onSuccess: data => {
|
|
72
|
+
const newOrderId = data.data.id;
|
|
73
|
+
const newGlobalAddress = data.data.globalAddress;
|
|
74
|
+
setOrderId(newOrderId);
|
|
75
|
+
setGlobalAddress(newGlobalAddress);
|
|
76
|
+
onOrderCreated?.(newOrderId);
|
|
77
|
+
},
|
|
78
|
+
onError: error => {
|
|
79
|
+
console.error("Failed to create deposit order:", error);
|
|
80
|
+
react_1.toast.error("Failed to create deposit order: " + error.message);
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
// Fetch order status
|
|
84
|
+
const { orderAndTransactions: oat } = (0, useAnyspendOrderAndTransactions_1.useAnyspendOrderAndTransactions)(orderId);
|
|
85
|
+
// Create order on mount
|
|
86
|
+
(0, react_2.useEffect)(() => {
|
|
87
|
+
if (orderCreatedRef.current)
|
|
88
|
+
return;
|
|
89
|
+
orderCreatedRef.current = true;
|
|
90
|
+
createOrder({
|
|
91
|
+
recipientAddress,
|
|
92
|
+
srcChain: sourceChainId,
|
|
93
|
+
dstChain: destinationChainId,
|
|
94
|
+
srcToken: sourceToken,
|
|
95
|
+
dstToken: destinationToken,
|
|
96
|
+
creatorAddress,
|
|
97
|
+
contractConfig: depositContractConfig,
|
|
98
|
+
});
|
|
99
|
+
}, [
|
|
100
|
+
recipientAddress,
|
|
101
|
+
sourceChainId,
|
|
102
|
+
destinationChainId,
|
|
103
|
+
sourceToken,
|
|
104
|
+
destinationToken,
|
|
105
|
+
creatorAddress,
|
|
106
|
+
depositContractConfig,
|
|
107
|
+
createOrder,
|
|
108
|
+
]);
|
|
109
|
+
// Call onSuccess when order is executed
|
|
110
|
+
(0, react_2.useEffect)(() => {
|
|
111
|
+
if (oat?.data?.order.status === "executed" && !onSuccessCalled.current) {
|
|
112
|
+
const txHash = oat?.data?.executeTx?.txHash;
|
|
113
|
+
onSuccess?.(txHash);
|
|
114
|
+
onSuccessCalled.current = true;
|
|
115
|
+
}
|
|
116
|
+
}, [oat?.data?.order.status, oat?.data?.executeTx?.txHash, onSuccess]);
|
|
117
|
+
// Reset onSuccess flag when orderId changes
|
|
118
|
+
(0, react_2.useEffect)(() => {
|
|
119
|
+
onSuccessCalled.current = false;
|
|
120
|
+
}, [orderId]);
|
|
121
|
+
const displayAddress = globalAddress || recipientAddress;
|
|
122
|
+
const handleCopyAddress = async () => {
|
|
123
|
+
if (displayAddress) {
|
|
124
|
+
await navigator.clipboard.writeText(displayAddress);
|
|
125
|
+
setCopied(true);
|
|
126
|
+
setTimeout(() => setCopied(false), 2000);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
const handleBack = () => {
|
|
130
|
+
setCopied(false);
|
|
131
|
+
onBack?.();
|
|
132
|
+
};
|
|
133
|
+
const handleClose = () => {
|
|
134
|
+
setCopied(false);
|
|
135
|
+
onClose?.();
|
|
136
|
+
};
|
|
137
|
+
// Show order details if order has deposits or is being processed
|
|
138
|
+
if (oat?.data && oat.data.depositTxs && oat.data.depositTxs.length > 0) {
|
|
139
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.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: (0, jsx_runtime_1.jsx)("div", { className: "anyspend-qr-order-details-content relative flex flex-col gap-4", children: (0, jsx_runtime_1.jsx)(OrderDetails_1.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 }) }) }));
|
|
140
|
+
}
|
|
141
|
+
// Show loading state while creating order (but not if we already have an orderId)
|
|
142
|
+
if (isCreatingOrder && !orderId) {
|
|
143
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.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: (0, jsx_runtime_1.jsxs)("div", { className: "anyspend-qr-loading-content flex flex-col items-center justify-center gap-4 py-12", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "anyspend-qr-loading-spinner text-as-brand h-8 w-8 animate-spin" }), (0, jsx_runtime_1.jsx)("p", { className: "anyspend-qr-loading-text text-as-secondary text-sm", children: "Creating deposit order..." })] }) }));
|
|
144
|
+
}
|
|
145
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.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: (0, jsx_runtime_1.jsxs)("div", { className: "anyspend-qr-deposit-content flex flex-col gap-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "anyspend-qr-header flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("button", { onClick: handleBack, className: "anyspend-qr-back-button text-as-secondary hover:text-as-primary", children: (0, jsx_runtime_1.jsx)("svg", { className: "h-5 w-5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: (0, jsx_runtime_1.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M15 19l-7-7 7-7" }) }) }), (0, jsx_runtime_1.jsx)("h2", { className: "anyspend-qr-title text-as-primary text-base font-semibold", children: "Deposit" }), onClose ? ((0, jsx_runtime_1.jsx)("button", { onClick: handleClose, className: "anyspend-qr-close-button text-as-secondary hover:text-as-primary", children: (0, jsx_runtime_1.jsx)("svg", { className: "h-5 w-5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: (0, jsx_runtime_1.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) }) })) : ((0, jsx_runtime_1.jsx)("div", { className: "w-5" }))] }), (0, jsx_runtime_1.jsxs)("div", { className: "anyspend-qr-token-selector flex flex-col gap-1.5", children: [(0, jsx_runtime_1.jsx)("label", { className: "anyspend-qr-token-label text-as-secondary text-sm", children: "Send" }), (0, jsx_runtime_1.jsx)(relay_kit_ui_1.TokenSelector, { chainIdsFilter: (0, anyspend_1.getAvailableChainIds)("from"), context: "from", fromChainWalletVMSupported: true, isValidAddress: true, lockedChainIds: (0, anyspend_1.getAvailableChainIds)("from"), multiWalletSupportEnabled: true, onAnalyticEvent: undefined, setToken: handleTokenSelect, supportedWalletVMs: ["evm"], token: undefined, trigger: (0, jsx_runtime_1.jsxs)(react_1.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: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2", children: [sourceToken.metadata?.logoURI ? ((0, jsx_runtime_1.jsx)(ChainTokenIcon_1.ChainTokenIcon, { chainUrl: anyspend_1.ALL_CHAINS[sourceChainId]?.logoUrl, tokenUrl: sourceToken.metadata.logoURI, className: "h-8 min-h-8 w-8 min-w-8" })) : ((0, jsx_runtime_1.jsx)("div", { className: "h-8 w-8 rounded-full bg-gray-700" })), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-start gap-0", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary font-semibold", children: sourceToken.symbol }), (0, jsx_runtime_1.jsx)("div", { className: "text-as-primary/70 text-xs", children: anyspend_1.ALL_CHAINS[sourceChainId]?.name ?? "Unknown" })] })] }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronsUpDown, { className: "h-4 w-4 shrink-0 opacity-70" })] }) })] }), (0, jsx_runtime_1.jsxs)("div", { className: "anyspend-qr-content border-as-stroke flex items-start gap-4 rounded-xl border p-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "anyspend-qr-code-container flex flex-col items-center gap-2", children: [(0, jsx_runtime_1.jsx)("div", { className: "anyspend-qr-code rounded-lg bg-white p-2", children: (0, jsx_runtime_1.jsx)(qrcode_react_1.QRCodeSVG, { value: displayAddress, size: 120, level: "M", marginSize: 0 }) }), (0, jsx_runtime_1.jsxs)("span", { className: "anyspend-qr-scan-hint text-as-secondary text-xs", children: ["SCAN WITH ", (0, jsx_runtime_1.jsx)("span", { className: "inline-block", children: "\uD83E\uDD8A" })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "anyspend-qr-address-container flex flex-1 flex-col gap-1", children: [(0, jsx_runtime_1.jsx)("span", { className: "anyspend-qr-address-label text-as-secondary text-sm", children: "Deposit address:" }), (0, jsx_runtime_1.jsxs)("div", { className: "anyspend-qr-address-row flex items-start gap-1", children: [(0, jsx_runtime_1.jsx)("span", { className: "anyspend-qr-address text-as-primary break-all font-mono text-sm leading-relaxed", children: displayAddress }), (0, jsx_runtime_1.jsx)("button", { onClick: handleCopyAddress, className: "anyspend-qr-copy-icon text-as-secondary hover:text-as-primary mt-0.5 shrink-0", children: copied ? (0, jsx_runtime_1.jsx)(lucide_react_1.Check, { className: "h-4 w-4" }) : (0, jsx_runtime_1.jsx)(lucide_react_1.Copy, { className: "h-4 w-4" }) })] })] })] }), (0, jsx_runtime_1.jsx)(WarningText_1.ChainWarningText, { chainId: destinationChainId }), (0, jsx_runtime_1.jsxs)(WarningText_1.WarningText, { children: ["Only send ", sourceToken.symbol, " on ", anyspend_1.ALL_CHAINS[sourceChainId]?.name ?? "the specified chain", ". Other tokens will not be converted."] }), (0, jsx_runtime_1.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" })] }) }));
|
|
146
|
+
}
|
|
@@ -37,6 +37,7 @@ function getOrderSuccessText({ order, tournament, formattedActualDstAmount, form
|
|
|
37
37
|
let actionText = "";
|
|
38
38
|
switch (order.type) {
|
|
39
39
|
case "swap":
|
|
40
|
+
case "deposit_first":
|
|
40
41
|
actionText = `sent ${formattedActualDstAmount || "--"} ${dstToken.symbol}`;
|
|
41
42
|
return `Successfully ${actionText} to ${recipient}`;
|
|
42
43
|
case "mint_nft":
|
|
@@ -158,6 +159,7 @@ exports.OrderDetails = (0, react_5.memo)(function OrderDetails({ mode = "modal",
|
|
|
158
159
|
const { data: walletClient } = (0, wagmi_1.useWalletClient)();
|
|
159
160
|
const [txHash, setTxHash] = (0, react_5.useState)();
|
|
160
161
|
const [showQRCode, setShowQRCode] = (0, react_5.useState)(false);
|
|
162
|
+
const [orderDetailsOpen, setOrderDetailsOpen] = (0, react_5.useState)(true);
|
|
161
163
|
const { isLoading: txLoading, isSuccess: txSuccess } = (0, wagmi_1.useWaitForTransactionReceipt)({ hash: txHash });
|
|
162
164
|
const { switchChainAndExecuteWithEOA, switchChainAndExecute, isSwitchingOrExecuting } = (0, react_1.useUnifiedChainSwitchAndExecute)();
|
|
163
165
|
// Track if auto-payment was attempted to avoid re-triggering
|
|
@@ -326,7 +328,8 @@ exports.OrderDetails = (0, react_5.memo)(function OrderDetails({ mode = "modal",
|
|
|
326
328
|
const expectedDstAmount = order.type === "mint_nft" ||
|
|
327
329
|
order.type === "join_tournament" ||
|
|
328
330
|
order.type === "fund_tournament" ||
|
|
329
|
-
order.type === "custom"
|
|
331
|
+
order.type === "custom" ||
|
|
332
|
+
order.type === "deposit_first"
|
|
330
333
|
? "0"
|
|
331
334
|
: order.payload.expectedDstAmount.toString();
|
|
332
335
|
const formattedExpectedDstAmount = (0, number_1.formatTokenAmount)(BigInt(expectedDstAmount), dstToken.decimals);
|
|
@@ -335,7 +338,7 @@ exports.OrderDetails = (0, react_5.memo)(function OrderDetails({ mode = "modal",
|
|
|
335
338
|
? (0, number_1.formatTokenAmount)(BigInt(actualDstAmount), dstToken.decimals)
|
|
336
339
|
: undefined;
|
|
337
340
|
if (refundTxs.length > 0) {
|
|
338
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(OrderStatus_1.OrderStatus, { order: order, selectedCryptoPaymentMethod: effectiveCryptoPaymentMethod }), (0, jsx_runtime_1.jsx)(OrderDetailsCollapsible_1.OrderDetailsCollapsible, { order: order, dstToken: dstToken, tournament: tournament, nft: nft, recipientName: recipientName, formattedExpectedDstAmount: formattedExpectedDstAmount, points: points }), (0, jsx_runtime_1.jsx)(Accordion_1.Accordion, { type: "single", collapsible: true, className: "order-details-accordion w-full", children: (0, jsx_runtime_1.jsxs)(Accordion_1.AccordionItem, { value: "refund-details", className: "order-details-refund-item", children: [(0, jsx_runtime_1.jsx)(Accordion_1.AccordionTrigger, { className: "accordion-trigger", children: "Transaction Details" }), (0, jsx_runtime_1.jsx)(Accordion_1.AccordionContent, { className: "accordion-content pl-2", children: (0, jsx_runtime_1.jsxs)("div", { className: "relative flex w-full flex-col gap-4", children: [(0, jsx_runtime_1.jsx)("div", { className: "bg-as-surface-secondary absolute bottom-2 left-4 top-2 z-[5] w-2", children: (0, jsx_runtime_1.jsx)(react_4.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
|
|
341
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(OrderStatus_1.OrderStatus, { order: order, selectedCryptoPaymentMethod: effectiveCryptoPaymentMethod }), (0, jsx_runtime_1.jsx)(OrderDetailsCollapsible_1.OrderDetailsCollapsible, { order: order, dstToken: dstToken, tournament: tournament, nft: nft, recipientName: recipientName, formattedExpectedDstAmount: formattedExpectedDstAmount, points: points, isOpen: orderDetailsOpen, onOpenChange: setOrderDetailsOpen }), (0, jsx_runtime_1.jsx)(Accordion_1.Accordion, { type: "single", collapsible: true, className: "order-details-accordion w-full", children: (0, jsx_runtime_1.jsxs)(Accordion_1.AccordionItem, { value: "refund-details", className: "order-details-refund-item", children: [(0, jsx_runtime_1.jsx)(Accordion_1.AccordionTrigger, { className: "accordion-trigger", children: "Transaction Details" }), (0, jsx_runtime_1.jsx)(Accordion_1.AccordionContent, { className: "accordion-content pl-2", children: (0, jsx_runtime_1.jsxs)("div", { className: "relative flex w-full flex-col gap-4", children: [(0, jsx_runtime_1.jsx)("div", { className: "bg-as-surface-secondary absolute bottom-2 left-4 top-2 z-[5] w-2", children: (0, jsx_runtime_1.jsx)(react_4.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
|
|
339
342
|
? depositTxs.map(dTx => ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: order.onrampMetadata?.vendor === "stripe-web2"
|
|
340
343
|
? `Received payment`
|
|
341
344
|
: `Received ${(0, number_1.formatTokenAmount)(BigInt(dTx.amount), srcToken.decimals)} ${srcToken.symbol}`, chainId: order.srcChain, tx: dTx, isProcessing: false }, dTx.txHash)))
|
|
@@ -344,13 +347,13 @@ exports.OrderDetails = (0, react_5.memo)(function OrderDetails({ mode = "modal",
|
|
|
344
347
|
: null] }) })] }) }), order.errorDetails && ((0, jsx_runtime_1.jsx)("div", { className: "flex justify-center", children: (0, jsx_runtime_1.jsx)("span", { className: "text-as-primary/50 text-center text-sm", style: { maxWidth: "40ch" }, children: (0, anyspend_1.getErrorDisplay)(order.errorDetails) }) })), (0, jsx_runtime_1.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" ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Return to Home ", (0, jsx_runtime_1.jsx)(lucide_react_1.Home, { className: "ml-2 h-4 w-4" })] })) : ("Close") })] }));
|
|
345
348
|
}
|
|
346
349
|
if (executeTx) {
|
|
347
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(OrderStatus_1.OrderStatus, { order: order, selectedCryptoPaymentMethod: effectiveCryptoPaymentMethod }), (0, jsx_runtime_1.jsx)(OrderDetailsCollapsible_1.OrderDetailsCollapsible, { order: order, dstToken: dstToken, tournament: tournament, nft: nft, recipientName: recipientName, formattedExpectedDstAmount: formattedExpectedDstAmount, points: points }), (0, jsx_runtime_1.jsx)(Accordion_1.Accordion, { type: "single", collapsible: true, className: "order-details-accordion w-full", children: (0, jsx_runtime_1.jsxs)(Accordion_1.AccordionItem, { value: "execute-details", className: "order-details-execute-item", children: [(0, jsx_runtime_1.jsx)(Accordion_1.AccordionTrigger, { className: "accordion-trigger", children: "Transaction Details" }), (0, jsx_runtime_1.jsx)(Accordion_1.AccordionContent, { className: "accordion-content pl-2", children: (0, jsx_runtime_1.jsxs)("div", { className: "relative flex w-full flex-col gap-4", children: [(0, jsx_runtime_1.jsx)("div", { className: "bg-as-surface-secondary absolute bottom-2 left-4 top-2 z-[5] w-2", children: (0, jsx_runtime_1.jsx)(react_4.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
|
|
350
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(OrderStatus_1.OrderStatus, { order: order, selectedCryptoPaymentMethod: effectiveCryptoPaymentMethod }), (0, jsx_runtime_1.jsx)(OrderDetailsCollapsible_1.OrderDetailsCollapsible, { order: order, dstToken: dstToken, tournament: tournament, nft: nft, recipientName: recipientName, formattedExpectedDstAmount: formattedExpectedDstAmount, points: points, isOpen: orderDetailsOpen, onOpenChange: setOrderDetailsOpen }), (0, jsx_runtime_1.jsx)(Accordion_1.Accordion, { type: "single", collapsible: true, className: "order-details-accordion w-full", children: (0, jsx_runtime_1.jsxs)(Accordion_1.AccordionItem, { value: "execute-details", className: "order-details-execute-item", children: [(0, jsx_runtime_1.jsx)(Accordion_1.AccordionTrigger, { className: "accordion-trigger", children: "Transaction Details" }), (0, jsx_runtime_1.jsx)(Accordion_1.AccordionContent, { className: "accordion-content pl-2", children: (0, jsx_runtime_1.jsxs)("div", { className: "relative flex w-full flex-col gap-4", children: [(0, jsx_runtime_1.jsx)("div", { className: "bg-as-surface-secondary absolute bottom-2 left-4 top-2 z-[5] w-2", children: (0, jsx_runtime_1.jsx)(react_4.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
|
|
348
351
|
? depositTxs.map(dTxs => ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: order.onrampMetadata?.vendor === "stripe-web2"
|
|
349
352
|
? `Received payment`
|
|
350
353
|
: `Received ${(0, number_1.formatTokenAmount)(BigInt(dTxs.amount), srcToken.decimals)} ${srcToken.symbol}`, chainId: order.srcChain, tx: dTxs, isProcessing: false }, dTxs.txHash)))
|
|
351
354
|
: null, relayTxs
|
|
352
|
-
? relayTxs.map(relayTx => ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: "Processed
|
|
353
|
-
: null, (0, jsx_runtime_1.jsx)(TransactionDetails, { title: order.type === "swap"
|
|
355
|
+
? relayTxs.map(relayTx => ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: "Processed Swap", chainId: relayTx.chain, tx: relayTx, delay: 0.5, isProcessing: false }, relayTx.txHash)))
|
|
356
|
+
: null, (0, jsx_runtime_1.jsx)(TransactionDetails, { title: order.type === "swap" || order.type === "deposit_first"
|
|
354
357
|
? "Processed Swap"
|
|
355
358
|
: order.type === "mint_nft"
|
|
356
359
|
? "Minted NFT"
|
|
@@ -369,12 +372,14 @@ exports.OrderDetails = (0, react_5.memo)(function OrderDetails({ mode = "modal",
|
|
|
369
372
|
}), (0, jsx_runtime_1.jsx)(lucide_react_1.ExternalLink, { className: "ml-2 h-4 w-4" })] }) }) }), order.type === "join_tournament" && order.status === "executed" && ((0, jsx_runtime_1.jsxs)(react_1.ShinyButton, { accentColor: "hsl(var(--as-brand))", textColor: "text-white", className: "flex w-full items-center gap-2", disabled: txLoading || isSwitchingOrExecuting, onClick: handleCloseModal, children: [(0, jsx_runtime_1.jsx)("span", { className: "pl-4", children: "Continue to Tournament" }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] })), order.status === "executed" && ((0, jsx_runtime_1.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" ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Return to Home ", (0, jsx_runtime_1.jsx)(lucide_react_1.Home, { className: "ml-2 h-4 w-4" })] })) : ("Close") }))] }));
|
|
370
373
|
}
|
|
371
374
|
if (relayTxs.length > 0 && relayTxs.every(tx => tx.status === "success")) {
|
|
372
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(OrderStatus_1.OrderStatus, { order: order, selectedCryptoPaymentMethod: effectiveCryptoPaymentMethod }), (0, jsx_runtime_1.jsx)(OrderDetailsCollapsible_1.OrderDetailsCollapsible, { order: order, dstToken: dstToken, tournament: tournament, nft: nft, recipientName: recipientName, formattedExpectedDstAmount: formattedExpectedDstAmount, points: points }), (0, jsx_runtime_1.jsx)(Accordion_1.Accordion, { type: "single", collapsible: true, className: "order-details-accordion w-full", children: (0, jsx_runtime_1.jsxs)(Accordion_1.AccordionItem, { value: "more-details", className: "order-details-more-item", children: [(0, jsx_runtime_1.jsx)(Accordion_1.AccordionTrigger, { className: "accordion-trigger", children: "More Details" }), (0, jsx_runtime_1.jsx)(Accordion_1.AccordionContent, { className: "accordion-content pl-2", children: (0, jsx_runtime_1.jsxs)("div", { className: "relative flex w-full flex-col gap-4", children: [(0, jsx_runtime_1.jsx)("div", { className: "bg-as-surface-secondary absolute bottom-2 left-4 top-2 z-[5] w-2", children: (0, jsx_runtime_1.jsx)(react_4.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
|
|
375
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(OrderStatus_1.OrderStatus, { order: order, selectedCryptoPaymentMethod: effectiveCryptoPaymentMethod }), (0, jsx_runtime_1.jsx)(OrderDetailsCollapsible_1.OrderDetailsCollapsible, { order: order, dstToken: dstToken, tournament: tournament, nft: nft, recipientName: recipientName, formattedExpectedDstAmount: formattedExpectedDstAmount, points: points, isOpen: orderDetailsOpen, onOpenChange: setOrderDetailsOpen }), (0, jsx_runtime_1.jsx)(Accordion_1.Accordion, { type: "single", collapsible: true, className: "order-details-accordion w-full", children: (0, jsx_runtime_1.jsxs)(Accordion_1.AccordionItem, { value: "more-details", className: "order-details-more-item", children: [(0, jsx_runtime_1.jsx)(Accordion_1.AccordionTrigger, { className: "accordion-trigger", children: "More Details" }), (0, jsx_runtime_1.jsx)(Accordion_1.AccordionContent, { className: "accordion-content pl-2", children: (0, jsx_runtime_1.jsxs)("div", { className: "relative flex w-full flex-col gap-4", children: [(0, jsx_runtime_1.jsx)("div", { className: "bg-as-surface-secondary absolute bottom-2 left-4 top-2 z-[5] w-2", children: (0, jsx_runtime_1.jsx)(react_4.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
|
|
373
376
|
? depositTxs.map(dTxs => ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: order.onrampMetadata?.vendor === "stripe-web2"
|
|
374
377
|
? `Received payment`
|
|
375
378
|
: `Received ${(0, number_1.formatTokenAmount)(BigInt(dTxs.amount), srcToken.decimals)} ${srcToken.symbol}`, chainId: order.srcChain, tx: dTxs, isProcessing: false }, dTxs.txHash)))
|
|
376
|
-
: null, relayTxs.map(relayTx => ((0, jsx_runtime_1.jsx)(TransactionDetails, { title:
|
|
377
|
-
?
|
|
379
|
+
: null, relayTxs.map(relayTx => ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: relayTx.chain === order.srcChain
|
|
380
|
+
? `Process swap on ${(0, anyspend_1.getChainName)(relayTx.chain)}`
|
|
381
|
+
: `Received on ${(0, anyspend_1.getChainName)(relayTx.chain)}`, chainId: relayTx.chain, isProcessing: false, tx: relayTx, delay: 0.5 }, relayTx.txHash))), order.status === "executing" && ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: order.type === "swap" || order.type === "x402_swap" || order.type === "deposit_first"
|
|
382
|
+
? "Processing swap"
|
|
378
383
|
: order.type === "mint_nft"
|
|
379
384
|
? "Minting NFT"
|
|
380
385
|
: order.type === "join_tournament"
|
|
@@ -390,10 +395,10 @@ exports.OrderDetails = (0, react_5.memo)(function OrderDetails({ mode = "modal",
|
|
|
390
395
|
// This boolean indicates that user finish payment, and waiting for the deposit to be confirmed. We get this from query params (waitingForDeposit=true)
|
|
391
396
|
const waitingForDeposit = new URLSearchParams(window.location.search).get("waitingForDeposit") === "true";
|
|
392
397
|
if (depositTxs?.length || waitingForDeposit) {
|
|
393
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(OrderStatus_1.OrderStatus, { order: order, selectedCryptoPaymentMethod: effectiveCryptoPaymentMethod }), (0, jsx_runtime_1.jsx)(OrderDetailsCollapsible_1.OrderDetailsCollapsible, { order: order, dstToken: dstToken, tournament: tournament, nft: nft, recipientName: recipientName, formattedExpectedDstAmount: formattedExpectedDstAmount, points: points }), (0, jsx_runtime_1.jsx)(Accordion_1.Accordion, { type: "single", collapsible: true, className: "order-details-accordion w-full", children: (0, jsx_runtime_1.jsxs)(Accordion_1.AccordionItem, { value: "deposit-details", className: "order-details-deposit-item", children: [(0, jsx_runtime_1.jsx)(Accordion_1.AccordionTrigger, { className: "accordion-trigger", children: "Transaction Details" }), (0, jsx_runtime_1.jsx)(Accordion_1.AccordionContent, { className: "accordion-content pl-2", children: (0, jsx_runtime_1.jsxs)("div", { className: "relative flex w-full flex-col gap-6", children: [(0, jsx_runtime_1.jsx)("div", { className: "bg-as-surface-secondary absolute bottom-2 left-4 top-2 z-[5] w-2", children: (0, jsx_runtime_1.jsx)(react_4.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) => ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: order.onrampMetadata?.vendor === "stripe-web2"
|
|
398
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(OrderStatus_1.OrderStatus, { order: order, selectedCryptoPaymentMethod: effectiveCryptoPaymentMethod }), (0, jsx_runtime_1.jsx)(OrderDetailsCollapsible_1.OrderDetailsCollapsible, { order: order, dstToken: dstToken, tournament: tournament, nft: nft, recipientName: recipientName, formattedExpectedDstAmount: formattedExpectedDstAmount, points: points, isOpen: orderDetailsOpen, onOpenChange: setOrderDetailsOpen }), (0, jsx_runtime_1.jsx)(Accordion_1.Accordion, { type: "single", collapsible: true, className: "order-details-accordion w-full", children: (0, jsx_runtime_1.jsxs)(Accordion_1.AccordionItem, { value: "deposit-details", className: "order-details-deposit-item", children: [(0, jsx_runtime_1.jsx)(Accordion_1.AccordionTrigger, { className: "accordion-trigger", children: "Transaction Details" }), (0, jsx_runtime_1.jsx)(Accordion_1.AccordionContent, { className: "accordion-content pl-2", children: (0, jsx_runtime_1.jsxs)("div", { className: "relative flex w-full flex-col gap-6", children: [(0, jsx_runtime_1.jsx)("div", { className: "bg-as-surface-secondary absolute bottom-2 left-4 top-2 z-[5] w-2", children: (0, jsx_runtime_1.jsx)(react_4.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) => ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: order.onrampMetadata?.vendor === "stripe-web2"
|
|
394
399
|
? `Received payment`
|
|
395
|
-
: `Received ${(0, number_1.formatTokenAmount)(BigInt(dTxs.amount), srcToken.decimals)} ${srcToken.symbol}`, chainId: order.srcChain, tx: dTxs, isProcessing: index < (depositTxs || []).length - 1 ? false : !depositEnoughAmount }, dTxs.txHash))), statusDisplay === "failure" ? ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: statusText, chainId: order.srcChain, tx: null, isProcessing: false, delay: 0.5 })) : depositEnoughAmount ? ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: order.type === "swap"
|
|
396
|
-
? "Processing
|
|
400
|
+
: `Received ${(0, number_1.formatTokenAmount)(BigInt(dTxs.amount), srcToken.decimals)} ${srcToken.symbol}`, chainId: order.srcChain, tx: dTxs, isProcessing: index < (depositTxs || []).length - 1 ? false : !depositEnoughAmount }, dTxs.txHash))), statusDisplay === "failure" ? ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: statusText, chainId: order.srcChain, tx: null, isProcessing: false, delay: 0.5 })) : depositEnoughAmount ? ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: order.type === "swap" || order.type === "deposit_first"
|
|
401
|
+
? "Processing swap"
|
|
397
402
|
: order.type === "mint_nft"
|
|
398
403
|
? "Minting NFT"
|
|
399
404
|
: order.type === "join_tournament"
|
|
@@ -417,7 +422,7 @@ exports.OrderDetails = (0, react_5.memo)(function OrderDetails({ mode = "modal",
|
|
|
417
422
|
? (0, centerTruncate_1.default)(phantomWalletAddress, 6)
|
|
418
423
|
: (0, centerTruncate_1.default)(account?.address || "", 6)] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex w-full flex-col items-center gap-2", children: [(0, jsx_runtime_1.jsxs)(react_1.ShinyButton, { accentColor: colorMode === "dark" ? "#ffffff" : "#000000", className: "flex w-5/6 items-center gap-2 sm:px-0", onClick: () => setShowQRCode(true), children: [(0, jsx_runtime_1.jsx)("span", { className: "pl-4 text-lg md:text-sm", children: "Pay from a different wallet" }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2", children: [(0, jsx_runtime_1.jsx)(react_3.WalletMetamask, { className: "h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)(react_3.WalletCoinbase, { className: "h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)(react_3.WalletPhantom, { className: "h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)(react_3.WalletTrust, { className: "h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)(react_3.WalletWalletConnect, { className: "h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)("span", { className: "label-style text-as-primary/30 text-xs", children: "& more" })] })] })] }) })) : (
|
|
419
424
|
// Default case - existing QR code flow
|
|
420
|
-
(0, jsx_runtime_1.jsx)(react_4.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: (0, jsx_runtime_1.jsxs)("div", { className: "order-details-qr-container mt-8 flex flex-col items-center rounded-lg bg-white p-6 pb-3", children: [(0, jsx_runtime_1.jsx)(qrcode_react_1.QRCodeSVG, { value: (0, anyspend_1.getPaymentUrl)(order.globalAddress, BigInt(order.srcAmount), order.srcTokenAddress === anyspend_1.ZERO_ADDRESS ? srcToken?.symbol || "ETH" : order.srcTokenAddress, order.srcChain, srcToken?.decimals), className: "order-details-qr-code max-w-[200px]" }), (0, jsx_runtime_1.jsxs)("div", { className: "order-details-qr-wallets mt-3 flex items-center justify-center gap-2 text-sm", children: [(0, jsx_runtime_1.jsx)("span", { className: "label-style text-as-brand/70 text-sm", children: "Scan with" }), (0, jsx_runtime_1.jsxs)(react_1.TextLoop, { interval: 3, children: [(0, jsx_runtime_1.jsx)(react_3.WalletMetamask, { className: "h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)(react_3.WalletCoinbase, { className: "h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)(react_3.WalletPhantom, { className: "h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)(react_3.WalletTrust, { className: "h-5 w-5", variant: "branded" })] })] })] }) }))] })) })), (0, jsx_runtime_1.jsxs)("div", { className: "order-details-time-remaining flex w-full items-center justify-center gap-1 text-sm", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary/30 order-details-time-label", children: "Time remaining:" }), (0, jsx_runtime_1.jsx)("div", { className: "text-as-primary order-details-time-value", children: depositEnoughAmount ? ("Received") : order.status === "expired" ? ("Expired") : ((0, jsx_runtime_1.jsx)(react_timeago_1.default, { date: new Date(order.expiredAt), live: true })) })] }), statusDisplay !== "processing" && ((0, jsx_runtime_1.jsx)(OrderDetailsCollapsible_1.OrderDetailsCollapsible, { order: order, dstToken: dstToken, tournament: tournament, nft: nft, recipientName: recipientName, formattedExpectedDstAmount: formattedExpectedDstAmount, points: points })), (0, jsx_runtime_1.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: [(0, jsx_runtime_1.jsx)(lucide_react_1.RefreshCcw, { className: "ml-2 h-4 w-4" }), " Cancel and start over"] })] }));
|
|
425
|
+
(0, jsx_runtime_1.jsx)(react_4.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: (0, jsx_runtime_1.jsxs)("div", { className: "order-details-qr-container mt-8 flex flex-col items-center rounded-lg bg-white p-6 pb-3", children: [(0, jsx_runtime_1.jsx)(qrcode_react_1.QRCodeSVG, { value: (0, anyspend_1.getPaymentUrl)(order.globalAddress, BigInt(order.srcAmount), order.srcTokenAddress === anyspend_1.ZERO_ADDRESS ? srcToken?.symbol || "ETH" : order.srcTokenAddress, order.srcChain, srcToken?.decimals), className: "order-details-qr-code max-w-[200px]" }), (0, jsx_runtime_1.jsxs)("div", { className: "order-details-qr-wallets mt-3 flex items-center justify-center gap-2 text-sm", children: [(0, jsx_runtime_1.jsx)("span", { className: "label-style text-as-brand/70 text-sm", children: "Scan with" }), (0, jsx_runtime_1.jsxs)(react_1.TextLoop, { interval: 3, children: [(0, jsx_runtime_1.jsx)(react_3.WalletMetamask, { className: "h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)(react_3.WalletCoinbase, { className: "h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)(react_3.WalletPhantom, { className: "h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)(react_3.WalletTrust, { className: "h-5 w-5", variant: "branded" })] })] })] }) }))] })) })), (0, jsx_runtime_1.jsxs)("div", { className: "order-details-time-remaining flex w-full items-center justify-center gap-1 text-sm", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary/30 order-details-time-label", children: "Time remaining:" }), (0, jsx_runtime_1.jsx)("div", { className: "text-as-primary order-details-time-value", children: depositEnoughAmount ? ("Received") : order.status === "expired" ? ("Expired") : ((0, jsx_runtime_1.jsx)(react_timeago_1.default, { date: new Date(order.expiredAt), live: true })) })] }), statusDisplay !== "processing" && ((0, jsx_runtime_1.jsx)(OrderDetailsCollapsible_1.OrderDetailsCollapsible, { order: order, dstToken: dstToken, tournament: tournament, nft: nft, recipientName: recipientName, formattedExpectedDstAmount: formattedExpectedDstAmount, points: points, isOpen: orderDetailsOpen, onOpenChange: setOrderDetailsOpen })), (0, jsx_runtime_1.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: [(0, jsx_runtime_1.jsx)(lucide_react_1.RefreshCcw, { className: "ml-2 h-4 w-4" }), " Cancel and start over"] })] }));
|
|
421
426
|
});
|
|
422
427
|
function TransactionDetails({ title, chainId, tx, isProcessing, delay, }) {
|
|
423
428
|
return ((0, jsx_runtime_1.jsxs)("div", { className: "order-details-transaction-item relative flex w-full flex-1 items-center justify-between gap-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "order-details-transaction-content flex grow items-center gap-4", children: [(0, jsx_runtime_1.jsx)(react_4.motion.div, { className: "bg-as-surface-secondary relative h-10 w-10 rounded-full", children: isProcessing ? ((0, jsx_runtime_1.jsx)(react_4.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: (0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "text-as-primary h-4 w-4 animate-spin" }) })) : ((0, jsx_runtime_1.jsx)(react_4.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: (0, jsx_runtime_1.jsx)(lucide_react_1.CheckIcon, { className: "text-as-content-icon-success h-4 w-4" }) })) }), (0, jsx_runtime_1.jsx)(react_4.motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { duration: 0.3, ease: "easeInOut", delay }, className: "shrink-0 text-base", children: isProcessing ? ((0, jsx_runtime_1.jsx)(react_1.TextShimmer, { duration: 1, children: title })) : ((0, jsx_runtime_1.jsx)("span", { className: "text-as-primary", children: title })) })] }), (0, jsx_runtime_1.jsx)("div", { className: "flex flex-col gap-1", children: tx ? ((0, jsx_runtime_1.jsx)(react_4.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: (0, jsx_runtime_1.jsx)("a", { href: (0, anyspend_1.getExplorerTxUrl)(chainId, tx.txHash), target: "_blank", children: (0, jsx_runtime_1.jsx)("div", { className: "text-as-primary/30 font-mono text-xs", children: (0, centerTruncate_1.default)(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 {};
|