@xyo-network/react-chain-provider 1.16.8 → 1.16.10

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 (55) hide show
  1. package/dist/browser/components/index.d.ts +0 -1
  2. package/dist/browser/components/index.d.ts.map +1 -1
  3. package/dist/browser/{types/account/BalanceHistoryItemRow.d.ts → hooks/account/BalanceHistoryItemFormatted.d.ts} +4 -3
  4. package/dist/browser/hooks/account/BalanceHistoryItemFormatted.d.ts.map +1 -0
  5. package/dist/browser/hooks/account/index.d.ts +3 -0
  6. package/dist/browser/hooks/account/index.d.ts.map +1 -0
  7. package/dist/browser/hooks/{useAccountBalanceHistory.d.ts → account/useAccountBalanceHistory.d.ts} +3 -3
  8. package/dist/browser/hooks/account/useAccountBalanceHistory.d.ts.map +1 -0
  9. package/dist/browser/hooks/index.d.ts +1 -1
  10. package/dist/browser/hooks/index.d.ts.map +1 -1
  11. package/dist/browser/hooks/useAddressBalance.d.ts +1 -3
  12. package/dist/browser/hooks/useAddressBalance.d.ts.map +1 -1
  13. package/dist/browser/hooks/useConnectAccount.d.ts +3 -6
  14. package/dist/browser/hooks/useConnectAccount.d.ts.map +1 -1
  15. package/dist/browser/index.d.ts +0 -1
  16. package/dist/browser/index.d.ts.map +1 -1
  17. package/dist/browser/index.mjs +142 -249
  18. package/dist/browser/index.mjs.map +1 -1
  19. package/dist/browser/lib/balanceForRange.d.ts.map +1 -1
  20. package/package.json +15 -16
  21. package/src/components/index.ts +0 -1
  22. package/src/{types/account/BalanceHistoryItemRow.ts → hooks/account/BalanceHistoryItemFormatted.ts} +4 -2
  23. package/src/hooks/account/index.ts +2 -0
  24. package/src/hooks/{useAccountBalanceHistory.ts → account/useAccountBalanceHistory.ts} +4 -4
  25. package/src/hooks/index.ts +1 -1
  26. package/src/hooks/useConnectAccount.ts +1 -1
  27. package/src/hooks/viewer/UseStepRewardWeightTest.stories.tsx +1 -1
  28. package/src/hooks/viewer/useCheckRpc.ts +1 -1
  29. package/src/hooks/viewer/useHttpRpcViewer.stories.tsx +1 -1
  30. package/src/hooks/viewer/useViewerFromWallet.stories.tsx +1 -1
  31. package/src/index.ts +0 -1
  32. package/src/lib/balanceForRange.ts +4 -2
  33. package/dist/browser/components/account/BalanceHistoryFlexbox.d.ts +0 -11
  34. package/dist/browser/components/account/BalanceHistoryFlexbox.d.ts.map +0 -1
  35. package/dist/browser/components/account/BalanceHistoryFlexbox.stories.d.ts +0 -6
  36. package/dist/browser/components/account/BalanceHistoryFlexbox.stories.d.ts.map +0 -1
  37. package/dist/browser/components/account/BalanceHistoryTable.d.ts +0 -8
  38. package/dist/browser/components/account/BalanceHistoryTable.d.ts.map +0 -1
  39. package/dist/browser/components/account/index.d.ts +0 -3
  40. package/dist/browser/components/account/index.d.ts.map +0 -1
  41. package/dist/browser/hooks/useAccountBalanceHistory.d.ts.map +0 -1
  42. package/dist/browser/types/account/BalanceHistoryItemRow.d.ts.map +0 -1
  43. package/dist/browser/types/account/Table.d.ts +0 -7
  44. package/dist/browser/types/account/Table.d.ts.map +0 -1
  45. package/dist/browser/types/account/index.d.ts +0 -3
  46. package/dist/browser/types/account/index.d.ts.map +0 -1
  47. package/dist/browser/types/index.d.ts +0 -2
  48. package/dist/browser/types/index.d.ts.map +0 -1
  49. package/src/components/account/BalanceHistoryFlexbox.stories.tsx +0 -25
  50. package/src/components/account/BalanceHistoryFlexbox.tsx +0 -65
  51. package/src/components/account/BalanceHistoryTable.tsx +0 -78
  52. package/src/components/account/index.ts +0 -2
  53. package/src/types/account/Table.ts +0 -14
  54. package/src/types/account/index.ts +0 -2
  55. package/src/types/index.ts +0 -1
@@ -1,3 +1,2 @@
1
- export * from './account/index.ts';
2
1
  export * from './connected/index.ts';
3
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA"}
@@ -1,6 +1,7 @@
1
1
  import type { Address, Hash } from '@xylabs/hex';
