@aori/mega-swap-widget 0.1.0
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/LICENSE +21 -0
- package/README.md +404 -0
- package/dist/AssetSelectionMenu-Y3EB32BT.cjs +13 -0
- package/dist/AssetSelectionMenu-Y3EB32BT.cjs.map +1 -0
- package/dist/AssetSelectionMenu-ZRG42UCZ.js +13 -0
- package/dist/AssetSelectionMenu-ZRG42UCZ.js.map +1 -0
- package/dist/ChainSelectionMenu-FBAPPFKI.cjs +11 -0
- package/dist/ChainSelectionMenu-FBAPPFKI.cjs.map +1 -0
- package/dist/ChainSelectionMenu-QO3H4TNR.js +11 -0
- package/dist/ChainSelectionMenu-QO3H4TNR.js.map +1 -0
- package/dist/SwapFormHorizontal-JDJUDFNX.js +573 -0
- package/dist/SwapFormHorizontal-JDJUDFNX.js.map +1 -0
- package/dist/SwapFormHorizontal-WG3Z3CFT.cjs +573 -0
- package/dist/SwapFormHorizontal-WG3Z3CFT.cjs.map +1 -0
- package/dist/SwapFormSplit-7CHTPLEQ.js +441 -0
- package/dist/SwapFormSplit-7CHTPLEQ.js.map +1 -0
- package/dist/SwapFormSplit-VDDIRQUQ.cjs +441 -0
- package/dist/SwapFormSplit-VDDIRQUQ.cjs.map +1 -0
- package/dist/WalletPlaceholderPanel-7YDQ4FT6.js +57 -0
- package/dist/WalletPlaceholderPanel-7YDQ4FT6.js.map +1 -0
- package/dist/WalletPlaceholderPanel-FZ6XIAMF.cjs +57 -0
- package/dist/WalletPlaceholderPanel-FZ6XIAMF.cjs.map +1 -0
- package/dist/WidgetWalletPanel-D7I5TAU3.js +789 -0
- package/dist/WidgetWalletPanel-D7I5TAU3.js.map +1 -0
- package/dist/WidgetWalletPanel-T7H6FGVN.cjs +789 -0
- package/dist/WidgetWalletPanel-T7H6FGVN.cjs.map +1 -0
- package/dist/chunk-3E6RNP2D.cjs +389 -0
- package/dist/chunk-3E6RNP2D.cjs.map +1 -0
- package/dist/chunk-5TH6MFQD.cjs +122 -0
- package/dist/chunk-5TH6MFQD.cjs.map +1 -0
- package/dist/chunk-5XSCUUOW.js +101 -0
- package/dist/chunk-5XSCUUOW.js.map +1 -0
- package/dist/chunk-6Q7MSCKS.js +2199 -0
- package/dist/chunk-6Q7MSCKS.js.map +1 -0
- package/dist/chunk-6XB5R4GF.cjs +368 -0
- package/dist/chunk-6XB5R4GF.cjs.map +1 -0
- package/dist/chunk-6YLNOZ7P.js +389 -0
- package/dist/chunk-6YLNOZ7P.js.map +1 -0
- package/dist/chunk-7AWG6OWF.js +27 -0
- package/dist/chunk-7AWG6OWF.js.map +1 -0
- package/dist/chunk-ARMW5POL.js +3082 -0
- package/dist/chunk-ARMW5POL.js.map +1 -0
- package/dist/chunk-B3ILUJ7G.cjs +101 -0
- package/dist/chunk-B3ILUJ7G.cjs.map +1 -0
- package/dist/chunk-GGM3MDFM.js +32 -0
- package/dist/chunk-GGM3MDFM.js.map +1 -0
- package/dist/chunk-GZUTUD5O.cjs +2199 -0
- package/dist/chunk-GZUTUD5O.cjs.map +1 -0
- package/dist/chunk-HXOGJSAI.cjs +3082 -0
- package/dist/chunk-HXOGJSAI.cjs.map +1 -0
- package/dist/chunk-LTA7IG3J.js +122 -0
- package/dist/chunk-LTA7IG3J.js.map +1 -0
- package/dist/chunk-NBJPKJBC.cjs +32 -0
- package/dist/chunk-NBJPKJBC.cjs.map +1 -0
- package/dist/chunk-PGYOJ5RB.cjs +27 -0
- package/dist/chunk-PGYOJ5RB.cjs.map +1 -0
- package/dist/chunk-QHW27RMH.js +199 -0
- package/dist/chunk-QHW27RMH.js.map +1 -0
- package/dist/chunk-TMC4SUEV.js +368 -0
- package/dist/chunk-TMC4SUEV.js.map +1 -0
- package/dist/chunk-XQINW7QP.cjs +199 -0
- package/dist/chunk-XQINW7QP.cjs.map +1 -0
- package/dist/index.cjs +1780 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.css +1424 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.cts +555 -0
- package/dist/index.d.ts +555 -0
- package/dist/index.js +1780 -0
- package/dist/index.js.map +1 -0
- package/package.json +82 -0
|
@@ -0,0 +1,789 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
import {
|
|
4
|
+
require_main
|
|
5
|
+
} from "./chunk-LTA7IG3J.js";
|
|
6
|
+
import {
|
|
7
|
+
useSwapFormContext,
|
|
8
|
+
useWidgetSwapUIStore
|
|
9
|
+
} from "./chunk-TMC4SUEV.js";
|
|
10
|
+
import {
|
|
11
|
+
ChainIcon_default,
|
|
12
|
+
CopyText_default,
|
|
13
|
+
Skeleton_default,
|
|
14
|
+
TokenImage_default,
|
|
15
|
+
TruncateString,
|
|
16
|
+
formatNumber,
|
|
17
|
+
getChainConfig,
|
|
18
|
+
getChainNames,
|
|
19
|
+
isGasToken,
|
|
20
|
+
useBulkBalances,
|
|
21
|
+
useChainData,
|
|
22
|
+
useEnabledChainIds,
|
|
23
|
+
useTokenData,
|
|
24
|
+
useTokenWithLazyLoad,
|
|
25
|
+
useWidgetConfig
|
|
26
|
+
} from "./chunk-6Q7MSCKS.js";
|
|
27
|
+
import {
|
|
28
|
+
useWalletState
|
|
29
|
+
} from "./chunk-7AWG6OWF.js";
|
|
30
|
+
import {
|
|
31
|
+
__toESM
|
|
32
|
+
} from "./chunk-GGM3MDFM.js";
|
|
33
|
+
|
|
34
|
+
// src/components/WidgetWalletPanel.tsx
|
|
35
|
+
import { useCallback as useCallback4, useState as useState5 } from "react";
|
|
36
|
+
import { useDisconnect } from "wagmi";
|
|
37
|
+
|
|
38
|
+
// src/hooks/useWidgetWalletData.ts
|
|
39
|
+
import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
40
|
+
function useWidgetWalletData(isActive) {
|
|
41
|
+
const { address, isConnected } = useWalletState();
|
|
42
|
+
const { chainDataMap } = useChainData();
|
|
43
|
+
const availableChainIds = useEnabledChainIds();
|
|
44
|
+
const { getToken, tokenRegistry } = useTokenData();
|
|
45
|
+
const { supportedInputTokens, supportedOutputTokens } = useWidgetConfig();
|
|
46
|
+
const allSupportedTokens = useMemo(() => {
|
|
47
|
+
if (!supportedInputTokens.length && !supportedOutputTokens.length) return [];
|
|
48
|
+
const seen = /* @__PURE__ */ new Set();
|
|
49
|
+
const result = [];
|
|
50
|
+
for (const t of [...supportedInputTokens, ...supportedOutputTokens]) {
|
|
51
|
+
const key = `${t.chainId}-${t.address.toLowerCase()}`;
|
|
52
|
+
if (!seen.has(key)) {
|
|
53
|
+
seen.add(key);
|
|
54
|
+
result.push(t);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return result;
|
|
58
|
+
}, [supportedInputTokens, supportedOutputTokens]);
|
|
59
|
+
const { balances, isLoading: balancesLoading, isError: balancesError, refetch } = useBulkBalances(
|
|
60
|
+
address,
|
|
61
|
+
availableChainIds,
|
|
62
|
+
{
|
|
63
|
+
enabled: isConnected && isActive && !!address,
|
|
64
|
+
refetchOnWindowFocus: false
|
|
65
|
+
},
|
|
66
|
+
allSupportedTokens.length > 0 ? allSupportedTokens : void 0
|
|
67
|
+
);
|
|
68
|
+
const supportedSet = useMemo(() => {
|
|
69
|
+
if (!allSupportedTokens.length) return null;
|
|
70
|
+
return new Set(allSupportedTokens.map((t) => `${t.chainId}-${t.address.toLowerCase()}`));
|
|
71
|
+
}, [allSupportedTokens]);
|
|
72
|
+
const groupedAssets = useMemo(() => {
|
|
73
|
+
if (!balances || balances.length === 0) return {};
|
|
74
|
+
const filtered = balances.filter((b) => {
|
|
75
|
+
if (!b.assetInfo) return false;
|
|
76
|
+
if (!b.balance || b.balance === "0") return false;
|
|
77
|
+
if (supportedSet) {
|
|
78
|
+
return supportedSet.has(`${b.chainId}-${b.address.toLowerCase()}`);
|
|
79
|
+
}
|
|
80
|
+
if (isGasToken(b.assetInfo)) return true;
|
|
81
|
+
if (tokenRegistry.length === 0) return true;
|
|
82
|
+
return tokenRegistry.some(
|
|
83
|
+
(t) => t.address.toLowerCase() === b.address.toLowerCase() && t.chainId === b.chainId
|
|
84
|
+
);
|
|
85
|
+
});
|
|
86
|
+
return filtered.reduce((acc, b) => {
|
|
87
|
+
const key = String(b.chainId);
|
|
88
|
+
if (!acc[key]) acc[key] = [];
|
|
89
|
+
acc[key].push({
|
|
90
|
+
token: b.address,
|
|
91
|
+
amount: b.balance,
|
|
92
|
+
decimals: b.decimals,
|
|
93
|
+
assetInfo: b.assetInfo
|
|
94
|
+
});
|
|
95
|
+
return acc;
|
|
96
|
+
}, {});
|
|
97
|
+
}, [balances, tokenRegistry, supportedSet]);
|
|
98
|
+
const totalBalance = useMemo(() => {
|
|
99
|
+
if (!balances || balances.length === 0) return 0;
|
|
100
|
+
return balances.reduce((total, b) => {
|
|
101
|
+
if (!b.assetInfo || b.decimals === void 0) return total;
|
|
102
|
+
return total + parseFloat(b.balance) / 10 ** b.decimals * (b.assetInfo.price || 0);
|
|
103
|
+
}, 0);
|
|
104
|
+
}, [balances]);
|
|
105
|
+
const chains = useMemo(() => {
|
|
106
|
+
if (availableChainIds.length === 0) return {};
|
|
107
|
+
return availableChainIds.reduce(
|
|
108
|
+
(acc, chainId) => {
|
|
109
|
+
const apiData = chainDataMap[chainId];
|
|
110
|
+
const staticConfig = getChainConfig(chainId);
|
|
111
|
+
acc[chainId.toString()] = {
|
|
112
|
+
chainId,
|
|
113
|
+
name: staticConfig?.displayName || apiData?.chainKey || `Chain ${chainId}`
|
|
114
|
+
};
|
|
115
|
+
return acc;
|
|
116
|
+
},
|
|
117
|
+
{}
|
|
118
|
+
);
|
|
119
|
+
}, [availableChainIds, chainDataMap]);
|
|
120
|
+
const tokenRegistryForPanel = useMemo(
|
|
121
|
+
() => tokenRegistry.map((t) => ({ address: t.address, chainId: t.chainId })),
|
|
122
|
+
[tokenRegistry]
|
|
123
|
+
);
|
|
124
|
+
const refetchTimerRef = useRef(null);
|
|
125
|
+
useEffect(() => {
|
|
126
|
+
return () => {
|
|
127
|
+
if (refetchTimerRef.current) clearTimeout(refetchTimerRef.current);
|
|
128
|
+
};
|
|
129
|
+
}, []);
|
|
130
|
+
const refetchBalances = useCallback(() => {
|
|
131
|
+
if (refetchTimerRef.current) clearTimeout(refetchTimerRef.current);
|
|
132
|
+
refetchTimerRef.current = setTimeout(() => refetch(), 2e3);
|
|
133
|
+
}, [refetch]);
|
|
134
|
+
return {
|
|
135
|
+
address,
|
|
136
|
+
isConnected,
|
|
137
|
+
groupedAssets,
|
|
138
|
+
totalBalance,
|
|
139
|
+
balancesLoading,
|
|
140
|
+
balancesError,
|
|
141
|
+
chains,
|
|
142
|
+
getToken,
|
|
143
|
+
useTokenWithLazyLoad,
|
|
144
|
+
tokenRegistry: tokenRegistryForPanel,
|
|
145
|
+
refetchBalances
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// src/components/wallet/WidgetWalletCard.tsx
|
|
150
|
+
var import_ethereum_gradient_base64 = __toESM(require_main(), 1);
|
|
151
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
152
|
+
var WidgetWalletCard = ({
|
|
153
|
+
address,
|
|
154
|
+
totalBalance,
|
|
155
|
+
isLoading = false
|
|
156
|
+
}) => {
|
|
157
|
+
const formatBalance = (balance) => new Intl.NumberFormat("en-US", {
|
|
158
|
+
style: "currency",
|
|
159
|
+
currency: "USD",
|
|
160
|
+
minimumFractionDigits: 2,
|
|
161
|
+
maximumFractionDigits: 2
|
|
162
|
+
}).format(balance);
|
|
163
|
+
return /* @__PURE__ */ jsx("div", { className: "p-2 w-full flex justify-center", children: /* @__PURE__ */ jsxs(
|
|
164
|
+
"div",
|
|
165
|
+
{
|
|
166
|
+
className: "relative w-full h-[140px] overflow-hidden",
|
|
167
|
+
style: {
|
|
168
|
+
borderRadius: "var(--widget-radius)",
|
|
169
|
+
border: "1px var(--widget-border-style) var(--widget-border)"
|
|
170
|
+
},
|
|
171
|
+
children: [
|
|
172
|
+
/* @__PURE__ */ jsxs("div", { className: "absolute inset-0 z-0", children: [
|
|
173
|
+
/* @__PURE__ */ jsx(
|
|
174
|
+
"img",
|
|
175
|
+
{
|
|
176
|
+
className: "w-full h-full object-cover opacity-60",
|
|
177
|
+
src: (0, import_ethereum_gradient_base64.makeGradient)(address),
|
|
178
|
+
alt: "address gradient"
|
|
179
|
+
}
|
|
180
|
+
),
|
|
181
|
+
/* @__PURE__ */ jsx("div", { className: "absolute inset-0 bg-gradient-to-t from-black/80 via-black/40 to-transparent" })
|
|
182
|
+
] }),
|
|
183
|
+
/* @__PURE__ */ jsxs("div", { className: "relative z-10 flex h-full flex-col justify-between p-3", children: [
|
|
184
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
185
|
+
/* @__PURE__ */ jsx("p", { className: "text-2xs uppercase mono", style: { color: "var(--widget-muted-foreground)", opacity: 0.7 }, children: "Token Balance:" }),
|
|
186
|
+
isLoading ? /* @__PURE__ */ jsx(Skeleton_default, { className: "h-8 w-28 bg-white/10 rounded mt-1" }) : /* @__PURE__ */ jsx("p", { className: "text-2xl font-bold mt-0.5", style: { color: "var(--widget-foreground)" }, children: formatBalance(totalBalance) })
|
|
187
|
+
] }),
|
|
188
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center", children: /* @__PURE__ */ jsx(CopyText_default, { text: address, type: "address", children: /* @__PURE__ */ jsx("p", { className: "mono text-2xs", style: { color: "var(--widget-foreground)", opacity: 0.7 }, children: address }) }) })
|
|
189
|
+
] })
|
|
190
|
+
]
|
|
191
|
+
}
|
|
192
|
+
) });
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
// src/components/wallet/WidgetWalletPortfolio.tsx
|
|
196
|
+
import { useCallback as useCallback2, useMemo as useMemo2, useState as useState2 } from "react";
|
|
197
|
+
|
|
198
|
+
// src/components/wallet/WidgetWalletAssetItem.tsx
|
|
199
|
+
import { useState } from "react";
|
|
200
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
201
|
+
var WidgetWalletAssetItem = ({
|
|
202
|
+
asset,
|
|
203
|
+
balanceAmount,
|
|
204
|
+
balanceDecimals,
|
|
205
|
+
price,
|
|
206
|
+
onSelect,
|
|
207
|
+
getToken,
|
|
208
|
+
useTokenWithLazyLoad: useTokenWithLazyLoad2
|
|
209
|
+
}) => {
|
|
210
|
+
const [hovered, setHovered] = useState(false);
|
|
211
|
+
const balance = balanceDecimals !== void 0 ? parseFloat(balanceAmount) / 10 ** balanceDecimals : 0;
|
|
212
|
+
const lazyLoadResult = useTokenWithLazyLoad2?.(asset.chainId, asset.address);
|
|
213
|
+
const lazyToken = lazyLoadResult?.token;
|
|
214
|
+
let finalPrice = price ?? null;
|
|
215
|
+
if (isGasToken(asset) && finalPrice == null) {
|
|
216
|
+
if (lazyToken?.price != null) {
|
|
217
|
+
finalPrice = lazyToken.price;
|
|
218
|
+
} else if (getToken) {
|
|
219
|
+
finalPrice = getToken(asset.chainId, asset.address)?.price ?? null;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return /* @__PURE__ */ jsx2(
|
|
223
|
+
"div",
|
|
224
|
+
{
|
|
225
|
+
role: "button",
|
|
226
|
+
tabIndex: 0,
|
|
227
|
+
className: "flex h-[52px] w-full flex-row items-center p-3 cursor-pointer transition-colors",
|
|
228
|
+
style: {
|
|
229
|
+
borderBottom: "1px var(--widget-border-style) var(--widget-border)",
|
|
230
|
+
backgroundColor: hovered ? "var(--widget-secondary)" : "transparent"
|
|
231
|
+
},
|
|
232
|
+
onMouseEnter: () => setHovered(true),
|
|
233
|
+
onMouseLeave: () => setHovered(false),
|
|
234
|
+
onClick: () => onSelect?.(asset),
|
|
235
|
+
onKeyDown: (e) => {
|
|
236
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
237
|
+
e.preventDefault();
|
|
238
|
+
onSelect?.(asset);
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
children: /* @__PURE__ */ jsxs2("div", { className: "flex h-full w-full flex-row items-center justify-between", children: [
|
|
242
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex h-full flex-row items-center gap-2", children: [
|
|
243
|
+
/* @__PURE__ */ jsx2(TokenImage_default, { asset, size: "sm" }),
|
|
244
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex flex-col items-start", children: [
|
|
245
|
+
/* @__PURE__ */ jsx2("p", { className: "text-sm font-medium uppercase", style: { color: "var(--widget-foreground)" }, children: asset.symbol }),
|
|
246
|
+
balance > 0 && /* @__PURE__ */ jsx2("p", { className: "mono text-xs", style: { color: "var(--widget-muted-foreground)" }, children: balance.toFixed(4) })
|
|
247
|
+
] })
|
|
248
|
+
] }),
|
|
249
|
+
/* @__PURE__ */ jsx2("p", { className: "text-sm font-medium", style: { color: "var(--widget-foreground)" }, children: finalPrice != null ? `$${(finalPrice * balance).toFixed(2)}` : "\u2014" })
|
|
250
|
+
] })
|
|
251
|
+
}
|
|
252
|
+
);
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
// src/components/wallet/WidgetWalletPortfolio.tsx
|
|
256
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
257
|
+
var usdFormat = new Intl.NumberFormat("en-US", {
|
|
258
|
+
style: "currency",
|
|
259
|
+
currency: "USD",
|
|
260
|
+
minimumFractionDigits: 2
|
|
261
|
+
});
|
|
262
|
+
var CHAIN_NAMES = getChainNames();
|
|
263
|
+
var WidgetWalletPortfolio = ({
|
|
264
|
+
groupedAssets,
|
|
265
|
+
chains,
|
|
266
|
+
tokenRegistry = [],
|
|
267
|
+
getToken,
|
|
268
|
+
useTokenWithLazyLoad: useTokenWithLazyLoad2,
|
|
269
|
+
onAssetSelect
|
|
270
|
+
}) => {
|
|
271
|
+
const [expandedChains, setExpandedChains] = useState2(/* @__PURE__ */ new Set());
|
|
272
|
+
const getChainName = useCallback2(
|
|
273
|
+
(chainId) => chains?.[chainId]?.name || CHAIN_NAMES[chainId] || `Chain ${chainId}`,
|
|
274
|
+
[chains]
|
|
275
|
+
);
|
|
276
|
+
const registrySet = useMemo2(() => {
|
|
277
|
+
const s = /* @__PURE__ */ new Set();
|
|
278
|
+
for (const t of tokenRegistry) {
|
|
279
|
+
s.add(`${t.chainId}-${t.address.toLowerCase()}`);
|
|
280
|
+
}
|
|
281
|
+
return s;
|
|
282
|
+
}, [tokenRegistry]);
|
|
283
|
+
const calculateDollarizedBalance = useCallback2((asset) => {
|
|
284
|
+
if (asset.decimals === void 0 || !asset.assetInfo?.price) return 0;
|
|
285
|
+
return parseFloat(asset.amount) / 10 ** asset.decimals * asset.assetInfo.price;
|
|
286
|
+
}, []);
|
|
287
|
+
const { filteredGroupedAssets, chainTotals } = useMemo2(() => {
|
|
288
|
+
const entries = Object.entries(groupedAssets).map(([chainId, assets]) => {
|
|
289
|
+
const filtered = assets.filter((asset) => {
|
|
290
|
+
if (!asset.assetInfo) return false;
|
|
291
|
+
if (isGasToken(asset.assetInfo)) return true;
|
|
292
|
+
if (registrySet.size > 0) {
|
|
293
|
+
return registrySet.has(
|
|
294
|
+
`${asset.assetInfo.chainId}-${asset.assetInfo.address?.toLowerCase() ?? ""}`
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
return true;
|
|
298
|
+
});
|
|
299
|
+
return [chainId, filtered];
|
|
300
|
+
}).filter(([, assets]) => assets.length > 0);
|
|
301
|
+
const totals = {};
|
|
302
|
+
for (const [chainId, assets] of entries) {
|
|
303
|
+
totals[chainId] = assets.reduce((sum, asset) => sum + calculateDollarizedBalance(asset), 0);
|
|
304
|
+
}
|
|
305
|
+
const sorted = [...entries].sort((a, b) => (totals[b[0]] ?? 0) - (totals[a[0]] ?? 0));
|
|
306
|
+
return { filteredGroupedAssets: sorted, chainTotals: totals };
|
|
307
|
+
}, [groupedAssets, registrySet, calculateDollarizedBalance]);
|
|
308
|
+
const toggleChain = useCallback2((chainId) => {
|
|
309
|
+
setExpandedChains((prev) => {
|
|
310
|
+
const next = new Set(prev);
|
|
311
|
+
if (next.has(chainId)) next.delete(chainId);
|
|
312
|
+
else next.add(chainId);
|
|
313
|
+
return next;
|
|
314
|
+
});
|
|
315
|
+
}, []);
|
|
316
|
+
const formatUSD = (v) => usdFormat.format(v);
|
|
317
|
+
if (filteredGroupedAssets.length === 0) {
|
|
318
|
+
return /* @__PURE__ */ jsx3("div", { className: "flex items-center justify-center p-6", children: /* @__PURE__ */ jsx3("p", { className: "text-sm", style: { color: "var(--widget-muted-foreground)" }, children: "No token balances found" }) });
|
|
319
|
+
}
|
|
320
|
+
return /* @__PURE__ */ jsx3("div", { className: "pb-2 pt-1", children: filteredGroupedAssets.map(([chainId, assets]) => {
|
|
321
|
+
const chainIdNum = parseInt(chainId);
|
|
322
|
+
const chainName = getChainName(chainIdNum);
|
|
323
|
+
const totalChainValue = chainTotals[chainId] || 0;
|
|
324
|
+
const isExpanded = expandedChains.has(chainId);
|
|
325
|
+
return /* @__PURE__ */ jsxs3(
|
|
326
|
+
"div",
|
|
327
|
+
{
|
|
328
|
+
className: "mx-2 mb-2",
|
|
329
|
+
style: {
|
|
330
|
+
border: "1px var(--widget-border-style) var(--widget-border)",
|
|
331
|
+
borderRadius: "var(--widget-radius)",
|
|
332
|
+
overflow: "hidden"
|
|
333
|
+
},
|
|
334
|
+
children: [
|
|
335
|
+
/* @__PURE__ */ jsxs3(
|
|
336
|
+
"button",
|
|
337
|
+
{
|
|
338
|
+
type: "button",
|
|
339
|
+
onClick: () => toggleChain(chainId),
|
|
340
|
+
className: "flex w-full flex-row items-center justify-between p-2 cursor-pointer transition-colors hover:bg-(--widget-secondary)",
|
|
341
|
+
style: { backgroundColor: "transparent" },
|
|
342
|
+
children: [
|
|
343
|
+
/* @__PURE__ */ jsxs3("div", { className: "inline-flex flex-row items-center gap-2", children: [
|
|
344
|
+
/* @__PURE__ */ jsx3(ChainIcon_default, { chain: chainIdNum, size: "sm" }),
|
|
345
|
+
/* @__PURE__ */ jsx3("p", { className: "text-sm font-medium capitalize", style: { color: "var(--widget-foreground)" }, children: chainName })
|
|
346
|
+
] }),
|
|
347
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-2", children: [
|
|
348
|
+
/* @__PURE__ */ jsx3("p", { className: "text-sm font-semibold", style: { color: "var(--widget-foreground)" }, children: formatUSD(totalChainValue) }),
|
|
349
|
+
/* @__PURE__ */ jsx3(
|
|
350
|
+
"span",
|
|
351
|
+
{
|
|
352
|
+
className: `transition-transform duration-200 ${isExpanded ? "rotate-180" : ""}`,
|
|
353
|
+
style: { color: "var(--widget-muted-foreground)" },
|
|
354
|
+
children: /* @__PURE__ */ jsx3("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", children: /* @__PURE__ */ jsx3(
|
|
355
|
+
"path",
|
|
356
|
+
{
|
|
357
|
+
d: "M2.5 4.5L6 8L9.5 4.5",
|
|
358
|
+
stroke: "currentColor",
|
|
359
|
+
strokeWidth: "1.5",
|
|
360
|
+
strokeLinecap: "round",
|
|
361
|
+
strokeLinejoin: "round"
|
|
362
|
+
}
|
|
363
|
+
) })
|
|
364
|
+
}
|
|
365
|
+
)
|
|
366
|
+
] })
|
|
367
|
+
]
|
|
368
|
+
}
|
|
369
|
+
),
|
|
370
|
+
/* @__PURE__ */ jsx3(
|
|
371
|
+
"div",
|
|
372
|
+
{
|
|
373
|
+
className: `overflow-hidden transition-all duration-200 ease-out ${isExpanded ? "max-h-[2000px] opacity-100" : "max-h-0 opacity-0"}`,
|
|
374
|
+
children: /* @__PURE__ */ jsx3("div", { style: { borderTop: "1px var(--widget-border-style) var(--widget-border)" }, children: assets.map((asset) => {
|
|
375
|
+
if (!asset.assetInfo) return null;
|
|
376
|
+
return /* @__PURE__ */ jsx3(
|
|
377
|
+
WidgetWalletAssetItem,
|
|
378
|
+
{
|
|
379
|
+
asset: asset.assetInfo,
|
|
380
|
+
balanceAmount: asset.amount,
|
|
381
|
+
balanceDecimals: asset.decimals,
|
|
382
|
+
price: asset.assetInfo?.price ?? null,
|
|
383
|
+
onSelect: onAssetSelect,
|
|
384
|
+
getToken,
|
|
385
|
+
useTokenWithLazyLoad: useTokenWithLazyLoad2
|
|
386
|
+
},
|
|
387
|
+
`${asset.assetInfo.chainId}-${asset.token}`
|
|
388
|
+
);
|
|
389
|
+
}) })
|
|
390
|
+
}
|
|
391
|
+
)
|
|
392
|
+
]
|
|
393
|
+
},
|
|
394
|
+
chainId
|
|
395
|
+
);
|
|
396
|
+
}) });
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
// src/components/wallet/WidgetWalletTradeHistory.tsx
|
|
400
|
+
import { useCallback as useCallback3, useRef as useRef2, useState as useState4 } from "react";
|
|
401
|
+
|
|
402
|
+
// src/hooks/useWidgetOrderHistory.ts
|
|
403
|
+
function useWidgetOrderHistory(_userAddress, _enabled) {
|
|
404
|
+
return {
|
|
405
|
+
orders: [],
|
|
406
|
+
isLoading: false,
|
|
407
|
+
error: null,
|
|
408
|
+
hasMore: false,
|
|
409
|
+
loadMore: async () => {
|
|
410
|
+
},
|
|
411
|
+
totalOrders: 0
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
// src/components/wallet/WidgetWalletTradeItem.tsx
|
|
416
|
+
import { useState as useState3 } from "react";
|
|
417
|
+
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
418
|
+
var IconCheck = () => /* @__PURE__ */ jsxs4("svg", { width: "10", height: "10", viewBox: "0 0 10 10", fill: "none", children: [
|
|
419
|
+
/* @__PURE__ */ jsx4("circle", { cx: "5", cy: "5", r: "4", stroke: "currentColor", strokeWidth: "1.2" }),
|
|
420
|
+
/* @__PURE__ */ jsx4("path", { d: "M3 5.2L4.3 6.5L7 3.5", stroke: "currentColor", strokeWidth: "1.2", strokeLinecap: "round", strokeLinejoin: "round" })
|
|
421
|
+
] });
|
|
422
|
+
var IconX = () => /* @__PURE__ */ jsxs4("svg", { width: "10", height: "10", viewBox: "0 0 10 10", fill: "none", children: [
|
|
423
|
+
/* @__PURE__ */ jsx4("circle", { cx: "5", cy: "5", r: "4", stroke: "currentColor", strokeWidth: "1.2" }),
|
|
424
|
+
/* @__PURE__ */ jsx4("path", { d: "M3.5 3.5L6.5 6.5M6.5 3.5L3.5 6.5", stroke: "currentColor", strokeWidth: "1.2", strokeLinecap: "round" })
|
|
425
|
+
] });
|
|
426
|
+
var IconClock = () => /* @__PURE__ */ jsxs4("svg", { width: "10", height: "10", viewBox: "0 0 10 10", fill: "none", children: [
|
|
427
|
+
/* @__PURE__ */ jsx4("circle", { cx: "5", cy: "5", r: "4", stroke: "currentColor", strokeWidth: "1.2" }),
|
|
428
|
+
/* @__PURE__ */ jsx4("path", { d: "M5 3V5.5L6.5 6.5", stroke: "currentColor", strokeWidth: "1", strokeLinecap: "round" })
|
|
429
|
+
] });
|
|
430
|
+
var IconDot = () => /* @__PURE__ */ jsxs4("svg", { width: "10", height: "10", viewBox: "0 0 10 10", fill: "none", children: [
|
|
431
|
+
/* @__PURE__ */ jsx4("circle", { cx: "5", cy: "5", r: "4", stroke: "currentColor", strokeWidth: "1.2" }),
|
|
432
|
+
/* @__PURE__ */ jsx4("circle", { cx: "5", cy: "5", r: "1.5", fill: "currentColor" })
|
|
433
|
+
] });
|
|
434
|
+
var getEventTypeIcon = (eventType) => {
|
|
435
|
+
switch ((eventType || "").toLowerCase()) {
|
|
436
|
+
case "completed":
|
|
437
|
+
case "settled":
|
|
438
|
+
case "success":
|
|
439
|
+
case "swapped":
|
|
440
|
+
case "swap":
|
|
441
|
+
return { icon: /* @__PURE__ */ jsx4(IconCheck, {}), color: "var(--widget-primary)" };
|
|
442
|
+
case "received":
|
|
443
|
+
return { icon: /* @__PURE__ */ jsx4(IconDot, {}), color: "var(--widget-accent)" };
|
|
444
|
+
case "failed":
|
|
445
|
+
case "error":
|
|
446
|
+
case "expired":
|
|
447
|
+
return { icon: /* @__PURE__ */ jsx4(IconX, {}), color: "var(--widget-destructive)" };
|
|
448
|
+
case "pending":
|
|
449
|
+
case "created":
|
|
450
|
+
case "placed":
|
|
451
|
+
return { icon: /* @__PURE__ */ jsx4(IconClock, {}), color: "var(--widget-muted-foreground)" };
|
|
452
|
+
default:
|
|
453
|
+
return { icon: /* @__PURE__ */ jsx4(IconDot, {}), color: "var(--widget-muted-foreground)" };
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
var getEventTypeHoverBg = (eventType) => {
|
|
457
|
+
switch ((eventType || "").toLowerCase()) {
|
|
458
|
+
case "completed":
|
|
459
|
+
case "settled":
|
|
460
|
+
case "success":
|
|
461
|
+
case "swapped":
|
|
462
|
+
case "swap":
|
|
463
|
+
return "color-mix(in srgb, var(--widget-primary) 5%, transparent)";
|
|
464
|
+
case "failed":
|
|
465
|
+
case "error":
|
|
466
|
+
case "expired":
|
|
467
|
+
return "color-mix(in srgb, var(--widget-destructive) 5%, transparent)";
|
|
468
|
+
case "pending":
|
|
469
|
+
case "created":
|
|
470
|
+
case "placed":
|
|
471
|
+
return "color-mix(in srgb, var(--widget-accent) 5%, transparent)";
|
|
472
|
+
default:
|
|
473
|
+
return "var(--widget-secondary)";
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
var formatAmountSafe = (rawAmount, tokenData) => {
|
|
477
|
+
try {
|
|
478
|
+
const numAmount = parseFloat(rawAmount || "0");
|
|
479
|
+
if (isNaN(numAmount) || numAmount === 0) return "0";
|
|
480
|
+
const decimals = tokenData?.decimals ?? 18;
|
|
481
|
+
return formatNumber(numAmount / 10 ** decimals);
|
|
482
|
+
} catch {
|
|
483
|
+
return "0";
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
var WidgetWalletTradeItem = ({
|
|
487
|
+
order,
|
|
488
|
+
baseToken,
|
|
489
|
+
quoteToken
|
|
490
|
+
}) => {
|
|
491
|
+
const [hovered, setHovered] = useState3(false);
|
|
492
|
+
const eventType = order?.status || order?.eventType || "unknown";
|
|
493
|
+
const { icon: eventIcon, color: eventColor } = getEventTypeIcon(eventType);
|
|
494
|
+
const formatDateTime = (timestamp) => {
|
|
495
|
+
if (!timestamp) return { date: "", time: "" };
|
|
496
|
+
const d = new Date(typeof timestamp === "number" ? timestamp : Number(timestamp) || timestamp);
|
|
497
|
+
return {
|
|
498
|
+
date: d.toLocaleDateString("en-US", { month: "short", day: "numeric", year: "numeric" }),
|
|
499
|
+
time: d.toLocaleTimeString("en-US", { hour: "2-digit", minute: "2-digit", timeZone: "UTC", hour12: false }) + " UTC"
|
|
500
|
+
};
|
|
501
|
+
};
|
|
502
|
+
const dateTime = formatDateTime(order?.timestamp || order?.createdAt || "");
|
|
503
|
+
const inputDisplay = baseToken ? { asset: baseToken, symbol: baseToken.symbol, amount: formatAmountSafe(order?.inputAmount, baseToken) } : { asset: null, symbol: (order?.inputToken || "").slice(0, 6) + "...", amount: formatAmountSafe(order?.inputAmount, null) };
|
|
504
|
+
const outputDisplay = quoteToken ? { asset: quoteToken, symbol: quoteToken.symbol, amount: formatAmountSafe(order?.outputAmount, quoteToken) } : { asset: null, symbol: (order?.outputToken || "").slice(0, 6) + "...", amount: formatAmountSafe(order?.outputAmount, null) };
|
|
505
|
+
return /* @__PURE__ */ jsxs4(
|
|
506
|
+
"a",
|
|
507
|
+
{
|
|
508
|
+
href: order?.explorerUrl || "#",
|
|
509
|
+
target: "_blank",
|
|
510
|
+
rel: "noopener noreferrer",
|
|
511
|
+
className: "group flex flex-col cursor-pointer transition-all duration-200 ease-in-out no-underline",
|
|
512
|
+
style: {
|
|
513
|
+
border: "1px var(--widget-border-style) var(--widget-border)",
|
|
514
|
+
backgroundColor: hovered ? getEventTypeHoverBg(eventType) : "transparent",
|
|
515
|
+
marginBottom: "0.5rem",
|
|
516
|
+
padding: "0.25rem"
|
|
517
|
+
},
|
|
518
|
+
onMouseEnter: () => setHovered(true),
|
|
519
|
+
onMouseLeave: () => setHovered(false),
|
|
520
|
+
children: [
|
|
521
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex flex-row items-center justify-between space-x-1", children: [
|
|
522
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex flex-row items-center space-x-1", children: [
|
|
523
|
+
/* @__PURE__ */ jsx4("div", { className: "-translate-y-px", style: { color: eventColor }, children: eventIcon }),
|
|
524
|
+
/* @__PURE__ */ jsx4("p", { className: "text-2xs mono uppercase", style: { color: eventColor }, children: eventType })
|
|
525
|
+
] }),
|
|
526
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex flex-row items-center space-x-2", children: [
|
|
527
|
+
/* @__PURE__ */ jsxs4("span", { className: "text-2xs mono", style: { color: hovered ? "var(--widget-foreground)" : "var(--widget-muted-foreground)" }, children: [
|
|
528
|
+
"\xAC ",
|
|
529
|
+
TruncateString(order?.quoteId || order?.orderHash || "")
|
|
530
|
+
] }),
|
|
531
|
+
/* @__PURE__ */ jsx4(
|
|
532
|
+
"svg",
|
|
533
|
+
{
|
|
534
|
+
className: "w-2.5 -translate-y-px opacity-70 group-hover:rotate-[-45deg] group-hover:opacity-100 duration-200",
|
|
535
|
+
style: { color: "var(--widget-foreground)" },
|
|
536
|
+
viewBox: "0 0 684 684",
|
|
537
|
+
fill: "none",
|
|
538
|
+
children: /* @__PURE__ */ jsx4(
|
|
539
|
+
"path",
|
|
540
|
+
{
|
|
541
|
+
d: "M0.666687 384.667L519.92 384.667L281.627 622.96L342 683.333L683.333 342L342 0.666687L281.627 61.04L519.92 299.333L0.666687 299.333V384.667Z",
|
|
542
|
+
fill: "currentColor"
|
|
543
|
+
}
|
|
544
|
+
)
|
|
545
|
+
}
|
|
546
|
+
)
|
|
547
|
+
] })
|
|
548
|
+
] }),
|
|
549
|
+
/* @__PURE__ */ jsxs4(
|
|
550
|
+
"div",
|
|
551
|
+
{
|
|
552
|
+
className: "flex flex-row items-center justify-between pr-2",
|
|
553
|
+
style: { backgroundColor: hovered ? "transparent" : "var(--widget-secondary)" },
|
|
554
|
+
children: [
|
|
555
|
+
/* @__PURE__ */ jsx4("div", { className: "flex flex-col w-full h-full p-2", children: /* @__PURE__ */ jsx4("div", { className: "flex h-8 w-full items-center justify-between px-2", children: /* @__PURE__ */ jsxs4("div", { className: "flex items-center space-x-1", children: [
|
|
556
|
+
/* @__PURE__ */ jsx4(TokenImage_default, { asset: inputDisplay.asset, size: "xs", className: "h-3 w-3" }),
|
|
557
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex flex-col", children: [
|
|
558
|
+
/* @__PURE__ */ jsx4("span", { className: "text-sm h-4", style: { color: "var(--widget-muted-foreground)" }, children: inputDisplay.amount }),
|
|
559
|
+
/* @__PURE__ */ jsx4("span", { className: "text-xs", style: { color: "var(--widget-foreground)" }, children: inputDisplay.symbol })
|
|
560
|
+
] }),
|
|
561
|
+
/* @__PURE__ */ jsx4("span", { className: "px-1", style: { color: "var(--widget-muted-foreground)" }, children: "\u2192" }),
|
|
562
|
+
/* @__PURE__ */ jsx4(TokenImage_default, { asset: outputDisplay.asset, size: "xs", className: "h-3 w-3" }),
|
|
563
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex flex-col", children: [
|
|
564
|
+
/* @__PURE__ */ jsx4("span", { className: "text-sm h-4", style: { color: "var(--widget-muted-foreground)" }, children: outputDisplay.amount }),
|
|
565
|
+
/* @__PURE__ */ jsx4("span", { className: "text-xs", style: { color: "var(--widget-foreground)" }, children: outputDisplay.symbol })
|
|
566
|
+
] })
|
|
567
|
+
] }) }) }),
|
|
568
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex flex-col items-end text-right shrink-0", children: [
|
|
569
|
+
/* @__PURE__ */ jsx4("span", { className: "text-2xs mono whitespace-nowrap", style: { color: "var(--widget-muted-foreground)" }, children: dateTime.date }),
|
|
570
|
+
dateTime.time && /* @__PURE__ */ jsx4("span", { className: "text-2xs mono whitespace-nowrap", style: { color: "var(--widget-muted-foreground)", opacity: 0.6 }, children: dateTime.time })
|
|
571
|
+
] })
|
|
572
|
+
]
|
|
573
|
+
}
|
|
574
|
+
)
|
|
575
|
+
]
|
|
576
|
+
}
|
|
577
|
+
);
|
|
578
|
+
};
|
|
579
|
+
|
|
580
|
+
// src/components/wallet/WidgetWalletTradeHistory.tsx
|
|
581
|
+
import { Fragment, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
582
|
+
var TradeSkeleton = () => /* @__PURE__ */ jsxs5(
|
|
583
|
+
"div",
|
|
584
|
+
{
|
|
585
|
+
className: "mt-2 flex flex-col",
|
|
586
|
+
style: {
|
|
587
|
+
height: "4rem",
|
|
588
|
+
border: "1px var(--widget-border-style) var(--widget-border)",
|
|
589
|
+
backgroundColor: "var(--widget-secondary)"
|
|
590
|
+
},
|
|
591
|
+
children: [
|
|
592
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex items-center space-x-2 p-2", children: [
|
|
593
|
+
/* @__PURE__ */ jsx5("div", { className: "h-4 w-4 rounded", style: { backgroundColor: "var(--widget-muted)" } }),
|
|
594
|
+
/* @__PURE__ */ jsx5("div", { className: "h-3 w-24 rounded", style: { backgroundColor: "var(--widget-muted)" } })
|
|
595
|
+
] }),
|
|
596
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex h-8 w-full items-center justify-between px-4", children: [
|
|
597
|
+
/* @__PURE__ */ jsx5("div", { className: "flex items-center space-x-1", children: [4, 16, 10, 4, 16, 10].map((w, i) => /* @__PURE__ */ jsx5("div", { className: "h-3 rounded", style: { width: `${w * 4}px`, backgroundColor: "var(--widget-muted)" } }, i)) }),
|
|
598
|
+
/* @__PURE__ */ jsx5("div", { className: "h-3 w-10 rounded", style: { backgroundColor: "var(--widget-muted)" } })
|
|
599
|
+
] })
|
|
600
|
+
]
|
|
601
|
+
}
|
|
602
|
+
);
|
|
603
|
+
var WidgetWalletTradeHistory = ({ isActive }) => {
|
|
604
|
+
const { address: userAddress } = useWalletState();
|
|
605
|
+
const { orders, isLoading, error, hasMore, loadMore } = useWidgetOrderHistory(userAddress, isActive);
|
|
606
|
+
const [isFetching, setIsFetching] = useState4(false);
|
|
607
|
+
const scrollRef = useRef2(null);
|
|
608
|
+
const handleScroll = useCallback3(
|
|
609
|
+
async (e) => {
|
|
610
|
+
const target = e.currentTarget;
|
|
611
|
+
const isNearBottom = target.scrollTop + target.clientHeight >= target.scrollHeight - 100;
|
|
612
|
+
if (isNearBottom && !isLoading && !isFetching && hasMore) {
|
|
613
|
+
setIsFetching(true);
|
|
614
|
+
try {
|
|
615
|
+
await loadMore();
|
|
616
|
+
} finally {
|
|
617
|
+
setIsFetching(false);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
},
|
|
621
|
+
[isLoading, isFetching, hasMore, loadMore]
|
|
622
|
+
);
|
|
623
|
+
if (!userAddress) {
|
|
624
|
+
return /* @__PURE__ */ jsx5("div", { className: "flex items-center justify-center p-4", children: /* @__PURE__ */ jsx5("p", { className: "text-sm", style: { color: "var(--widget-muted-foreground)" }, children: "Connect your wallet to view activity" }) });
|
|
625
|
+
}
|
|
626
|
+
if (error) {
|
|
627
|
+
return /* @__PURE__ */ jsx5("div", { className: "flex items-center justify-center p-4", children: /* @__PURE__ */ jsx5("p", { className: "text-sm", style: { color: "var(--widget-destructive)" }, children: "Error loading activity" }) });
|
|
628
|
+
}
|
|
629
|
+
return /* @__PURE__ */ jsx5(
|
|
630
|
+
"div",
|
|
631
|
+
{
|
|
632
|
+
ref: scrollRef,
|
|
633
|
+
className: "flex flex-col flex-1 min-h-0 overflow-y-auto p-2",
|
|
634
|
+
onScroll: handleScroll,
|
|
635
|
+
style: { backgroundColor: "transparent" },
|
|
636
|
+
children: isLoading ? Array.from({ length: 5 }).map((_, i) => /* @__PURE__ */ jsx5(TradeSkeleton, {}, i)) : orders.length === 0 ? /* @__PURE__ */ jsx5("div", { className: "flex flex-col items-center justify-center h-full p-6", children: /* @__PURE__ */ jsx5("p", { className: "text-sm", style: { color: "var(--widget-muted-foreground)" }, children: "No Activity" }) }) : /* @__PURE__ */ jsxs5(Fragment, { children: [
|
|
637
|
+
orders.map((order) => /* @__PURE__ */ jsx5(
|
|
638
|
+
WidgetWalletTradeItem,
|
|
639
|
+
{
|
|
640
|
+
order,
|
|
641
|
+
baseToken: order.enrichedTokens?.base ?? null,
|
|
642
|
+
quoteToken: order.enrichedTokens?.quote ?? null
|
|
643
|
+
},
|
|
644
|
+
order.orderHash
|
|
645
|
+
)),
|
|
646
|
+
isFetching && /* @__PURE__ */ jsx5(TradeSkeleton, {})
|
|
647
|
+
] })
|
|
648
|
+
}
|
|
649
|
+
);
|
|
650
|
+
};
|
|
651
|
+
|
|
652
|
+
// src/components/WidgetWalletPanel.tsx
|
|
653
|
+
import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
654
|
+
var WidgetWalletSkeleton = () => /* @__PURE__ */ jsxs6("div", { className: "flex flex-col w-full h-full overflow-hidden", children: [
|
|
655
|
+
/* @__PURE__ */ jsx6("div", { className: "p-2 w-full flex justify-center", children: /* @__PURE__ */ jsx6(
|
|
656
|
+
"div",
|
|
657
|
+
{
|
|
658
|
+
className: "relative w-full h-[140px] animate-pulse",
|
|
659
|
+
style: {
|
|
660
|
+
borderRadius: "var(--widget-radius)",
|
|
661
|
+
border: "1px var(--widget-border-style) var(--widget-border)",
|
|
662
|
+
backgroundColor: "var(--widget-secondary)"
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
) }),
|
|
666
|
+
/* @__PURE__ */ jsx6("div", { className: "px-2 flex flex-col gap-1.5 mt-1", children: [80, 60, 72, 55, 65].map((w, i) => /* @__PURE__ */ jsxs6("div", { className: "flex items-center justify-between py-1.5", children: [
|
|
667
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-2", children: [
|
|
668
|
+
/* @__PURE__ */ jsx6(
|
|
669
|
+
"div",
|
|
670
|
+
{
|
|
671
|
+
className: "h-6 w-6 rounded-full animate-pulse shrink-0",
|
|
672
|
+
style: { backgroundColor: "var(--widget-secondary)" }
|
|
673
|
+
}
|
|
674
|
+
),
|
|
675
|
+
/* @__PURE__ */ jsx6(
|
|
676
|
+
"div",
|
|
677
|
+
{
|
|
678
|
+
className: "h-3.5 animate-pulse",
|
|
679
|
+
style: { width: `${w}px`, backgroundColor: "var(--widget-secondary)", borderRadius: "0.25rem" }
|
|
680
|
+
}
|
|
681
|
+
)
|
|
682
|
+
] }),
|
|
683
|
+
/* @__PURE__ */ jsx6(
|
|
684
|
+
"div",
|
|
685
|
+
{
|
|
686
|
+
className: "h-3.5 w-14 animate-pulse",
|
|
687
|
+
style: { backgroundColor: "var(--widget-secondary)", opacity: 0.5, borderRadius: "0.25rem" }
|
|
688
|
+
}
|
|
689
|
+
)
|
|
690
|
+
] }, i)) }),
|
|
691
|
+
/* @__PURE__ */ jsx6("div", { className: "mt-auto shrink-0 p-2", style: { borderTop: "1px var(--widget-border-style) var(--widget-border)" }, children: /* @__PURE__ */ jsx6(
|
|
692
|
+
"div",
|
|
693
|
+
{
|
|
694
|
+
className: "w-full animate-pulse",
|
|
695
|
+
style: {
|
|
696
|
+
height: "34px",
|
|
697
|
+
backgroundColor: "var(--widget-secondary)",
|
|
698
|
+
opacity: 0.35,
|
|
699
|
+
borderRadius: "var(--widget-radius)"
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
) })
|
|
703
|
+
] });
|
|
704
|
+
var WidgetWalletPanel = () => {
|
|
705
|
+
const walletTab = useWidgetSwapUIStore((state) => state.walletTab);
|
|
706
|
+
const [signOutHovered, setSignOutHovered] = useState5(false);
|
|
707
|
+
const { disconnect } = useDisconnect();
|
|
708
|
+
const { setQuoteToken } = useSwapFormContext();
|
|
709
|
+
const handleAssetSelect = useCallback4(
|
|
710
|
+
async (asset) => {
|
|
711
|
+
await setQuoteToken(asset);
|
|
712
|
+
useWidgetSwapUIStore.getState().setView("swap");
|
|
713
|
+
},
|
|
714
|
+
[setQuoteToken]
|
|
715
|
+
);
|
|
716
|
+
const {
|
|
717
|
+
address,
|
|
718
|
+
groupedAssets,
|
|
719
|
+
totalBalance,
|
|
720
|
+
balancesLoading,
|
|
721
|
+
chains,
|
|
722
|
+
getToken,
|
|
723
|
+
useTokenWithLazyLoad: useTokenWithLazyLoad2,
|
|
724
|
+
tokenRegistry
|
|
725
|
+
} = useWidgetWalletData(true);
|
|
726
|
+
if (!address) {
|
|
727
|
+
return /* @__PURE__ */ jsx6("div", { className: "flex flex-col items-center justify-center h-full p-4", children: /* @__PURE__ */ jsx6("p", { className: "text-sm", style: { color: "var(--widget-muted-foreground)" }, children: "Connect your wallet to view your portfolio" }) });
|
|
728
|
+
}
|
|
729
|
+
if (balancesLoading && walletTab === "wallet") {
|
|
730
|
+
return /* @__PURE__ */ jsx6(WidgetWalletSkeleton, {});
|
|
731
|
+
}
|
|
732
|
+
return /* @__PURE__ */ jsxs6("div", { className: "flex flex-col w-full h-full overflow-hidden", children: [
|
|
733
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex-1 overflow-y-auto", style: { minHeight: 0 }, children: [
|
|
734
|
+
walletTab === "wallet" && /* @__PURE__ */ jsxs6(Fragment2, { children: [
|
|
735
|
+
/* @__PURE__ */ jsx6(
|
|
736
|
+
WidgetWalletCard,
|
|
737
|
+
{
|
|
738
|
+
address,
|
|
739
|
+
totalBalance,
|
|
740
|
+
isLoading: balancesLoading
|
|
741
|
+
}
|
|
742
|
+
),
|
|
743
|
+
/* @__PURE__ */ jsx6(
|
|
744
|
+
WidgetWalletPortfolio,
|
|
745
|
+
{
|
|
746
|
+
groupedAssets,
|
|
747
|
+
chains,
|
|
748
|
+
tokenRegistry,
|
|
749
|
+
getToken,
|
|
750
|
+
useTokenWithLazyLoad: useTokenWithLazyLoad2,
|
|
751
|
+
onAssetSelect: handleAssetSelect
|
|
752
|
+
}
|
|
753
|
+
)
|
|
754
|
+
] }),
|
|
755
|
+
walletTab === "activity" && /* @__PURE__ */ jsx6(WidgetWalletTradeHistory, { isActive: walletTab === "activity" })
|
|
756
|
+
] }),
|
|
757
|
+
/* @__PURE__ */ jsx6(
|
|
758
|
+
"div",
|
|
759
|
+
{
|
|
760
|
+
className: "shrink-0 p-2",
|
|
761
|
+
style: { borderTop: "1px var(--widget-border-style) var(--widget-border)" },
|
|
762
|
+
children: /* @__PURE__ */ jsx6(
|
|
763
|
+
"button",
|
|
764
|
+
{
|
|
765
|
+
type: "button",
|
|
766
|
+
onClick: () => {
|
|
767
|
+
disconnect();
|
|
768
|
+
useWidgetSwapUIStore.getState().setView("swap");
|
|
769
|
+
},
|
|
770
|
+
onMouseEnter: () => setSignOutHovered(true),
|
|
771
|
+
onMouseLeave: () => setSignOutHovered(false),
|
|
772
|
+
className: "w-full py-2 text-xs mono uppercase cursor-pointer transition-colors",
|
|
773
|
+
style: {
|
|
774
|
+
backgroundColor: signOutHovered ? "var(--widget-destructive)" : "transparent",
|
|
775
|
+
color: signOutHovered ? "var(--widget-destructive-foreground)" : "var(--widget-destructive)",
|
|
776
|
+
border: "1px var(--widget-border-style) var(--widget-destructive)",
|
|
777
|
+
borderRadius: "var(--widget-radius)"
|
|
778
|
+
},
|
|
779
|
+
children: "Sign Out"
|
|
780
|
+
}
|
|
781
|
+
)
|
|
782
|
+
}
|
|
783
|
+
)
|
|
784
|
+
] });
|
|
785
|
+
};
|
|
786
|
+
export {
|
|
787
|
+
WidgetWalletPanel
|
|
788
|
+
};
|
|
789
|
+
//# sourceMappingURL=WidgetWalletPanel-D7I5TAU3.js.map
|