@xyo-network/react-chain-provider 1.16.1 → 1.16.3

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 (61) hide show
  1. package/dist/browser/components/account/BalanceHistoryFlexbox.d.ts +11 -0
  2. package/dist/browser/components/account/BalanceHistoryFlexbox.d.ts.map +1 -0
  3. package/dist/browser/components/account/BalanceHistoryFlexbox.stories.d.ts +6 -0
  4. package/dist/browser/components/account/BalanceHistoryFlexbox.stories.d.ts.map +1 -0
  5. package/dist/browser/components/account/BalanceHistoryTable.d.ts +8 -0
  6. package/dist/browser/components/account/BalanceHistoryTable.d.ts.map +1 -0
  7. package/dist/browser/components/account/index.d.ts +3 -0
  8. package/dist/browser/components/account/index.d.ts.map +1 -0
  9. package/dist/browser/components/index.d.ts +1 -0
  10. package/dist/browser/components/index.d.ts.map +1 -1
  11. package/dist/browser/hooks/client/helpers/findCaveat.d.ts +1 -2
  12. package/dist/browser/hooks/client/helpers/findCaveat.d.ts.map +1 -1
  13. package/dist/browser/hooks/client/useGateway.d.ts +1 -1
  14. package/dist/browser/hooks/index.d.ts +1 -0
  15. package/dist/browser/hooks/index.d.ts.map +1 -1
  16. package/dist/browser/hooks/useAccountBalanceHistory.d.ts +11 -0
  17. package/dist/browser/hooks/useAccountBalanceHistory.d.ts.map +1 -0
  18. package/dist/browser/hooks/useAddressBalance.d.ts +1 -3
  19. package/dist/browser/hooks/useAddressBalance.d.ts.map +1 -1
  20. package/dist/browser/hooks/useConnectAccount.d.ts +3 -7
  21. package/dist/browser/hooks/useConnectAccount.d.ts.map +1 -1
  22. package/dist/browser/hooks/useNetwork.d.ts +2 -2
  23. package/dist/browser/hooks/useNetwork.d.ts.map +1 -1
  24. package/dist/browser/hooks/useSigner.d.ts +1 -1
  25. package/dist/browser/hooks/useSigner.d.ts.map +1 -1
  26. package/dist/browser/hooks/viewer/UseStepRewardWeightTest.stories.d.ts.map +1 -1
  27. package/dist/browser/hooks/viewer/useViewerFromWallet.d.ts +1 -1
  28. package/dist/browser/hooks/viewer/useViewerFromWallet.d.ts.map +1 -1
  29. package/dist/browser/hooks/viewer/useViewerFromWallet.stories.d.ts.map +1 -1
  30. package/dist/browser/index.d.ts +1 -0
  31. package/dist/browser/index.d.ts.map +1 -1
  32. package/dist/browser/index.mjs +266 -72
  33. package/dist/browser/index.mjs.map +1 -1
  34. package/dist/browser/types/account/BalanceHistoryItemRow.d.ts +14 -0
  35. package/dist/browser/types/account/BalanceHistoryItemRow.d.ts.map +1 -0
  36. package/dist/browser/types/account/Table.d.ts +7 -0
  37. package/dist/browser/types/account/Table.d.ts.map +1 -0
  38. package/dist/browser/types/account/index.d.ts +3 -0
  39. package/dist/browser/types/account/index.d.ts.map +1 -0
  40. package/dist/browser/types/index.d.ts +2 -0
  41. package/dist/browser/types/index.d.ts.map +1 -0
  42. package/package.json +17 -14
  43. package/src/components/account/BalanceHistoryFlexbox.stories.tsx +25 -0
  44. package/src/components/account/BalanceHistoryFlexbox.tsx +67 -0
  45. package/src/components/account/BalanceHistoryTable.tsx +81 -0
  46. package/src/components/account/index.ts +2 -0
  47. package/src/components/index.ts +1 -0
  48. package/src/hooks/client/helpers/findCaveat.ts +3 -2
  49. package/src/hooks/index.ts +1 -0
  50. package/src/hooks/useAccountBalanceHistory.ts +104 -0
  51. package/src/hooks/useConnectAccount.ts +1 -1
  52. package/src/hooks/useNetwork.ts +2 -2
  53. package/src/hooks/useSigner.ts +4 -3
  54. package/src/hooks/viewer/UseStepRewardWeightTest.stories.tsx +1 -3
  55. package/src/hooks/viewer/useViewerFromWallet.stories.tsx +1 -3
  56. package/src/hooks/viewer/useViewerFromWallet.ts +6 -9
  57. package/src/index.ts +1 -0
  58. package/src/types/account/BalanceHistoryItemRow.ts +14 -0
  59. package/src/types/account/Table.ts +14 -0
  60. package/src/types/account/index.ts +2 -0
  61. package/src/types/index.ts +1 -0