2
2
  import type { AccountBalanceHistoryItem } from '@xyo-network/xl1-protocol-sdk';
3
- export interface AccountBalanceHistoryItemRow {
3
+ export type BalanceTransactionType = 'send' | 'receive';
4
+ export interface AccountBalanceHistoryItemFormatted {
4
5
  amount: bigint;
5
6
  blockNumber: number;
6
7
  debug: AccountBalanceHistoryItem;
@@ -9,6 +10,6 @@ export interface AccountBalanceHistoryItemRow {
9
10
  timestamp: number;
10
11
  to: Address;
11
12
  txHash: Hash | undefined;
12
- type: 'send' | 'receive';
13
+ type: BalanceTransactionType;
13
14
  }
14
- //# sourceMappingURL=BalanceHistoryItemRow.d.ts.map
15
+ //# sourceMappingURL=BalanceHistoryItemFormatted.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BalanceHistoryItemFormatted.d.ts","sourceRoot":"","sources":["../../../../src/hooks/account/BalanceHistoryItemFormatted.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAA;AAE9E,MAAM,MAAM,sBAAsB,GAAG,MAAM,GAAG,SAAS,CAAA;AAEvD,MAAM,WAAW,kCAAkC;IACjD,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,yBAAyB,CAAA;IAChC,IAAI,EAAE,OAAO,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,EAAE,MAAM,CAAA;IACjB,EAAE,EAAE,OAAO,CAAA;IACX,MAAM,EAAE,IAAI,GAAG,SAAS,CAAA;IACxB,IAAI,EAAE,sBAAsB,CAAA;CAC7B"}
@@ -0,0 +1,3 @@
1
+ export * from './BalanceHistoryItemFormatted.ts';
2
+ export * from './useAccountBalanceHistory.ts';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/account/index.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAA;AAChD,cAAc,+BAA+B,CAAA"}
@@ -1,9 +1,9 @@
1
1
  import { type Address } from '@xylabs/hex';
2
2
  import type { AccountBalanceHistoryItem, XyoViewer } from '@xyo-network/xl1-protocol-sdk';
3
- import type { AccountBalanceHistoryItemRow } from '../types/index.ts';
4
- export declare const formatAccountBalanceHistory: (address: Address, history: AccountBalanceHistoryItem[]) => AccountBalanceHistoryItemRow[];
3
+ import type { AccountBalanceHistoryItemFormatted } from './BalanceHistoryItemFormatted.ts';
4
+ export declare const formatAccountBalanceHistory: (address: Address, history: AccountBalanceHistoryItem[]) => AccountBalanceHistoryItemFormatted[];
5
5
  export declare const useAccountBalanceHistory: (address?: Address, viewer?: XyoViewer, refresh?: number) => [{
6
- history: AccountBalanceHistoryItemRow[];
6
+ history: AccountBalanceHistoryItemFormatted[];
7
7
  balance: [import("@xyo-network/xl1-protocol").AttoXL1, import("@xyo-network/xl1-protocol").AttoXL1];
8
8
  truncated: boolean;
9
9
  } | undefined, Error | undefined, import("@xylabs/react-promise").UsePromiseState | undefined];
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAccountBalanceHistory.d.ts","sourceRoot":"","sources":["../../../../src/hooks/account/useAccountBalanceHistory.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EAEb,MAAM,aAAa,CAAA;AAIpB,OAAO,KAAK,EAAE,yBAAyB,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAA;AAGzF,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,kCAAkC,CAAA;AAE1F,eAAO,MAAM,2BAA2B,GAAI,SAAS,OAAO,EAAE,SAAS,yBAAyB,EAAE,KAAG,kCAAkC,EAiCtI,CAAA;AAED,eAAO,MAAM,wBAAwB,GAAI,UAAU,OAAO,EAAE,SAAS,SAAS,EAAE,UAAU,MAAM;;;;8FAqC/F,CAAA"}
@@ -1,6 +1,6 @@
1
+ export * from './account/index.ts';
1
2
  export * from './client/index.ts';
2
3
  export * from './helpers/index.ts';
3
- export * from './useAccountBalanceHistory.ts';
4
4
  export * from './useAddressBalance.ts';
5
5
  export * from './useConfirmTransactionBase.ts';
6
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,+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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,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"}
@@ -2,9 +2,7 @@ import type { Address } from '@xylabs/hex';
2
2
  import type { AttoXL1 } from '@xyo-network/xl1-protocol';
3
3
  import type { XyoViewer } from '@xyo-network/xl1-protocol-sdk';
4
4
  export declare const useAddressBalance: (address?: Address, viewer?: XyoViewer, refresh?: number) => {
5
- address: import("@xylabs/typeof").Brand<import("@xylabs/hex").Hex, {
6
- readonly __address: true;
7
- }> | undefined;
5
+ address: Address | undefined;
8
6
  balanceForAddress: AttoXL1 | null | undefined;
9
7
  balanceIntlFriendly: string | undefined;
10
8
  shortBalanceIntlFriendly: string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"useAddressBalance.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAddressBalance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAG1C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AAExD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAA;AAK9D,eAAO,MAAM,iBAAiB,GAE5B,UAAU,OAAO,EAEjB,SAAS,SAAS,EAElB,UAAU,MAAM;;;;;;;;;CAkEjB,CAAA"}
1
+ {"version":3,"file":"useAddressBalance.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAddressBalance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAG1C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AAExD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAA;AAK9D,eAAO,MAAM,iBAAiB,GAE5B,UAAU,OAAO,EAEjB,SAAS,SAAS,EAElB,UAAU,MAAM;;;;;;;CAkEjB,CAAA"}
@@ -1,11 +1,8 @@
1
+ import { type Address } from '@xylabs/hex';
1
2
  import type { GatewayName } from '@xyo-network/xl1-protocol';
2
3
  export declare const useConnectAccount: (gatewayName?: GatewayName, timeout?: number) => {
3
- address: import("@xylabs/typeof").Brand<import("@xylabs/hex").Hex, {
4
- readonly __address: true;
5
- }> | undefined;
6
- connectSigner: () => Promise<import("@xylabs/typeof").Brand<import("@xylabs/hex").Hex, {
7
- readonly __address: true;
8
- }> | undefined>;
4
+ address: Address | undefined;
5
+ connectSigner: () => Promise<Address | undefined>;
9
6
  error: Error | undefined;
10
7
  gateway: import("@xyo-network/xl1-protocol-sdk").XyoGateway | null | undefined;
11
8
  timedout: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"useConnectAccount.d.ts","sourceRoot":"","sources":["../../../src/hooks/useConnectAccount.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAK5D,eAAO,MAAM,iBAAiB,GAAI,cAAa,WAA4B,EAAE,UAAU,MAAM;;;;;;;;;;CA0B5F,CAAA"}
1
+ {"version":3,"file":"useConnectAccount.d.ts","sourceRoot":"","sources":["../../../src/hooks/useConnectAccount.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,OAAO,EAAa,MAAM,aAAa,CAAA;AAErD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAK5D,eAAO,MAAM,iBAAiB,GAAI,cAAa,WAA4B,EAAE,UAAU,MAAM;;;;;;CA0B5F,CAAA"}
@@ -1,5 +1,4 @@
1
1
  export * from './components/index.ts';
2
2
  export * from './hooks/index.ts';
3
3
  export * from './lib/index.ts';
4
- export * from './types/index.ts';
5
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;AAChC,cAAc,gBAAgB,CAAA;AAC9B,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,gBAAgB,CAAA"}
@@ -1,20 +1,140 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
 
4
- // src/components/account/BalanceHistoryFlexbox.tsx
5
- import { Typography } from "@mui/material";
6
- import { FlexCol } from "@xylabs/react-flexbox";
7
- import { isDefined as isDefined9 } from "@xylabs/typeof";
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 isDefined8, isUndefined as isUndefined8 } from "@xylabs/typeof";
8
31
  import { ErrorRender } from "@xyo-network/react-error";
9
- import { AttoXL1, XL1Amount as XL1Amount2 } from "@xyo-network/xl1-protocol";
10
- import React2 from "react";
32
+ import React2, { useEffect as useEffect4 } from "react";
33
+
34
+ // src/hooks/account/useAccountBalanceHistory.ts
35
+ import { hexToBigInt as hexToBigInt2 } from "@xylabs/hex";
36
+ import { usePromise } from "@xylabs/react-promise";
37
+ import { isUndefined } from "@xylabs/typeof";
38
+
39
+ // src/lib/balanceForRange.ts
40
+ import { hexToBigInt, isHex, toHex } from "@xylabs/hex";
41
+ var balanceForRange = /* @__PURE__ */ __name((address, results) => {
42
+ const totalReceivedBalance = results?.reduce((a, [_block, _tx, transfer]) => {
43
+ return a + hexToBigInt(transfer.transfers[address] ?? toHex(0));
44
+ }, 0n);
45
+ const totalSentBalance = results?.reduce((a, [_block, _tx, transfer]) => {
46
+ return transfer.from === address ? a + Object.values(transfer.transfers).reduce((a2, v) => a2 + (isHex(v) ? hexToBigInt(v) : 0n), 0n) : a;
47
+ }, 0n);
48
+ return [
49
+ totalReceivedBalance,
50
+ totalSentBalance
51
+ ];
52
+ }, "balanceForRange");
53
+
54
+ // src/lib/findMinimumBlock.ts
55
+ var findMinimumBlock = /* @__PURE__ */ __name((history) => {
56
+ if (history.length === 0) return 0;
57
+ const blockNumbers = history.map(([blockBw]) => blockBw.block);
58
+ const min = Math.min(...blockNumbers);
59
+ return Math.max(min - 1, 0);
60
+ }, "findMinimumBlock");
61
+
62
+ // src/hooks/account/useAccountBalanceHistory.ts
63
+ var formatAccountBalanceHistory = /* @__PURE__ */ __name((address, history) => {
64
+ let results = [];
65
+ for (const item of history) {
66
+ const [blockBw, txBw, transfer] = item;
67
+ if (address === transfer.from) {
68
+ for (const [to, amount] of Object.entries(transfer.transfers)) {
69
+ results.push({
70
+ amount: hexToBigInt2(amount),
71
+ blockNumber: blockBw.block,
72
+ from: transfer.from,
73
+ timestamp: blockBw.$epoch,
74
+ key: globalThis.crypto.randomUUID(),
75
+ to,
76
+ txHash: txBw?._hash,
77
+ debug: item,
78
+ type: "send"
79
+ });
80
+ }
81
+ } else {
82
+ results.push({
83
+ amount: hexToBigInt2(transfer.transfers[address]),
84
+ blockNumber: blockBw.block,
85
+ from: transfer.from,
86
+ key: globalThis.crypto.randomUUID(),
87
+ timestamp: blockBw.$epoch,
88
+ to: address,
89
+ txHash: txBw?._hash,
90
+ debug: item,
91
+ type: "receive"
92
+ });
93
+ }
94
+ }
95
+ return results;
96
+ }, "formatAccountBalanceHistory");
97
+ var useAccountBalanceHistory = /* @__PURE__ */ __name((address, viewer, refresh) => {
98
+ return usePromise(async () => {
99
+ if (isUndefined(viewer) || isUndefined(address)) return;
100
+ let page = 1;
101
+ let lastBlock;
102
+ const maxPage = 10;
103
+ const pagedHistory = [];
104
+ const history = await viewer.accountBalanceHistory(address);
105
+ if (history.length > 0) {
106
+ pagedHistory.push(...history);
107
+ lastBlock = findMinimumBlock(history);
108
+ while (page < maxPage) {
109
+ const nextHistory = await viewer.accountBalanceHistory(address, [
110
+ 0,
111
+ lastBlock
112
+ ]);
113
+ if (nextHistory.length === 0) break;
114
+ lastBlock = findMinimumBlock(nextHistory);
115
+ pagedHistory.push(...nextHistory);
116
+ page++;
117
+ }
118
+ }
119
+ const formattedHistory = formatAccountBalanceHistory(address, pagedHistory);
120
+ return {
121
+ history: formattedHistory,
122
+ balance: balanceForRange(address, pagedHistory),
123
+ truncated: page >= maxPage
124
+ };
125
+ }, [
126
+ address,
127
+ viewer,
128
+ refresh
129
+ ]);
130
+ }, "useAccountBalanceHistory");
11
131
 
12
132
  // src/hooks/client/useClient.ts
13
133
  import { isNull as isNull2 } from "@xylabs/typeof";
14
134
  import { useCallback, useEffect, useSyncExternalStore } from "react";
15
135
 
16
136
  // src/hooks/helpers/getXyoClient.ts
17
- import { isUndefined } from "@xylabs/typeof";
137
+ import { isUndefined as isUndefined2 } from "@xylabs/typeof";
18
138
  var CLIENT_LISTENER_TIMEOUT = 500;
19
139
  var hasXyoClient = /* @__PURE__ */ __name(() => {
20
140
  return "client" in globalThis.xyo;
@@ -34,7 +154,7 @@ var listenForClientInjection = /* @__PURE__ */ __name((onClientReady, timeout, o
34
154
  }, timeout);
35
155
  }, "listenForClientInjection");
36
156
  async function getXyoClient(timeout = CLIENT_LISTENER_TIMEOUT) {
37
- if (isUndefined(globalThis.xyo)) {
157
+ if (isUndefined2(globalThis.xyo)) {
38
158
  return null;
39
159
  }
40
160
  return hasXyoClient() ? globalThis.xyo.client : await new Promise((resolve) => {
@@ -245,7 +365,7 @@ var usePermissions = /* @__PURE__ */ __name(() => {
245
365
  }, "usePermissions");
246
366
 
247
367
  // src/hooks/client/permissions/usePermissionsAccounts.ts
248
- import { usePromise } from "@xylabs/react-promise";
368
+ import { usePromise as usePromise2 } from "@xylabs/react-promise";
249
369
  import { isArray, isDefined as isDefined3, isDefinedNotNull, isString } from "@xylabs/typeof";
250
370
 
251
371
  // src/hooks/client/helpers/findCaveat.ts
@@ -275,7 +395,7 @@ var validateRestrictedAccounts = /* @__PURE__ */ __name((restrictedAccounts) =>
275
395
  }, "validateRestrictedAccounts");
276
396
  var useAccountPermissions = /* @__PURE__ */ __name(() => {
277
397
  const { permissions, error } = usePermissions();
278
- return usePromise(async () => {
398
+ return usePromise2(async () => {
279
399
  if (isDefinedNotNull(error)) throw error;
280
400
  if (isDefined3(permissions)) {
281
401
  const restrictedAccounts = await findCaveat(
@@ -310,104 +430,6 @@ var useGateway = /* @__PURE__ */ __name((gatewayName, timeout) => {
310
430
  };
311
431
  }, "useGateway");
312
432
 
313
- // src/hooks/useAccountBalanceHistory.ts
314
- import { hexToBigInt as hexToBigInt2 } from "@xylabs/hex";
315
- import { usePromise as usePromise2 } from "@xylabs/react-promise";
316
- import { isUndefined as isUndefined2 } from "@xylabs/typeof";
317
-
318
- // src/lib/balanceForRange.ts
319
- import { hexToBigInt, toHex } from "@xylabs/hex";
320
- var balanceForRange = /* @__PURE__ */ __name((address, results) => {
321
- const totalReceivedBalance = results?.reduce((a, [_block, _tx, transfer]) => {
322
- return a + hexToBigInt(transfer.transfers[address] ?? toHex(0));
323
- }, 0n);
324
- const totalSentBalance = results?.reduce((a, [_block, _tx, transfer]) => {
325
- return transfer.from === address ? a + Object.values(transfer.transfers).reduce((a2, v) => a2 + (v ? hexToBigInt(v) : 0n), 0n) : a;
326
- }, 0n);
327
- return [
328
- totalReceivedBalance,
329
- totalSentBalance
330
- ];
331
- }, "balanceForRange");
332
-
333
- // src/lib/findMinimumBlock.ts
334
- var findMinimumBlock = /* @__PURE__ */ __name((history) => {
335
- if (history.length === 0) return 0;
336
- const blockNumbers = history.map(([blockBw]) => blockBw.block);
337
- const min = Math.min(...blockNumbers);
338
- return Math.max(min - 1, 0);
339
- }, "findMinimumBlock");
340
-
341
- // src/hooks/useAccountBalanceHistory.ts
342
- var formatAccountBalanceHistory = /* @__PURE__ */ __name((address, history) => {
343
- let results = [];
344
- for (const item of history) {
345
- const [blockBw, txBw, transfer] = item;
346
- if (address === transfer.from) {
347
- for (const [to, amount] of Object.entries(transfer.transfers)) {
348
- results.push({
349
- amount: hexToBigInt2(amount),
350
- blockNumber: blockBw.block,
351
- from: transfer.from,
352
- timestamp: blockBw.$epoch,
353
- key: globalThis.crypto.randomUUID(),
354
- to,
355
- txHash: txBw?._hash,
356
- debug: item,
357
- type: "send"
358
- });
359
- }
360
- } else {
361
- results.push({
362
- amount: hexToBigInt2(transfer.transfers[address]),
363
- blockNumber: blockBw.block,
364
- from: transfer.from,
365
- key: globalThis.crypto.randomUUID(),
366
- timestamp: blockBw.$epoch,
367
- to: address,
368
- txHash: txBw?._hash,
369
- debug: item,
370
- type: "receive"
371
- });
372
- }
373
- }
374
- return results;
375
- }, "formatAccountBalanceHistory");
376
- var useAccountBalanceHistory = /* @__PURE__ */ __name((address, viewer, refresh) => {
377
- return usePromise2(async () => {
378
- if (isUndefined2(viewer) || isUndefined2(address)) return;
379
- let page = 1;
380
- let lastBlock;
381
- const maxPage = 10;
382
- const pagedHistory = [];
383
- const history = await viewer.accountBalanceHistory(address);
384
- if (history.length > 0) {
385
- pagedHistory.push(...history);
386
- lastBlock = findMinimumBlock(history);
387
- while (page < maxPage) {
388
- const nextHistory = await viewer.accountBalanceHistory(address, [
389
- 0,
390
- lastBlock
391
- ]);
392
- if (nextHistory.length === 0) break;
393
- lastBlock = findMinimumBlock(nextHistory);
394
- pagedHistory.push(...nextHistory);
395
- page++;
396
- }
397
- }
398
- const formattedHistory = formatAccountBalanceHistory(address, pagedHistory);
399
- return {
400
- history: formattedHistory,
401
- balance: balanceForRange(address, pagedHistory),
402
- truncated: page >= maxPage
403
- };
404
- }, [
405
- address,
406
- viewer,
407
- refresh
408
- ]);
409
- }, "useAccountBalanceHistory");
410
-
411
433
  // src/hooks/useAddressBalance.ts
412
434
  import { usePromise as usePromise3 } from "@xylabs/react-promise";
413
435
  import { isUndefined as isUndefined3, isUndefinedOrNull } from "@xylabs/typeof";
@@ -537,7 +559,7 @@ var useConfirmTransactionBase = /* @__PURE__ */ __name((transaction, onBroadcast
537
559
  // src/hooks/useConnectAccount.ts
538
560
  import { assertEx as assertEx2 } from "@xylabs/assert";
539
561
  import { asAddress } from "@xylabs/hex";
540
- import { MainNetwork } from "@xyo-network/chain-network-model";
562
+ import { MainNetwork } from "@xyo-network/xl1-network-model";
541
563
  import { useCallback as useCallback2, useState as useState3 } from "react";
542
564
  var useConnectAccount = /* @__PURE__ */ __name((gatewayName = MainNetwork.id, timeout) => {
543
565
  const [connectError, setConnectError] = useState3();
@@ -624,7 +646,7 @@ var useSigner = /* @__PURE__ */ __name((_provider, account) => {
624
646
  // src/hooks/viewer/useCheckRpc.ts
625
647
  import { delay as delay2 } from "@xylabs/delay";
626
648
  import { isDefined as isDefined6, isUndefined as isUndefined6 } from "@xylabs/typeof";
627
- import { LocalNetwork, SequenceNetwork } from "@xyo-network/chain-network-model";
649
+ import { LocalNetwork, SequenceNetwork } from "@xyo-network/xl1-network-model";
628
650
  import { HttpRpcTransport as HttpRpcTransport2, JsonRpcNetworkStakeViewer, JsonRpcXyoViewer, NetworkStakeViewerRpcSchemas, XyoViewerRpcSchemas } from "@xyo-network/xl1-rpc";
629
651
  import { useEffect as useEffect3, useMemo as useMemo5, useState as useState4 } from "react";
630
652
  var INTERVAL = 5e3;
@@ -722,143 +744,17 @@ var useViewerFromWallet = /* @__PURE__ */ __name((networkId, timeout) => {
722
744
  return result;
723
745
  }, "useViewerFromWallet");
724
746
 
725
- // src/components/account/BalanceHistoryTable.tsx
726
- import { Table, TableBody, TableCell, TableHead, TableRow, Tooltip } from "@mui/material";
727
- import { isDefined as isDefined8 } from "@xylabs/typeof";
728
- import { BlockAddressChip, BlockEpochTableCellInner, BlockNumberTableCellInner } from "@xyo-network/react-chain-blockchain";
729
- import { RawInfoIconButton } from "@xyo-network/react-payload-raw-info";
730
- import { XL1Amount } from "@xyo-network/xl1-protocol";
731
- import React from "react";
732
-
733
- // src/types/account/Table.ts
734
- var TableHeadingLabels = [
735
- "Tx Hash",
736
- "BlockNumber",
737
- "Timestamp",
738
- "From",
739
- "To",
740
- "Amount",
741
- "Debug"
742
- ];
743
-
744
- // src/components/account/BalanceHistoryTable.tsx
745
- var AccountBalanceHistoryTable = /* @__PURE__ */ __name(({ history, ...props }) => {
746
- const formatAmount = /* @__PURE__ */ __name((amount) => {
747
- if (!isDefined8(amount)) {
748
- return "N/A";
749
- }
750
- const xl1Amount = new XL1Amount(amount);
751
- return xl1Amount.toString(void 0, {
752
- places: 18,
753
- maxDecimal: 12,
754
- maxCharacters: 12,
755
- minDecimals: 1,
756
- locale: navigator.language
757
- });
758
- }, "formatAmount");
759
- return isDefined8(history) ? /* @__PURE__ */ React.createElement(Table, props, /* @__PURE__ */ React.createElement(TableHead, null, /* @__PURE__ */ React.createElement(TableRow, null, TableHeadingLabels.map((heading) => /* @__PURE__ */ React.createElement(TableCell, {
760
- key: heading
761
- }, heading)))), /* @__PURE__ */ React.createElement(TableBody, null, history?.map(({ amount, blockNumber, debug, from, key, timestamp, to, type, txHash }) => /* @__PURE__ */ React.createElement(TableRow, {
762
- key
763
- }, /* @__PURE__ */ React.createElement(TableCell, null, txHash || "N/A"), /* @__PURE__ */ React.createElement(BlockNumberTableCellInner, {
764
- blockNumber
765
- }), /* @__PURE__ */ React.createElement(BlockEpochTableCellInner, {
766
- epoch: timestamp
767
- }), /* @__PURE__ */ React.createElement(TableCell, null, /* @__PURE__ */ React.createElement(Tooltip, {
768
- title: `From Address: ${from}`
769
- }, /* @__PURE__ */ React.createElement(BlockAddressChip, {
770
- address: from,
771
- toolTipTitle: `From: ${from}`
772
- }))), /* @__PURE__ */ React.createElement(TableCell, null, /* @__PURE__ */ React.createElement(Tooltip, {
773
- title: `To Address: ${to}`
774
- }, /* @__PURE__ */ React.createElement(BlockAddressChip, {
775
- address: to,
776
- toolTipTitle: `To: ${to}`
777
- }))), /* @__PURE__ */ React.createElement(TableCell, null, /* @__PURE__ */ React.createElement(Tooltip, {
778
- title: `Raw Amount: ${amount}`
779
- }, /* @__PURE__ */ React.createElement("span", null, type === "send" ? "-" : "", formatAmount(amount)))), /* @__PURE__ */ React.createElement(TableCell, null, /* @__PURE__ */ React.createElement(RawInfoIconButton, {
780
- rawValue: debug
781
- })))))) : null;
782
- }, "AccountBalanceHistoryTable");
783
-
784
- // src/components/account/BalanceHistoryFlexbox.tsx
785
- var AccountBalanceHistoryFlexBox = /* @__PURE__ */ __name(({ address, refresh, viewer, ...props }) => {
786
- const [results, error] = useAccountBalanceHistory(address, viewer, refresh);
787
- const { history, balance, truncated } = results || {
788
- balance: [
789
- AttoXL1(0n),
790
- AttoXL1(0n)
791
- ],
792
- history: void 0
793
- };
794
- const formatBalance = /* @__PURE__ */ __name((balance2) => {
795
- const xl1Amount = new XL1Amount2(balance2);
796
- return xl1Amount.toString(void 0, {
797
- places: 18,
798
- maxDecimal: 12,
799
- maxCharacters: 12,
800
- minDecimals: 1,
801
- locale: navigator.language
802
- });
803
- }, "formatBalance");
804
- const formatBalanceMagnitude = /* @__PURE__ */ __name((set) => {
805
- const [received, sent] = set;
806
- const netBalance = received - sent;
807
- return netBalance < 0n ? `-${formatBalance(sent - received)}` : formatBalance(netBalance);
808
- }, "formatBalanceMagnitude");
809
- return isDefined9(history) && isDefined9(address) ? /* @__PURE__ */ React2.createElement(FlexCol, props, /* @__PURE__ */ React2.createElement(ErrorRender, {
810
- error,
811
- scope: "AccountBalanceHistoryTable"
812
- }), /* @__PURE__ */ React2.createElement(Typography, {
813
- variant: "h6",
814
- gutterBottom: true
815
- }, formatBalanceMagnitude(balance)), truncated ? /* @__PURE__ */ React2.createElement(Typography, {
816
- variant: "caption",
817
- gutterBottom: true
818
- }, "Ranged Balance from", " ", history.at(-1).blockNumber, " ", "-", " ", history[0].blockNumber) : null, /* @__PURE__ */ React2.createElement(AccountBalanceHistoryTable, {
819
- history
820
- })) : null;
821
- }, "AccountBalanceHistoryFlexBox");
822
-
823
- // src/components/connected/account/Connected.tsx
824
- import { Stack, Tooltip as Tooltip2, Typography as Typography2 } from "@mui/material";
825
- import { EthAddressWrapper } from "@xylabs/eth-address";
826
- import { BlockiesAvatarAddress } from "@xyo-network/react-chain-blockies";
827
- import React3 from "react";
828
- var ConnectedAccount = /* @__PURE__ */ __name(({ address }) => {
829
- const shortenedAddress = `${EthAddressWrapper.fromString(address)?.toShortString(4)}`;
830
- return /* @__PURE__ */ React3.createElement(Stack, {
831
- direction: "row",
832
- alignItems: "center",
833
- spacing: 1
834
- }, /* @__PURE__ */ React3.createElement(BlockiesAvatarAddress, {
835
- address,
836
- size: 21
837
- }), /* @__PURE__ */ React3.createElement(Tooltip2, {
838
- title: address
839
- }, /* @__PURE__ */ React3.createElement(Typography2, {
840
- color: "textSecondary",
841
- variant: "caption",
842
- fontFamily: "monospace"
843
- }, shortenedAddress)));
844
- }, "ConnectedAccount");
845
-
846
747
  // src/components/connected/ConnectAccountsStack.tsx
847
- import { Alert, AlertTitle, Button, Stack as Stack2, Typography as Typography3 } from "@mui/material";
848
- import { ButtonEx } from "@xylabs/react-button";
849
- import { isDefined as isDefined10, isUndefined as isUndefined8 } from "@xylabs/typeof";
850
- import { ErrorRender as ErrorRender2 } from "@xyo-network/react-error";
851
- import React4, { useEffect as useEffect4 } from "react";
852
- var DefaultConnectComponent = /* @__PURE__ */ __name((props) => /* @__PURE__ */ React4.createElement(ButtonEx, {
748
+ var DefaultConnectComponent = /* @__PURE__ */ __name((props) => /* @__PURE__ */ React2.createElement(ButtonEx, {
853
749
  variant: "contained",
854
750
  size: "small",
855
751
  ...props
856
752
  }), "DefaultConnectComponent");
857
- var DefaultNoWalletInstalledComponent = /* @__PURE__ */ __name(() => /* @__PURE__ */ React4.createElement(Alert, {
753
+ var DefaultNoWalletInstalledComponent = /* @__PURE__ */ __name(() => /* @__PURE__ */ React2.createElement(Alert, {
858
754
  severity: "warning"
859
- }, /* @__PURE__ */ React4.createElement(AlertTitle, null, "XL1 Wallet Not Found"), /* @__PURE__ */ React4.createElement(Typography3, {
755
+ }, /* @__PURE__ */ React2.createElement(AlertTitle, null, "XL1 Wallet Not Found"), /* @__PURE__ */ React2.createElement(Typography2, {
860
756
  gutterBottom: true
861
- }, "Please ensure that your XL1 Wallet is installed to connect your account."), /* @__PURE__ */ React4.createElement(Button, {
757
+ }, "Please ensure that your XL1 Wallet is installed to connect your account."), /* @__PURE__ */ React2.createElement(Button, {
862
758
  sx: {
863
759
  display: "flex",
864
760
  justifySelf: "end"
@@ -872,7 +768,7 @@ var DefaultNoWalletInstalledComponent = /* @__PURE__ */ __name(() => /* @__PURE_
872
768
  var ConnectAccountsStack = /* @__PURE__ */ __name(({ AccountComponent = ConnectedAccount, ConnectComponent = DefaultConnectComponent, NoWalletInstalledComponent = DefaultNoWalletInstalledComponent, onAccountConnected, onCancel, timeout, ...props }) => {
873
769
  const { address, connectSigner, error, timedout } = useConnectAccount(void 0, timeout);
874
770
  useEffect4(() => {
875
- if (isDefined10(error) && isDefined10(onCancel)) {
771
+ if (isDefined8(error) && isDefined8(onCancel)) {
876
772
  onCancel();
877
773
  }
878
774
  }, [
@@ -880,33 +776,30 @@ var ConnectAccountsStack = /* @__PURE__ */ __name(({ AccountComponent = Connecte
880
776
  onCancel
881
777
  ]);
882
778
  useEffect4(() => {
883
- if (isDefined10(address) && isDefined10(onAccountConnected)) {
779
+ if (isDefined8(address) && isDefined8(onAccountConnected)) {
884
780
  onAccountConnected(address);
885
781
  }
886
782
  }, [
887
783
  address,
888
784
  onAccountConnected
889
785
  ]);
890
- return /* @__PURE__ */ React4.createElement(Stack2, {
786
+ return /* @__PURE__ */ React2.createElement(Stack2, {
891
787
  direction: "row",
892
788
  alignItems: "start",
893
789
  spacing: 2,
894
790
  ...props
895
- }, isDefined10(address) ? /* @__PURE__ */ React4.createElement(AccountComponent, {
791
+ }, isDefined8(address) ? /* @__PURE__ */ React2.createElement(AccountComponent, {
896
792
  address
897
- }) : null, isUndefined8(address) && !timedout ? /* @__PURE__ */ React4.createElement(ConnectComponent, {
793
+ }) : null, isUndefined8(address) && !timedout ? /* @__PURE__ */ React2.createElement(ConnectComponent, {
898
794
  onClick: /* @__PURE__ */ __name(() => void connectSigner(), "onClick")
899
- }, "Connect") : null, isUndefined8(address) && timedout ? /* @__PURE__ */ React4.createElement(NoWalletInstalledComponent, null) : null, /* @__PURE__ */ React4.createElement(ErrorRender2, {
795
+ }, "Connect") : null, isUndefined8(address) && timedout ? /* @__PURE__ */ React2.createElement(NoWalletInstalledComponent, null) : null, /* @__PURE__ */ React2.createElement(ErrorRender, {
900
796
  error,
901
797
  scope: "ConnectSigner:error"
902
798
  }));
903
799
  }, "ConnectAccountsStack");
904
800
  export {
905
- AccountBalanceHistoryFlexBox,
906
- AccountBalanceHistoryTable,
907
801
  ConnectAccountsStack,
908
802
  ConnectedAccount,
909
- TableHeadingLabels,
910
803
  TransactionConfirmationStatus,
911
804
  balanceForRange,
912
805
  findMinimumBlock,