@xyo-network/react-chain-provider 1.16.9 → 1.16.11

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 (79) hide show
  1. package/dist/browser/components/connected/ConnectAccountsStack.d.ts +1 -1
  2. package/dist/browser/components/connected/ConnectAccountsStack.d.ts.map +1 -1
  3. package/dist/browser/components/index.d.ts +0 -1
  4. package/dist/browser/components/index.d.ts.map +1 -1
  5. package/dist/browser/{types/account/BalanceHistoryItemRow.d.ts → hooks/account/BalanceHistoryItemFormatted.d.ts} +5 -4
  6. package/dist/browser/hooks/account/BalanceHistoryItemFormatted.d.ts.map +1 -0
  7. package/dist/browser/hooks/account/index.d.ts +3 -0
  8. package/dist/browser/hooks/account/index.d.ts.map +1 -0
  9. package/dist/browser/hooks/{useAccountBalanceHistory.d.ts → account/useAccountBalanceHistory.d.ts} +4 -4
  10. package/dist/browser/hooks/account/useAccountBalanceHistory.d.ts.map +1 -0
  11. package/dist/browser/hooks/client/helpers/findCaveat.d.ts +1 -1
  12. package/dist/browser/hooks/helpers/transaction/Confirmation.d.ts +1 -2
  13. package/dist/browser/hooks/helpers/transaction/Confirmation.d.ts.map +1 -1
  14. package/dist/browser/hooks/index.d.ts +1 -1
  15. package/dist/browser/hooks/index.d.ts.map +1 -1
  16. package/dist/browser/hooks/useAddressBalance.d.ts +2 -4
  17. package/dist/browser/hooks/useAddressBalance.d.ts.map +1 -1
  18. package/dist/browser/hooks/useConfirmTransactionBase.d.ts +1 -1
  19. package/dist/browser/hooks/useConfirmTransactionBase.d.ts.map +1 -1
  20. package/dist/browser/hooks/useConnectAccount.d.ts +3 -6
  21. package/dist/browser/hooks/useConnectAccount.d.ts.map +1 -1
  22. package/dist/browser/hooks/viewer/useCheckRpc.d.ts.map +1 -1
  23. package/dist/browser/index.d.ts +0 -1
  24. package/dist/browser/index.d.ts.map +1 -1
  25. package/dist/browser/index.mjs +157 -270
  26. package/dist/browser/index.mjs.map +1 -1
  27. package/dist/browser/lib/balanceForRange.d.ts +1 -1
  28. package/dist/browser/lib/balanceForRange.d.ts.map +1 -1
  29. package/package.json +11 -19
  30. package/src/components/connected/ConnectAccountsStack.tsx +2 -2
  31. package/src/components/connected/account/Connected.tsx +1 -1
  32. package/src/components/index.ts +0 -1
  33. package/src/{types/account/BalanceHistoryItemRow.ts → hooks/account/BalanceHistoryItemFormatted.ts} +5 -3
  34. package/src/hooks/account/index.ts +2 -0
  35. package/src/hooks/{useAccountBalanceHistory.ts → account/useAccountBalanceHistory.ts} +7 -7
  36. package/src/hooks/client/helpers/findCaveat.ts +1 -1
  37. package/src/hooks/client/permissions/usePermissionsAccounts.ts +1 -1
  38. package/src/hooks/client/useClient.ts +1 -1
  39. package/src/hooks/client/useGateway.ts +1 -1
  40. package/src/hooks/helpers/getXyoClient.ts +1 -1
  41. package/src/hooks/helpers/transaction/Confirmation.ts +4 -6
  42. package/src/hooks/index.ts +1 -1
  43. package/src/hooks/useAddressBalance.ts +2 -2
  44. package/src/hooks/useConfirmTransactionBase.ts +4 -4
  45. package/src/hooks/useConnectAccount.ts +3 -3
  46. package/src/hooks/useCurrentBlock.ts +1 -1
  47. package/src/hooks/useHttpRpcRunner.ts +1 -1
  48. package/src/hooks/useNetwork.ts +1 -1
  49. package/src/hooks/viewer/UseStepRewardWeightTest.stories.tsx +2 -2
  50. package/src/hooks/viewer/useCheckRpc.ts +4 -3
  51. package/src/hooks/viewer/useHttpRpcViewer.stories.tsx +2 -2
  52. package/src/hooks/viewer/useHttpRpcViewer.ts +1 -1
  53. package/src/hooks/viewer/useViewerFromWallet.stories.tsx +2 -2
  54. package/src/hooks/viewer/useViewerFromWallet.ts +1 -1
  55. package/src/index.ts +0 -1
  56. package/src/lib/balanceForRange.ts +5 -3
  57. package/dist/browser/components/account/BalanceHistoryFlexbox.d.ts +0 -11
  58. package/dist/browser/components/account/BalanceHistoryFlexbox.d.ts.map +0 -1
  59. package/dist/browser/components/account/BalanceHistoryFlexbox.stories.d.ts +0 -6
  60. package/dist/browser/components/account/BalanceHistoryFlexbox.stories.d.ts.map +0 -1
  61. package/dist/browser/components/account/BalanceHistoryTable.d.ts +0 -8
  62. package/dist/browser/components/account/BalanceHistoryTable.d.ts.map +0 -1
  63. package/dist/browser/components/account/index.d.ts +0 -3
  64. package/dist/browser/components/account/index.d.ts.map +0 -1
  65. package/dist/browser/hooks/useAccountBalanceHistory.d.ts.map +0 -1
  66. package/dist/browser/types/account/BalanceHistoryItemRow.d.ts.map +0 -1
  67. package/dist/browser/types/account/Table.d.ts +0 -7
  68. package/dist/browser/types/account/Table.d.ts.map +0 -1
  69. package/dist/browser/types/account/index.d.ts +0 -3
  70. package/dist/browser/types/account/index.d.ts.map +0 -1
  71. package/dist/browser/types/index.d.ts +0 -2
  72. package/dist/browser/types/index.d.ts.map +0 -1
  73. package/src/components/account/BalanceHistoryFlexbox.stories.tsx +0 -25
  74. package/src/components/account/BalanceHistoryFlexbox.tsx +0 -65
  75. package/src/components/account/BalanceHistoryTable.tsx +0 -78
  76. package/src/components/account/index.ts +0 -2
  77. package/src/types/account/Table.ts +0 -14
  78. package/src/types/account/index.ts +0 -2
  79. package/src/types/index.ts +0 -1