@@ -1,35 +1,13 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
 
4
- // src/components/connected/account/Connected.tsx
5
- import { Stack, Tooltip, Typography } from "@mui/material";
6
- import { EthAddressWrapper } from "@xylabs/eth-address";
7
- import { BlockiesAvatarAddress } from "@xyo-network/react-chain-blockies";
8
- import React from "react";
9
- var ConnectedAccount = /* @__PURE__ */ __name(({ address }) => {
10
- const shortenedAddress = `${EthAddressWrapper.fromString(address)?.toShortString(4)}`;
11
- return /* @__PURE__ */ React.createElement(Stack, {
12
- direction: "row",
13
- alignItems: "center",
14
- spacing: 1
15
- }, /* @__PURE__ */ React.createElement(BlockiesAvatarAddress, {
16
- address,
17
- size: 21
18
- }), /* @__PURE__ */ React.createElement(Tooltip, {
19
- title: address
20
- }, /* @__PURE__ */ React.createElement(Typography, {
21
- color: "textSecondary",
22
- variant: "caption",
23
- fontFamily: "monospace"
24
- }, shortenedAddress)));
25
- }, "ConnectedAccount");
26
-
27
- // src/components/connected/ConnectAccountsStack.tsx
28
- import { Alert, AlertTitle, Button, Stack as Stack2, Typography as Typography2 } from "@mui/material";
29
- import { ButtonEx } from "@xylabs/react-button";
30
- import { isDefined as isDefined7, isUndefined as isUndefined6 } from "@xylabs/typeof";
4
+ // src/components/account/BalanceHistoryFlexbox.tsx
5
+ import { Typography } from "@mui/material";
6
+ import { FlexCol } from "@xylabs/react-flexbox";
7
+ import { isDefined as isDefined8 } from "@xylabs/typeof";
31
8
  import { ErrorRender } from "@xyo-network/react-error";
32
- import React2, { useEffect as useEffect3 } from "react";
9
+ import { AttoXL1, XL1Amount as XL1Amount2 } from "@xyo-network/xl1-protocol";
10
+ import React2 from "react";
33
11
 
34
12
  // src/hooks/client/useClient.ts
35
13
  import { useSyncExternalStore } from "react";
@@ -299,9 +277,100 @@ var useGateway = /* @__PURE__ */ __name((gatewayName, timeout) => {
299
277
  };
300
278
  }, "useGateway");
301
279
 
302
- // src/hooks/useAddressBalance.ts
280
+ // src/hooks/useAccountBalanceHistory.ts
281
+ import { hexToBigInt, toHex } from "@xylabs/hex";
303
282
  import { usePromise as usePromise2 } from "@xylabs/react-promise";
