@elizaos/plugin-wallet-ui 2.0.3-beta.5 → 2.0.3-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/dist/InventoryView.d.ts +19 -0
  2. package/dist/InventoryView.d.ts.map +1 -0
  3. package/dist/InventoryView.helpers.d.ts +32 -0
  4. package/dist/InventoryView.helpers.d.ts.map +1 -0
  5. package/dist/InventoryView.helpers.js +104 -0
  6. package/dist/InventoryView.helpers.js.map +1 -0
  7. package/dist/InventoryView.interact.d.ts +2 -0
  8. package/dist/InventoryView.interact.d.ts.map +1 -0
  9. package/dist/InventoryView.interact.js +47 -0
  10. package/dist/InventoryView.interact.js.map +1 -0
  11. package/dist/InventoryView.js +242 -0
  12. package/dist/InventoryView.js.map +1 -0
  13. package/dist/components/InventoryAppView.d.ts +2 -0
  14. package/dist/components/InventoryAppView.d.ts.map +1 -0
  15. package/dist/components/InventoryAppView.js +1744 -0
  16. package/dist/components/InventoryAppView.js.map +1 -0
  17. package/dist/components/InventorySpatialView.d.ts +86 -0
  18. package/dist/components/InventorySpatialView.d.ts.map +1 -0
  19. package/dist/components/InventorySpatialView.js +218 -0
  20. package/dist/components/InventorySpatialView.js.map +1 -0
  21. package/dist/index.d.ts +15 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +65 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/inventory/ChainIcon.d.ts +9 -0
  26. package/dist/inventory/ChainIcon.d.ts.map +1 -0
  27. package/dist/inventory/ChainIcon.js +71 -0
  28. package/dist/inventory/ChainIcon.js.map +1 -0
  29. package/dist/inventory/TokenLogo.d.ts +8 -0
  30. package/dist/inventory/TokenLogo.d.ts.map +1 -0
  31. package/dist/inventory/TokenLogo.js +52 -0
  32. package/dist/inventory/TokenLogo.js.map +1 -0
  33. package/dist/inventory/chainConfig.d.ts +89 -0
  34. package/dist/inventory/chainConfig.d.ts.map +1 -0
  35. package/dist/inventory/chainConfig.js +252 -0
  36. package/dist/inventory/chainConfig.js.map +1 -0
  37. package/dist/inventory/constants.d.ts +31 -0
  38. package/dist/inventory/constants.d.ts.map +1 -0
  39. package/dist/inventory/constants.js +59 -0
  40. package/dist/inventory/constants.js.map +1 -0
  41. package/dist/inventory/index.d.ts +5 -0
  42. package/dist/inventory/index.d.ts.map +1 -0
  43. package/dist/inventory/index.js +43 -0
  44. package/dist/inventory/index.js.map +1 -0
  45. package/dist/inventory/inventory-chain-filters.d.ts +11 -0
  46. package/dist/inventory/inventory-chain-filters.d.ts.map +1 -0
  47. package/dist/inventory/inventory-chain-filters.js +49 -0
  48. package/dist/inventory/inventory-chain-filters.js.map +1 -0
  49. package/dist/inventory/media-url.d.ts +6 -0
  50. package/dist/inventory/media-url.d.ts.map +1 -0
  51. package/dist/inventory/media-url.js +32 -0
  52. package/dist/inventory/media-url.js.map +1 -0
  53. package/dist/inventory/useInventoryData.d.ts +38 -0
  54. package/dist/inventory/useInventoryData.d.ts.map +1 -0
  55. package/dist/inventory/useInventoryData.js +311 -0
  56. package/dist/inventory/useInventoryData.js.map +1 -0
  57. package/dist/plugin.d.ts +3 -0
  58. package/dist/plugin.d.ts.map +1 -0
  59. package/dist/plugin.js +55 -0
  60. package/dist/plugin.js.map +1 -0
  61. package/dist/register-routes.d.ts +9 -0
  62. package/dist/register-routes.d.ts.map +1 -0
  63. package/dist/register-routes.js +22 -0
  64. package/dist/register-routes.js.map +1 -0
  65. package/dist/register-terminal-view.d.ts +15 -0
  66. package/dist/register-terminal-view.d.ts.map +1 -0
  67. package/dist/register-terminal-view.js +33 -0
  68. package/dist/register-terminal-view.js.map +1 -0
  69. package/dist/register.d.ts +4 -0
  70. package/dist/register.d.ts.map +1 -0
  71. package/dist/register.js +20 -0
  72. package/dist/register.js.map +1 -0
  73. package/dist/ui.d.ts +13 -0
  74. package/dist/ui.d.ts.map +1 -0
  75. package/dist/ui.js +62 -0
  76. package/dist/ui.js.map +1 -0
  77. package/dist/views/bundle.js +1072 -0
  78. package/dist/views/bundle.js.map +1 -0
  79. package/dist/wallet-rpc.d.ts +2 -0
  80. package/dist/wallet-rpc.d.ts.map +1 -0
  81. package/dist/wallet-rpc.js +9 -0
  82. package/dist/wallet-rpc.js.map +1 -0
  83. package/dist/wallet-view-bundle.d.ts +3 -0
  84. package/dist/wallet-view-bundle.d.ts.map +1 -0
  85. package/dist/wallet-view-bundle.js +7 -0
  86. package/dist/wallet-view-bundle.js.map +1 -0
  87. package/dist/widgets/wallet-status.d.ts +3 -0
  88. package/dist/widgets/wallet-status.d.ts.map +1 -0
  89. package/dist/widgets/wallet-status.helpers.d.ts +3 -0
  90. package/dist/widgets/wallet-status.helpers.d.ts.map +1 -0
  91. package/dist/widgets/wallet-status.helpers.js +12 -0
  92. package/dist/widgets/wallet-status.helpers.js.map +1 -0
  93. package/dist/widgets/wallet-status.js +291 -0
  94. package/dist/widgets/wallet-status.js.map +1 -0
  95. package/package.json +7 -7