@@ -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/sdk-js";
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/sdk-js";
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 { usePromise } from "@xylabs/react-promise";
36
+ import { hexToBigInt as hexToBigInt2 } from "@xylabs/sdk-js";
37
+ import { isUndefined } from "@xylabs/sdk-js";
38
+
39
+ // src/lib/balanceForRange.ts
40
+ import { hexToBigInt, isHex, toHex } from "@xylabs/sdk-js";
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
- import { isNull as isNull2 } from "@xylabs/typeof";
133
+ import { isNull as isNull2 } from "@xylabs/sdk-js";
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/sdk-js";
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) => {
@@ -48,10 +168,7 @@ async function getXyoClient(timeout = CLIENT_LISTENER_TIMEOUT) {
48
168
  __name(getXyoClient, "getXyoClient");
49
169
 
50
170
  // src/hooks/helpers/transaction/Confirmation.ts
51
- import { assertEx } from "@xylabs/assert";
52
- import { delay } from "@xylabs/delay";
53
- import { forget } from "@xylabs/forget";
54
- import { isDefined, isNull } from "@xylabs/typeof";
171
+ import { assertEx, delay, forget, isDefined, isNull } from "@xylabs/sdk-js";
55
172
  var TransactionConfirmationStatus = class _TransactionConfirmationStatus {
56
173
  static {
57
174
  __name(this, "TransactionConfirmationStatus");
@@ -245,11 +362,11 @@ var usePermissions = /* @__PURE__ */ __name(() => {
245
362
  }, "usePermissions");
246
363
 
247
364
  // src/hooks/client/permissions/usePermissionsAccounts.ts
248
- import { usePromise } from "@xylabs/react-promise";
249
- import { isArray, isDefined as isDefined3, isDefinedNotNull, isString } from "@xylabs/typeof";
365
+ import { usePromise as usePromise2 } from "@xylabs/react-promise";
366
+ import { isArray, isDefined as isDefined3, isDefinedNotNull, isString } from "@xylabs/sdk-js";
250
367
 
251
368
  // src/hooks/client/helpers/findCaveat.ts
252
- import { isDefined as isDefined2 } from "@xylabs/typeof";
369
+ import { isDefined as isDefined2 } from "@xylabs/sdk-js";
253
370
  var findCaveat = /* @__PURE__ */ __name(async (permissions, targetCapability, targetCaveatType) => {
254
371
  const existingPermissions = await permissions.getPermissions();
255
372
  if (isDefined2(existingPermissions) && existingPermissions.length > 0) {
@@ -275,7 +392,7 @@ var validateRestrictedAccounts = /* @__PURE__ */ __name((restrictedAccounts) =>
275
392
  }, "validateRestrictedAccounts");
276
393
  var useAccountPermissions = /* @__PURE__ */ __name(() => {
277
394
  const { permissions, error } = usePermissions();
278
- return usePromise(async () => {
395
+ return usePromise2(async () => {
279
396
  if (isDefinedNotNull(error)) throw error;
280
397
  if (isDefined3(permissions)) {
281
398
  const restrictedAccounts = await findCaveat(
@@ -292,7 +409,7 @@ var useAccountPermissions = /* @__PURE__ */ __name(() => {
292
409
  }, "useAccountPermissions");
293
410
 
294
411
  // src/hooks/client/useGateway.ts
295
- import { isDefined as isDefined4, isNull as isNull3 } from "@xylabs/typeof";
412
+ import { isDefined as isDefined4, isNull as isNull3 } from "@xylabs/sdk-js";
296
413
  var useGateway = /* @__PURE__ */ __name((gatewayName, timeout) => {
297
414
  const { client, isLoading, error, timedout } = useClient(timeout);
298
415
  const resolveGateway = /* @__PURE__ */ __name(() => {
@@ -310,107 +427,9 @@ var useGateway = /* @__PURE__ */ __name((gatewayName, timeout) => {
310
427
  };
311
428
  }, "useGateway");
312
429
 
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
430
  // src/hooks/useAddressBalance.ts
412
431
  import { usePromise as usePromise3 } from "@xylabs/react-promise";
413
- import { isUndefined as isUndefined3, isUndefinedOrNull } from "@xylabs/typeof";
432
+ import { isUndefined as isUndefined3, isUndefinedOrNull } from "@xylabs/sdk-js";
414
433
  import { ShiftedBigInt } from "@xyo-network/xl1-protocol";
415
434
  import { useMemo, useRef, useState } from "react";
416
435
  var useAddressBalance = /* @__PURE__ */ __name((address, viewer, refresh) => {
@@ -483,10 +502,8 @@ var useAddressBalance = /* @__PURE__ */ __name((address, viewer, refresh) => {
483
502
  }, "useAddressBalance");
484
503
 
485
504
  // src/hooks/useConfirmTransactionBase.ts
486
- import { forget as forget2 } from "@xylabs/forget";
487
- import { isHash } from "@xylabs/hex";
488
505
  import { usePromise as usePromise4 } from "@xylabs/react-promise";
489
- import { isDefined as isDefined5 } from "@xylabs/typeof";
506
+ import { forget as forget2, isDefined as isDefined5, isHash } from "@xylabs/sdk-js";
490
507
  import { PayloadBuilder } from "@xyo-network/payload-builder";
491
508
  import { useEffect as useEffect2, useState as useState2 } from "react";
492
509
  var useConfirmTransactionBase = /* @__PURE__ */ __name((transaction, onBroadcast, onStatusUpdate, runner, viewer) => {
@@ -535,9 +552,9 @@ var useConfirmTransactionBase = /* @__PURE__ */ __name((transaction, onBroadcast
535
552
  }, "useConfirmTransactionBase");
536
553
 
537
554
  // src/hooks/useConnectAccount.ts
538
- import { assertEx as assertEx2 } from "@xylabs/assert";
539
- import { asAddress } from "@xylabs/hex";
540
- import { MainNetwork } from "@xyo-network/chain-network-model";
555
+ import { asAddress } from "@xylabs/sdk-js";
556
+ import { assertEx as assertEx2 } from "@xylabs/sdk-js";
557
+ import { MainNetwork } from "@xyo-network/xl1-network-model";
541
558
  import { useCallback as useCallback2, useState as useState3 } from "react";
542
559
  var useConnectAccount = /* @__PURE__ */ __name((gatewayName = MainNetwork.id, timeout) => {
543
560
  const [connectError, setConnectError] = useState3();
@@ -569,7 +586,7 @@ var useConnectAccount = /* @__PURE__ */ __name((gatewayName = MainNetwork.id, ti
569
586
 
570
587
  // src/hooks/useCurrentBlock.ts
571
588
  import { usePromise as usePromise5 } from "@xylabs/react-promise";
572
- import { isDefinedNotNull as isDefinedNotNull2 } from "@xylabs/typeof";
589
+ import { isDefinedNotNull as isDefinedNotNull2 } from "@xylabs/sdk-js";
573
590
  var useCurrentBlock = /* @__PURE__ */ __name((refresh = 1, viewer) => {
574
591
  return usePromise5(async () => {
575
592
  if (isDefinedNotNull2(viewer) && refresh > 0) {
@@ -583,7 +600,7 @@ var useCurrentBlock = /* @__PURE__ */ __name((refresh = 1, viewer) => {
583
600
  }, "useCurrentBlock");
584
601
 
585
602
  // src/hooks/useHttpRpcRunner.ts
586
- import { isUndefined as isUndefined4 } from "@xylabs/typeof";
603
+ import { isUndefined as isUndefined4 } from "@xylabs/sdk-js";
587
604
  import { AllRpcSchemas, HttpRpcTransport, JsonRpcXyoRunner } from "@xyo-network/xl1-rpc";
588
605
  import { useMemo as useMemo2 } from "react";
589
606
  var useHttpRpcRunner = /* @__PURE__ */ __name((url) => {
@@ -599,7 +616,7 @@ var useHttpRpcRunner = /* @__PURE__ */ __name((url) => {
599
616
  }, "useHttpRpcRunner");
600
617
 
601
618
  // src/hooks/useNetwork.ts
602
- import { isUndefined as isUndefined5 } from "@xylabs/typeof";
619
+ import { isUndefined as isUndefined5 } from "@xylabs/sdk-js";
603
620
  import { SimpleXyoNetwork } from "@xyo-network/xl1-protocol-sdk";
604
621
  import { useMemo as useMemo3 } from "react";
605
622
  var useNetwork = /* @__PURE__ */ __name((id) => {
@@ -622,9 +639,8 @@ var useSigner = /* @__PURE__ */ __name((_provider, account) => {
622
639
  }, "useSigner");
623
640
 
624
641
  // src/hooks/viewer/useCheckRpc.ts
625
- import { delay as delay2 } from "@xylabs/delay";
626
- import { isDefined as isDefined6, isUndefined as isUndefined6 } from "@xylabs/typeof";
627
- import { LocalNetwork, SequenceNetwork } from "@xyo-network/chain-network-model";
642
+ import { delay as delay2, isDefined as isDefined6, isUndefined as isUndefined6 } from "@xylabs/sdk-js";
643
+ import { LocalNetwork, SequenceNetwork } from "@xyo-network/xl1-network-model";
628
644
  import { HttpRpcTransport as HttpRpcTransport2, JsonRpcNetworkStakeViewer, JsonRpcXyoViewer, NetworkStakeViewerRpcSchemas, XyoViewerRpcSchemas } from "@xyo-network/xl1-rpc";
629
645
  import { useEffect as useEffect3, useMemo as useMemo5, useState as useState4 } from "react";
630
646
  var INTERVAL = 5e3;
@@ -680,7 +696,7 @@ var useCheckRpc = /* @__PURE__ */ __name((endpoint) => {
680
696
  }, "useCheckRpc");
681
697
 
682
698
  // src/hooks/viewer/useHttpRpcViewer.ts
683
- import { isUndefined as isUndefined7 } from "@xylabs/typeof";
699
+ import { isUndefined as isUndefined7 } from "@xylabs/sdk-js";
684
700
  import { HttpRpcTransport as HttpRpcTransport3, JsonRpcNetworkStakeViewer as JsonRpcNetworkStakeViewer2, JsonRpcXyoViewer as JsonRpcXyoViewer2, NetworkStakeViewerRpcSchemas as NetworkStakeViewerRpcSchemas2, XyoViewerRpcSchemas as XyoViewerRpcSchemas2 } from "@xyo-network/xl1-rpc";
685
701
  import { useMemo as useMemo6 } from "react";
686
702
  var useHttpRpcViewer = /* @__PURE__ */ __name((url) => {
@@ -703,7 +719,7 @@ var useHttpRpcViewer = /* @__PURE__ */ __name((url) => {
703
719
 
704
720
  // src/hooks/viewer/useViewerFromWallet.ts
705
721
  import { usePromise as usePromise6 } from "@xylabs/react-promise";
706
- import { isDefined as isDefined7, isDefinedNotNull as isDefinedNotNull3, isNull as isNull4 } from "@xylabs/typeof";
722
+ import { isDefined as isDefined7, isDefinedNotNull as isDefinedNotNull3, isNull as isNull4 } from "@xylabs/sdk-js";
707
723
  var useViewerFromWallet = /* @__PURE__ */ __name((networkId, timeout) => {
708
724
  const { gateway, error, isLoading, timedout } = useGateway(networkId, timeout);
709
725
  const result = usePromise6(async () => {
@@ -722,143 +738,17 @@ var useViewerFromWallet = /* @__PURE__ */ __name((networkId, timeout) => {
722
738
  return result;
723
739
  }, "useViewerFromWallet");
724
740
 
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
741
  // 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, {
742
+ var DefaultConnectComponent = /* @__PURE__ */ __name((props) => /* @__PURE__ */ React2.createElement(ButtonEx, {
853
743
  variant: "contained",
854
744
  size: "small",
855
745
  ...props
856
746
  }), "DefaultConnectComponent");
857
- var DefaultNoWalletInstalledComponent = /* @__PURE__ */ __name(() => /* @__PURE__ */ React4.createElement(Alert, {
747
+ var DefaultNoWalletInstalledComponent = /* @__PURE__ */ __name(() => /* @__PURE__ */ React2.createElement(Alert, {
858
748
  severity: "warning"
859
- }, /* @__PURE__ */ React4.createElement(AlertTitle, null, "XL1 Wallet Not Found"), /* @__PURE__ */ React4.createElement(Typography3, {
749
+ }, /* @__PURE__ */ React2.createElement(AlertTitle, null, "XL1 Wallet Not Found"), /* @__PURE__ */ React2.createElement(Typography2, {
860
750
  gutterBottom: true
861
- }, "Please ensure that your XL1 Wallet is installed to connect your account."), /* @__PURE__ */ React4.createElement(Button, {
751
+ }, "Please ensure that your XL1 Wallet is installed to connect your account."), /* @__PURE__ */ React2.createElement(Button, {
862
752
  sx: {
863
753
  display: "flex",
864
754
  justifySelf: "end"
@@ -872,7 +762,7 @@ var DefaultNoWalletInstalledComponent = /* @__PURE__ */ __name(() => /* @__PURE_
872
762
  var ConnectAccountsStack = /* @__PURE__ */ __name(({ AccountComponent = ConnectedAccount, ConnectComponent = DefaultConnectComponent, NoWalletInstalledComponent = DefaultNoWalletInstalledComponent, onAccountConnected, onCancel, timeout, ...props }) => {
873
763
  const { address, connectSigner, error, timedout } = useConnectAccount(void 0, timeout);
874
764
  useEffect4(() => {
875
- if (isDefined10(error) && isDefined10(onCancel)) {
765
+ if (isDefined8(error) && isDefined8(onCancel)) {
876
766
  onCancel();
877
767
  }
878
768
  }, [
@@ -880,33 +770,30 @@ var ConnectAccountsStack = /* @__PURE__ */ __name(({ AccountComponent = Connecte
880
770
  onCancel
881
771
  ]);
882
772
  useEffect4(() => {
883
- if (isDefined10(address) && isDefined10(onAccountConnected)) {
773
+ if (isDefined8(address) && isDefined8(onAccountConnected)) {
884
774
  onAccountConnected(address);
885
775
  }
886
776
  }, [
887
777
  address,
888
778
  onAccountConnected
889
779
  ]);
890
- return /* @__PURE__ */ React4.createElement(Stack2, {
780
+ return /* @__PURE__ */ React2.createElement(Stack2, {
891
781
  direction: "row",
892
782
  alignItems: "start",
893
783
  spacing: 2,
894
784
  ...props
895
- }, isDefined10(address) ? /* @__PURE__ */ React4.createElement(AccountComponent, {
785
+ }, isDefined8(address) ? /* @__PURE__ */ React2.createElement(AccountComponent, {
896
786
  address
897
- }) : null, isUndefined8(address) && !timedout ? /* @__PURE__ */ React4.createElement(ConnectComponent, {
787
+ }) : null, isUndefined8(address) && !timedout ? /* @__PURE__ */ React2.createElement(ConnectComponent, {
898
788
  onClick: /* @__PURE__ */ __name(() => void connectSigner(), "onClick")
899
- }, "Connect") : null, isUndefined8(address) && timedout ? /* @__PURE__ */ React4.createElement(NoWalletInstalledComponent, null) : null, /* @__PURE__ */ React4.createElement(ErrorRender2, {
789
+ }, "Connect") : null, isUndefined8(address) && timedout ? /* @__PURE__ */ React2.createElement(NoWalletInstalledComponent, null) : null, /* @__PURE__ */ React2.createElement(ErrorRender, {
900
790
  error,
901
791
  scope: "ConnectSigner:error"
902
792
  }));
903
793
  }, "ConnectAccountsStack");
904
794
  export {
905
- AccountBalanceHistoryFlexBox,
906
- AccountBalanceHistoryTable,
907
795
  ConnectAccountsStack,
908
796
  ConnectedAccount,
909
- TableHeadingLabels,
910
797
  TransactionConfirmationStatus,
911
798
  balanceForRange,
912
799
  findMinimumBlock,