@xyo-network/xl1-react-client-sdk 5.6.1 → 5.6.2

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.
@@ -34,7 +34,7 @@ var ConnectedAccount = ({ address }) => {
34
34
  };
35
35
 
36
36
  // src/client/components/connected/ApprovedLakeSelector.tsx
37
- import { isDefined as isDefined3, isDefinedNotNull as isDefinedNotNull2 } from "@ariestools/sdk";
37
+ import { isDefined as isDefined4, isDefinedNotNull as isDefinedNotNull2 } from "@ariestools/sdk";
38
38
  import { ButtonEx } from "@ariestools/sdk-react";
39
39
  import {
40
40
  Alert,
@@ -46,9 +46,9 @@ import {
46
46
  Typography as Typography2
47
47
  } from "@mui/material";
48
48
  import {
49
- useCallback,
50
- useEffect as useEffect2,
51
- useState as useState2
49
+ useCallback as useCallback2,
50
+ useEffect as useEffect3,
51
+ useState as useState3
52
52
  } from "react";
53
53
 
54
54
  // src/client/hooks/client/helpers/findCaveat.ts
@@ -64,12 +64,99 @@ var findCaveat = async (permissions, targetCapability, targetCaveatType) => {
64
64
  return [];
65
65
  };
66
66
 
67
+ // src/client/hooks/client/permissions/useGrantedAccounts.ts
68
+ import {
69
+ asAddress,
70
+ assertEx,
71
+ isArray,
72
+ isDefined as isDefined2,
73
+ isString,
74
+ isUndefined
75
+ } from "@ariestools/sdk";
76
+ import { asXyoAddress } from "@xyo-network/sdk";
77
+ import {
78
+ useCallback,
79
+ useEffect,
80
+ useRef,
81
+ useState
82
+ } from "react";
83
+ var ACCOUNTS_CAPABILITY = "xyoWallet_getAccounts";
84
+ var RESTRICT_RETURNED_ACCOUNTS = "restrictReturnedAccounts";
85
+ function toError(error) {
86
+ return error instanceof Error ? error : new Error(String(error));
87
+ }
88
+ function grantedAccountsFromCaveat(value) {
89
+ if (!isArray(value)) {
90
+ throw new TypeError(`Unrecognized restrictReturnedAccounts caveat, expected an array of account addresses: ${JSON.stringify(value)}`);
91
+ }
92
+ const accounts = value.map((entry) => {
93
+ const account = isString(entry) ? asXyoAddress(entry) ?? asAddress(entry) : void 0;
94
+ if (isUndefined(account)) {
95
+ throw new TypeError(`Unrecognized account in restrictReturnedAccounts caveat: ${JSON.stringify(entry)}`);
96
+ }
97
+ return account;
98
+ });
99
+ return [...new Set(accounts)];
100
+ }
101
+ function isSameAccounts(first, second) {
102
+ if (first === second) return true;
103
+ return isDefined2(first) && isDefined2(second) && first.length === second.length && first.every((account, index) => account === second[index]);
104
+ }
105
+ function settleRead(previous, next) {
106
+ if (previous?.permissions !== next.permissions) return next;
107
+ const accounts = isDefined2(next.error) ? previous.accounts : next.accounts;
108
+ const settled = {
109
+ accounts: isSameAccounts(previous.accounts, accounts) ? previous.accounts : accounts,
110
+ error: previous.error?.message === next.error?.message ? previous.error : next.error,
111
+ permissions: next.permissions
112
+ };
113
+ return settled.accounts === previous.accounts && settled.error === previous.error ? previous : settled;
114
+ }
115
+ function useGrantedAccounts(permissions) {
116
+ const [read, setRead] = useState();
117
+ const readCountRef = useRef(0);
118
+ const refresh = useCallback(async () => {
119
+ if (isUndefined(permissions)) return;
120
+ readCountRef.current += 1;
121
+ const readNumber = readCountRef.current;
122
+ let next;
123
+ try {
124
+ const caveat = await findCaveat(permissions, ACCOUNTS_CAPABILITY, RESTRICT_RETURNED_ACCOUNTS);
125
+ next = { accounts: grantedAccountsFromCaveat(caveat), permissions };
126
+ } catch (error) {
127
+ next = { error: toError(error), permissions };
128
+ }
129
+ if (readNumber === readCountRef.current) setRead((previous) => settleRead(previous, next));
130
+ return next.accounts;
131
+ }, [permissions]);
132
+ const request = useCallback(async () => {
133
+ const provider = assertEx(permissions, () => "Wallet permissions are not available");
134
+ await provider.requestPermissions([{ [ACCOUNTS_CAPABILITY]: {} }]);
135
+ return await refresh();
136
+ }, [permissions, refresh]);
137
+ useEffect(() => {
138
+ if (isUndefined(permissions)) return;
139
+ void refresh();
140
+ const controller = new AbortController();
141
+ addEventListener("focus", () => void refresh(), { signal: controller.signal });
142
+ return () => controller.abort();
143
+ }, [permissions, refresh]);
144
+ const current = isDefined2(permissions) && read?.permissions === permissions ? read : void 0;
145
+ return {
146
+ accounts: current?.accounts,
147
+ error: current?.error,
148
+ isLoading: isDefined2(permissions) && isUndefined(current),
149
+ refresh,
150
+ request
151
+ };
152
+ }
153
+
67
154
  // src/client/hooks/client/useClientFromWallet.ts
68
- import { isUndefined as isUndefined2 } from "@ariestools/sdk";
69
- import { useEffect, useState } from "react";
155
+ import { isUndefined as isUndefined3 } from "@ariestools/sdk";
156
+ import { useEffect as useEffect2, useState as useState2 } from "react";
70
157
 
71
158
  // src/client/hooks/helpers/getXyoClient.ts
72
- import { isUndefined } from "@ariestools/sdk";
159
+ import { isUndefined as isUndefined2 } from "@ariestools/sdk";
73
160
  var CLIENT_LISTENER_TIMEOUT = 2e3;
74
161
  var hasXyoClient = () => {
75
162
  return "client" in globalThis.xyo;
@@ -104,7 +191,7 @@ function discoveryAbortError(reason) {
104
191
  }
105
192
  async function getXyoClient(timeout = CLIENT_LISTENER_TIMEOUT, signal) {
106
193
  if (signal?.aborted === true) throw discoveryAbortError(signal.reason);
107
- if (isUndefined(globalThis.xyo)) return null;
194
+ if (isUndefined2(globalThis.xyo)) return null;
108
195
  if (hasXyoClient()) return globalThis.xyo.client;
109
196
  return await new Promise((resolve, reject) => {
110
197
  let dispose = () => {
@@ -140,8 +227,8 @@ var initialState = {
140
227
  timedout: false
141
228
  };
142
229
  var useClientFromWallet = (timeout) => {
143
- const [state, setState] = useState(initialState);
144
- useEffect(() => {
230
+ const [state, setState] = useState2(initialState);
231
+ useEffect2(() => {
145
232
  let cancelled = false;
146
233
  const controller = new AbortController();
147
234
  const initialize = async () => {
@@ -186,7 +273,7 @@ var useClientFromWallet = (timeout) => {
186
273
  void initialize();
187
274
  const onPluginReady = () => {
188
275
  if (cancelled) return;
189
- const client = isUndefined2(globalThis.xyo) ? null : globalThis.xyo?.client ?? null;
276
+ const client = isUndefined3(globalThis.xyo) ? null : globalThis.xyo?.client ?? null;
190
277
  setState({
191
278
  client,
192
279
  isLoading: false,
@@ -223,15 +310,15 @@ var usePermissions = () => {
223
310
 
224
311
  // src/client/hooks/client/permissions/usePermissionsAccounts.ts
225
312
  import {
226
- isArray,
227
- isDefined as isDefined2,
313
+ isArray as isArray2,
314
+ isDefined as isDefined3,
228
315
  isDefinedNotNull,
229
- isString
316
+ isString as isString2
230
317
  } from "@ariestools/sdk";
231
318
  import { usePromise } from "@ariestools/sdk-react";
232
319
  var validateRestrictedAccounts = (restrictedAccounts) => {
233
- if (isDefined2(restrictedAccounts)) {
234
- if (isArray(restrictedAccounts) && restrictedAccounts.every(isString)) {
320
+ if (isDefined3(restrictedAccounts)) {
321
+ if (isArray2(restrictedAccounts) && restrictedAccounts.every(isString2)) {
235
322
  return restrictedAccounts;
236
323
  }
237
324
  throw new Error(
@@ -246,7 +333,7 @@ var useAccountPermissions = () => {
246
333
  const { permissions, error } = usePermissions();
247
334
  return usePromise(async () => {
248
335
  if (isDefinedNotNull(error)) throw error;
249
- if (isDefined2(permissions)) {
336
+ if (isDefined3(permissions)) {
250
337
  const restrictedAccounts = await findCaveat(
251
338
  permissions,
252
339
  // TODO - extract to constant in protocol package
@@ -299,12 +386,12 @@ var ApprovedLakeSelector = ({
299
386
  isLoading,
300
387
  timedout
301
388
  } = useClientFromWallet(timeout);
302
- const [lakes, setLakes] = useState2();
303
- const [fetchError, setFetchError] = useState2();
304
- const [refreshing, setRefreshing] = useState2(false);
389
+ const [lakes, setLakes] = useState3();
390
+ const [fetchError, setFetchError] = useState3();
391
+ const [refreshing, setRefreshing] = useState3(false);
305
392
  const dataLakes = client?.dataLakes;
306
393
  const supported = isDefinedNotNull2(dataLakes);
307
- const refresh = useCallback(async () => {
394
+ const refresh = useCallback2(async () => {
308
395
  if (!isDefinedNotNull2(dataLakes)) return;
309
396
  setFetchError(void 0);
310
397
  setRefreshing(true);
@@ -317,7 +404,7 @@ var ApprovedLakeSelector = ({
317
404
  setRefreshing(false);
318
405
  }
319
406
  }, [dataLakes]);
320
- useEffect2(() => {
407
+ useEffect3(() => {
321
408
  if (supported && lakes === void 0 && !refreshing) {
322
409
  void refresh();
323
410
  }
@@ -326,7 +413,7 @@ var ApprovedLakeSelector = ({
326
413
  return /* @__PURE__ */ jsxs2(Stack2, { sx: { gap: 1, width: "100%" }, children: [
327
414
  timedout ? /* @__PURE__ */ jsx2(Alert, { severity: "warning", children: "Wallet not detected." }) : null,
328
415
  isDefinedNotNull2(client) && !supported ? /* @__PURE__ */ jsx2(Alert, { severity: "warning", children: "This wallet does not expose `xyo.client.dataLakes`." }) : null,
329
- isDefined3(lakes) && filtered.length === 0 ? /* @__PURE__ */ jsxs2(Alert, { severity: "info", children: [
416
+ isDefined4(lakes) && filtered.length === 0 ? /* @__PURE__ */ jsxs2(Alert, { severity: "info", children: [
330
417
  "No approved lakes with",
331
418
  " ",
332
419
  /* @__PURE__ */ jsx2("strong", { children: capability }),
@@ -360,7 +447,7 @@ var ApprovedLakeSelector = ({
360
447
  children: "Refresh"
361
448
  }
362
449
  ),
363
- isDefined3(lakes) ? /* @__PURE__ */ jsxs2(Typography2, { variant: "caption", sx: { color: "text.secondary", alignSelf: "center" }, children: [
450
+ isDefined4(lakes) ? /* @__PURE__ */ jsxs2(Typography2, { variant: "caption", sx: { color: "text.secondary", alignSelf: "center" }, children: [
364
451
  lakes.length,
365
452
  " ",
366
453
  "approved",
@@ -382,7 +469,7 @@ var ApprovedLakeSelector = ({
382
469
 
383
470
  // src/client/components/connected/AutoSignChainPanel.tsx
384
471
  import {
385
- isDefined as isDefined6,
472
+ isDefined as isDefined7,
386
473
  isDefinedNotNull as isDefinedNotNull4,
387
474
  toHex
388
475
  } from "@ariestools/sdk";
@@ -399,23 +486,23 @@ import {
399
486
  import { asSchema, PayloadBuilder } from "@xyo-network/sdk";
400
487
  import { ExplorerLinks, LocalNetwork } from "@xyo-network/xl1-sdk";
401
488
  import {
402
- useCallback as useCallback3,
489
+ useCallback as useCallback4,
403
490
  useMemo,
404
- useState as useState4
491
+ useState as useState5
405
492
  } from "react";
406
493
 
407
494
  // src/client/components/connected/RequestPermissionsButton.tsx
408
- import { isDefined as isDefined5, isDefinedNotNull as isDefinedNotNull3 } from "@ariestools/sdk";
495
+ import { isDefined as isDefined6, isDefinedNotNull as isDefinedNotNull3 } from "@ariestools/sdk";
409
496
  import { ButtonEx as ButtonEx3 } from "@ariestools/sdk-react";
410
497
  import { Alert as Alert3, Stack as Stack4 } from "@mui/material";
411
498
  import {
412
- useCallback as useCallback2,
413
- useEffect as useEffect3,
414
- useState as useState3
499
+ useCallback as useCallback3,
500
+ useEffect as useEffect4,
501
+ useState as useState4
415
502
  } from "react";
416
503
 
417
504
  // src/client/components/connected/PermissionsReviewDialog.tsx
418
- import { isDefined as isDefined4 } from "@ariestools/sdk";
505
+ import { isDefined as isDefined5 } from "@ariestools/sdk";
419
506
  import { ButtonEx as ButtonEx2 } from "@ariestools/sdk-react";
420
507
  import {
421
508
  Alert as Alert2,
@@ -450,11 +537,11 @@ var renderCaveatValue = (caveat) => {
450
537
  if (caveat.type === "dataLakeAccess" && typeof caveat.value === "object" && caveat.value !== null) {
451
538
  const value = caveat.value;
452
539
  return /* @__PURE__ */ jsxs3(Stack3, { sx: { gap: 0.5 }, children: [
453
- isDefined4(value.perOriginId) ? /* @__PURE__ */ jsxs3(Stack3, { direction: "row", sx: { alignItems: "center", gap: 1 }, children: [
540
+ isDefined5(value.perOriginId) ? /* @__PURE__ */ jsxs3(Stack3, { direction: "row", sx: { alignItems: "center", gap: 1 }, children: [
454
541
  /* @__PURE__ */ jsx3(Typography3, { variant: "caption", sx: { color: "text.secondary" }, children: "id:" }),
455
542
  /* @__PURE__ */ jsx3(Typography3, { variant: "body2", sx: { fontFamily: "monospace", wordBreak: "break-all" }, children: value.perOriginId })
456
543
  ] }) : null,
457
- isDefined4(value.narrowedSchemas) && value.narrowedSchemas.length > 0 ? /* @__PURE__ */ jsxs3(
544
+ isDefined5(value.narrowedSchemas) && value.narrowedSchemas.length > 0 ? /* @__PURE__ */ jsxs3(
458
545
  Stack3,
459
546
  {
460
547
  direction: "row",
@@ -497,7 +584,7 @@ var renderCaveatValue = (caveat) => {
497
584
  var renderPermission = (permission) => {
498
585
  const caveats = permission.caveats ?? [];
499
586
  let grantedAt;
500
- if (isDefined4(permission.date)) {
587
+ if (isDefined5(permission.date)) {
501
588
  const grantedDate = new Date(permission.date);
502
589
  grantedAt = grantedDate.toLocaleString();
503
590
  }
@@ -574,13 +661,13 @@ var RequestPermissionsButton = ({
574
661
  isLoading,
575
662
  timedout
576
663
  } = useClientFromWallet(timeout);
577
- const [granted, setGranted] = useState3();
578
- const [fetchError, setFetchError] = useState3();
579
- const [requestError, setRequestError] = useState3();
580
- const [requesting, setRequesting] = useState3(false);
581
- const [dialogOpen, setDialogOpen] = useState3(false);
664
+ const [granted, setGranted] = useState4();
665
+ const [fetchError, setFetchError] = useState4();
666
+ const [requestError, setRequestError] = useState4();
667
+ const [requesting, setRequesting] = useState4(false);
668
+ const [dialogOpen, setDialogOpen] = useState4(false);
582
669
  const permissionsApi = client?.permissions;
583
- const refreshGranted = useCallback2(async () => {
670
+ const refreshGranted = useCallback3(async () => {
584
671
  if (!isDefinedNotNull3(permissionsApi)) return;
585
672
  setFetchError(void 0);
586
673
  try {
@@ -591,12 +678,12 @@ var RequestPermissionsButton = ({
591
678
  setFetchError(e);
592
679
  }
593
680
  }, [permissionsApi]);
594
- useEffect3(() => {
681
+ useEffect4(() => {
595
682
  if (isDefinedNotNull3(permissionsApi) && granted === void 0) {
596
683
  void refreshGranted();
597
684
  }
598
685
  }, [permissionsApi, granted, refreshGranted]);
599
- const requestPermissions = useCallback2(async () => {
686
+ const requestPermissions = useCallback3(async () => {
600
687
  if (!isDefinedNotNull3(permissionsApi)) return;
601
688
  setRequestError(void 0);
602
689
  setRequesting(true);
@@ -609,7 +696,7 @@ var RequestPermissionsButton = ({
609
696
  setRequesting(false);
610
697
  }
611
698
  }, [permissionsApi, permissions, refreshGranted]);
612
- const hasGranted = isDefined5(granted) && granted.length > 0;
699
+ const hasGranted = isDefined6(granted) && granted.length > 0;
613
700
  const handleClick = () => {
614
701
  if (hasGranted) {
615
702
  setDialogOpen(true);
@@ -756,10 +843,10 @@ var FireSection = ({
756
843
  {
757
844
  label: `#${attempt.index + 1}`,
758
845
  size: "small",
759
- color: isDefined6(attempt.error) ? "error" : "success"
846
+ color: isDefined7(attempt.error) ? "error" : "success"
760
847
  }
761
848
  ),
762
- isDefined6(attempt.txHash) ? /* @__PURE__ */ jsxs5(
849
+ isDefined7(attempt.txHash) ? /* @__PURE__ */ jsxs5(
763
850
  Link,
764
851
  {
765
852
  href: txUrl(attempt.txHash),
@@ -816,17 +903,17 @@ var AutoSignChainPanel = ({
816
903
  error: gatewayError,
817
904
  timedout
818
905
  } = useGatewayFromWallet(gatewayName, timeout);
819
- const [resolvedAddress, setResolvedAddress] = useState4();
820
- const [resolving, setResolving] = useState4(false);
821
- const [resolveError, setResolveError] = useState4();
822
- const [granting, setGranting] = useState4(false);
823
- const [grantError, setGrantError] = useState4();
824
- const [granted, setGranted] = useState4(false);
825
- const [firing, setFiring] = useState4(false);
826
- const [attempts, setAttempts] = useState4(EMPTY_RESULTS);
906
+ const [resolvedAddress, setResolvedAddress] = useState5();
907
+ const [resolving, setResolving] = useState5(false);
908
+ const [resolveError, setResolveError] = useState5();
909
+ const [granting, setGranting] = useState5(false);
910
+ const [grantError, setGrantError] = useState5();
911
+ const [granted, setGranted] = useState5(false);
912
+ const [firing, setFiring] = useState5(false);
913
+ const [attempts, setAttempts] = useState5(EMPTY_RESULTS);
827
914
  const permissionsApi = client?.permissions;
828
915
  const explorer = useMemo(() => new ExplorerLinks(explorerUrl, gatewayName), [explorerUrl, gatewayName]);
829
- const handleResolve = useCallback3(async () => {
916
+ const handleResolve = useCallback4(async () => {
830
917
  if (!isDefinedNotNull4(gateway)) return;
831
918
  const signer = gateway.signer;
832
919
  if (!isDefinedNotNull4(signer)) return;
@@ -840,8 +927,8 @@ var AutoSignChainPanel = ({
840
927
  setResolving(false);
841
928
  }
842
929
  }, [gateway]);
843
- const handleGrant = useCallback3(async () => {
844
- if (!isDefinedNotNull4(permissionsApi) || !isDefined6(resolvedAddress)) return;
930
+ const handleGrant = useCallback4(async () => {
931
+ if (!isDefinedNotNull4(permissionsApi) || !isDefined7(resolvedAddress)) return;
845
932
  setGrantError(void 0);
846
933
  setGranting(true);
847
934
  try {
@@ -860,7 +947,7 @@ var AutoSignChainPanel = ({
860
947
  setGranting(false);
861
948
  }
862
949
  }, [permissionsApi, resolvedAddress, chainId, maxTxCount, schemaPatterns]);
863
- const handleFire = useCallback3(async () => {
950
+ const handleFire = useCallback4(async () => {
864
951
  if (!isDefinedNotNull4(gateway)) return;
865
952
  setFiring(true);
866
953
  setAttempts(EMPTY_RESULTS);
@@ -871,8 +958,8 @@ var AutoSignChainPanel = ({
871
958
  }
872
959
  }, [gateway, burstSize, offChainSchema]);
873
960
  const canResolve = isDefinedNotNull4(gateway) && !resolving;
874
- const canGrant = isDefinedNotNull4(permissionsApi) && isDefined6(resolvedAddress) && !granting;
875
- const canFire = isDefinedNotNull4(gateway) && isDefined6(resolvedAddress) && !firing;
961
+ const canGrant = isDefinedNotNull4(permissionsApi) && isDefined7(resolvedAddress) && !granting;
962
+ const canFire = isDefinedNotNull4(gateway) && isDefined7(resolvedAddress) && !firing;
876
963
  return /* @__PURE__ */ jsxs5(
877
964
  Stack5,
878
965
  {
@@ -902,7 +989,7 @@ var AutoSignChainPanel = ({
902
989
  children: "Resolve account"
903
990
  }
904
991
  ),
905
- isDefined6(resolvedAddress) ? /* @__PURE__ */ jsxs5(Typography4, { variant: "caption", sx: { color: "text.secondary" }, children: [
992
+ isDefined7(resolvedAddress) ? /* @__PURE__ */ jsxs5(Typography4, { variant: "caption", sx: { color: "text.secondary" }, children: [
906
993
  "Account:",
907
994
  " ",
908
995
  /* @__PURE__ */ jsx5("code", { children: resolvedAddress })
@@ -959,7 +1046,7 @@ var AutoSignChainPanel = ({
959
1046
  };
960
1047
 
961
1048
  // src/client/components/connected/ConnectAccountsStack.tsx
962
- import { isDefined as isDefined7, isUndefined as isUndefined3 } from "@ariestools/sdk";
1049
+ import { isDefined as isDefined8 } from "@ariestools/sdk";
963
1050
  import { ButtonEx as ButtonEx5 } from "@ariestools/sdk-react";
964
1051
  import {
965
1052
  Alert as Alert5,
@@ -968,48 +1055,54 @@ import {
968
1055
  Stack as Stack6,
969
1056
  Typography as Typography5
970
1057
  } from "@mui/material";
971
- import { useEffect as useEffect4 } from "react";
1058
+ import { useEffect as useEffect5 } from "react";
972
1059
 
973
1060
  // src/client/components/connected/hooks/useConnectAccount.ts
974
1061
  import {
975
- asAddress,
976
- assertEx,
977
- isArray as isArray2,
978
- isString as isString2
1062
+ asAddress as asAddress2,
1063
+ isDefinedNotNull as isDefinedNotNull5,
1064
+ isNull as isNull2,
1065
+ isUndefined as isUndefined4
979
1066
  } from "@ariestools/sdk";
980
1067
  import { MainNetwork } from "@xyo-network/xl1-sdk";
981
- import { useCallback as useCallback4, useState as useState5 } from "react";
982
- var ACCOUNTS_CAPABILITY = "xyoWallet_getAccounts";
983
- var RESTRICT_RETURNED_ACCOUNTS = "restrictReturnedAccounts";
984
- var firstGrantedAccount = (grantedAccounts) => isArray2(grantedAccounts) && isString2(grantedAccounts[0]) ? grantedAccounts[0] : void 0;
1068
+ import { useCallback as useCallback5, useState as useState6 } from "react";
985
1069
  var useConnectAccount = (gatewayName = MainNetwork.id, timeout) => {
986
- const [connectError, setConnectError] = useState5();
1070
+ const [connectError, setConnectError] = useState6();
987
1071
  const {
988
- gateway,
989
- error,
1072
+ client,
1073
+ error: clientError,
990
1074
  timedout
991
- } = useGatewayFromWallet(gatewayName, timeout);
992
- const [accountPermissions, accountPermissionsError] = useAccountPermissions();
993
- const { permissions } = usePermissions();
994
- const [address, setAddress] = useState5();
995
- const connectSigner = useCallback4(async () => {
1075
+ } = useClientFromWallet(timeout);
1076
+ const {
1077
+ accounts,
1078
+ error: grantError,
1079
+ isLoading: isReadingGrant,
1080
+ refresh,
1081
+ request
1082
+ } = useGrantedAccounts(client?.permissions);
1083
+ const requestAccounts = useCallback5(async () => {
1084
+ setConnectError(void 0);
996
1085
  try {
997
- setConnectError(void 0);
998
- const assertedPermissions = assertEx(permissions, () => "Wallet permissions are not available");
999
- await assertedPermissions.requestPermissions([{ [ACCOUNTS_CAPABILITY]: {} }]);
1000
- const grantedAccounts = await findCaveat(assertedPermissions, ACCOUNTS_CAPABILITY, RESTRICT_RETURNED_ACCOUNTS);
1001
- const connectedAddress = firstGrantedAccount(grantedAccounts);
1002
- setAddress(connectedAddress);
1003
- return asAddress(connectedAddress);
1086
+ return await request();
1004
1087
  } catch (e) {
1005
- setConnectError(e);
1088
+ setConnectError(e instanceof Error ? e : new Error(String(e)));
1006
1089
  }
1007
- }, [permissions]);
1090
+ }, [request]);
1091
+ const connectSigner = useCallback5(async () => {
1092
+ const granted = await requestAccounts();
1093
+ return asAddress2(granted?.[0]);
1094
+ }, [requestAccounts]);
1095
+ const isDiscovering = isUndefined4(client) && !isDefinedNotNull5(clientError);
1008
1096
  return {
1009
- address: asAddress(accountPermissions?.[0] ?? address),
1097
+ accounts,
1098
+ address: asAddress2(accounts?.[0]),
1010
1099
  connectSigner,
1011
- error: error ?? accountPermissionsError ?? connectError,
1012
- gateway,
1100
+ error: clientError ?? grantError ?? connectError,
1101
+ // Same three-state contract as useGatewayFromWallet.
1102
+ gateway: isNull2(client) ? null : client?.gateways?.[gatewayName],
1103
+ isLoading: isDiscovering || isReadingGrant,
1104
+ refreshAccounts: refresh,
1105
+ requestAccounts,
1013
1106
  timedout
1014
1107
  };
1015
1108
  };
@@ -1017,6 +1110,7 @@ var useConnectAccount = (gatewayName = MainNetwork.id, timeout) => {
1017
1110
  // src/client/components/connected/ConnectAccountsStack.tsx
1018
1111
  import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
1019
1112
  var DefaultConnectComponent = (props) => /* @__PURE__ */ jsx6(ButtonEx5, { variant: "contained", size: "small", ...props });
1113
+ var DefaultLoadingComponent = () => /* @__PURE__ */ jsx6(ButtonEx5, { variant: "contained", size: "small", busy: true, disabled: true, children: "Connect" });
1020
1114
  var DefaultNoWalletInstalledComponent = () => /* @__PURE__ */ jsxs6(Alert5, { severity: "warning", children: [
1021
1115
  /* @__PURE__ */ jsx6(AlertTitle, { children: "XL1 Wallet Not Found" }),
1022
1116
  /* @__PURE__ */ jsx6(Typography5, { gutterBottom: true, children: "Please ensure that your XL1 Wallet is installed to connect your account." }),
@@ -1036,28 +1130,38 @@ var DefaultNoWalletInstalledComponent = () => /* @__PURE__ */ jsxs6(Alert5, { se
1036
1130
  var ConnectAccountsStack = ({
1037
1131
  AccountComponent = ConnectedAccount,
1038
1132
  ConnectComponent = DefaultConnectComponent,
1133
+ LoadingComponent = DefaultLoadingComponent,
1039
1134
  NoWalletInstalledComponent = DefaultNoWalletInstalledComponent,
1040
1135
  onAccountConnected,
1136
+ onAccountsChanged,
1041
1137
  onCancel,
1042
1138
  timeout,
1043
1139
  ...props
1044
1140
  }) => {
1045
1141
  const {
1046
- address,
1047
- connectSigner,
1142
+ accounts,
1048
1143
  error,
1144
+ isLoading,
1145
+ requestAccounts,
1049
1146
  timedout
1050
1147
  } = useConnectAccount(void 0, timeout);
1051
- useEffect4(() => {
1052
- if (isDefined7(error) && isDefined7(onCancel)) {
1148
+ const firstAccount = accounts?.[0];
1149
+ const hasAccounts = isDefined8(firstAccount);
1150
+ useEffect5(() => {
1151
+ if (isDefined8(error) && isDefined8(onCancel)) {
1053
1152
  onCancel();
1054
1153
  }
1055
1154
  }, [error, onCancel]);
1056
- useEffect4(() => {
1057
- if (isDefined7(address) && isDefined7(onAccountConnected)) {
1058
- onAccountConnected(address);
1155
+ useEffect5(() => {
1156
+ if (isDefined8(firstAccount) && isDefined8(onAccountConnected)) {
1157
+ onAccountConnected(firstAccount);
1158
+ }
1159
+ }, [firstAccount, onAccountConnected]);
1160
+ useEffect5(() => {
1161
+ if (isDefined8(accounts) && isDefined8(onAccountsChanged)) {
1162
+ onAccountsChanged(accounts);
1059
1163
  }
1060
- }, [address, onAccountConnected]);
1164
+ }, [accounts, onAccountsChanged]);
1061
1165
  return /* @__PURE__ */ jsxs6(
1062
1166
  Stack6,
1063
1167
  {
@@ -1066,9 +1170,10 @@ var ConnectAccountsStack = ({
1066
1170
  ...props,
1067
1171
  sx: { alignItems: "start", ...props.sx },
1068
1172
  children: [
1069
- isDefined7(address) ? /* @__PURE__ */ jsx6(AccountComponent, { address }) : null,
1070
- isUndefined3(address) && !timedout ? /* @__PURE__ */ jsx6(ConnectComponent, { onClick: () => void connectSigner(), children: "Connect" }) : null,
1071
- isUndefined3(address) && timedout ? /* @__PURE__ */ jsx6(NoWalletInstalledComponent, {}) : null,
1173
+ isLoading ? /* @__PURE__ */ jsx6(LoadingComponent, {}) : null,
1174
+ !isLoading && hasAccounts ? accounts?.map((account) => /* @__PURE__ */ jsx6(AccountComponent, { account, address: account }, account)) : null,
1175
+ !isLoading && !hasAccounts && !timedout ? /* @__PURE__ */ jsx6(ConnectComponent, { onClick: () => void requestAccounts(), children: "Connect" }) : null,
1176
+ !isLoading && !hasAccounts && timedout ? /* @__PURE__ */ jsx6(NoWalletInstalledComponent, {}) : null,
1072
1177
  /* @__PURE__ */ jsx6(ErrorRender, { error, scope: "ConnectSigner:error" })
1073
1178
  ]
1074
1179
  }
@@ -1076,7 +1181,7 @@ var ConnectAccountsStack = ({
1076
1181
  };
1077
1182
 
1078
1183
  // src/client/components/connected/DataLakeAddToChainPanel.tsx
1079
- import { isDefined as isDefined8, isDefinedNotNull as isDefinedNotNull5 } from "@ariestools/sdk";
1184
+ import { isDefined as isDefined9, isDefinedNotNull as isDefinedNotNull6 } from "@ariestools/sdk";
1080
1185
  import { ButtonEx as ButtonEx6, usePromise as usePromise2 } from "@ariestools/sdk-react";
1081
1186
  import { OpenInNew as OpenInNew2 } from "@mui/icons-material";
1082
1187
  import {
@@ -1100,7 +1205,7 @@ import {
1100
1205
  HashSchema,
1101
1206
  SequenceNetwork
1102
1207
  } from "@xyo-network/xl1-sdk";
1103
- import { useMemo as useMemo2, useState as useState6 } from "react";
1208
+ import { useMemo as useMemo2, useState as useState7 } from "react";
1104
1209
  import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
1105
1210
  var DEFAULT_EXPLORER_URL2 = "https://explore.xyo.network";
1106
1211
  var DEFAULT_PAYLOAD_SCHEMA = asSchema2("network.xyo.observation.v2", true);
@@ -1187,7 +1292,7 @@ var InsertSection = ({
1187
1292
  children: "Insert into lake"
1188
1293
  }
1189
1294
  ),
1190
- isDefined8(storedHash) ? /* @__PURE__ */ jsxs7(
1295
+ isDefined9(storedHash) ? /* @__PURE__ */ jsxs7(
1191
1296
  Stack7,
1192
1297
  {
1193
1298
  direction: "row",
@@ -1232,7 +1337,7 @@ var AddToChainSection = ({
1232
1337
  children: "Add to chain"
1233
1338
  }
1234
1339
  ),
1235
- isDefined8(txHash) && isDefined8(explorerTxUrl) ? /* @__PURE__ */ jsxs7(Stack7, { sx: { gap: 0.5 }, children: [
1340
+ isDefined9(txHash) && isDefined9(explorerTxUrl) ? /* @__PURE__ */ jsxs7(Stack7, { sx: { gap: 0.5 }, children: [
1236
1341
  /* @__PURE__ */ jsxs7(
1237
1342
  Stack7,
1238
1343
  {
@@ -1265,7 +1370,7 @@ var AddToChainSection = ({
1265
1370
  ]
1266
1371
  }
1267
1372
  ),
1268
- isDefined8(signedTx) ? /* @__PURE__ */ jsxs7(Typography6, { variant: "caption", sx: { color: "text.secondary" }, children: [
1373
+ isDefined9(signedTx) ? /* @__PURE__ */ jsxs7(Typography6, { variant: "caption", sx: { color: "text.secondary" }, children: [
1269
1374
  "Signed transaction recorded \u2014 open the explorer link above to verify inclusion on",
1270
1375
  " ",
1271
1376
  /* @__PURE__ */ jsx7("code", { children: gatewayName }),
@@ -1288,28 +1393,28 @@ var DataLakeAddToChainPanel = ({
1288
1393
  error: gatewayError,
1289
1394
  timedout
1290
1395
  } = useGatewayFromWallet(gatewayName, timeout);
1291
- const [payloadText, setPayloadText] = useState6(initialPayloadJson ?? "");
1396
+ const [payloadText, setPayloadText] = useState7(initialPayloadJson ?? "");
1292
1397
  usePromise2(async () => setPayloadText(await buildDefaultPayload(payloadSchema)), [payloadSchema]);
1293
1398
  const parse = useMemo2(() => parsePayload(payloadText), [payloadText]);
1294
- const [selectedLakeId, setSelectedLakeId] = useState6("");
1295
- const [storedPayload, setStoredPayload] = useState6();
1296
- const [inserting, setInserting] = useState6(false);
1297
- const [insertError, setInsertError] = useState6();
1298
- const [txHash, setTxHash] = useState6();
1299
- const [signedTx, setSignedTx] = useState6();
1300
- const [addingToChain, setAddingToChain] = useState6(false);
1301
- const [chainError, setChainError] = useState6();
1399
+ const [selectedLakeId, setSelectedLakeId] = useState7("");
1400
+ const [storedPayload, setStoredPayload] = useState7();
1401
+ const [inserting, setInserting] = useState7(false);
1402
+ const [insertError, setInsertError] = useState7();
1403
+ const [txHash, setTxHash] = useState7();
1404
+ const [signedTx, setSignedTx] = useState7();
1405
+ const [addingToChain, setAddingToChain] = useState7(false);
1406
+ const [chainError, setChainError] = useState7();
1302
1407
  const dataLakes = client?.dataLakes;
1303
- const [storedHash] = usePromise2(async () => isDefined8(storedPayload) ? await PayloadBuilder2.dataHash(storedPayload) : void 0, [storedPayload]);
1304
- const canInsert = parse.ok && selectedLakeId.length > 0 && isDefinedNotNull5(dataLakes) && !inserting;
1305
- const canAddToChain = isDefined8(storedHash) && isDefined8(storedPayload) && isDefinedNotNull5(gateway) && !addingToChain;
1408
+ const [storedHash] = usePromise2(async () => isDefined9(storedPayload) ? await PayloadBuilder2.dataHash(storedPayload) : void 0, [storedPayload]);
1409
+ const canInsert = parse.ok && selectedLakeId.length > 0 && isDefinedNotNull6(dataLakes) && !inserting;
1410
+ const canAddToChain = isDefined9(storedHash) && isDefined9(storedPayload) && isDefinedNotNull6(gateway) && !addingToChain;
1306
1411
  const explorerTxUrl = useMemo2(() => {
1307
- if (!isDefined8(txHash)) return;
1412
+ if (!isDefined9(txHash)) return;
1308
1413
  const links = new ExplorerLinks2(explorerUrl, gatewayName);
1309
1414
  return links.transaction(txHash);
1310
1415
  }, [txHash, explorerUrl, gatewayName]);
1311
1416
  const handleInsert = async () => {
1312
- if (!canInsert || !parse.ok || !isDefinedNotNull5(dataLakes)) return;
1417
+ if (!canInsert || !parse.ok || !isDefinedNotNull6(dataLakes)) return;
1313
1418
  setInsertError(void 0);
1314
1419
  setStoredPayload(void 0);
1315
1420
  setTxHash(void 0);
@@ -1318,7 +1423,7 @@ var DataLakeAddToChainPanel = ({
1318
1423
  setInserting(true);
1319
1424
  try {
1320
1425
  const [stored] = await dataLakes.insert(selectedLakeId, [parse.payload]);
1321
- if (!isDefined8(stored)) {
1426
+ if (!isDefined9(stored)) {
1322
1427
  setInsertError(new Error("Lake returned no entries for this insert \u2014 the lake may disallow the payload's schema."));
1323
1428
  return;
1324
1429
  }
@@ -1334,7 +1439,7 @@ var DataLakeAddToChainPanel = ({
1334
1439
  }
1335
1440
  };
1336
1441
  const handleAddToChain = async () => {
1337
- if (!canAddToChain || !isDefinedNotNull5(gateway) || !isDefined8(storedPayload) || !isDefined8(storedHash)) return;
1442
+ if (!canAddToChain || !isDefinedNotNull6(gateway) || !isDefined9(storedPayload) || !isDefined9(storedHash)) return;
1338
1443
  setChainError(void 0);
1339
1444
  setTxHash(void 0);
1340
1445
  setSignedTx(void 0);
@@ -1402,14 +1507,14 @@ var DataLakeAddToChainPanel = ({
1402
1507
  };
1403
1508
 
1404
1509
  // src/client/components/connected/DataLakeGetButton.tsx
1405
- import { isDefined as isDefined9, isDefinedNotNull as isDefinedNotNull6 } from "@ariestools/sdk";
1510
+ import { isDefined as isDefined10, isDefinedNotNull as isDefinedNotNull7 } from "@ariestools/sdk";
1406
1511
  import { ButtonEx as ButtonEx7 } from "@ariestools/sdk-react";
1407
1512
  import {
1408
1513
  Alert as Alert7,
1409
1514
  Stack as Stack8,
1410
1515
  Typography as Typography7
1411
1516
  } from "@mui/material";
1412
- import { useState as useState7 } from "react";
1517
+ import { useState as useState8 } from "react";
1413
1518
  import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
1414
1519
  var DataLakeGetButton = ({
1415
1520
  id,
@@ -1423,14 +1528,14 @@ var DataLakeGetButton = ({
1423
1528
  isLoading,
1424
1529
  timedout
1425
1530
  } = useClientFromWallet(timeout);
1426
- const [result, setResult] = useState7();
1427
- const [requestError, setRequestError] = useState7();
1428
- const [requesting, setRequesting] = useState7(false);
1531
+ const [result, setResult] = useState8();
1532
+ const [requestError, setRequestError] = useState8();
1533
+ const [requesting, setRequesting] = useState8(false);
1429
1534
  const dataLakes = client?.dataLakes;
1430
- const supported = isDefinedNotNull6(dataLakes);
1535
+ const supported = isDefinedNotNull7(dataLakes);
1431
1536
  const argsReady = id.length > 0 && hashes.length > 0;
1432
1537
  const handleClick = async () => {
1433
- if (!isDefinedNotNull6(dataLakes)) return;
1538
+ if (!isDefinedNotNull7(dataLakes)) return;
1434
1539
  setRequestError(void 0);
1435
1540
  setResult(void 0);
1436
1541
  setRequesting(true);
@@ -1454,7 +1559,7 @@ var DataLakeGetButton = ({
1454
1559
  },
1455
1560
  children: [
1456
1561
  timedout ? /* @__PURE__ */ jsx8(Alert7, { severity: "warning", children: "Wallet not detected." }) : null,
1457
- isDefinedNotNull6(client) && !supported ? /* @__PURE__ */ jsx8(Alert7, { severity: "warning", children: "This wallet does not expose `xyo.client.dataLakes`." }) : null,
1562
+ isDefinedNotNull7(client) && !supported ? /* @__PURE__ */ jsx8(Alert7, { severity: "warning", children: "This wallet does not expose `xyo.client.dataLakes`." }) : null,
1458
1563
  /* @__PURE__ */ jsxs8(
1459
1564
  ButtonEx7,
1460
1565
  {
@@ -1474,7 +1579,7 @@ var DataLakeGetButton = ({
1474
1579
  }
1475
1580
  ),
1476
1581
  argsReady ? null : /* @__PURE__ */ jsx8(Typography7, { variant: "caption", sx: { color: "text.secondary" }, children: "Provide a per-origin `id` and at least one hash to enable the button." }),
1477
- isDefined9(result) ? /* @__PURE__ */ jsxs8(Stack8, { sx: { gap: 0.5 }, children: [
1582
+ isDefined10(result) ? /* @__PURE__ */ jsxs8(Stack8, { sx: { gap: 0.5 }, children: [
1478
1583
  /* @__PURE__ */ jsx8(Typography7, { variant: "subtitle2", children: result.length === 0 ? "No payloads returned" : `Payloads (${result.length})` }),
1479
1584
  /* @__PURE__ */ jsx8(
1480
1585
  Typography7,
@@ -1502,11 +1607,11 @@ import {
1502
1607
  TextField as TextField2,
1503
1608
  Typography as Typography8
1504
1609
  } from "@mui/material";
1505
- import { useMemo as useMemo3, useState as useState8 } from "react";
1610
+ import { useMemo as useMemo3, useState as useState9 } from "react";
1506
1611
  import { jsx as jsx9, jsxs as jsxs9 } from "react/jsx-runtime";
1507
1612
  var DataLakeGetPanel = ({ timeout, ...props }) => {
1508
- const [selectedId, setSelectedId] = useState8("");
1509
- const [hashesText, setHashesText] = useState8("");
1613
+ const [selectedId, setSelectedId] = useState9("");
1614
+ const [hashesText, setHashesText] = useState9("");
1510
1615
  const hashes = useMemo3(() => {
1511
1616
  return hashesText.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
1512
1617
  }, [hashesText]);
@@ -1550,14 +1655,14 @@ var DataLakeGetPanel = ({ timeout, ...props }) => {
1550
1655
  };
1551
1656
 
1552
1657
  // src/client/components/connected/DataLakeInsertButton.tsx
1553
- import { isDefined as isDefined10, isDefinedNotNull as isDefinedNotNull7 } from "@ariestools/sdk";
1658
+ import { isDefined as isDefined11, isDefinedNotNull as isDefinedNotNull8 } from "@ariestools/sdk";
1554
1659
  import { ButtonEx as ButtonEx8 } from "@ariestools/sdk-react";
1555
1660
  import {
1556
1661
  Alert as Alert8,
1557
1662
  Stack as Stack10,
1558
1663
  Typography as Typography9
1559
1664
  } from "@mui/material";
1560
- import { useState as useState9 } from "react";
1665
+ import { useState as useState10 } from "react";
1561
1666
  import { jsx as jsx10, jsxs as jsxs10 } from "react/jsx-runtime";
1562
1667
  var DataLakeInsertButton = ({
1563
1668
  id,
@@ -1571,14 +1676,14 @@ var DataLakeInsertButton = ({
1571
1676
  isLoading,
1572
1677
  timedout
1573
1678
  } = useClientFromWallet(timeout);
1574
- const [result, setResult] = useState9();
1575
- const [requestError, setRequestError] = useState9();
1576
- const [requesting, setRequesting] = useState9(false);
1679
+ const [result, setResult] = useState10();
1680
+ const [requestError, setRequestError] = useState10();
1681
+ const [requesting, setRequesting] = useState10(false);
1577
1682
  const dataLakes = client?.dataLakes;
1578
- const supported = isDefinedNotNull7(dataLakes);
1683
+ const supported = isDefinedNotNull8(dataLakes);
1579
1684
  const argsReady = id.length > 0 && payloads.length > 0;
1580
1685
  const handleClick = async () => {
1581
- if (!isDefinedNotNull7(dataLakes)) return;
1686
+ if (!isDefinedNotNull8(dataLakes)) return;
1582
1687
  setRequestError(void 0);
1583
1688
  setResult(void 0);
1584
1689
  setRequesting(true);
@@ -1602,7 +1707,7 @@ var DataLakeInsertButton = ({
1602
1707
  },
1603
1708
  children: [
1604
1709
  timedout ? /* @__PURE__ */ jsx10(Alert8, { severity: "warning", children: "Wallet not detected." }) : null,
1605
- isDefinedNotNull7(client) && !supported ? /* @__PURE__ */ jsx10(Alert8, { severity: "warning", children: "This wallet does not expose `xyo.client.dataLakes`." }) : null,
1710
+ isDefinedNotNull8(client) && !supported ? /* @__PURE__ */ jsx10(Alert8, { severity: "warning", children: "This wallet does not expose `xyo.client.dataLakes`." }) : null,
1606
1711
  /* @__PURE__ */ jsxs10(
1607
1712
  ButtonEx8,
1608
1713
  {
@@ -1622,7 +1727,7 @@ var DataLakeInsertButton = ({
1622
1727
  }
1623
1728
  ),
1624
1729
  argsReady ? null : /* @__PURE__ */ jsx10(Typography9, { variant: "caption", sx: { color: "text.secondary" }, children: "Provide a per-origin `id` and at least one payload to enable the button." }),
1625
- isDefined10(result) ? /* @__PURE__ */ jsxs10(Stack10, { sx: { gap: 0.5 }, children: [
1730
+ isDefined11(result) ? /* @__PURE__ */ jsxs10(Stack10, { sx: { gap: 0.5 }, children: [
1626
1731
  /* @__PURE__ */ jsx10(Typography9, { variant: "subtitle2", children: result.length === 0 ? "No payloads written (wallet filtered all)" : `Inserted (${result.length})` }),
1627
1732
  /* @__PURE__ */ jsx10(
1628
1733
  Typography9,
@@ -1651,7 +1756,7 @@ import {
1651
1756
  TextField as TextField3,
1652
1757
  Typography as Typography10
1653
1758
  } from "@mui/material";
1654
- import { useMemo as useMemo4, useState as useState10 } from "react";
1759
+ import { useMemo as useMemo4, useState as useState11 } from "react";
1655
1760
  import { jsx as jsx11, jsxs as jsxs11 } from "react/jsx-runtime";
1656
1761
  function buildDefaultPayload2() {
1657
1762
  const now = /* @__PURE__ */ new Date();
@@ -1678,8 +1783,8 @@ function parsePayload2(raw) {
1678
1783
  }
1679
1784
  }
1680
1785
  var DataLakeInsertPanel = ({ timeout, ...props }) => {
1681
- const [selectedId, setSelectedId] = useState10("");
1682
- const [payloadText, setPayloadText] = useState10(buildDefaultPayload2);
1786
+ const [selectedId, setSelectedId] = useState11("");
1787
+ const [payloadText, setPayloadText] = useState11(buildDefaultPayload2);
1683
1788
  const parse = useMemo4(() => parsePayload2(payloadText), [payloadText]);
1684
1789
  return /* @__PURE__ */ jsxs11(
1685
1790
  Stack11,
@@ -1735,14 +1840,14 @@ var DataLakeInsertPanel = ({ timeout, ...props }) => {
1735
1840
  };
1736
1841
 
1737
1842
  // src/client/components/connected/DataLakeListButton.tsx
1738
- import { isDefined as isDefined11, isDefinedNotNull as isDefinedNotNull8 } from "@ariestools/sdk";
1843
+ import { isDefined as isDefined12, isDefinedNotNull as isDefinedNotNull9 } from "@ariestools/sdk";
1739
1844
  import { ButtonEx as ButtonEx9 } from "@ariestools/sdk-react";
1740
1845
  import {
1741
1846
  Alert as Alert10,
1742
1847
  Stack as Stack12,
1743
1848
  Typography as Typography11
1744
1849
  } from "@mui/material";
1745
- import { useState as useState11 } from "react";
1850
+ import { useState as useState12 } from "react";
1746
1851
  import { jsx as jsx12, jsxs as jsxs12 } from "react/jsx-runtime";
1747
1852
  var DataLakeListButton = ({ timeout, ...props }) => {
1748
1853
  const {
@@ -1751,13 +1856,13 @@ var DataLakeListButton = ({ timeout, ...props }) => {
1751
1856
  isLoading,
1752
1857
  timedout
1753
1858
  } = useClientFromWallet(timeout);
1754
- const [lakes, setLakes] = useState11();
1755
- const [requestError, setRequestError] = useState11();
1756
- const [requesting, setRequesting] = useState11(false);
1859
+ const [lakes, setLakes] = useState12();
1860
+ const [requestError, setRequestError] = useState12();
1861
+ const [requesting, setRequesting] = useState12(false);
1757
1862
  const dataLakes = client?.dataLakes;
1758
- const supported = isDefinedNotNull8(dataLakes);
1863
+ const supported = isDefinedNotNull9(dataLakes);
1759
1864
  const handleClick = async () => {
1760
- if (!isDefinedNotNull8(dataLakes)) return;
1865
+ if (!isDefinedNotNull9(dataLakes)) return;
1761
1866
  setRequestError(void 0);
1762
1867
  setLakes(void 0);
1763
1868
  setRequesting(true);
@@ -1781,7 +1886,7 @@ var DataLakeListButton = ({ timeout, ...props }) => {
1781
1886
  },
1782
1887
  children: [
1783
1888
  timedout ? /* @__PURE__ */ jsx12(Alert10, { severity: "warning", children: "Wallet not detected." }) : null,
1784
- isDefinedNotNull8(client) && !supported ? /* @__PURE__ */ jsx12(Alert10, { severity: "warning", children: "This wallet does not expose `xyo.client.dataLakes`." }) : null,
1889
+ isDefinedNotNull9(client) && !supported ? /* @__PURE__ */ jsx12(Alert10, { severity: "warning", children: "This wallet does not expose `xyo.client.dataLakes`." }) : null,
1785
1890
  /* @__PURE__ */ jsx12(
1786
1891
  ButtonEx9,
1787
1892
  {
@@ -1793,7 +1898,7 @@ var DataLakeListButton = ({ timeout, ...props }) => {
1793
1898
  children: "List approved data lakes"
1794
1899
  }
1795
1900
  ),
1796
- isDefined11(lakes) ? /* @__PURE__ */ jsxs12(Stack12, { sx: { gap: 0.5 }, children: [
1901
+ isDefined12(lakes) ? /* @__PURE__ */ jsxs12(Stack12, { sx: { gap: 0.5 }, children: [
1797
1902
  /* @__PURE__ */ jsx12(Typography11, { variant: "subtitle2", children: lakes.length === 0 ? "No approved lakes" : `Approved lakes (${lakes.length})` }),
1798
1903
  /* @__PURE__ */ jsx12(
1799
1904
  Typography11,
@@ -1833,17 +1938,17 @@ import {
1833
1938
  Stack as Stack14
1834
1939
  } from "@mui/material";
1835
1940
  import { asSchema as asSchema3 } from "@xyo-network/sdk";
1836
- import { useMemo as useMemo5, useState as useState13 } from "react";
1941
+ import { useMemo as useMemo5, useState as useState14 } from "react";
1837
1942
 
1838
1943
  // src/client/components/connected/DataLakeRequestAccessButton.tsx
1839
- import { isDefined as isDefined12, isDefinedNotNull as isDefinedNotNull9 } from "@ariestools/sdk";
1944
+ import { isDefined as isDefined13, isDefinedNotNull as isDefinedNotNull10 } from "@ariestools/sdk";
1840
1945
  import { ButtonEx as ButtonEx10 } from "@ariestools/sdk-react";
1841
1946
  import {
1842
1947
  Alert as Alert11,
1843
1948
  Stack as Stack13,
1844
1949
  Typography as Typography12
1845
1950
  } from "@mui/material";
1846
- import { useState as useState12 } from "react";
1951
+ import { useState as useState13 } from "react";
1847
1952
  import { jsx as jsx13, jsxs as jsxs13 } from "react/jsx-runtime";
1848
1953
  var DataLakeRequestAccessButton = ({
1849
1954
  options,
@@ -1856,13 +1961,13 @@ var DataLakeRequestAccessButton = ({
1856
1961
  isLoading,
1857
1962
  timedout
1858
1963
  } = useClientFromWallet(timeout);
1859
- const [granted, setGranted] = useState12();
1860
- const [requestError, setRequestError] = useState12();
1861
- const [requesting, setRequesting] = useState12(false);
1964
+ const [granted, setGranted] = useState13();
1965
+ const [requestError, setRequestError] = useState13();
1966
+ const [requesting, setRequesting] = useState13(false);
1862
1967
  const dataLakes = client?.dataLakes;
1863
- const supported = isDefinedNotNull9(dataLakes);
1968
+ const supported = isDefinedNotNull10(dataLakes);
1864
1969
  const handleClick = async () => {
1865
- if (!isDefinedNotNull9(dataLakes)) return;
1970
+ if (!isDefinedNotNull10(dataLakes)) return;
1866
1971
  setRequestError(void 0);
1867
1972
  setGranted(void 0);
1868
1973
  setRequesting(true);
@@ -1886,7 +1991,7 @@ var DataLakeRequestAccessButton = ({
1886
1991
  },
1887
1992
  children: [
1888
1993
  timedout ? /* @__PURE__ */ jsx13(Alert11, { severity: "warning", children: "Wallet not detected." }) : null,
1889
- isDefinedNotNull9(client) && !supported ? /* @__PURE__ */ jsx13(Alert11, { severity: "warning", children: "This wallet does not expose `xyo.client.dataLakes`." }) : null,
1994
+ isDefinedNotNull10(client) && !supported ? /* @__PURE__ */ jsx13(Alert11, { severity: "warning", children: "This wallet does not expose `xyo.client.dataLakes`." }) : null,
1890
1995
  /* @__PURE__ */ jsx13(
1891
1996
  ButtonEx10,
1892
1997
  {
@@ -1898,7 +2003,7 @@ var DataLakeRequestAccessButton = ({
1898
2003
  children: "Request data lake access"
1899
2004
  }
1900
2005
  ),
1901
- isDefined12(granted) ? /* @__PURE__ */ jsxs13(Stack13, { sx: { gap: 0.5 }, children: [
2006
+ isDefined13(granted) ? /* @__PURE__ */ jsxs13(Stack13, { sx: { gap: 0.5 }, children: [
1902
2007
  /* @__PURE__ */ jsx13(Typography12, { variant: "subtitle2", children: "Granted:" }),
1903
2008
  /* @__PURE__ */ jsxs13(Typography12, { variant: "body2", sx: { fontFamily: "monospace", wordBreak: "break-all" }, children: [
1904
2009
  "id:",
@@ -1918,8 +2023,8 @@ import { jsx as jsx14, jsxs as jsxs14 } from "react/jsx-runtime";
1918
2023
  var observationSchema = asSchema3("network.xyo.observation.v2", true);
1919
2024
  var locationSchema = asSchema3("network.xyo.location", true);
1920
2025
  var DataLakeRequestAccessPanel = ({ timeout, ...props }) => {
1921
- const [capability, setCapability] = useState13("read+write");
1922
- const [includeSchemas, setIncludeSchemas] = useState13(true);
2026
+ const [capability, setCapability] = useState14("read+write");
2027
+ const [includeSchemas, setIncludeSchemas] = useState14(true);
1923
2028
  const supportsSchemasFilter = capability !== "viewer";
1924
2029
  const options = useMemo5(() => {
1925
2030
  const cap = capability === "read+write" ? { read: true, write: true } : capability;
@@ -2015,8 +2120,8 @@ var DataLakeOperationsPanel = ({ timeout, ...props }) => {
2015
2120
  // src/client/components/connected/SignTransactionButton.tsx
2016
2121
  import {
2017
2122
  assertEx as assertEx2,
2018
- isDefined as isDefined13,
2019
- isDefinedNotNull as isDefinedNotNull10
2123
+ isDefined as isDefined14,
2124
+ isDefinedNotNull as isDefinedNotNull11
2020
2125
  } from "@ariestools/sdk";
2021
2126
  import { ButtonEx as ButtonEx11 } from "@ariestools/sdk-react";
2022
2127
  import {
@@ -2033,7 +2138,7 @@ import {
2033
2138
  HashSchema as HashSchema2,
2034
2139
  SequenceNetwork as SequenceNetwork2
2035
2140
  } from "@xyo-network/xl1-sdk";
2036
- import { useCallback as useCallback5, useState as useState14 } from "react";
2141
+ import { useCallback as useCallback6, useState as useState15 } from "react";
2037
2142
  import { jsx as jsx16, jsxs as jsxs16 } from "react/jsx-runtime";
2038
2143
  var EMPTY_PAYLOADS = [];
2039
2144
  var SIGNER_PERMISSIONS2 = [
@@ -2053,14 +2158,14 @@ var SignTransactionButton = ({
2053
2158
  error: gatewayError,
2054
2159
  timedout
2055
2160
  } = useGatewayFromWallet(gatewayName, timeout);
2056
- const [signing, setSigning] = useState14(false);
2057
- const [signError, setSignError] = useState14();
2058
- const [signedHash, setSignedHash] = useState14();
2161
+ const [signing, setSigning] = useState15(false);
2162
+ const [signError, setSignError] = useState15();
2163
+ const [signedHash, setSignedHash] = useState15();
2059
2164
  const signer = gateway?.signer;
2060
2165
  const viewer = gateway?.connection?.viewer;
2061
- const canSign = isDefinedNotNull10(signer) && isDefinedNotNull10(viewer) && !signing;
2062
- const handleSign = useCallback5(async () => {
2063
- if (!isDefinedNotNull10(gateway)) return;
2166
+ const canSign = isDefinedNotNull11(signer) && isDefinedNotNull11(viewer) && !signing;
2167
+ const handleSign = useCallback6(async () => {
2168
+ if (!isDefinedNotNull11(gateway)) return;
2064
2169
  const resolvedSigner = assertEx2(gateway.signer, () => "No signer available on gateway");
2065
2170
  const resolvedViewer = assertEx2(gateway.connection?.viewer, () => "No viewer available on gateway connection");
2066
2171
  setSignError(void 0);
@@ -2072,7 +2177,7 @@ var SignTransactionButton = ({
2072
2177
  const exp = asXL1BlockNumber(nbf + 10, true);
2073
2178
  const from = await resolvedSigner.address();
2074
2179
  const referencedHashes = await PayloadBuilder3.hashes(referencedPayloads);
2075
- const onChainPayloads = anchorOnChain && isDefined13(referencedHashes[0]) ? [{ schema: HashSchema2, hash: referencedHashes[0] }] : [];
2180
+ const onChainPayloads = anchorOnChain && isDefined14(referencedHashes[0]) ? [{ schema: HashSchema2, hash: referencedHashes[0] }] : [];
2076
2181
  let tx = await buildUnsignedTransaction(
2077
2182
  chain,
2078
2183
  onChainPayloads,
@@ -2147,7 +2252,7 @@ var SignTransactionButton = ({
2147
2252
  ),
2148
2253
  /* @__PURE__ */ jsx16(PopoverErrorRender, { error: gatewayError ?? signError, scope: "SignTransactionButton" })
2149
2254
  ] }),
2150
- isDefined13(signedHash) ? /* @__PURE__ */ jsxs16(
2255
+ isDefined14(signedHash) ? /* @__PURE__ */ jsxs16(
2151
2256
  Stack16,
2152
2257
  {
2153
2258
  direction: "row",
@@ -2177,7 +2282,7 @@ import { createContextEx as createContextEx2 } from "@ariestools/sdk-react";
2177
2282
  var InPageGatewaysContext = createContextEx2();
2178
2283
 
2179
2284
  // src/client/context/in-page/lib/buildGateway.ts
2180
- import { assertEx as assertEx3, isDefined as isDefined14 } from "@ariestools/sdk";
2285
+ import { assertEx as assertEx3, isDefined as isDefined15 } from "@ariestools/sdk";
2181
2286
  import {
2182
2287
  basicRemoteRunnerLocator,
2183
2288
  basicRemoteViewerLocator,
@@ -2194,7 +2299,7 @@ var buildGateway = async (gatewayName, localEndpoint, signerTransport, signerFac
2194
2299
  const rpcUrl = `${resolvedNetwork.url}/rpc`;
2195
2300
  if (transport === "rpc") {
2196
2301
  const rpcConnection = { protocol: "http", url: rpcUrl };
2197
- const locator = isDefined14(signerTransport) || isDefined14(signerFactory) || isDefined14(signerAccount) ? await basicRemoteRunnerLocator(gatewayName, rpcConnection, signerTransport, void 0, { signerAccount, signerFactory }) : await basicRemoteViewerLocator(gatewayName, rpcConnection);
2302
+ const locator = isDefined15(signerTransport) || isDefined15(signerFactory) || isDefined15(signerAccount) ? await basicRemoteRunnerLocator(gatewayName, rpcConnection, signerTransport, void 0, { signerAccount, signerFactory }) : await basicRemoteViewerLocator(gatewayName, rpcConnection);
2198
2303
  return await locator.getInstance(XyoGatewayMoniker);
2199
2304
  }
2200
2305
  const config = gatewayName === LocalNetwork2.id ? {
@@ -2202,7 +2307,7 @@ var buildGateway = async (gatewayName, localEndpoint, signerTransport, signerFac
2202
2307
  chainState: { readUrl: `${localEndpoint}/state` },
2203
2308
  index: { readUrl: `${localEndpoint}/indexes` }
2204
2309
  } : restGatewayConfigFromEndpoint(`https://${gatewayName}.xyo.space`);
2205
- if (isDefined14(signerFactory)) {
2310
+ if (isDefined15(signerFactory)) {
2206
2311
  return await getRestGatewayRunner({
2207
2312
  ...config,
2208
2313
  name: gatewayName,
@@ -2210,7 +2315,7 @@ var buildGateway = async (gatewayName, localEndpoint, signerTransport, signerFac
2210
2315
  signerFactory
2211
2316
  });
2212
2317
  }
2213
- if (isDefined14(signerAccount)) {
2318
+ if (isDefined15(signerAccount)) {
2214
2319
  return await getRestGatewayRunner({
2215
2320
  ...config,
2216
2321
  name: gatewayName,
@@ -2218,7 +2323,7 @@ var buildGateway = async (gatewayName, localEndpoint, signerTransport, signerFac
2218
2323
  signerAccount
2219
2324
  });
2220
2325
  }
2221
- if (isDefined14(signerTransport)) {
2326
+ if (isDefined15(signerTransport)) {
2222
2327
  return await getRestGatewayRunner({
2223
2328
  ...config,
2224
2329
  name: gatewayName,
@@ -2266,10 +2371,10 @@ import { bindPageLifecycle } from "@ariestools/browser-kit-page";
2266
2371
  import { DefaultNetworks as DefaultNetworks3 } from "@xyo-network/xl1-sdk";
2267
2372
  import {
2268
2373
  startTransition,
2269
- useCallback as useCallback6,
2270
- useEffect as useEffect5,
2374
+ useCallback as useCallback7,
2375
+ useEffect as useEffect6,
2271
2376
  useMemo as useMemo6,
2272
- useState as useState15
2377
+ useState as useState16
2273
2378
  } from "react";
2274
2379
  import { jsx as jsx17 } from "react/jsx-runtime";
2275
2380
  var DEFAULT_LOCAL_ENDPOINT = "https://chain.aries.test:8791";
@@ -2282,11 +2387,11 @@ var InPageGatewaysProvider = ({
2282
2387
  transport = "rpc",
2283
2388
  children
2284
2389
  }) => {
2285
- const [gateways, setGateways] = useState15({});
2286
- const [errors, setErrors] = useState15({});
2287
- const [previousSignerTransport, setPreviousSignerTransport] = useState15(signerTransport);
2288
- const [pageGeneration, setPageGeneration] = useState15(0);
2289
- const clearAll = useCallback6(() => {
2390
+ const [gateways, setGateways] = useState16({});
2391
+ const [errors, setErrors] = useState16({});
2392
+ const [previousSignerTransport, setPreviousSignerTransport] = useState16(signerTransport);
2393
+ const [pageGeneration, setPageGeneration] = useState16(0);
2394
+ const clearAll = useCallback7(() => {
2290
2395
  setGateways({});
2291
2396
  setErrors({});
2292
2397
  }, []);
@@ -2294,7 +2399,7 @@ var InPageGatewaysProvider = ({
2294
2399
  clearAll();
2295
2400
  setPreviousSignerTransport(signerTransport);
2296
2401
  }
2297
- useEffect5(() => {
2402
+ useEffect6(() => {
2298
2403
  const controller = new AbortController();
2299
2404
  addEventListener("pageshow", (event) => {
2300
2405
  if (!event.persisted) return;
@@ -2303,7 +2408,7 @@ var InPageGatewaysProvider = ({
2303
2408
  }, { signal: controller.signal });
2304
2409
  return () => controller.abort();
2305
2410
  }, [clearAll]);
2306
- useEffect5(() => {
2411
+ useEffect6(() => {
2307
2412
  let cancelled = false;
2308
2413
  const ownedSystems = [];
2309
2414
  const buildAll = async () => {
@@ -2379,7 +2484,7 @@ import { useContextEx } from "@ariestools/sdk-react";
2379
2484
  var useProvidedInPageGateways = (required = true) => useContextEx(InPageGatewaysContext, "InPageGateways", required);
2380
2485
 
2381
2486
  // src/client/context/providers/GatewayProvider.tsx
2382
- import { isDefinedNotNull as isDefinedNotNull11, isNull as isNull2 } from "@ariestools/sdk";
2487
+ import { isDefinedNotNull as isDefinedNotNull12, isNull as isNull3 } from "@ariestools/sdk";
2383
2488
  import { useMemo as useMemo7 } from "react";
2384
2489
  import { jsx as jsx18, jsxs as jsxs17 } from "react/jsx-runtime";
2385
2490
  var GatewayProvider = ({ gatewayName, children }) => {
@@ -2395,7 +2500,7 @@ var GatewayProvider = ({ gatewayName, children }) => {
2395
2500
  const gatewayFromConfig = gatewayName ? allGateways[gatewayName] : void 0;
2396
2501
  const gatewayFromConfigError = gatewayName ? allGatewayErrors[gatewayName] : void 0;
2397
2502
  const { defaultGateway, gateways } = useMemo7(() => {
2398
- if (isNull2(gatewayFromWallet)) {
2503
+ if (isNull3(gatewayFromWallet)) {
2399
2504
  return {
2400
2505
  defaultGateway: gatewayFromConfig,
2401
2506
  gateways: {
@@ -2404,7 +2509,7 @@ var GatewayProvider = ({ gatewayName, children }) => {
2404
2509
  }
2405
2510
  };
2406
2511
  }
2407
- if (isDefinedNotNull11(gatewayFromWallet)) {
2512
+ if (isDefinedNotNull12(gatewayFromWallet)) {
2408
2513
  return {
2409
2514
  defaultGateway: gatewayFromWallet,
2410
2515
  gateways: {
@@ -2484,12 +2589,12 @@ import { useContextEx as useContextEx2 } from "@ariestools/sdk-react";
2484
2589
  var useProvidedGateway = (required = true) => useContextEx2(GatewayContext, "Gateway", required);
2485
2590
 
2486
2591
  // src/model/types/XyoGlobal.ts
2487
- import { isDefinedNotNull as isDefinedNotNull12, isObject } from "@ariestools/sdk";
2592
+ import { isDefinedNotNull as isDefinedNotNull13, isObject } from "@ariestools/sdk";
2488
2593
  var isXyoGlobal = (obj) => {
2489
- return isDefinedNotNull12(obj) && isObject(obj) && "client" in obj && "connections" in obj && "errors" in obj && "sessionId" in obj && "walletExtensionId" in obj;
2594
+ return isDefinedNotNull13(obj) && isObject(obj) && "client" in obj && "connections" in obj && "errors" in obj && "sessionId" in obj && "walletExtensionId" in obj;
2490
2595
  };
2491
2596
  var isUninitializedXyoGlobal = (obj) => {
2492
- return isDefinedNotNull12(obj) && isObject(obj) && "connections" in obj && "sessionId" in obj && "walletExtensionId" in obj && !("client" in obj) && "errors" in obj && Array.isArray(obj.errors) && obj.errors.length === 0;
2597
+ return isDefinedNotNull13(obj) && isObject(obj) && "connections" in obj && "sessionId" in obj && "walletExtensionId" in obj && !("client" in obj) && "errors" in obj && Array.isArray(obj.errors) && obj.errors.length === 0;
2493
2598
  };
2494
2599
 
2495
2600
  // src/shared/components/menu-item/ActiveMenuItem.tsx
@@ -2533,7 +2638,7 @@ var ActiveMenuItem = ({
2533
2638
  };
2534
2639
 
2535
2640
  // src/shared/components/stack/DetailsStack.tsx
2536
- import { isDefined as isDefined15 } from "@ariestools/sdk";
2641
+ import { isDefined as isDefined16 } from "@ariestools/sdk";
2537
2642
  import {
2538
2643
  Stack as Stack17,
2539
2644
  Tooltip as Tooltip2,
@@ -2551,7 +2656,7 @@ var DetailsStack = ({
2551
2656
  ...props
2552
2657
  }) => {
2553
2658
  const theme = useTheme2();
2554
- const hasTooltip = isDefined15(tooltipTitle);
2659
+ const hasTooltip = isDefined16(tooltipTitle);
2555
2660
  const resolvedIconComponent = useMemo9(() => {
2556
2661
  return isComponentType(IconComponent) ? /* @__PURE__ */ jsx21(
2557
2662
  IconComponent,
@@ -2712,6 +2817,7 @@ export {
2712
2817
  useConnectAccount,
2713
2818
  useGateway,
2714
2819
  useGatewayFromWallet,
2820
+ useGrantedAccounts,
2715
2821
  usePermissions,
2716
2822
  useProvidedGateway,
2717
2823
  useProvidedInPageGateways