304
- import { isUndefined, isUndefinedOrNull } from "@xylabs/typeof";
283
+ import { isUndefined } from "@xylabs/typeof";
284
+ var formatAccountBalanceHistory = /* @__PURE__ */ __name((address, history) => {
285
+ let results = [];
286
+ for (const item of history) {
287
+ const [blockBw, txBw, transfer] = item;
288
+ if (address === transfer.from) {
289
+ for (const [to, amount] of Object.entries(transfer.transfers)) {
290
+ results.push({
291
+ amount: hexToBigInt(amount),
292
+ blockNumber: blockBw.block,
293
+ from: transfer.from,
294
+ timestamp: blockBw.$epoch,
295
+ key: globalThis.crypto.randomUUID(),
296
+ to,
297
+ txHash: txBw?._hash,
298
+ debug: item,
299
+ type: "send"
300
+ });
301
+ }
302
+ } else {
303
+ results.push({
304
+ amount: hexToBigInt(transfer.transfers[address]),
305
+ blockNumber: blockBw.block,
306
+ from: transfer.from,
307
+ key: globalThis.crypto.randomUUID(),
308
+ timestamp: blockBw.$epoch,
309
+ to: address,
310
+ txHash: txBw?._hash,
311
+ debug: item,
312
+ type: "receive"
313
+ });
314
+ }
315
+ }
316
+ return results;
317
+ }, "formatAccountBalanceHistory");
318
+ var findMinimumBlock = /* @__PURE__ */ __name((history) => {
319
+ if (history.length === 0) return 0;
320
+ const blockNumbers = history.map(([blockBw]) => blockBw.block);
321
+ const min = Math.min(...blockNumbers);
322
+ return Math.max(min - 1, 0);
323
+ }, "findMinimumBlock");
324
+ var balanceForRange = /* @__PURE__ */ __name((address, results) => {
325
+ const totalReceivedBalance = results?.reduce((a, [_block, _tx, transfer]) => {
326
+ return a + hexToBigInt(transfer.transfers[address] ?? toHex(0));
327
+ }, 0n);
328
+ const totalSentBalance = results?.reduce((a, [_block, _tx, transfer]) => {
329
+ return transfer.from === address ? a + Object.values(transfer.transfers).reduce((a2, v) => a2 + (v ? hexToBigInt(v) : 0n), 0n) : a;
330
+ }, 0n);
331
+ return [
332
+ totalReceivedBalance,
333
+ totalSentBalance
334
+ ];
335
+ }, "balanceForRange");
336
+ var useAccountBalanceHistory = /* @__PURE__ */ __name((address, viewer, refresh) => {
337
+ return usePromise2(async () => {
338
+ if (isUndefined(viewer) || isUndefined(address)) return;
339
+ let page = 1;
340
+ let lastBlock;
341
+ const maxPage = 10;
342
+ const pagedHistory = [];
343
+ const history = await viewer.accountBalanceHistory(address);
344
+ if (history.length > 0) {
345
+ pagedHistory.push(...history);
346
+ lastBlock = findMinimumBlock(history);
347
+ while (page < maxPage) {
348
+ const nextHistory = await viewer.accountBalanceHistory(address, [
349
+ 0,
350
+ lastBlock
351
+ ]);
352
+ if (nextHistory.length === 0) break;
353
+ lastBlock = findMinimumBlock(nextHistory);
354
+ pagedHistory.push(...nextHistory);
355
+ page++;
356
+ }
357
+ }
358
+ const formattedHistory = formatAccountBalanceHistory(address, pagedHistory);
359
+ return {
360
+ history: formattedHistory,
361
+ balance: balanceForRange(address, pagedHistory),
362
+ truncated: page >= maxPage
363
+ };
364
+ }, [
365
+ address,
366
+ viewer,
367
+ refresh
368
+ ]);
369
+ }, "useAccountBalanceHistory");
370
+
371
+ // src/hooks/useAddressBalance.ts
372
+ import { usePromise as usePromise3 } from "@xylabs/react-promise";
373
+ import { isUndefined as isUndefined2, isUndefinedOrNull } from "@xylabs/typeof";
305
374
  import { ShiftedBigInt } from "@xyo-network/xl1-protocol";
306
375
  import { useMemo, useRef, useState } from "react";
