@xyo-network/react-chain-provider 1.16.2 → 1.16.4

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 (46) 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/index.d.ts +1 -0
  12. package/dist/browser/hooks/index.d.ts.map +1 -1
  13. package/dist/browser/hooks/useAccountBalanceHistory.d.ts +11 -0
  14. package/dist/browser/hooks/useAccountBalanceHistory.d.ts.map +1 -0
  15. package/dist/browser/hooks/viewer/useViewerFromWallet.d.ts +1 -1
  16. package/dist/browser/hooks/viewer/useViewerFromWallet.d.ts.map +1 -1
  17. package/dist/browser/index.d.ts +1 -0
  18. package/dist/browser/index.d.ts.map +1 -1
  19. package/dist/browser/index.mjs +268 -62
  20. package/dist/browser/index.mjs.map +1 -1
  21. package/dist/browser/types/account/BalanceHistoryItemRow.d.ts +14 -0
  22. package/dist/browser/types/account/BalanceHistoryItemRow.d.ts.map +1 -0
  23. package/dist/browser/types/account/Table.d.ts +7 -0
  24. package/dist/browser/types/account/Table.d.ts.map +1 -0
  25. package/dist/browser/types/account/index.d.ts +3 -0
  26. package/dist/browser/types/account/index.d.ts.map +1 -0
  27. package/dist/browser/types/index.d.ts +2 -0
  28. package/dist/browser/types/index.d.ts.map +1 -0
  29. package/package.json +11 -8
  30. package/src/components/account/BalanceHistoryFlexbox.stories.tsx +25 -0
  31. package/src/components/account/BalanceHistoryFlexbox.tsx +65 -0
  32. package/src/components/account/BalanceHistoryTable.tsx +79 -0
  33. package/src/components/account/index.ts +2 -0
  34. package/src/components/connected/ConnectAccountsStack.stories.tsx +1 -1
  35. package/src/components/index.ts +1 -0
  36. package/src/hooks/index.ts +1 -0
  37. package/src/hooks/useAccountBalanceHistory.ts +104 -0
  38. package/src/hooks/useConnectAccount.ts +1 -1
  39. package/src/hooks/viewer/UseStepRewardWeightTest.stories.tsx +1 -1
  40. package/src/hooks/viewer/useViewerFromWallet.stories.tsx +1 -1
  41. package/src/hooks/viewer/useViewerFromWallet.ts +9 -6
  42. package/src/index.ts +1 -0
  43. package/src/types/account/BalanceHistoryItemRow.ts +14 -0
  44. package/src/types/account/Table.ts +14 -0
  45. package/src/types/account/index.ts +2 -0
  46. package/src/types/index.ts +1 -0