@@ -0,0 +1,1072 @@
1
+ import { client as e } from "@elizaos/ui/api";
2
+ import { useActivityEvents as t } from "@elizaos/ui/hooks";
3
+ import { Button as n, Card as r, Divider as i, HStack as a, List as o, SpatialSurface as s, Text as c, VStack as l } from "@elizaos/ui/spatial";
4
+ import { useAppSelectorShallow as u } from "@elizaos/ui/state";
5
+ import { useCallback as d, useEffect as f, useMemo as p, useRef as m, useState as h } from "react";
6
+ import { jsx as g, jsxs as _ } from "react/jsx-runtime";
7
+ //#region src/components/InventorySpatialView.tsx
8
+ var v = [
9
+ "tokens",
10
+ "defi",
11
+ "nfts"
12
+ ];
13
+ function y(e) {
14
+ return Number.isFinite(e) ? Math.abs(e) >= 1e3 ? `$${e.toLocaleString("en-US", { maximumFractionDigits: 0 })}` : `$${e.toFixed(2)}` : "$0";
15
+ }
16
+ function b(e) {
17
+ return e ? e.length <= 12 ? e : `${e.slice(0, 6)}..${e.slice(-4)}` : "-";
18
+ }
19
+ function x(e) {
20
+ return e > 0 ? "success" : e < 0 ? "danger" : "muted";
21
+ }
22
+ function S(e) {
23
+ return e > 0 ? "+" : e < 0 ? "-" : ".";
24
+ }
25
+ function C(e) {
26
+ return e > 0 ? "success" : e < 0 ? "danger" : "muted";
27
+ }
28
+ function w({ snapshot: e, onAction: t }) {
29
+ let s = (e) => () => t?.(e), { portfolioValueUsd: u, tokenRows: d, walletNfts: f, marketMovers: p, tradingProfile: m, addresses: h, config: w, walletEnabled: T } = e, E = w.selectedRpcProviders.length > 0 ? w.selectedRpcProviders.join(", ") : "default";
30
+ return /* @__PURE__ */ _(r, {
31
+ gap: 1,
32
+ padding: 1,
33
+ children: [
34
+ /* @__PURE__ */ _(a, {
35
+ gap: 1,
36
+ align: "center",
37
+ children: [/* @__PURE__ */ g(c, {
38
+ style: "subheading",
39
+ grow: 1,
40
+ children: y(u)
41
+ }), /* @__PURE__ */ g(c, {
42
+ style: "caption",
43
+ tone: "muted",
44
+ children: e.loading ? "loading" : `${d.length} tokens`
45
+ })]
46
+ }),
47
+ /* @__PURE__ */ _(a, {
48
+ gap: 1,
49
+ align: "center",
50
+ children: [
51
+ /* @__PURE__ */ g(c, {
52
+ style: "caption",
53
+ tone: w.evmBalanceReady ? "success" : "muted",
54
+ children: w.evmBalanceReady ? "evm-ready" : "evm-off"
55
+ }),
56
+ /* @__PURE__ */ g(c, {
57
+ style: "caption",
58
+ tone: w.solanaBalanceReady ? "success" : "muted",
59
+ grow: 1,
60
+ children: w.solanaBalanceReady ? "sol-ready" : "sol-off"
61
+ }),
62
+ /* @__PURE__ */ g(n, {
63
+ variant: "outline",
64
+ tone: "default",
65
+ agent: "rpc-settings",
66
+ onPress: s("rpc-settings"),
67
+ children: E
68
+ })
69
+ ]
70
+ }),
71
+ e.error ? /* @__PURE__ */ g(c, {
72
+ tone: "danger",
73
+ style: "caption",
74
+ children: e.error
75
+ }) : null,
76
+ T === !1 ? /* @__PURE__ */ g(n, {
77
+ grow: 1,
78
+ agent: "enable-wallet",
79
+ onPress: s("enable-wallet"),
80
+ children: "Enable wallet"
81
+ }) : null,
82
+ /* @__PURE__ */ _(a, {
83
+ gap: 1,
84
+ wrap: !0,
85
+ children: [v.map((e) => /* @__PURE__ */ g(n, {
86
+ variant: "outline",
87
+ tone: "default",
88
+ grow: 1,
89
+ agent: `tab-${e}`,
90
+ onPress: s(`tab:${e}`),
91
+ children: e
92
+ }, e)), /* @__PURE__ */ g(n, {
93
+ agent: "refresh",
94
+ onPress: s("refresh"),
95
+ children: "Refresh"
96
+ })]
97
+ }),
98
+ /* @__PURE__ */ g(i, { label: "tokens" }),
99
+ d.length === 0 ? /* @__PURE__ */ g(c, {
100
+ tone: "muted",
101
+ align: "center",
102
+ style: "caption",
103
+ children: "None"
104
+ }) : /* @__PURE__ */ g(o, {
105
+ gap: 0,
106
+ children: d.slice(0, 8).map((e) => /* @__PURE__ */ _(a, {
107
+ gap: 1,
108
+ align: "center",
109
+ children: [
110
+ /* @__PURE__ */ _(l, {
111
+ gap: 0,
112
+ grow: 1,
113
+ children: [/* @__PURE__ */ g(c, {
114
+ bold: !0,
115
+ wrap: !1,
116
+ children: e.symbol
117
+ }), /* @__PURE__ */ _(c, {
118
+ style: "caption",
119
+ tone: "muted",
120
+ wrap: !1,
121
+ children: [
122
+ e.chain,
123
+ " ",
124
+ e.balance
125
+ ]
126
+ })]
127
+ }),
128
+ /* @__PURE__ */ g(c, {
129
+ wrap: !1,
130
+ children: y(e.valueUsd)
131
+ }),
132
+ /* @__PURE__ */ g(n, {
133
+ variant: "ghost",
134
+ tone: "default",
135
+ agent: `open-${e.id}`,
136
+ onPress: s(`open-token:${e.id}`),
137
+ children: "Open"
138
+ }),
139
+ /* @__PURE__ */ g(n, {
140
+ variant: "ghost",
141
+ tone: "danger",
142
+ agent: `hide-${e.id}`,
143
+ onPress: s(`hide-token:${e.id}`),
144
+ children: "Hide"
145
+ })
146
+ ]
147
+ }, e.id))
148
+ }),
149
+ /* @__PURE__ */ g(i, { label: "movers" }),
150
+ p.length === 0 ? /* @__PURE__ */ g(c, {
151
+ tone: "muted",
152
+ align: "center",
153
+ style: "caption",
154
+ children: "—"
155
+ }) : /* @__PURE__ */ g(o, {
156
+ gap: 0,
157
+ children: p.slice(0, 5).map((e) => /* @__PURE__ */ _(a, {
158
+ gap: 1,
159
+ align: "center",
160
+ children: [
161
+ /* @__PURE__ */ g(c, {
162
+ bold: !0,
163
+ grow: 1,
164
+ wrap: !1,
165
+ children: e.symbol
166
+ }),
167
+ /* @__PURE__ */ g(c, {
168
+ style: "caption",
169
+ tone: "muted",
170
+ wrap: !1,
171
+ children: y(e.priceUsd)
172
+ }),
173
+ /* @__PURE__ */ _(c, {
174
+ tone: x(e.change24hPct),
175
+ wrap: !1,
176
+ children: [
177
+ S(e.change24hPct),
178
+ Math.abs(e.change24hPct).toFixed(1),
179
+ "%"
180
+ ]
181
+ })
182
+ ]
183
+ }, e.id))
184
+ }),
185
+ /* @__PURE__ */ g(i, { label: "pnl" }),
186
+ /* @__PURE__ */ _(a, {
187
+ gap: 1,
188
+ align: "center",
189
+ children: [/* @__PURE__ */ g(c, {
190
+ grow: 1,
191
+ children: "Realized P&L"
192
+ }), /* @__PURE__ */ _(c, {
193
+ tone: C(m.realizedPnlBnb),
194
+ wrap: !1,
195
+ children: [
196
+ m.realizedPnlBnb >= 0 ? "+" : "",
197
+ m.realizedPnlBnb.toFixed(4),
198
+ " BNB"
199
+ ]
200
+ })]
201
+ }),
202
+ m.recentSwaps.length > 0 ? /* @__PURE__ */ g(o, {
203
+ gap: 0,
204
+ children: m.recentSwaps.slice(0, 4).map((e) => /* @__PURE__ */ _(a, {
205
+ gap: 1,
206
+ align: "center",
207
+ children: [/* @__PURE__ */ g(c, {
208
+ grow: 1,
209
+ wrap: !1,
210
+ children: e.pair
211
+ }), /* @__PURE__ */ g(c, {
212
+ style: "caption",
213
+ tone: "muted",
214
+ wrap: !1,
215
+ children: e.when
216
+ })]
217
+ }, e.id))
218
+ }) : null,
219
+ /* @__PURE__ */ g(i, { label: "nfts" }),
220
+ f.length === 0 ? /* @__PURE__ */ g(c, {
221
+ tone: "muted",
222
+ align: "center",
223
+ style: "caption",
224
+ children: "None"
225
+ }) : /* @__PURE__ */ g(o, {
226
+ gap: 0,
227
+ children: f.slice(0, 6).map((e) => /* @__PURE__ */ _(a, {
228
+ gap: 1,
229
+ align: "center",
230
+ agent: `nft-${e.id}`,
231
+ children: [
232
+ /* @__PURE__ */ g(c, {
233
+ tone: "primary",
234
+ wrap: !1,
235
+ children: "#"
236
+ }),
237
+ /* @__PURE__ */ _(l, {
238
+ gap: 0,
239
+ grow: 1,
240
+ children: [/* @__PURE__ */ g(c, {
241
+ bold: !0,
242
+ wrap: !1,
243
+ children: e.name
244
+ }), /* @__PURE__ */ g(c, {
245
+ style: "caption",
246
+ tone: "muted",
247
+ wrap: !1,
248
+ children: e.collectionName
249
+ })]
250
+ }),
251
+ /* @__PURE__ */ g(c, {
252
+ style: "caption",
253
+ tone: "muted",
254
+ wrap: !1,
255
+ children: e.chain
256
+ })
257
+ ]
258
+ }, e.id))
259
+ }),
260
+ /* @__PURE__ */ g(i, { label: "addresses" }),
261
+ /* @__PURE__ */ _(a, {
262
+ gap: 1,
263
+ align: "center",
264
+ children: [/* @__PURE__ */ _(c, {
265
+ style: "caption",
266
+ tone: "muted",
267
+ grow: 1,
268
+ wrap: !1,
269
+ children: ["EVM ", b(h.evmAddress)]
270
+ }), /* @__PURE__ */ g(n, {
271
+ variant: "ghost",
272
+ tone: "default",
273
+ disabled: !h.evmAddress,
274
+ agent: "copy-evm",
275
+ onPress: s("copy-evm"),
276
+ children: "Copy"
277
+ })]
278
+ }),
279
+ /* @__PURE__ */ _(a, {
280
+ gap: 1,
281
+ align: "center",
282
+ children: [/* @__PURE__ */ _(c, {
283
+ style: "caption",
284
+ tone: "muted",
285
+ grow: 1,
286
+ wrap: !1,
287
+ children: ["SOL ", b(h.solanaAddress)]
288
+ }), /* @__PURE__ */ g(n, {
289
+ variant: "ghost",
290
+ tone: "default",
291
+ disabled: !h.solanaAddress,
292
+ agent: "copy-solana",
293
+ onPress: s("copy-solana"),
294
+ children: "Copy"
295
+ })]
296
+ })
297
+ ]
298
+ });
299
+ }
300
+ //#endregion
301
+ //#region src/InventoryView.helpers.ts
302
+ function T({ walletAddresses: e, walletConfig: t }) {
303
+ return {
304
+ evmAddress: e?.evmAddress ?? t?.evmAddress ?? null,
305
+ solanaAddress: e?.solanaAddress ?? t?.solanaAddress ?? null
306
+ };
307
+ }
308
+ function E(e) {
309
+ if (typeof e == "number") return Number.isFinite(e) ? e : 0;
310
+ if (typeof e != "string") return 0;
311
+ let t = Number.parseFloat(e);
312
+ return Number.isFinite(t) ? t : 0;
313
+ }
314
+ function D(e) {
315
+ let t = [], n = [];
316
+ for (let r of e?.evm?.chains ?? []) {
317
+ let e = E(r.nativeValueUsd);
318
+ if (t.push({
319
+ chain: r.chain,
320
+ symbol: r.nativeSymbol,
321
+ name: `${r.chain} native`,
322
+ contractAddress: null,
323
+ balance: r.nativeBalance,
324
+ valueUsd: e,
325
+ isNative: !0
326
+ }), r.error) {
327
+ n.push({
328
+ chain: r.chain,
329
+ error: r.error
330
+ });
331
+ continue;
332
+ }
333
+ for (let e of r.tokens) t.push({
334
+ chain: r.chain,
335
+ symbol: e.symbol,
336
+ name: e.name,
337
+ contractAddress: e.contractAddress,
338
+ balance: e.balance,
339
+ valueUsd: E(e.valueUsd),
340
+ isNative: !1
341
+ });
342
+ }
343
+ if (e?.solana) {
344
+ t.push({
345
+ chain: "Solana",
346
+ symbol: "SOL",
347
+ name: "Solana native",
348
+ contractAddress: null,
349
+ balance: e.solana.solBalance,
350
+ valueUsd: E(e.solana.solValueUsd),
351
+ isNative: !0
352
+ });
353
+ for (let n of e.solana.tokens) t.push({
354
+ chain: "Solana",
355
+ symbol: n.symbol,
356
+ name: n.name,
357
+ contractAddress: n.mint,
358
+ balance: n.balance,
359
+ valueUsd: E(n.valueUsd),
360
+ isNative: !1
361
+ });
362
+ }
363
+ return t.sort((e, t) => t.valueUsd - e.valueUsd), {
364
+ totalUsd: t.reduce((e, t) => e + t.valueUsd, 0),
365
+ tokens: t,
366
+ chainErrors: n
367
+ };
368
+ }
369
+ async function O() {
370
+ let [t, n, r, i, a] = await Promise.all([
371
+ e.getWalletAddresses().catch(() => null),
372
+ e.getWalletConfig().catch(() => null),
373
+ e.getWalletBalances().catch(() => null),
374
+ e.getWalletNfts().catch(() => null),
375
+ e.getWalletMarketOverview().catch(() => null)
376
+ ]);
377
+ return {
378
+ walletAddresses: t,
379
+ walletConfig: n,
380
+ walletBalances: r,
381
+ walletNfts: i,
382
+ marketOverview: a,
383
+ summary: D(r)
384
+ };
385
+ }
386
+ //#endregion
387
+ //#region src/inventory/constants.ts
388
+ function k(e) {
389
+ return e.trim().toLowerCase();
390
+ }
391
+ function A(e) {
392
+ let t = k(e);
393
+ return t === "bsc" || t === "bnb chain" || t === "bnb smart chain";
394
+ }
395
+ function j(e) {
396
+ let t = M(e);
397
+ return t === 0 ? "0" : t < 1e-4 ? "<0.0001" : t < 1 ? t.toFixed(6) : t < 1e3 ? t.toFixed(4) : t.toLocaleString("en-US", { maximumFractionDigits: 2 });
398
+ }
399
+ function M(e) {
400
+ if (typeof e == "number") return Number.isFinite(e) ? e : 0;
401
+ if (typeof e != "string") return 0;
402
+ let t = Number.parseFloat(e);
403
+ return Number.isFinite(t) ? t : 0;
404
+ }
405
+ //#endregion
406
+ //#region src/inventory/chainConfig.ts
407
+ var N = /^0x[a-fA-F0-9]{40}$/, P = {
408
+ bsc: {
409
+ chainKey: "bsc",
410
+ name: "BSC",
411
+ nativeSymbol: "BNB",
412
+ nativeDecimals: 18,
413
+ isEvm: !0,
414
+ explorerBaseUrl: "https://bscscan.com",
415
+ explorerTokenPath: "/token/{address}",
416
+ explorerTxPath: "/tx/{hash}",
417
+ nativeLogoUrl: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/smartchain/info/logo.png",
418
+ trustWalletSlug: "smartchain",
419
+ gasReadyThreshold: .005,
420
+ swapGasReserve: .002,
421
+ stablecoins: [{
422
+ symbol: "USDT",
423
+ address: "0x55d398326f99059fF775485246999027B3197955"
424
+ }, {
425
+ symbol: "USDC",
426
+ address: "0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"
427
+ }],
428
+ addressRegex: N,
429
+ dexScreenerChainId: "bsc",
430
+ nameVariants: [
431
+ "bsc",
432
+ "bnb chain",
433
+ "bnb smart chain"
434
+ ],
435
+ color: "var(--color-chain-bsc)"
436
+ },
437
+ avax: {
438
+ chainKey: "avax",
439
+ name: "Avalanche",
440
+ nativeSymbol: "AVAX",
441
+ nativeDecimals: 18,
442
+ isEvm: !0,
443
+ explorerBaseUrl: "https://snowtrace.io",
444
+ explorerTokenPath: "/token/{address}",
445
+ explorerTxPath: "/tx/{hash}",
446
+ nativeLogoUrl: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/avalanchec/info/logo.png",
447
+ trustWalletSlug: "avalanchec",
448
+ gasReadyThreshold: .01,
449
+ swapGasReserve: .005,
450
+ stablecoins: [{
451
+ symbol: "USDT",
452
+ address: "0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7"
453
+ }, {
454
+ symbol: "USDC",
455
+ address: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"
456
+ }],
457
+ addressRegex: N,
458
+ dexScreenerChainId: "avalanche",
459
+ nameVariants: [
460
+ "avax",
461
+ "avalanche",
462
+ "c-chain",
463
+ "avalanche c-chain"
464
+ ],
465
+ color: "#e84142"
466
+ },
467
+ solana: {
468
+ chainKey: "solana",
469
+ name: "Solana",
470
+ nativeSymbol: "SOL",
471
+ nativeDecimals: 9,
472
+ isEvm: !1,
473
+ explorerBaseUrl: "https://solscan.io",
474
+ explorerTokenPath: "/token/{address}",
475
+ explorerTxPath: "/tx/{hash}",
476
+ nativeLogoUrl: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/solana/info/logo.png",
477
+ trustWalletSlug: "solana",
478
+ gasReadyThreshold: .01,
479
+ swapGasReserve: .005,
480
+ stablecoins: [{
481
+ symbol: "USDC",
482
+ address: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
483
+ }],
484
+ addressRegex: /^[1-9A-HJ-NP-Za-km-z]{32,44}$/,
485
+ dexScreenerChainId: "solana",
486
+ nameVariants: ["solana", "sol"],
487
+ color: "var(--color-chain-sol)"
488
+ },
489
+ ethereum: {
490
+ chainKey: "ethereum",
491
+ name: "Ethereum",
492
+ nativeSymbol: "ETH",
493
+ nativeDecimals: 18,
494
+ isEvm: !0,
495
+ explorerBaseUrl: "https://etherscan.io",
496
+ explorerTokenPath: "/token/{address}",
497
+ explorerTxPath: "/tx/{hash}",
498
+ nativeLogoUrl: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/info/logo.png",
499
+ trustWalletSlug: "ethereum",
500
+ gasReadyThreshold: .005,
501
+ swapGasReserve: .002,
502
+ stablecoins: [{
503
+ symbol: "USDT",
504
+ address: "0xdAC17F958D2ee523a2206206994597C13D831ec7"
505
+ }, {
506
+ symbol: "USDC",
507
+ address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
508
+ }],
509
+ addressRegex: N,
510
+ dexScreenerChainId: "ethereum",
511
+ nameVariants: [
512
+ "ethereum",
513
+ "mainnet",
514
+ "eth"
515
+ ],
516
+ color: "var(--color-chain-eth)"
517
+ },
518
+ base: {
519
+ chainKey: "base",
520
+ name: "Base",
521
+ nativeSymbol: "ETH",
522
+ nativeDecimals: 18,
523
+ isEvm: !0,
524
+ explorerBaseUrl: "https://basescan.org",
525
+ explorerTokenPath: "/token/{address}",
526
+ explorerTxPath: "/tx/{hash}",
527
+ nativeLogoUrl: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/base/info/logo.png",
528
+ trustWalletSlug: "base",
529
+ gasReadyThreshold: .005,
530
+ swapGasReserve: .001,
531
+ stablecoins: [{
532
+ symbol: "USDC",
533
+ address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
534
+ }],
535
+ addressRegex: N,
536
+ dexScreenerChainId: "base",
537
+ nameVariants: ["base"],
538
+ color: "var(--color-chain-base)"
539
+ },
540
+ arbitrum: {
541
+ chainKey: "arbitrum",
542
+ name: "Arbitrum",
543
+ nativeSymbol: "ETH",
544
+ nativeDecimals: 18,
545
+ isEvm: !0,
546
+ explorerBaseUrl: "https://arbiscan.io",
547
+ explorerTokenPath: "/token/{address}",
548
+ explorerTxPath: "/tx/{hash}",
549
+ nativeLogoUrl: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/info/logo.png",
550
+ trustWalletSlug: null,
551
+ gasReadyThreshold: .005,
552
+ swapGasReserve: .001,
553
+ stablecoins: [{
554
+ symbol: "USDC",
555
+ address: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831"
556
+ }],
557
+ addressRegex: N,
558
+ dexScreenerChainId: "arbitrum",
559
+ nameVariants: ["arbitrum"],
560
+ color: "var(--color-chain-arb)"
561
+ },
562
+ optimism: {
563
+ chainKey: "optimism",
564
+ name: "Optimism",
565
+ nativeSymbol: "ETH",
566
+ nativeDecimals: 18,
567
+ isEvm: !0,
568
+ explorerBaseUrl: "https://optimistic.etherscan.io",
569
+ explorerTokenPath: "/token/{address}",
570
+ explorerTxPath: "/tx/{hash}",
571
+ nativeLogoUrl: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/info/logo.png",
572
+ trustWalletSlug: null,
573
+ gasReadyThreshold: .005,
574
+ swapGasReserve: .001,
575
+ stablecoins: [{
576
+ symbol: "USDC",
577
+ address: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85"
578
+ }],
579
+ addressRegex: N,
580
+ dexScreenerChainId: "optimism",
581
+ nameVariants: ["optimism"],
582
+ color: "var(--color-chain-op)"
583
+ },
584
+ polygon: {
585
+ chainKey: "polygon",
586
+ name: "Polygon",
587
+ nativeSymbol: "MATIC",
588
+ nativeDecimals: 18,
589
+ isEvm: !0,
590
+ explorerBaseUrl: "https://polygonscan.com",
591
+ explorerTokenPath: "/token/{address}",
592
+ explorerTxPath: "/tx/{hash}",
593
+ nativeLogoUrl: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/polygon/info/logo.png",
594
+ trustWalletSlug: "polygon",
595
+ gasReadyThreshold: .5,
596
+ swapGasReserve: .1,
597
+ stablecoins: [{
598
+ symbol: "USDT",
599
+ address: "0xc2132D05D31c914a87C6611C10748AEb04B58e8F"
600
+ }, {
601
+ symbol: "USDC",
602
+ address: "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359"
603
+ }],
604
+ addressRegex: N,
605
+ dexScreenerChainId: "polygon",
606
+ nameVariants: ["polygon"],
607
+ color: "var(--color-chain-pol)"
608
+ }
609
+ }, F = /* @__PURE__ */ new Map();
610
+ for (let e of Object.values(P)) for (let t of e.nameVariants) F.set(t.toLowerCase(), e);
611
+ function I(e) {
612
+ return F.get(e.trim().toLowerCase()) ?? null;
613
+ }
614
+ function L(e) {
615
+ return I(e)?.chainKey ?? null;
616
+ }
617
+ var R = [
618
+ "ethereum",
619
+ "base",
620
+ "bsc",
621
+ "avax",
622
+ "solana"
623
+ ], z = [
624
+ "ethereum",
625
+ "base",
626
+ "bsc",
627
+ "avax",
628
+ "solana"
629
+ ], B = {
630
+ ethereum: !0,
631
+ base: !0,
632
+ bsc: !0,
633
+ avax: !0,
634
+ solana: !0
635
+ };
636
+ function V(e) {
637
+ return z.includes(e);
638
+ }
639
+ function H(e, t) {
640
+ let n = W(t), r = L(e);
641
+ return !r || !V(r) ? !1 : n[r] === !0;
642
+ }
643
+ function U(e) {
644
+ let t = W(e), n = z.filter((e) => t[e]);
645
+ return n.length === 1 ? n[0] : null;
646
+ }
647
+ function W(e) {
648
+ return {
649
+ ...B,
650
+ ...e
651
+ };
652
+ }
653
+ //#endregion
654
+ //#region src/inventory/useInventoryData.ts
655
+ function G(e) {
656
+ return e.balanceRaw > 0 || e.valueUsd > 0;
657
+ }
658
+ function K(e, t) {
659
+ return L(e) === t;
660
+ }
661
+ function q({ walletBalances: e, walletAddresses: t, walletConfig: n }) {
662
+ let r = [], i = t?.evmAddress ?? n?.evmAddress;
663
+ if (e?.evm) {
664
+ let t = /* @__PURE__ */ new Set();
665
+ for (let n of e.evm.chains) {
666
+ let e = L(n.chain);
667
+ if (e && t.add(e), r.push({
668
+ chain: n.chain,
669
+ symbol: n.nativeSymbol,
670
+ name: `${n.chain} native`,
671
+ contractAddress: null,
672
+ logoUrl: null,
673
+ balance: n.nativeBalance,
674
+ valueUsd: M(n.nativeValueUsd),
675
+ balanceRaw: M(n.nativeBalance),
676
+ isNative: !0
677
+ }), !n.error) for (let e of n.tokens) r.push({
678
+ chain: n.chain,
679
+ symbol: e.symbol,
680
+ name: e.name,
681
+ contractAddress: e.contractAddress ?? null,
682
+ logoUrl: e.logoUrl ?? null,
683
+ balance: e.balance,
684
+ valueUsd: M(e.valueUsd),
685
+ balanceRaw: M(e.balance),
686
+ isNative: !1
687
+ });
688
+ }
689
+ if (i) for (let e of R) {
690
+ if (e === "solana" || t.has(e)) continue;
691
+ let n = P[e];
692
+ r.unshift({
693
+ chain: n.name,
694
+ symbol: n.nativeSymbol,
695
+ name: `${n.name} native`,
696
+ contractAddress: null,
697
+ logoUrl: null,
698
+ balance: "0",
699
+ valueUsd: 0,
700
+ balanceRaw: 0,
701
+ isNative: !0
702
+ });
703
+ }
704
+ } else if (i) for (let e of R) {
705
+ if (e === "solana") continue;
706
+ let t = P[e];
707
+ r.push({
708
+ chain: t.name,
709
+ symbol: t.nativeSymbol,
710
+ name: `${t.name} native`,
711
+ contractAddress: null,
712
+ logoUrl: null,
713
+ balance: "0",
714
+ valueUsd: 0,
715
+ balanceRaw: 0,
716
+ isNative: !0
717
+ });
718
+ }
719
+ if (e?.solana) {
720
+ r.push({
721
+ chain: "Solana",
722
+ symbol: "SOL",
723
+ name: "Solana native",
724
+ contractAddress: null,
725
+ logoUrl: null,
726
+ balance: e.solana.solBalance,
727
+ valueUsd: M(e.solana.solValueUsd),
728
+ balanceRaw: M(e.solana.solBalance),
729
+ isNative: !0
730
+ });
731
+ for (let t of e.solana.tokens) r.push({
732
+ chain: "Solana",
733
+ symbol: t.symbol,
734
+ name: t.name,
735
+ contractAddress: t.mint ?? null,
736
+ logoUrl: t.logoUrl ?? null,
737
+ balance: t.balance,
738
+ valueUsd: M(t.valueUsd),
739
+ balanceRaw: M(t.balance),
740
+ isNative: !1
741
+ });
742
+ }
743
+ return r.filter(G);
744
+ }
745
+ function J({ walletBalances: e, walletAddresses: t, walletConfig: n, walletNfts: r, inventorySort: i, inventorySortDirection: a, inventoryChainFilters: o }) {
746
+ let s = p(() => U(o), [o]), c = t?.evmAddress ?? n?.evmAddress;
747
+ t?.solanaAddress ?? n?.solanaAddress;
748
+ let l = p(() => e?.evm?.chains ? e.evm.chains.find((e) => A(e.chain)) ?? null : null, [e]), u = p(() => l ? M(l.nativeBalance) : 0, [l]), d = p(() => q({
749
+ walletBalances: e,
750
+ walletAddresses: t,
751
+ walletConfig: n
752
+ }), [
753
+ e,
754
+ t,
755
+ n
756
+ ]), f = p(() => d.filter((e) => H(e.chain, o)), [d, o]), m = p(() => {
757
+ let e = [...f], t = a === "asc";
758
+ return i === "value" ? e.sort((e, n) => {
759
+ let r = e.valueUsd - n.valueUsd;
760
+ if (r !== 0) return t ? r : -r;
761
+ let i = e.balanceRaw - n.balanceRaw;
762
+ return t ? i : -i;
763
+ }) : i === "chain" ? e.sort((e, n) => {
764
+ let r = e.chain.localeCompare(n.chain);
765
+ if (r !== 0) return t ? r : -r;
766
+ let i = e.symbol.localeCompare(n.symbol);
767
+ return t ? i : -i;
768
+ }) : i === "symbol" && e.sort((e, n) => {
769
+ let r = e.symbol.localeCompare(n.symbol);
770
+ if (r !== 0) return t ? r : -r;
771
+ let i = e.chain.localeCompare(n.chain);
772
+ return t ? i : -i;
773
+ }), e;
774
+ }, [
775
+ f,
776
+ i,
777
+ a
778
+ ]), h = p(() => (e?.evm?.chains ?? []).filter((e) => e.error), [e]), g = p(() => h.some((e) => H(e.chain, o)), [h, o]), _ = p(() => {
779
+ if (!r) return [];
780
+ let e = [];
781
+ for (let t of r.evm) for (let n of t.nfts) e.push({
782
+ chain: t.chain,
783
+ name: n.name,
784
+ imageUrl: n.imageUrl,
785
+ collectionName: n.collectionName || n.tokenType
786
+ });
787
+ if (r.solana) for (let t of r.solana.nfts) e.push({
788
+ chain: "Solana",
789
+ name: t.name,
790
+ imageUrl: t.imageUrl,
791
+ collectionName: t.collectionName
792
+ });
793
+ let t = [...e.filter((e) => H(e.chain, o))], n = a === "asc";
794
+ return (i === "value" ? "symbol" : i) === "chain" ? t.sort((e, t) => {
795
+ let r = e.chain.localeCompare(t.chain);
796
+ if (r !== 0) return n ? r : -r;
797
+ let i = e.name.localeCompare(t.name);
798
+ return n ? i : -i;
799
+ }) : t.sort((e, t) => {
800
+ let r = e.name.localeCompare(t.name);
801
+ if (r !== 0) return n ? r : -r;
802
+ let i = e.chain.localeCompare(t.chain);
803
+ return n ? i : -i;
804
+ }), t;
805
+ }, [
806
+ r,
807
+ o,
808
+ i,
809
+ a
810
+ ]), v = p(() => {
811
+ if (!s) return null;
812
+ if (s === "solana") return {
813
+ name: P.solana.name,
814
+ nativeSymbol: P.solana.nativeSymbol,
815
+ nativeBalance: e?.solana?.solBalance ?? null,
816
+ error: null
817
+ };
818
+ let t = P[s], n = e?.evm?.chains.find((e) => K(e.chain, s)) ?? null;
819
+ return !t && !n ? null : {
820
+ name: n?.chain ?? t?.name ?? s,
821
+ nativeSymbol: n?.nativeSymbol ?? t?.nativeSymbol ?? null,
822
+ nativeBalance: n?.nativeBalance ?? (c ? "0" : null),
823
+ error: n?.error ?? null
824
+ };
825
+ }, [
826
+ s,
827
+ c,
828
+ e
829
+ ]), y = l?.error ?? h.find((e) => A(e.chain))?.error ?? null, b = l?.nativeBalance ?? null;
830
+ return {
831
+ singleChainFocus: s,
832
+ tokenRows: f,
833
+ tokenRowsAllChains: d,
834
+ sortedRows: m,
835
+ chainErrors: h,
836
+ focusChainHasError: g,
837
+ allNfts: _,
838
+ primaryChain: l,
839
+ primaryNativeBalanceNum: u,
840
+ focusedRows: m,
841
+ visibleRows: m,
842
+ totalUsd: p(() => f.reduce((e, t) => e + t.valueUsd, 0), [f]),
843
+ visibleChainErrors: p(() => h.filter((e) => H(e.chain, o)), [h, o]),
844
+ focusedChainName: v?.name ?? null,
845
+ focusedChainError: v?.error ?? null,
846
+ focusedNativeBalance: v?.nativeBalance ?? null,
847
+ focusedNativeSymbol: v?.nativeSymbol ?? null,
848
+ primaryChainError: y,
849
+ primaryNativeBalance: b
850
+ };
851
+ }
852
+ //#endregion
853
+ //#region src/InventoryView.tsx
854
+ var Y = {
855
+ ethereum: !0,
856
+ base: !0,
857
+ bsc: !0,
858
+ avax: !0,
859
+ solana: !0
860
+ }, X = "eliza:wallet:hidden-token-ids:v1", Z = 2e4;
861
+ function ee() {
862
+ if (typeof window > "u") return /* @__PURE__ */ new Set();
863
+ let e = window.localStorage.getItem(X);
864
+ if (!e) return /* @__PURE__ */ new Set();
865
+ let t = JSON.parse(e);
866
+ return Array.isArray(t) ? new Set(t.filter((e) => typeof e == "string")) : /* @__PURE__ */ new Set();
867
+ }
868
+ function te(e) {
869
+ typeof window > "u" || window.localStorage.setItem(X, JSON.stringify([...e]));
870
+ }
871
+ function Q(e) {
872
+ let t = e.contractAddress && e.contractAddress.length > 0 ? e.contractAddress.toLowerCase() : `native:${e.symbol.toLowerCase()}`;
873
+ return `${e.chain.toLowerCase()}:${t}`;
874
+ }
875
+ function ne(e) {
876
+ return e.balanceRaw > 0 || e.valueUsd > 0;
877
+ }
878
+ function re(e) {
879
+ if (!e) return 0;
880
+ let t = Number.parseFloat(e);
881
+ return Number.isFinite(t) ? t : 0;
882
+ }
883
+ function $(e) {
884
+ !e || typeof navigator > "u" || !navigator.clipboard || navigator.clipboard.writeText(e);
885
+ }
886
+ function ie(e) {
887
+ e("settings"), typeof window < "u" && (window.location.hash = "wallet-rpc");
888
+ }
889
+ function ae() {
890
+ let { walletEnabled: n, walletAddresses: r, walletConfig: i, walletBalances: a, walletNfts: o, loadWalletConfig: c, loadBalances: l, loadNfts: _, setState: v, setTab: y, setActionNotice: b } = u((e) => ({
891
+ walletEnabled: e.walletEnabled,
892
+ walletAddresses: e.walletAddresses,
893
+ walletConfig: e.walletConfig,
894
+ walletBalances: e.walletBalances,
895
+ walletNfts: e.walletNfts,
896
+ loadWalletConfig: e.loadWalletConfig,
897
+ loadBalances: e.loadBalances,
898
+ loadNfts: e.loadNfts,
899
+ setState: e.setState,
900
+ setTab: e.setTab,
901
+ setActionNotice: e.setActionNotice
902
+ })), { events: x } = t(), [S, C] = h(() => ee()), [E, D] = h(0), [O, k] = h(null), A = m(!1), M = d(async () => {
903
+ D(re((await e.getWalletTradingProfile("30d")).summary.realizedPnlBnb));
904
+ }, []);
905
+ f(() => {
906
+ A.current || (A.current = !0, c(), n !== !1 && (l(), _(), M()));
907
+ }, [
908
+ l,
909
+ _,
910
+ M,
911
+ c,
912
+ n
913
+ ]), f(() => {
914
+ if (n === !1) return;
915
+ let e = window.setInterval(() => {
916
+ c(), l(), _(), M();
917
+ }, Z);
918
+ return () => window.clearInterval(e);
919
+ }, [
920
+ l,
921
+ _,
922
+ M,
923
+ c,
924
+ n
925
+ ]);
926
+ let N = J({
927
+ walletBalances: a,
928
+ walletAddresses: r,
929
+ walletConfig: i,
930
+ walletNfts: o,
931
+ inventorySort: "value",
932
+ inventorySortDirection: "desc",
933
+ inventoryChainFilters: Y
934
+ }), P = p(() => T({
935
+ walletAddresses: r,
936
+ walletConfig: i
937
+ }), [r, i]), F = p(() => N.tokenRowsAllChains.filter(ne).filter((e) => !S.has(Q(e))), [S, N.tokenRowsAllChains]), I = p(() => {
938
+ let e = i?.selectedRpcProviders ? Object.values(i.selectedRpcProviders).filter((e) => typeof e == "string") : [];
939
+ return {
940
+ portfolioValueUsd: F.reduce((e, t) => e + t.valueUsd, 0),
941
+ tokenRows: F.map((e) => ({
942
+ id: Q(e),
943
+ symbol: e.symbol,
944
+ chain: e.chain,
945
+ balance: j(e.balance),
946
+ valueUsd: e.valueUsd,
947
+ contractAddress: e.contractAddress,
948
+ logoUrl: e.logoUrl
949
+ })),
950
+ walletNfts: N.allNfts.map((e) => ({
951
+ id: `${e.chain}:${e.collectionName}:${e.name}`,
952
+ chain: e.chain,
953
+ collectionName: e.collectionName,
954
+ name: e.name,
955
+ imageUrl: e.imageUrl
956
+ })),
957
+ marketMovers: [],
958
+ tradingProfile: {
959
+ realizedPnlBnb: E,
960
+ recentSwaps: []
961
+ },
962
+ addresses: P,
963
+ config: {
964
+ evmBalanceReady: !!i?.evmBalanceReady,
965
+ solanaBalanceReady: !!i?.solanaBalanceReady,
966
+ selectedRpcProviders: [...new Set(e)]
967
+ },
968
+ walletEnabled: n,
969
+ error: O
970
+ };
971
+ }, [
972
+ P,
973
+ O,
974
+ N.allNfts,
975
+ E,
976
+ F,
977
+ i,
978
+ n
979
+ ]), L = d((e) => {
980
+ let t = F.find((t) => Q(t) === e), n = new Set(S);
981
+ n.add(e), C(n), te(n), t && b(`${t.symbol} hidden from this wallet view.`);
982
+ }, [
983
+ S,
984
+ b,
985
+ F
986
+ ]), R = d(() => {
987
+ k(null), c(), l(), _(), M();
988
+ }, [
989
+ l,
990
+ _,
991
+ M,
992
+ c
993
+ ]), z = d(() => {
994
+ v("walletEnabled", !0), c(), l(), _();
995
+ }, [
996
+ l,
997
+ _,
998
+ c,
999
+ v
1000
+ ]);
1001
+ return /* @__PURE__ */ g(s, { children: /* @__PURE__ */ g(w, {
1002
+ snapshot: I,
1003
+ onAction: d((e) => {
1004
+ if (e.startsWith("hide-token:")) {
1005
+ L(e.slice(11));
1006
+ return;
1007
+ }
1008
+ if (e.startsWith("open-token:")) {
1009
+ y("settings");
1010
+ return;
1011
+ }
1012
+ if (!e.startsWith("tab:")) switch (e) {
1013
+ case "refresh":
1014
+ R();
1015
+ return;
1016
+ case "enable-wallet":
1017
+ z();
1018
+ return;
1019
+ case "rpc-settings":
1020
+ ie(y);
1021
+ return;
1022
+ case "copy-evm":
1023
+ $(P.evmAddress);
1024
+ return;
1025
+ case "copy-solana":
1026
+ $(P.solanaAddress);
1027
+ return;
1028
+ }
1029
+ }, [
1030
+ P,
1031
+ z,
1032
+ L,
1033
+ R,
1034
+ y
1035
+ ])
1036
+ }) });
1037
+ }
1038
+ //#endregion
1039
+ //#region src/InventoryView.interact.ts
1040
+ async function oe(t, n) {
1041
+ if (t === "terminal-wallet-state") {
1042
+ let e = await O();
1043
+ return {
1044
+ viewType: "tui",
1045
+ addresses: T({
1046
+ walletAddresses: e.walletAddresses,
1047
+ walletConfig: e.walletConfig
1048
+ }),
1049
+ totalUsd: e.summary.totalUsd,
1050
+ tokenCount: e.summary.tokens.length,
1051
+ nftCount: (e.walletNfts?.evm?.reduce((e, t) => e + t.nfts.length, 0) ?? 0) + (e.walletNfts?.solana?.nfts.length ?? 0),
1052
+ chainErrors: e.summary.chainErrors,
1053
+ tokens: e.summary.tokens.slice(0, typeof n?.limit == "number" ? n.limit : 20)
1054
+ };
1055
+ }
1056
+ if (t === "terminal-wallet-market-overview") return {
1057
+ viewType: "tui",
1058
+ overview: await e.getWalletMarketOverview()
1059
+ };
1060
+ if (t === "terminal-wallet-trading-profile") {
1061
+ let t = n?.window === "24h" || n?.window === "7d" || n?.window === "30d" ? n.window : "30d";
1062
+ return {
1063
+ viewType: "tui",
1064
+ profile: await e.getWalletTradingProfile(t)
1065
+ };
1066
+ }
1067
+ throw Error(`Unsupported capability "${t}"`);
1068
+ }
1069
+ //#endregion
1070
+ export { ae as InventoryView, oe as interact };
1071
+
1072
+ //# sourceMappingURL=bundle.js.map