307
376
  var useAddressBalance = /* @__PURE__ */ __name((address, viewer, refresh) => {
@@ -309,8 +378,8 @@ var useAddressBalance = /* @__PURE__ */ __name((address, viewer, refresh) => {
309
378
  const [loading, setLoading] = useState(false);
310
379
  const [balancesError, setBalancesError] = useState();
311
380
  const balancePromiseRef = useRef(null);
312
- usePromise2(async () => {
313
- if (isUndefined(viewer) || isUndefined(address)) return;
381
+ usePromise3(async () => {
382
+ if (isUndefined2(viewer) || isUndefined2(address)) return;
314
383
  setLoading(true);
315
384
  setBalancesError(void 0);
316
385
  const currentPromise = viewer.accountBalance(address);
@@ -376,7 +445,7 @@ var useAddressBalance = /* @__PURE__ */ __name((address, viewer, refresh) => {
376
445
  // src/hooks/useConfirmTransactionBase.ts
377
446
  import { forget as forget2 } from "@xylabs/forget";
378
447
  import { isHash } from "@xylabs/hex";
379
- import { usePromise as usePromise3 } from "@xylabs/react-promise";
448
+ import { usePromise as usePromise4 } from "@xylabs/react-promise";
380
449
  import { isDefined as isDefined4 } from "@xylabs/typeof";
381
450
  import { PayloadBuilder } from "@xyo-network/payload-builder";
382
451
  import { useEffect, useState as useState2 } from "react";
@@ -386,7 +455,7 @@ var useConfirmTransactionBase = /* @__PURE__ */ __name((transaction, onBroadcast
386
455
  setStatus(newStatus);
387
456
  onStatusUpdate?.(newStatus);
388
457
  }, "onStatusUpdateLocal");
389
- const [transactionConfirmationStatus, transactionConfirmationError] = usePromise3(async () => {
458
+ const [transactionConfirmationStatus, transactionConfirmationError] = usePromise4(async () => {
390
459
  const hasRunner = isDefined4(runner);
391
460
  if (transaction && viewer) {
392
461
  const hash = hasRunner ? await runner.broadcastTransaction(transaction) : await PayloadBuilder.hash(transaction[0]);
@@ -438,7 +507,7 @@ var useConnectAccount = /* @__PURE__ */ __name((gatewayName = MainNetwork.id, ti
438
507
  const connectSigner = useCallback(async () => {
439
508
  try {
440
509
  const assertedGateway = assertEx2(gateway, () => `Gateway ${gatewayName} is not available`);
441
- const signer = await assertedGateway.signer();
510
+ const signer = await assertedGateway.signer;
442
511
  const address2 = await signer.address();
443
512
  setAddress(address2);
444
513
  return address2;
@@ -459,10 +528,10 @@ var useConnectAccount = /* @__PURE__ */ __name((gatewayName = MainNetwork.id, ti
459
528
  }, "useConnectAccount");
460
529
 
461
530
  // src/hooks/useCurrentBlock.ts
462
- import { usePromise as usePromise4 } from "@xylabs/react-promise";
531
+ import { usePromise as usePromise5 } from "@xylabs/react-promise";
463
532
  import { isDefinedNotNull as isDefinedNotNull2 } from "@xylabs/typeof";
464
533
  var useCurrentBlock = /* @__PURE__ */ __name((refresh = 1, viewer) => {
465
- return usePromise4(async () => {
534
+ return usePromise5(async () => {
466
535
  if (isDefinedNotNull2(viewer) && refresh > 0) {
467
536
  const block = await viewer.currentBlock();
468
537
  return block;
@@ -474,12 +543,12 @@ var useCurrentBlock = /* @__PURE__ */ __name((refresh = 1, viewer) => {
474
543
  }, "useCurrentBlock");
475
544
 
476
545
  // src/hooks/useHttpRpcRunner.ts
477
- import { isUndefined as isUndefined2 } from "@xylabs/typeof";
546
+ import { isUndefined as isUndefined3 } from "@xylabs/typeof";
478
547
  import { AllRpcSchemas, HttpRpcTransport, JsonRpcXyoRunner } from "@xyo-network/xl1-rpc";
479
548
  import { useMemo as useMemo2 } from "react";
480
549
  var useHttpRpcRunner = /* @__PURE__ */ __name((url) => {
481
550
  return useMemo2(() => {
482
- if (isUndefined2(url)) {
551
+ if (isUndefined3(url)) {
483
552
  return;
484
553
  }
485
554
  const transport = new HttpRpcTransport(`${url}/rpc`, AllRpcSchemas);
@@ -490,13 +559,13 @@ var useHttpRpcRunner = /* @__PURE__ */ __name((url) => {
490
559
  }, "useHttpRpcRunner");
491
560
 
492
561
  // src/hooks/useNetwork.ts
493
- import { isUndefined as isUndefined3 } from "@xylabs/typeof";
494
- import { MemoryXyoNetwork } from "@xyo-network/xl1-rpc";
562
+ import { isUndefined as isUndefined4 } from "@xylabs/typeof";
563
+ import { SimpleXyoNetwork } from "@xyo-network/xl1-protocol-sdk";
495
564
  import { useMemo as useMemo3 } from "react";
496
565
  var useNetwork = /* @__PURE__ */ __name((id) => {
497
566
  const network = useMemo3(() => {
498
- if (isUndefined3(id)) return;
499
- return new MemoryXyoNetwork(id);
567
+ if (isUndefined4(id)) return;
568
+ return new SimpleXyoNetwork(id);
500
569
  }, [
501
570
  id
502
571
  ]);
@@ -504,17 +573,17 @@ var useNetwork = /* @__PURE__ */ __name((id) => {
504
573
  }, "useNetwork");
505
574
 
506
575
  // src/hooks/useSigner.ts
507
- import { MemoryXyoSigner } from "@xyo-network/xl1-rpc";
576
+ import { SimpleXyoSigner } from "@xyo-network/xl1-protocol-sdk";
508
577
  import { useMemo as useMemo4 } from "react";
509
578
  var useSigner = /* @__PURE__ */ __name((_provider, account) => {
510
- return useMemo4(() => account ? new MemoryXyoSigner(account) : void 0, [
579
+ return useMemo4(() => account ? new SimpleXyoSigner(account) : void 0, [
511
580
  account
512
581
  ]);
513
582
  }, "useSigner");
514
583
 
515
584
  // src/hooks/viewer/useCheckRpc.ts
516
585
  import { delay as delay2 } from "@xylabs/delay";
517
- import { isDefined as isDefined5, isUndefined as isUndefined4 } from "@xylabs/typeof";
586
+ import { isDefined as isDefined5, isUndefined as isUndefined5 } from "@xylabs/typeof";
518
587
  import { LocalNetwork, SequenceNetwork } from "@xyo-network/chain-network-model";
519
588
  import { HttpRpcTransport as HttpRpcTransport2, JsonRpcNetworkStakeViewer, JsonRpcXyoViewer, NetworkStakeViewerRpcSchemas, XyoViewerRpcSchemas } from "@xyo-network/xl1-rpc";
520
589
  import { useEffect as useEffect2, useMemo as useMemo5, useState as useState4 } from "react";
@@ -533,7 +602,7 @@ var useCheckRpc = /* @__PURE__ */ __name((endpoint) => {
533
602
  const [isLocalProducer, setIsLocalProducer] = useState4(false);
534
603
  const [error, setError] = useState4();
535
604
  const viewer = useMemo5(() => {
536
- if (isUndefined4(endpoint)) return;
605
+ if (isUndefined5(endpoint)) return;
537
606
  const transport = new HttpRpcTransport2(endpoint, {
538
607
  ...XyoViewerRpcSchemas,
539
608
  ...NetworkStakeViewerRpcSchemas
@@ -547,7 +616,7 @@ var useCheckRpc = /* @__PURE__ */ __name((endpoint) => {
547
616
  endpoint
548
617
  ]);
549
618
  useEffect2(() => {
550
- if (isUndefined4(viewer)) return;
619
+ if (isUndefined5(viewer)) return;
551
620
  void (async () => {
552
621
  setError(void 0);
553
622
  while (!isLocalProducer) {
@@ -571,12 +640,12 @@ var useCheckRpc = /* @__PURE__ */ __name((endpoint) => {
571
640
  }, "useCheckRpc");
572
641
 
573
642
  // src/hooks/viewer/useHttpRpcViewer.ts
574
- import { isUndefined as isUndefined5 } from "@xylabs/typeof";
643
+ import { isUndefined as isUndefined6 } from "@xylabs/typeof";
575
644
  import { HttpRpcTransport as HttpRpcTransport3, JsonRpcNetworkStakeViewer as JsonRpcNetworkStakeViewer2, JsonRpcXyoViewer as JsonRpcXyoViewer2, NetworkStakeViewerRpcSchemas as NetworkStakeViewerRpcSchemas2, XyoViewerRpcSchemas as XyoViewerRpcSchemas2 } from "@xyo-network/xl1-rpc";
576
645
  import { useMemo as useMemo6 } from "react";
577
646
  var useHttpRpcViewer = /* @__PURE__ */ __name((url) => {
578
647
  const resolvedViewer = useMemo6(() => {
579
- if (isUndefined5(url)) {
648
+ if (isUndefined6(url)) {
580
649
  return;
581
650
  }
582
651
  const transport = new HttpRpcTransport3(`${url}/rpc`, {
@@ -593,34 +662,154 @@ var useHttpRpcViewer = /* @__PURE__ */ __name((url) => {
593
662
  }, "useHttpRpcViewer");
594
663
 
595
664
  // src/hooks/viewer/useViewerFromWallet.ts
596
- import { usePromise as usePromise5 } from "@xylabs/react-promise";
597
665
  import { isDefined as isDefined6, isDefinedNotNull as isDefinedNotNull3 } from "@xylabs/typeof";
598
666
  var useViewerFromWallet = /* @__PURE__ */ __name((networkId) => {
599
667
  const { gateway, error, isLoading } = useGateway(networkId);
600
- return usePromise5(async () => {
601
- if (isDefinedNotNull3(error)) return null;
602
- if (isLoading) return;
603
- if (isDefined6(gateway) && isDefined6(networkId)) {
604
- const connection = await gateway?.connection();
605
- return connection?.viewer;
606
- }
607
- }, [
608
- gateway,
609
- networkId
610
- ]);
668
+ if (isDefinedNotNull3(error)) return null;
669
+ if (isLoading) return;
670
+ if (isDefined6(gateway) && isDefined6(networkId)) {
671
+ const connection = gateway?.connection;
672
+ return connection?.viewer;
673
+ }
611
674
  }, "useViewerFromWallet");
612
675
 
676
+ // src/components/account/BalanceHistoryTable.tsx
677
+ import { Table, TableBody, TableCell, TableHead, TableRow, Tooltip } from "@mui/material";
678
+ import { isDefined as isDefined7 } from "@xylabs/typeof";
679
+ import { BlockAddressChip, BlockEpochTableCellInner, BlockNumberTableCellInner } from "@xyo-network/react-chain-blockchain";
680
+ import { RawInfoIconButton } from "@xyo-network/react-payload-raw-info";
681
+ import { XL1Amount } from "@xyo-network/xl1-protocol";
682
+ import React from "react";
683
+
684
+ // src/types/account/Table.ts
685
+ var TableHeadingLabels = [
686
+ "Tx Hash",
687
+ "BlockNumber",
688
+ "Timestamp",
689
+ "From",
690
+ "To",
691
+ "Amount",
692
+ "Debug"
693
+ ];
694
+
695
+ // src/components/account/BalanceHistoryTable.tsx
696
+ var AccountBalanceHistoryTable = /* @__PURE__ */ __name(({ history, ...props }) => {
697
+ const formatAmount = /* @__PURE__ */ __name((amount) => {
698
+ if (!isDefined7(amount)) {
699
+ return "N/A";
700
+ }
701
+ const xl1Amount = new XL1Amount(amount);
702
+ return xl1Amount.toString(void 0, {
703
+ places: 18,
704
+ maxDecimal: 12,
705
+ maxCharacters: 12,
706
+ minDecimals: 1,
707
+ locale: navigator.language
708
+ });
709
+ }, "formatAmount");
710
+ return isDefined7(history) ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Table, props, /* @__PURE__ */ React.createElement(TableHead, null, /* @__PURE__ */ React.createElement(TableRow, null, TableHeadingLabels.map((heading) => /* @__PURE__ */ React.createElement(TableCell, {
711
+ key: heading
712
+ }, heading)))), /* @__PURE__ */ React.createElement(TableBody, null, history?.map(({ amount, blockNumber, debug, from, key, timestamp, to, type, txHash }) => /* @__PURE__ */ React.createElement(TableRow, {
713
+ key
714
+ }, /* @__PURE__ */ React.createElement(TableCell, null, txHash || "N/A"), /* @__PURE__ */ React.createElement(BlockNumberTableCellInner, {
715
+ blockNumber
716
+ }), /* @__PURE__ */ React.createElement(BlockEpochTableCellInner, {
717
+ epoch: timestamp
718
+ }), /* @__PURE__ */ React.createElement(TableCell, null, /* @__PURE__ */ React.createElement(Tooltip, {
719
+ title: `From Address: ${from}`
720
+ }, /* @__PURE__ */ React.createElement(BlockAddressChip, {
721
+ address: from,
722
+ toolTipTitle: `From: ${from}`
723
+ }))), /* @__PURE__ */ React.createElement(TableCell, null, /* @__PURE__ */ React.createElement(Tooltip, {
724
+ title: `To Address: ${to}`
725
+ }, /* @__PURE__ */ React.createElement(BlockAddressChip, {
726
+ address: to,
727
+ toolTipTitle: `To: ${to}`
728
+ }))), /* @__PURE__ */ React.createElement(TableCell, null, /* @__PURE__ */ React.createElement(Tooltip, {
729
+ title: `Raw Amount: ${amount}`
730
+ }, /* @__PURE__ */ React.createElement("span", null, type === "send" ? "-" : "", formatAmount(amount)))), /* @__PURE__ */ React.createElement(TableCell, null, /* @__PURE__ */ React.createElement(RawInfoIconButton, {
731
+ rawValue: debug
732
+ }))))))) : null;
733
+ }, "AccountBalanceHistoryTable");
734
+
735
+ // src/components/account/BalanceHistoryFlexbox.tsx
736
+ var AccountBalanceHistoryFlexBox = /* @__PURE__ */ __name(({ address, refresh, viewer, ...props }) => {
737
+ const [results, error] = useAccountBalanceHistory(address, viewer, refresh);
738
+ const { history, balance, truncated } = results || {
739
+ balance: [
740
+ AttoXL1(0n),
741
+ AttoXL1(0n)
742
+ ],
743
+ history: void 0
744
+ };
745
+ const formatBalance = /* @__PURE__ */ __name((balance2) => {
746
+ const xl1Amount = new XL1Amount2(balance2);
747
+ return xl1Amount.toString(void 0, {
748
+ places: 18,
749
+ maxDecimal: 12,
750
+ maxCharacters: 12,
751
+ minDecimals: 1,
752
+ locale: navigator.language
753
+ });
754
+ }, "formatBalance");
755
+ const formatBalanceMagnitude = /* @__PURE__ */ __name((set) => {
756
+ const [received, sent] = set;
757
+ const netBalance = received - sent;
758
+ return netBalance < 0n ? `-${formatBalance(sent - received)}` : formatBalance(netBalance);
759
+ }, "formatBalanceMagnitude");
760
+ return isDefined8(history) && isDefined8(address) ? /* @__PURE__ */ React2.createElement(FlexCol, props, /* @__PURE__ */ React2.createElement(ErrorRender, {
761
+ error,
762
+ scope: "AccountBalanceHistoryTable"
763
+ }), /* @__PURE__ */ React2.createElement(Typography, {
764
+ variant: "h6",
765
+ gutterBottom: true
766
+ }, formatBalanceMagnitude(balance)), truncated ? /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(Typography, {
767
+ variant: "caption",
768
+ gutterBottom: true
769
+ }, "Ranged Balance from", " ", history.at(-1).blockNumber, " ", "-", " ", history[0].blockNumber)) : null, /* @__PURE__ */ React2.createElement(AccountBalanceHistoryTable, {
770
+ history
771
+ })) : null;
772
+ }, "AccountBalanceHistoryFlexBox");
773
+
774
+ // src/components/connected/account/Connected.tsx
775
+ import { Stack, Tooltip as Tooltip2, Typography as Typography2 } from "@mui/material";
776
+ import { EthAddressWrapper } from "@xylabs/eth-address";
777
+ import { BlockiesAvatarAddress } from "@xyo-network/react-chain-blockies";
778
+ import React3 from "react";
779
+ var ConnectedAccount = /* @__PURE__ */ __name(({ address }) => {
780
+ const shortenedAddress = `${EthAddressWrapper.fromString(address)?.toShortString(4)}`;
781
+ return /* @__PURE__ */ React3.createElement(Stack, {
782
+ direction: "row",
783
+ alignItems: "center",
784
+ spacing: 1
785
+ }, /* @__PURE__ */ React3.createElement(BlockiesAvatarAddress, {
786
+ address,
787
+ size: 21
788
+ }), /* @__PURE__ */ React3.createElement(Tooltip2, {
789
+ title: address
790
+ }, /* @__PURE__ */ React3.createElement(Typography2, {
791
+ color: "textSecondary",
792
+ variant: "caption",
793
+ fontFamily: "monospace"
794
+ }, shortenedAddress)));
795
+ }, "ConnectedAccount");
796
+
613
797
  // src/components/connected/ConnectAccountsStack.tsx
614
- var DefaultConnectComponent = /* @__PURE__ */ __name((props) => /* @__PURE__ */ React2.createElement(ButtonEx, {
798
+ import { Alert, AlertTitle, Button, Stack as Stack2, Typography as Typography3 } from "@mui/material";
799
+ import { ButtonEx } from "@xylabs/react-button";
800
+ import { isDefined as isDefined9, isUndefined as isUndefined7 } from "@xylabs/typeof";
801
+ import { ErrorRender as ErrorRender2 } from "@xyo-network/react-error";
802
+ import React4, { useEffect as useEffect3 } from "react";
803
+ var DefaultConnectComponent = /* @__PURE__ */ __name((props) => /* @__PURE__ */ React4.createElement(ButtonEx, {
615
804
  variant: "contained",
616
805
  size: "small",
617
806
  ...props
618
807
  }), "DefaultConnectComponent");
619
- var DefaultNoWalletInstalledComponent = /* @__PURE__ */ __name(() => /* @__PURE__ */ React2.createElement(Alert, {
808
+ var DefaultNoWalletInstalledComponent = /* @__PURE__ */ __name(() => /* @__PURE__ */ React4.createElement(Alert, {
620
809
  severity: "warning"
621
- }, /* @__PURE__ */ React2.createElement(AlertTitle, null, "XL1 Wallet Not Found"), /* @__PURE__ */ React2.createElement(Typography2, {
810
+ }, /* @__PURE__ */ React4.createElement(AlertTitle, null, "XL1 Wallet Not Found"), /* @__PURE__ */ React4.createElement(Typography3, {
622
811
  gutterBottom: true
623
- }, "Please ensure that your XL1 Wallet is installed to connect your account."), /* @__PURE__ */ React2.createElement(Button, {
812
+ }, "Please ensure that your XL1 Wallet is installed to connect your account."), /* @__PURE__ */ React4.createElement(Button, {
624
813
  sx: {
625
814
  display: "flex",
626
815
  justifySelf: "end"
@@ -634,7 +823,7 @@ var DefaultNoWalletInstalledComponent = /* @__PURE__ */ __name(() => /* @__PURE_
634
823
  var ConnectAccountsStack = /* @__PURE__ */ __name(({ AccountComponent = ConnectedAccount, ConnectComponent = DefaultConnectComponent, NoWalletInstalledComponent = DefaultNoWalletInstalledComponent, onAccountConnected, onCancel, timeout, ...props }) => {
635
824
  const { address, connectSigner, error, timedout } = useConnectAccount(void 0, timeout);
636
825
  useEffect3(() => {
637
- if (isDefined7(error) && isDefined7(onCancel)) {
826
+ if (isDefined9(error) && isDefined9(onCancel)) {
638
827
  onCancel();
639
828
  }
640
829
  }, [
@@ -642,33 +831,38 @@ var ConnectAccountsStack = /* @__PURE__ */ __name(({ AccountComponent = Connecte
642
831
  onCancel
643
832
  ]);
644
833
  useEffect3(() => {
645
- if (isDefined7(address) && isDefined7(onAccountConnected)) {
834
+ if (isDefined9(address) && isDefined9(onAccountConnected)) {
646
835
  onAccountConnected(address);
647
836
  }
648
837
  }, [
649
838
  address,
650
839
  onAccountConnected
651
840
  ]);
652
- return /* @__PURE__ */ React2.createElement(Stack2, {
841
+ return /* @__PURE__ */ React4.createElement(Stack2, {
653
842
  direction: "row",
654
843
  alignItems: "start",
655
844
  spacing: 2,
656
845
  ...props
657
- }, isDefined7(address) ? /* @__PURE__ */ React2.createElement(AccountComponent, {
846
+ }, isDefined9(address) ? /* @__PURE__ */ React4.createElement(AccountComponent, {
658
847
  address
659
- }) : null, isUndefined6(address) && !timedout ? /* @__PURE__ */ React2.createElement(ConnectComponent, {
848
+ }) : null, isUndefined7(address) && !timedout ? /* @__PURE__ */ React4.createElement(ConnectComponent, {
660
849
  onClick: /* @__PURE__ */ __name(() => void connectSigner(), "onClick")
661
- }, "Connect") : null, isUndefined6(address) && timedout ? /* @__PURE__ */ React2.createElement(NoWalletInstalledComponent, null) : null, /* @__PURE__ */ React2.createElement(ErrorRender, {
850
+ }, "Connect") : null, isUndefined7(address) && timedout ? /* @__PURE__ */ React4.createElement(NoWalletInstalledComponent, null) : null, /* @__PURE__ */ React4.createElement(ErrorRender2, {
662
851
  error,
663
852
  scope: "ConnectSigner:error"
664
853
  }));
665
854
  }, "ConnectAccountsStack");
666
855
  export {
856
+ AccountBalanceHistoryFlexBox,
857
+ AccountBalanceHistoryTable,
667
858
  ConnectAccountsStack,
668
859
  ConnectedAccount,
860
+ TableHeadingLabels,
669
861
  TransactionConfirmationStatus,
862
+ formatAccountBalanceHistory,
670
863
  getXyoClient,
671
864
  listenForClientInjection,
865
+ useAccountBalanceHistory,
672
866
  useAccountPermissions,
673
867
  useAddressBalance,
674
868
  useCheckLocalRpc,