@@ -0,0 +1,11 @@
1
+ import { type Address } from '@xylabs/hex';
2
+ import type { FlexBoxProps } from '@xylabs/react-flexbox';
3
+ import type { XyoViewer } from '@xyo-network/xl1-protocol-sdk';
4
+ import React from 'react';
5
+ export interface AccountBalanceHistoryFlexBoxProps extends FlexBoxProps {
6
+ address?: Address;
7
+ refresh?: number;
8
+ viewer?: XyoViewer;
9
+ }
10
+ export declare const AccountBalanceHistoryFlexBox: React.FC<AccountBalanceHistoryFlexBoxProps>;
11
+ //# sourceMappingURL=BalanceHistoryFlexbox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BalanceHistoryFlexbox.d.ts","sourceRoot":"","sources":["../../../../src/components/account/BalanceHistoryFlexbox.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAKzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAA;AAC9D,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,MAAM,WAAW,iCAAkC,SAAQ,YAAY;IACrE,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,SAAS,CAAA;CACnB;AAED,eAAO,MAAM,4BAA4B,EAAE,KAAK,CAAC,EAAE,CAAC,iCAAiC,CA6CpF,CAAA"}
@@ -0,0 +1,6 @@
1
+ import type { Meta } from '@storybook/react-vite';
2
+ declare const _default: Meta;
3
+ export default _default;
4
+ declare const Default: import("storybook/internal/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, import("./BalanceHistoryFlexbox.tsx").AccountBalanceHistoryFlexBoxProps>;
5
+ export { Default };
6
+ //# sourceMappingURL=BalanceHistoryFlexbox.stories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BalanceHistoryFlexbox.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/account/BalanceHistoryFlexbox.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAW,MAAM,uBAAuB,CAAA;wBAWrD,IAAI;AAHT,wBAGS;AAOT,QAAA,MAAM,OAAO,sKAAoB,CAAA;AAMjC,OAAO,EAAE,OAAO,EAAE,CAAA"}
@@ -0,0 +1,8 @@
1
+ import type { TableProps } from '@mui/material';
2
+ import React from 'react';
3
+ import type { AccountBalanceHistoryItemRow } from '../../types/index.ts';
4
+ export interface AccountBalanceHistoryTableProps extends TableProps {
5
+ history?: AccountBalanceHistoryItemRow[];
6
+ }
7
+ export declare const AccountBalanceHistoryTable: React.FC<AccountBalanceHistoryTableProps>;
8
+ //# sourceMappingURL=BalanceHistoryTable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BalanceHistoryTable.d.ts","sourceRoot":"","sources":["../../../../src/components/account/BalanceHistoryTable.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAa/C,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAA;AAGxE,MAAM,WAAW,+BAAgC,SAAQ,UAAU;IACjE,OAAO,CAAC,EAAE,4BAA4B,EAAE,CAAA;CACzC;AAED,eAAO,MAAM,0BAA0B,EAAE,KAAK,CAAC,EAAE,CAAC,+BAA+B,CAwDhF,CAAA"}
@@ -0,0 +1,3 @@
1
+ export * from './BalanceHistoryFlexbox.tsx';
2
+ export * from './BalanceHistoryTable.tsx';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/account/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAA;AAC3C,cAAc,2BAA2B,CAAA"}
@@ -1,2 +1,3 @@
1
+ export * from './account/index.ts';
1
2
  export * from './connected/index.ts';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA"}
@@ -1,5 +1,6 @@
1
1
  export * from './client/index.ts';
2
2
  export * from './helpers/index.ts';
3
+ export * from './useAccountBalanceHistory.ts';
3
4
  export * from './useAddressBalance.ts';
4
5
  export * from './useConfirmTransactionBase.ts';
5
6
  export * from './useConnectAccount.ts';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,oBAAoB,CAAA;AAClC,cAAc,wBAAwB,CAAA;AACtC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,wBAAwB,CAAA;AACtC,cAAc,sBAAsB,CAAA;AACpC,cAAc,uBAAuB,CAAA;AACrC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,oBAAoB,CAAA;AAClC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,wBAAwB,CAAA;AACtC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,wBAAwB,CAAA;AACtC,cAAc,sBAAsB,CAAA;AACpC,cAAc,uBAAuB,CAAA;AACrC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA"}
@@ -0,0 +1,11 @@
1
+ import { type Address } from '@xylabs/hex';
2
+ import type { AttoXL1 } from '@xyo-network/xl1-protocol';
3
+ import type { AccountBalanceHistoryItem, XyoViewer } from '@xyo-network/xl1-protocol-sdk';
4
+ import type { AccountBalanceHistoryItemRow } from '../types/index.ts';
5
+ export declare const formatAccountBalanceHistory: (address: Address, history: AccountBalanceHistoryItem[]) => AccountBalanceHistoryItemRow[];
6
+ export declare const useAccountBalanceHistory: (address?: Address, viewer?: XyoViewer, refresh?: number) => [{
7
+ history: AccountBalanceHistoryItemRow[];
8
+ balance: [AttoXL1, AttoXL1];
9
+ truncated: boolean;
10
+ } | undefined, Error | undefined, import("@xylabs/react-promise").UsePromiseState | undefined];
11
+ //# sourceMappingURL=useAccountBalanceHistory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAccountBalanceHistory.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAccountBalanceHistory.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EAGb,MAAM,aAAa,CAAA;AAGpB,OAAO,KAAK,EAAE,OAAO,EAAiB,MAAM,2BAA2B,CAAA;AACvE,OAAO,KAAK,EAAE,yBAAyB,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAA;AAEzF,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,mBAAmB,CAAA;AAErE,eAAO,MAAM,2BAA2B,GAAI,SAAS,OAAO,EAAE,SAAS,yBAAyB,EAAE,KAAG,4BAA4B,EAiChI,CAAA;AAqBD,eAAO,MAAM,wBAAwB,GAAI,UAAU,OAAO,EAAE,SAAS,SAAS,EAAE,UAAU,MAAM;;;;8FAqC/F,CAAA"}
@@ -5,5 +5,5 @@ import type { GatewayName } from '@xyo-network/xl1-protocol';
5
5
  * @returns An instance of XyoViewer if the networkId is found in wallet gateways
6
6
  * otherwise undefined.
7
7
  */
8
- export declare const useViewerFromWallet: (networkId?: GatewayName) => import("@xyo-network/xl1-protocol-sdk").XyoViewer | null | undefined;
8
+ export declare const useViewerFromWallet: (networkId?: GatewayName) => [import("@xyo-network/xl1-protocol-sdk").XyoViewer | null | undefined, Error | undefined, import("@xylabs/react-promise").UsePromiseState | undefined];
9
9
  //# sourceMappingURL=useViewerFromWallet.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useViewerFromWallet.d.ts","sourceRoot":"","sources":["../../../../src/hooks/viewer/useViewerFromWallet.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAI5D;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAAI,YAAY,WAAW,yEAW1D,CAAA"}
1
+ {"version":3,"file":"useViewerFromWallet.d.ts","sourceRoot":"","sources":["../../../../src/hooks/viewer/useViewerFromWallet.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAI5D;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAAI,YAAY,WAAW,2JAa1D,CAAA"}
@@ -1,3 +1,4 @@
1
1
  export * from './components/index.ts';
2
2
  export * from './hooks/index.ts';
3
+ export * from './types/index.ts';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA"}
@@ -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,12 +559,12 @@ var useHttpRpcRunner = /* @__PURE__ */ __name((url) => {
490
559
  }, "useHttpRpcRunner");
491
560
 
492
561
  // src/hooks/useNetwork.ts
493
- import { isUndefined as isUndefined3 } from "@xylabs/typeof";
562
+ import { isUndefined as isUndefined4 } from "@xylabs/typeof";
494
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;
567
+ if (isUndefined4(id)) return;
499
568
  return new SimpleXyoNetwork(id);
500
569
  }, [
501
570
  id
@@ -514,7 +583,7 @@ var useSigner = /* @__PURE__ */ __name((_provider, account) => {
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,28 +662,160 @@ var useHttpRpcViewer = /* @__PURE__ */ __name((url) => {
593
662
  }, "useHttpRpcViewer");
594
663
 
595
664
  // src/hooks/viewer/useViewerFromWallet.ts
665
+ import { usePromise as usePromise6 } from "@xylabs/react-promise";
596
666
  import { isDefined as isDefined6, isDefinedNotNull as isDefinedNotNull3 } from "@xylabs/typeof";
597
667
  var useViewerFromWallet = /* @__PURE__ */ __name((networkId) => {
598
668
  const { gateway, error, isLoading } = useGateway(networkId);
599
- if (isDefinedNotNull3(error)) return null;
600
- if (isLoading) return;
601
- if (isDefined6(gateway) && isDefined6(networkId)) {
602
- const connection = gateway?.connection;
603
- return connection?.viewer;
604
- }
669
+ return usePromise6(async () => {
670
+ if (isDefinedNotNull3(error)) return null;
671
+ if (isLoading) return;
672
+ if (isDefined6(gateway) && isDefined6(networkId)) {
673
+ const connection = await gateway?.connection();
674
+ return connection?.viewer;
675
+ }
676
+ }, [
677
+ gateway,
678
+ networkId
679
+ ]);
605
680
  }, "useViewerFromWallet");
606
681
 
682
+ // src/components/account/BalanceHistoryTable.tsx
683
+ import { Table, TableBody, TableCell, TableHead, TableRow, Tooltip } from "@mui/material";
684
+ import { isDefined as isDefined7 } from "@xylabs/typeof";
685
+ import { BlockAddressChip, BlockEpochTableCellInner, BlockNumberTableCellInner } from "@xyo-network/react-chain-blockchain";
686
+ import { RawInfoIconButton } from "@xyo-network/react-payload-raw-info";
687
+ import { XL1Amount } from "@xyo-network/xl1-protocol";
688
+ import React from "react";
689
+
690
+ // src/types/account/Table.ts
691
+ var TableHeadingLabels = [
692
+ "Tx Hash",
693
+ "BlockNumber",
694
+ "Timestamp",
695
+ "From",
696
+ "To",
697
+ "Amount",
698
+ "Debug"
699
+ ];
700
+
701
+ // src/components/account/BalanceHistoryTable.tsx
702
+ var AccountBalanceHistoryTable = /* @__PURE__ */ __name(({ history, ...props }) => {
703
+ const formatAmount = /* @__PURE__ */ __name((amount) => {
704
+ if (!isDefined7(amount)) {
705
+ return "N/A";
706
+ }
707
+ const xl1Amount = new XL1Amount(amount);
708
+ return xl1Amount.toString(void 0, {
709
+ places: 18,
710
+ maxDecimal: 12,
711
+ maxCharacters: 12,
712
+ minDecimals: 1,
713
+ locale: navigator.language
714
+ });
715
+ }, "formatAmount");
716
+ return isDefined7(history) ? /* @__PURE__ */ React.createElement(Table, props, /* @__PURE__ */ React.createElement(TableHead, null, /* @__PURE__ */ React.createElement(TableRow, null, TableHeadingLabels.map((heading) => /* @__PURE__ */ React.createElement(TableCell, {
717
+ key: heading
718
+ }, heading)))), /* @__PURE__ */ React.createElement(TableBody, null, history?.map(({ amount, blockNumber, debug, from, key, timestamp, to, type, txHash }) => /* @__PURE__ */ React.createElement(TableRow, {
719
+ key
720
+ }, /* @__PURE__ */ React.createElement(TableCell, null, txHash || "N/A"), /* @__PURE__ */ React.createElement(BlockNumberTableCellInner, {
721
+ blockNumber
722
+ }), /* @__PURE__ */ React.createElement(BlockEpochTableCellInner, {
723
+ epoch: timestamp
724
+ }), /* @__PURE__ */ React.createElement(TableCell, null, /* @__PURE__ */ React.createElement(Tooltip, {
725
+ title: `From Address: ${from}`
726
+ }, /* @__PURE__ */ React.createElement(BlockAddressChip, {
727
+ address: from,
728
+ toolTipTitle: `From: ${from}`
729
+ }))), /* @__PURE__ */ React.createElement(TableCell, null, /* @__PURE__ */ React.createElement(Tooltip, {
730
+ title: `To Address: ${to}`
731
+ }, /* @__PURE__ */ React.createElement(BlockAddressChip, {
732
+ address: to,
733
+ toolTipTitle: `To: ${to}`
734
+ }))), /* @__PURE__ */ React.createElement(TableCell, null, /* @__PURE__ */ React.createElement(Tooltip, {
735
+ title: `Raw Amount: ${amount}`
736
+ }, /* @__PURE__ */ React.createElement("span", null, type === "send" ? "-" : "", formatAmount(amount)))), /* @__PURE__ */ React.createElement(TableCell, null, /* @__PURE__ */ React.createElement(RawInfoIconButton, {
737
+ rawValue: debug
738
+ })))))) : null;
739
+ }, "AccountBalanceHistoryTable");
740
+
741
+ // src/components/account/BalanceHistoryFlexbox.tsx
742
+ var AccountBalanceHistoryFlexBox = /* @__PURE__ */ __name(({ address, refresh, viewer, ...props }) => {
743
+ const [results, error] = useAccountBalanceHistory(address, viewer, refresh);
744
+ const { history, balance, truncated } = results || {
745
+ balance: [
746
+ AttoXL1(0n),
747
+ AttoXL1(0n)
748
+ ],
749
+ history: void 0
750
+ };
751
+ const formatBalance = /* @__PURE__ */ __name((balance2) => {
752
+ const xl1Amount = new XL1Amount2(balance2);
753
+ return xl1Amount.toString(void 0, {
754
+ places: 18,
755
+ maxDecimal: 12,
756
+ maxCharacters: 12,
757
+ minDecimals: 1,
758
+ locale: navigator.language
759
+ });
760
+ }, "formatBalance");
761
+ const formatBalanceMagnitude = /* @__PURE__ */ __name((set) => {
762
+ const [received, sent] = set;
763
+ const netBalance = received - sent;
764
+ return netBalance < 0n ? `-${formatBalance(sent - received)}` : formatBalance(netBalance);
765
+ }, "formatBalanceMagnitude");
766
+ return isDefined8(history) && isDefined8(address) ? /* @__PURE__ */ React2.createElement(FlexCol, props, /* @__PURE__ */ React2.createElement(ErrorRender, {
767
+ error,
768
+ scope: "AccountBalanceHistoryTable"
769
+ }), /* @__PURE__ */ React2.createElement(Typography, {
770
+ variant: "h6",
771
+ gutterBottom: true
772
+ }, formatBalanceMagnitude(balance)), truncated ? /* @__PURE__ */ React2.createElement(Typography, {
773
+ variant: "caption",
774
+ gutterBottom: true
775
+ }, "Ranged Balance from", " ", history.at(-1).blockNumber, " ", "-", " ", history[0].blockNumber) : null, /* @__PURE__ */ React2.createElement(AccountBalanceHistoryTable, {
776
+ history
777
+ })) : null;
778
+ }, "AccountBalanceHistoryFlexBox");
779
+
780
+ // src/components/connected/account/Connected.tsx
781
+ import { Stack, Tooltip as Tooltip2, Typography as Typography2 } from "@mui/material";
782
+ import { EthAddressWrapper } from "@xylabs/eth-address";
783
+ import { BlockiesAvatarAddress } from "@xyo-network/react-chain-blockies";
784
+ import React3 from "react";
785
+ var ConnectedAccount = /* @__PURE__ */ __name(({ address }) => {
786
+ const shortenedAddress = `${EthAddressWrapper.fromString(address)?.toShortString(4)}`;
787
+ return /* @__PURE__ */ React3.createElement(Stack, {
788
+ direction: "row",
789
+ alignItems: "center",
790
+ spacing: 1
791
+ }, /* @__PURE__ */ React3.createElement(BlockiesAvatarAddress, {
792
+ address,
793
+ size: 21
794
+ }), /* @__PURE__ */ React3.createElement(Tooltip2, {
795
+ title: address
796
+ }, /* @__PURE__ */ React3.createElement(Typography2, {
797
+ color: "textSecondary",
798
+ variant: "caption",
799
+ fontFamily: "monospace"
800
+ }, shortenedAddress)));
801
+ }, "ConnectedAccount");
802
+
607
803
  // src/components/connected/ConnectAccountsStack.tsx
608
- var DefaultConnectComponent = /* @__PURE__ */ __name((props) => /* @__PURE__ */ React2.createElement(ButtonEx, {
804
+ import { Alert, AlertTitle, Button, Stack as Stack2, Typography as Typography3 } from "@mui/material";
805
+ import { ButtonEx } from "@xylabs/react-button";
806
+ import { isDefined as isDefined9, isUndefined as isUndefined7 } from "@xylabs/typeof";
807
+ import { ErrorRender as ErrorRender2 } from "@xyo-network/react-error";
808
+ import React4, { useEffect as useEffect3 } from "react";
809
+ var DefaultConnectComponent = /* @__PURE__ */ __name((props) => /* @__PURE__ */ React4.createElement(ButtonEx, {
609
810
  variant: "contained",
610
811
  size: "small",
611
812
  ...props
612
813
  }), "DefaultConnectComponent");
613
- var DefaultNoWalletInstalledComponent = /* @__PURE__ */ __name(() => /* @__PURE__ */ React2.createElement(Alert, {
814
+ var DefaultNoWalletInstalledComponent = /* @__PURE__ */ __name(() => /* @__PURE__ */ React4.createElement(Alert, {
614
815
  severity: "warning"
615
- }, /* @__PURE__ */ React2.createElement(AlertTitle, null, "XL1 Wallet Not Found"), /* @__PURE__ */ React2.createElement(Typography2, {
816
+ }, /* @__PURE__ */ React4.createElement(AlertTitle, null, "XL1 Wallet Not Found"), /* @__PURE__ */ React4.createElement(Typography3, {
616
817
  gutterBottom: true
617
- }, "Please ensure that your XL1 Wallet is installed to connect your account."), /* @__PURE__ */ React2.createElement(Button, {
818
+ }, "Please ensure that your XL1 Wallet is installed to connect your account."), /* @__PURE__ */ React4.createElement(Button, {
618
819
  sx: {
619
820
  display: "flex",
620
821
  justifySelf: "end"
@@ -628,7 +829,7 @@ var DefaultNoWalletInstalledComponent = /* @__PURE__ */ __name(() => /* @__PURE_
628
829
  var ConnectAccountsStack = /* @__PURE__ */ __name(({ AccountComponent = ConnectedAccount, ConnectComponent = DefaultConnectComponent, NoWalletInstalledComponent = DefaultNoWalletInstalledComponent, onAccountConnected, onCancel, timeout, ...props }) => {
629
830
  const { address, connectSigner, error, timedout } = useConnectAccount(void 0, timeout);
630
831
  useEffect3(() => {
631
- if (isDefined7(error) && isDefined7(onCancel)) {
832
+ if (isDefined9(error) && isDefined9(onCancel)) {
632
833
  onCancel();
633
834
  }
634
835
  }, [
@@ -636,33 +837,38 @@ var ConnectAccountsStack = /* @__PURE__ */ __name(({ AccountComponent = Connecte
636
837
  onCancel
637
838
  ]);
638
839
  useEffect3(() => {
639
- if (isDefined7(address) && isDefined7(onAccountConnected)) {
840
+ if (isDefined9(address) && isDefined9(onAccountConnected)) {
640
841
  onAccountConnected(address);
641
842
  }
642
843
  }, [
643
844
  address,
644
845
  onAccountConnected
645
846
  ]);
646
- return /* @__PURE__ */ React2.createElement(Stack2, {
847
+ return /* @__PURE__ */ React4.createElement(Stack2, {
647
848
  direction: "row",
648
849
  alignItems: "start",
649
850
  spacing: 2,
650
851
  ...props
651
- }, isDefined7(address) ? /* @__PURE__ */ React2.createElement(AccountComponent, {
852
+ }, isDefined9(address) ? /* @__PURE__ */ React4.createElement(AccountComponent, {
652
853
  address
653
- }) : null, isUndefined6(address) && !timedout ? /* @__PURE__ */ React2.createElement(ConnectComponent, {
854
+ }) : null, isUndefined7(address) && !timedout ? /* @__PURE__ */ React4.createElement(ConnectComponent, {
654
855
  onClick: /* @__PURE__ */ __name(() => void connectSigner(), "onClick")
655
- }, "Connect") : null, isUndefined6(address) && timedout ? /* @__PURE__ */ React2.createElement(NoWalletInstalledComponent, null) : null, /* @__PURE__ */ React2.createElement(ErrorRender, {
856
+ }, "Connect") : null, isUndefined7(address) && timedout ? /* @__PURE__ */ React4.createElement(NoWalletInstalledComponent, null) : null, /* @__PURE__ */ React4.createElement(ErrorRender2, {
656
857
  error,
657
858
  scope: "ConnectSigner:error"
658
859
  }));
659
860
  }, "ConnectAccountsStack");
660
861
  export {
862
+ AccountBalanceHistoryFlexBox,
863
+ AccountBalanceHistoryTable,
661
864
  ConnectAccountsStack,
662
865
  ConnectedAccount,
866
+ TableHeadingLabels,
663
867
  TransactionConfirmationStatus,
868
+ formatAccountBalanceHistory,
664
869
  getXyoClient,
665
870
  listenForClientInjection,
871
+ useAccountBalanceHistory,
666
872
  useAccountPermissions,
667
873
  useAddressBalance,
668
874
  useCheckLocalRpc,