@xyo-network/react-sentinel 7.4.2 → 7.5.1

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.
@@ -2,12 +2,12 @@ import type { Meta } from '@storybook/react-vite';
2
2
  import React from 'react';
3
3
  import { SentinelCard } from './Card.tsx';
4
4
  declare const StorybookEntry: Meta<typeof SentinelCard>;
5
- declare const NftSentinelCard: import(".store/storybook-virtual-a067dd1507/package/internal/csf").AnnotatedStoryFn<import("@storybook/react-vite").ReactRenderer, import("@mui/material").CardOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "classes" | "className" | "style" | "children" | "sx" | "variant" | "elevation" | "square" | "raised"> & {
5
+ declare const NftSentinelCard: import("storybook/internal/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, import("@mui/material").CardOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "classes" | "className" | "style" | "children" | "sx" | "variant" | "elevation" | "square" | "raised"> & {
6
6
  component?: React.ElementType;
7
7
  } & import("@xyo-network/react-module").ModuleRenderProps<import("@xyo-network/sentinel-model").SentinelInstance<import("@xyo-network/sentinel-model").SentinelParams<import("@xyo-network/module-model").AnyConfigSchema<import("@xyo-network/sentinel-model").SentinelConfig>>, import("@xyo-network/sentinel-model").SentinelModuleEventData<import("@xyo-network/module-model").Module<import("@xyo-network/module-model").ModuleParams<import("@xyo-network/module-model").AnyConfigSchema<import("@xyo-network/module-model").ModuleConfig>>, import("@xyo-network/module-model").ModuleEventData<object>>>>> & {
8
8
  inPayloads?: import("@xyo-network/payload-model").Payload[];
9
9
  }>;
10
- declare const NftTokensSentinelCard: import(".store/storybook-virtual-a067dd1507/package/internal/csf").AnnotatedStoryFn<import("@storybook/react-vite").ReactRenderer, import("@mui/material").CardOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "classes" | "className" | "style" | "children" | "sx" | "variant" | "elevation" | "square" | "raised"> & {
10
+ declare const NftTokensSentinelCard: import("storybook/internal/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, import("@mui/material").CardOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "classes" | "className" | "style" | "children" | "sx" | "variant" | "elevation" | "square" | "raised"> & {
11
11
  component?: React.ElementType;
12
12
  } & import("@xyo-network/react-module").ModuleRenderProps<import("@xyo-network/sentinel-model").SentinelInstance<import("@xyo-network/sentinel-model").SentinelParams<import("@xyo-network/module-model").AnyConfigSchema<import("@xyo-network/sentinel-model").SentinelConfig>>, import("@xyo-network/sentinel-model").SentinelModuleEventData<import("@xyo-network/module-model").Module<import("@xyo-network/module-model").ModuleParams<import("@xyo-network/module-model").AnyConfigSchema<import("@xyo-network/module-model").ModuleConfig>>, import("@xyo-network/module-model").ModuleEventData<object>>>>> & {
13
13
  inPayloads?: import("@xyo-network/payload-model").Payload[];
@@ -1 +1 @@
1
- {"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../src/contexts/Provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAEjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAKjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAEjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAC9C,OAAO,KAEN,MAAM,OAAO,CAAA;AAMd,MAAM,WAAW,qBAAqB;IACpC,+CAA+C;IAC/C,OAAO,EAAE,eAAe,CAAA;IACxB,+EAA+E;IAC/E,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,GAAG,CAAC,EAAE,gBAAgB,EAAE,CAAA;IACxB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,SAAS,CAAC,EAAE,eAAe,EAAE,CAAA;CAC9B;AAED,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAAC,qBAAqB,CAAC,CAsG/E,CAAA"}
1
+ {"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../src/contexts/Provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAEjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAKjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAEjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAC9C,OAAO,KAEN,MAAM,OAAO,CAAA;AAMd,MAAM,WAAW,qBAAqB;IACpC,+CAA+C;IAC/C,OAAO,EAAE,eAAe,CAAA;IACxB,+EAA+E;IAC/E,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,GAAG,CAAC,EAAE,gBAAgB,EAAE,CAAA;IACxB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,SAAS,CAAC,EAAE,eAAe,EAAE,CAAA;CAC9B;AAED,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAAC,qBAAqB,CAAC,CAmG/E,CAAA"}
@@ -1,6 +1,6 @@
1
- import type { EnumValue } from '@xylabs/enum';
2
- import { Enum } from '@xylabs/enum';
3
1
  import type { ContextExState } from '@xylabs/react-shared';
2
+ import type { EnumValue } from '@xylabs/sdk-js';
3
+ import { Enum } from '@xylabs/sdk-js';
4
4
  import type { ArchivistModuleInstance } from '@xyo-network/archivist-model';
5
5
  import type { BoundWitness } from '@xyo-network/boundwitness-model';
6
6
  import type { SentinelModule } from '@xyo-network/sentinel-model';
@@ -1 +1 @@
1
- {"version":3,"file":"State.d.ts","sourceRoot":"","sources":["../../../src/contexts/State.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAA;AAC3E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAE/D,eAAO,MAAM,oBAAoB;;;;;;EAM/B,CAAA;AAEF,MAAM,MAAM,oBAAoB,GAAG,SAAS,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAEzE,MAAM,WAAW,6BAA6B;IAC5C,MAAM,EAAE,oBAAoB,CAAA;IAC5B,OAAO,EAAE,aAAa,CAAA;CACvB;AAED,MAAM,WAAW,kCAAkC;IACjD,SAAS,EAAE,uBAAuB,CAAA;IAClC,MAAM,EAAE,oBAAoB,CAAA;CAC7B;AAED,MAAM,WAAW,sBAAsB;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,kCAAkC,CAAC,CAAA;IAC/D,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,6BAA6B,CAAC,CAAA;CAC1D;AAED,MAAM,MAAM,oBAAoB,GAAG,cAAc,CAAC;IAChD,OAAO,CAAC,EAAE,YAAY,EAAE,CAAA;IACxB,QAAQ,CAAC,EAAE,sBAAsB,CAAA;IACjC,eAAe,CAAC,EAAE,KA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;IACzB,QAAQ,CAAC,EAAE,cAAc,CAAA;IACzB,MAAM,CAAC,EAAE,oBAAoB,CAAA;CAC9B,CAAC,CAAA"}
@@ -1,13 +1,23 @@
1
1
  export declare const useSentinelContext: () => {
2
2
  history: {
3
- schema: "network.xyo.boundwitness";
4
- addresses: import(".store/@xylabs-hex-npm-5.0.50-a7a7e1b900/package").Address[];
5
- payload_hashes: import(".store/@xylabs-hex-npm-5.0.50-a7a7e1b900/package").Hash[];
6
- payload_schemas: string[];
7
- previous_hashes: (import(".store/@xylabs-hex-npm-5.0.50-a7a7e1b900/package").Hash | null)[];
8
- $signatures: (import(".store/@xylabs-hex-npm-5.0.50-a7a7e1b900/package").Hex | null)[];
9
- $destination?: import(".store/@xylabs-hex-npm-5.0.50-a7a7e1b900/package").Address | undefined;
10
- $sourceQuery?: import(".store/@xylabs-hex-npm-5.0.50-a7a7e1b900/package").Hash | undefined;
3
+ schema: "network.xyo.boundwitness" & {
4
+ readonly __schema: true;
5
+ };
6
+ addresses: (Lowercase<string> & {
7
+ readonly __hex: true;
8
+ } & {
9
+ readonly __address: true;
10
+ })[];
11
+ payload_hashes: import("@xylabs/hex").BrandedHash[];
12
+ payload_schemas: import("@xyo-network/payload-model").BrandedSchema<string>[];
13
+ previous_hashes: (import("@xylabs/hex").BrandedHash | null)[];
14
+ $signatures: (import("@xylabs/hex").BrandedHex | null)[];
15
+ $destination?: (Lowercase<string> & {
16
+ readonly __hex: true;
17
+ } & {
18
+ readonly __address: true;
19
+ }) | undefined;
20
+ $sourceQuery?: import("@xylabs/hex").BrandedHash | undefined;
11
21
  }[] | undefined;
12
22
  progress: import("./State.ts").SentinelReportProgress | undefined;
13
23
  reportingErrors: Error[] | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"use.d.ts","sourceRoot":"","sources":["../../../src/contexts/use.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;CAO9B,CAAA"}
1
+ {"version":3,"file":"use.d.ts","sourceRoot":"","sources":["../../../src/contexts/use.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;CAO9B,CAAA"}
@@ -1,69 +1,77 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
1
4
  // src/components/Card/Card.tsx
2
5
  import { Card } from "@mui/material";
3
6
  import { usePromise } from "@xylabs/react-promise";
4
- import { useState } from "react";
7
+ import React4, { useState } from "react";
5
8
 
6
9
  // src/components/Card/CardActions.tsx
7
10
  import { ButtonEx } from "@xylabs/react-button";
8
11
  import { ModuleCardActions } from "@xyo-network/react-module";
9
- import { jsx } from "react/jsx-runtime";
10
- var SentinelCardActions = ({
11
- onReport,
12
- mod,
13
- ...props
14
- }) => {
15
- return /* @__PURE__ */ jsx(ModuleCardActions, { mod, ...props, children: /* @__PURE__ */ jsx(ButtonEx, { onClick: () => onReport?.(mod), size: "small", variant: "outlined", children: "Report" }) });
16
- };
12
+ import React from "react";
13
+ var SentinelCardActions = /* @__PURE__ */ __name(({ onReport, mod, ...props }) => {
14
+ return /* @__PURE__ */ React.createElement(ModuleCardActions, {
15
+ mod,
16
+ ...props
17
+ }, /* @__PURE__ */ React.createElement(ButtonEx, {
18
+ onClick: /* @__PURE__ */ __name(() => onReport?.(mod), "onClick"),
19
+ size: "small",
20
+ variant: "outlined"
21
+ }, "Report"));
22
+ }, "SentinelCardActions");
17
23
 
18
24
  // src/components/Card/CardContent.tsx
19
25
  import { FlexGrowRow } from "@xylabs/react-flexbox";
20
26
  import { ModuleCardContent } from "@xyo-network/react-module";
21
27
  import { JsonViewerEx } from "@xyo-network/react-payload-raw-info";
22
- import { jsx as jsx2, jsxs } from "react/jsx-runtime";
23
- var SentinelCardContent = ({
24
- children,
25
- report,
26
- mod,
27
- ...props
28
- }) => {
29
- return /* @__PURE__ */ jsx2(ModuleCardContent, { mod, ...props, children: /* @__PURE__ */ jsxs(FlexGrowRow, { flexWrap: "wrap", justifyContent: "start", gap: 2, children: [
30
- report ? /* @__PURE__ */ jsx2(JsonViewerEx, { value: report }) : null,
31
- children
32
- ] }) });
33
- };
28
+ import React2 from "react";
29
+ var SentinelCardContent = /* @__PURE__ */ __name(({ children, report, mod, ...props }) => {
30
+ return /* @__PURE__ */ React2.createElement(ModuleCardContent, {
31
+ mod,
32
+ ...props
33
+ }, /* @__PURE__ */ React2.createElement(FlexGrowRow, {
34
+ flexWrap: "wrap",
35
+ justifyContent: "start",
36
+ gap: 2
37
+ }, report ? /* @__PURE__ */ React2.createElement(JsonViewerEx, {
38
+ value: report
39
+ }) : null, children));
40
+ }, "SentinelCardContent");
34
41
 
35
42
  // src/components/Card/CardHeader.tsx
36
43
  import { ModuleCardHeader } from "@xyo-network/react-module";
37
- import { jsx as jsx3 } from "react/jsx-runtime";
38
- var SentinelCardHeader = ({
39
- title,
40
- mod,
41
- ...props
42
- }) => {
43
- return /* @__PURE__ */ jsx3(ModuleCardHeader, { mod, title: title ?? mod?.config.name ?? "Sentinel", ...props });
44
- };
44
+ import React3 from "react";
45
+ var SentinelCardHeader = /* @__PURE__ */ __name(({ title, mod, ...props }) => {
46
+ return /* @__PURE__ */ React3.createElement(ModuleCardHeader, {
47
+ mod,
48
+ title: title ?? mod?.config.name ?? "Sentinel",
49
+ ...props
50
+ });
51
+ }, "SentinelCardHeader");
45
52
 
46
53
  // src/components/Card/Card.tsx
47
- import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
48
- var SentinelCard = ({
49
- children,
50
- inPayloads,
51
- mod,
52
- ...props
53
- }) => {
54
+ var SentinelCard = /* @__PURE__ */ __name(({ children, inPayloads, mod, ...props }) => {
54
55
  const [retry, setRetry] = useState(-1);
55
56
  const [report] = usePromise(async () => {
56
57
  if (retry >= 0) {
57
58
  return await mod?.report(inPayloads);
58
59
  }
59
- }, [mod, retry, inPayloads]);
60
- return /* @__PURE__ */ jsxs2(Card, { ...props, children: [
61
- /* @__PURE__ */ jsx4(SentinelCardHeader, { mod }),
62
- /* @__PURE__ */ jsx4(SentinelCardContent, { mod, report }),
63
- children,
64
- /* @__PURE__ */ jsx4(SentinelCardActions, { mod, onReport: () => setRetry(retry + 1) })
65
- ] });
66
- };
60
+ }, [
61
+ mod,
62
+ retry,
63
+ inPayloads
64
+ ]);
65
+ return /* @__PURE__ */ React4.createElement(Card, props, /* @__PURE__ */ React4.createElement(SentinelCardHeader, {
66
+ mod
67
+ }), /* @__PURE__ */ React4.createElement(SentinelCardContent, {
68
+ mod,
69
+ report
70
+ }), children, /* @__PURE__ */ React4.createElement(SentinelCardActions, {
71
+ mod,
72
+ onReport: /* @__PURE__ */ __name(() => setRetry(retry + 1), "onReport")
73
+ }));
74
+ }, "SentinelCard");
67
75
 
68
76
  // src/contexts/Context.ts
69
77
  import { createContextEx } from "@xylabs/react-shared";
@@ -75,14 +83,10 @@ import { useWitnessesFromNode } from "@xyo-network/react-witness";
75
83
  import { MemorySentinel } from "@xyo-network/sentinel-memory";
76
84
  import { SentinelConfigSchema } from "@xyo-network/sentinel-model";
77
85
  import { asWitnessInstance } from "@xyo-network/witness-model";
78
- import {
79
- useEffect,
80
- useMemo,
81
- useState as useState2
82
- } from "react";
86
+ import React5, { useMemo, useState as useState2 } from "react";
83
87
 
84
88
  // src/contexts/State.ts
85
- import { Enum } from "@xylabs/enum";
89
+ import { Enum } from "@xylabs/sdk-js";
86
90
  var SentinelReportStatus = Enum({
87
91
  Idle: "idle",
88
92
  Queued: "queued",
@@ -92,94 +96,94 @@ var SentinelReportStatus = Enum({
92
96
  });
93
97
 
94
98
  // src/contexts/Provider.tsx
95
- import { jsx as jsx5 } from "react/jsx-runtime";
96
- var SentinelProvider = ({
97
- account,
98
- archivist,
99
- children,
100
- ids,
101
- name,
102
- required = false
103
- }) => {
99
+ var SentinelProvider = /* @__PURE__ */ __name(({ account, archivist, children, ids, name, required = false }) => {
104
100
  const [sentinel, setSentinel] = useState2();
105
101
  const [history, setHistory] = useState2();
106
102
  const [progress, setProgress] = useState2({});
107
103
  const [status, setStatus] = useState2(SentinelReportStatus.Idle);
108
104
  const [reportingErrors, setReportingErrors] = useState2();
109
105
  const [witnesses] = useWitnessesFromNode(ids);
110
- useAsyncEffect(
111
- async (mounted) => {
112
- const sentinel2 = await MemorySentinel.create({
113
- account,
114
- config: {
115
- archivists: archivist ? [archivist] : void 0,
116
- name,
117
- schema: SentinelConfigSchema,
118
- synchronous: true,
119
- tasks: witnesses?.map((mod) => ({ mod: mod.address }))
106
+ useAsyncEffect(async (mounted) => {
107
+ const sentinel2 = await MemorySentinel.create({
108
+ account,
109
+ config: {
110
+ archivists: archivist ? [
111
+ archivist
112
+ ] : void 0,
113
+ name,
114
+ schema: SentinelConfigSchema,
115
+ synchronous: true,
116
+ tasks: witnesses?.map((mod) => ({
117
+ mod: mod.address
118
+ }))
119
+ }
120
+ });
121
+ const offCallbacks = [
122
+ sentinel2.on("reportEnd", ({ mod, outPayloads }) => {
123
+ if (mounted()) {
124
+ setProgress({
125
+ archivists: progress.archivists,
126
+ witnesses: progress.witnesses
127
+ });
128
+ setStatus(outPayloads?.length ? SentinelReportStatus.Succeeded : SentinelReportStatus.Failed);
129
+ setReportingErrors([
130
+ new Error(`Witness failed [${mod?.config?.name ?? mod.address}]`)
131
+ ]);
132
+ }
133
+ }),
134
+ sentinel2.on("reportStart", () => {
135
+ if (mounted()) {
136
+ setProgress({
137
+ archivists: {},
138
+ witnesses: {}
139
+ });
140
+ setStatus(SentinelReportStatus.Started);
120
141
  }
121
- });
122
- const offCallbacks = [
123
- sentinel2.on("reportEnd", ({ mod, outPayloads }) => {
124
- if (mounted()) {
125
- setProgress({
126
- archivists: progress.archivists,
127
- witnesses: progress.witnesses
128
- });
129
- setStatus(outPayloads?.length ? SentinelReportStatus.Succeeded : SentinelReportStatus.Failed);
130
- setReportingErrors([new Error(`Witness failed [${mod?.config?.name ?? mod.address}]`)]);
131
- }
132
- }),
133
- sentinel2.on("reportStart", () => {
134
- if (mounted()) {
135
- setProgress({ archivists: {}, witnesses: {} });
136
- setStatus(SentinelReportStatus.Started);
137
- }
138
- })
139
- ];
140
- if (witnesses)
141
- for (const witness of witnesses) {
142
- offCallbacks.push(
143
- witness.on("observeEnd", ({ mod, outPayloads }) => {
144
- const witnesses2 = progress.witnesses ?? {};
145
- witnesses2[witness.address] = {
146
- status: outPayloads?.length ? SentinelReportStatus.Succeeded : SentinelReportStatus.Failed,
147
- witness: asWitnessInstance(mod, () => `Module is not a witness [${mod.id}]`, { required: true })
148
- };
149
- if (mounted()) {
150
- setProgress({
151
- archivists: progress.archivists,
152
- witnesses: witnesses2
153
- });
154
- }
155
- }),
156
- witness.on("observeStart", ({ mod }) => {
157
- const witnesses2 = progress.witnesses ?? {};
158
- witnesses2[witness.address] = {
159
- status: SentinelReportStatus.Started,
160
- witness: asWitnessInstance(mod, () => `Module is not a witness [${mod.id}]`, { required: true })
161
- };
162
- if (mounted()) {
163
- setProgress({
164
- archivists: progress.archivists,
165
- witnesses: witnesses2
166
- });
167
- }
168
- })
169
- );
142
+ })
143
+ ];
144
+ if (witnesses) for (const witness of witnesses) {
145
+ offCallbacks.push(witness.on("observeEnd", ({ mod, outPayloads }) => {
146
+ const witnesses2 = progress.witnesses ?? {};
147
+ witnesses2[witness.address] = {
148
+ status: outPayloads?.length ? SentinelReportStatus.Succeeded : SentinelReportStatus.Failed,
149
+ witness: asWitnessInstance(mod, () => `Module is not a witness [${mod.id}]`, {
150
+ required: true
151
+ })
152
+ };
153
+ if (mounted()) {
154
+ setProgress({
155
+ archivists: progress.archivists,
156
+ witnesses: witnesses2
157
+ });
170
158
  }
171
- setSentinel(sentinel2);
172
- return () => {
173
- for (const callback of offCallbacks) {
174
- callback();
159
+ }), witness.on("observeStart", ({ mod }) => {
160
+ const witnesses2 = progress.witnesses ?? {};
161
+ witnesses2[witness.address] = {
162
+ status: SentinelReportStatus.Started,
163
+ witness: asWitnessInstance(mod, () => `Module is not a witness [${mod.id}]`, {
164
+ required: true
165
+ })
166
+ };
167
+ if (mounted()) {
168
+ setProgress({
169
+ archivists: progress.archivists,
170
+ witnesses: witnesses2
171
+ });
175
172
  }
176
- };
177
- },
178
- [account, archivist, witnesses]
179
- );
180
- useEffect(() => {
181
- setHistory(sentinel?.history);
182
- }, [sentinel]);
173
+ }));
174
+ }
175
+ setSentinel(sentinel2);
176
+ setHistory(sentinel2?.history);
177
+ return () => {
178
+ for (const callback of offCallbacks) {
179
+ callback();
180
+ }
181
+ };
182
+ }, [
183
+ account,
184
+ archivist,
185
+ witnesses
186
+ ]);
183
187
  const value = useMemo(() => ({
184
188
  history,
185
189
  progress,
@@ -187,20 +191,22 @@ var SentinelProvider = ({
187
191
  reportingErrors,
188
192
  sentinel,
189
193
  status
190
- }), [history, progress, reportingErrors, sentinel, status]);
191
- return !required || sentinel ? /* @__PURE__ */ jsx5(SentinelContext, { value, children }) : null;
192
- };
193
-
194
- // src/contexts/use.ts
195
- import { useContextEx } from "@xylabs/react-shared";
196
- var useSentinelContext = () => {
197
- const {
198
- sentinel,
194
+ }), [
199
195
  history,
200
196
  progress,
201
197
  reportingErrors,
198
+ sentinel,
202
199
  status
203
- } = useContextEx(SentinelContext, "Sentinel");
200
+ ]);
201
+ return !required || sentinel ? /* @__PURE__ */ React5.createElement(SentinelContext, {
202
+ value
203
+ }, children) : null;
204
+ }, "SentinelProvider");
205
+
206
+ // src/contexts/use.ts
207
+ import { useContextEx } from "@xylabs/react-shared";
208
+ var useSentinelContext = /* @__PURE__ */ __name(() => {
209
+ const { sentinel, history, progress, reportingErrors, status } = useContextEx(SentinelContext, "Sentinel");
204
210
  return {
205
211
  history,
206
212
  progress,
@@ -208,29 +214,38 @@ var useSentinelContext = () => {
208
214
  sentinel,
209
215
  status
210
216
  };
211
- };
217
+ }, "useSentinelContext");
212
218
 
213
219
  // src/hooks/node/useSentinelFromNode.tsx
214
220
  import { useModuleFromNode } from "@xyo-network/react-node";
215
221
  import { asSentinelInstance } from "@xyo-network/sentinel-model";
216
- var useSentinelFromNode = (nameOrAddressOrInstance, config) => {
222
+ var useSentinelFromNode = /* @__PURE__ */ __name((nameOrAddressOrInstance, config) => {
217
223
  const [mod, error] = useModuleFromNode(nameOrAddressOrInstance, config);
218
224
  const instance = asSentinelInstance(mod);
219
225
  if (mod && !instance) {
220
226
  const error2 = new Error(`Resolved module is not a SentinelInstance [${mod.config?.schema}:${mod.config?.name}:${mod.address}]`);
221
227
  console.error(error2.message);
222
- return [void 0, error2];
228
+ return [
229
+ void 0,
230
+ error2
231
+ ];
223
232
  }
224
- return [instance, error];
225
- };
233
+ return [
234
+ instance,
235
+ error
236
+ ];
237
+ }, "useSentinelFromNode");
226
238
 
227
239
  // src/hooks/node/useSentinelsFromNode.tsx
228
240
  import { useModulesFromNode } from "@xyo-network/react-node";
229
241
  import { isSentinelInstance } from "@xyo-network/sentinel-model";
230
- var useSentinelsFromNode = (ids, config) => {
242
+ var useSentinelsFromNode = /* @__PURE__ */ __name((ids, config) => {
231
243
  const [modules, error] = useModulesFromNode(ids, config);
232
244
  if (error) {
233
- return [null, error];
245
+ return [
246
+ null,
247
+ error
248
+ ];
234
249
  }
235
250
  return modules ? [
236
251
  // eslint-disable-next-line unicorn/no-array-reduce
@@ -241,24 +256,33 @@ var useSentinelsFromNode = (ids, config) => {
241
256
  return prev;
242
257
  }, []),
243
258
  void 0
244
- ] : [modules, error];
245
- };
259
+ ] : [
260
+ modules,
261
+ error
262
+ ];
263
+ }, "useSentinelsFromNode");
246
264
 
247
265
  // src/hooks/node/useWeakSentinelFromNode.tsx
248
266
  import { useWeakModuleFromNode } from "@xyo-network/react-node";
249
267
  import { isSentinelInstance as isSentinelInstance2 } from "@xyo-network/sentinel-model";
250
- var useWeakSentinelFromNode = (nameOrAddressOrInstance, config) => {
251
- return useWeakModuleFromNode(nameOrAddressOrInstance, { identity: isSentinelInstance2, ...config });
252
- };
268
+ var useWeakSentinelFromNode = /* @__PURE__ */ __name((nameOrAddressOrInstance, config) => {
269
+ return useWeakModuleFromNode(nameOrAddressOrInstance, {
270
+ identity: isSentinelInstance2,
271
+ ...config
272
+ });
273
+ }, "useWeakSentinelFromNode");
253
274
 
254
275
  // src/hooks/node/useWeakSentinelsFromNode.tsx
255
- import { exists } from "@xylabs/exists";
276
+ import { exists } from "@xylabs/sdk-js";
256
277
  import { useWeakModulesFromNode } from "@xyo-network/react-node";
257
278
  import { asSentinelInstance as asSentinelInstance2 } from "@xyo-network/sentinel-model";
258
- var useWeakSentinelsFromNode = (ids, config) => {
279
+ var useWeakSentinelsFromNode = /* @__PURE__ */ __name((ids, config) => {
259
280
  const [modules, error] = useWeakModulesFromNode(ids, config);
260
281
  if (error) {
261
- return [null, error];
282
+ return [
283
+ null,
284
+ error
285
+ ];
262
286
  }
263
287
  return [
264
288
  modules?.map((mod) => {
@@ -269,7 +293,7 @@ var useWeakSentinelsFromNode = (ids, config) => {
269
293
  }).filter(exists) ?? [],
270
294
  void 0
271
295
  ];
272
- };
296
+ }, "useWeakSentinelsFromNode");
273
297
  export {
274
298
  SentinelCard,
275
299
  SentinelCardContent,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/Card/Card.tsx","../../src/components/Card/CardActions.tsx","../../src/components/Card/CardContent.tsx","../../src/components/Card/CardHeader.tsx","../../src/contexts/Context.ts","../../src/contexts/Provider.tsx","../../src/contexts/State.ts","../../src/contexts/use.ts","../../src/hooks/node/useSentinelFromNode.tsx","../../src/hooks/node/useSentinelsFromNode.tsx","../../src/hooks/node/useWeakSentinelFromNode.tsx","../../src/hooks/node/useWeakSentinelsFromNode.tsx"],"sourcesContent":["import type { CardProps } from '@mui/material'\nimport { Card } from '@mui/material'\nimport { usePromise } from '@xylabs/react-promise'\nimport type { Payload } from '@xyo-network/payload-model'\nimport type { ModuleRenderProps } from '@xyo-network/react-module'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport React, { useState } from 'react'\n\nimport { SentinelCardActions } from './CardActions.tsx'\nimport { SentinelCardContent } from './CardContent.tsx'\nimport { SentinelCardHeader } from './CardHeader.tsx'\n\nexport type SentinelCardProps = CardProps\n & ModuleRenderProps<SentinelInstance> & {\n inPayloads?: Payload[]\n }\n\nexport const SentinelCard: React.FC<SentinelCardProps> = ({\n children, inPayloads, mod, ...props\n}) => {\n const [retry, setRetry] = useState(-1)\n const [report] = usePromise(async () => {\n if (retry >= 0) {\n return await mod?.report(inPayloads)\n }\n }, [mod, retry, inPayloads])\n return (\n <Card {...props}>\n <SentinelCardHeader mod={mod} />\n <SentinelCardContent mod={mod} report={report} />\n {children}\n <SentinelCardActions mod={mod} onReport={() => setRetry(retry + 1)} />\n </Card>\n )\n}\n","import type { CardActionsProps } from '@mui/material'\nimport { ButtonEx } from '@xylabs/react-button'\nimport type { ModuleRenderProps } from '@xyo-network/react-module'\nimport { ModuleCardActions } from '@xyo-network/react-module'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport React from 'react'\n\nexport type SentinelCardActionsProps = ModuleRenderProps<SentinelInstance>\n & CardActionsProps & {\n onReport?: (mod?: SentinelInstance) => void\n }\n\nexport const SentinelCardActions: React.FC<SentinelCardActionsProps> = ({\n onReport, mod, ...props\n}) => {\n return (\n <ModuleCardActions mod={mod} {...props}>\n <ButtonEx onClick={() => onReport?.(mod)} size=\"small\" variant=\"outlined\">\n Report\n </ButtonEx>\n </ModuleCardActions>\n )\n}\n","import type { CardContentProps } from '@mui/material'\nimport { FlexGrowRow } from '@xylabs/react-flexbox'\nimport type { Payload } from '@xyo-network/payload-model'\nimport type { ModuleRenderProps } from '@xyo-network/react-module'\nimport { ModuleCardContent } from '@xyo-network/react-module'\nimport { JsonViewerEx } from '@xyo-network/react-payload-raw-info'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport React from 'react'\n\nexport type SentinelCardContentProps = ModuleRenderProps<SentinelInstance>\n & CardContentProps & {\n report?: Payload[]\n }\n\nexport const SentinelCardContent: React.FC<SentinelCardContentProps> = ({\n children, report, mod, ...props\n}) => {\n return (\n <ModuleCardContent mod={mod} {...props}>\n <FlexGrowRow flexWrap=\"wrap\" justifyContent=\"start\" gap={2}>\n {report\n ? <JsonViewerEx value={report} />\n : null}\n {children}\n </FlexGrowRow>\n </ModuleCardContent>\n )\n}\n","import type { CardHeaderProps } from '@mui/material'\nimport type { ModuleRenderProps } from '@xyo-network/react-module'\nimport { ModuleCardHeader } from '@xyo-network/react-module'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport React from 'react'\n\nexport const SentinelCardHeader: React.FC<ModuleRenderProps<SentinelInstance> & CardHeaderProps> = ({\n title, mod, ...props\n}) => {\n return <ModuleCardHeader mod={mod} title={title ?? mod?.config.name ?? 'Sentinel'} {...props} />\n}\n","import { createContextEx } from '@xylabs/react-shared'\n\nimport type { SentinelContextState } from './State.ts'\n\nexport const SentinelContext = createContextEx<SentinelContextState>()\n","import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport type { AccountInstance } from '@xyo-network/account-model'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport type { ModuleIdentifier } from '@xyo-network/module-model'\nimport { useWitnessesFromNode } from '@xyo-network/react-witness'\nimport { MemorySentinel } from '@xyo-network/sentinel-memory'\nimport type { SentinelConfig } from '@xyo-network/sentinel-model'\nimport { SentinelConfigSchema } from '@xyo-network/sentinel-model'\nimport type { WitnessInstance } from '@xyo-network/witness-model'\nimport { asWitnessInstance } from '@xyo-network/witness-model'\nimport type { PropsWithChildren } from 'react'\nimport React, {\n useEffect, useMemo, useState,\n} from 'react'\n\nimport { SentinelContext } from './Context.ts'\nimport type { SentinelContextState, SentinelReportProgress } from './State.ts'\nimport { SentinelReportStatus } from './State.ts'\n\nexport interface SentinelProviderProps {\n /** Account used by the sentinel for signing */\n account: AccountInstance\n /** @deprecated - sentinel no longer uses archive but relies on an archivist */\n archive?: string\n archivist?: string\n ids?: ModuleIdentifier[]\n name?: string\n required?: boolean\n witnesses?: WitnessInstance[]\n}\n\nexport const SentinelProvider: React.FC<PropsWithChildren<SentinelProviderProps>> = ({\n account, archivist, children, ids, name, required = false,\n}) => {\n const [sentinel, setSentinel] = useState<MemorySentinel>()\n const [history, setHistory] = useState<BoundWitness[]>()\n const [progress, setProgress] = useState<SentinelReportProgress>({})\n const [status, setStatus] = useState<SentinelReportStatus>(SentinelReportStatus.Idle)\n const [reportingErrors, setReportingErrors] = useState<Error[]>()\n const [witnesses] = useWitnessesFromNode(ids)\n\n useAsyncEffect(\n\n async (mounted) => {\n const sentinel = await MemorySentinel.create({\n account,\n config: {\n archivists: archivist ? [archivist] : undefined,\n name,\n\n schema: SentinelConfigSchema,\n synchronous: true,\n\n tasks: witnesses?.map(mod => ({ mod: mod.address })),\n } as SentinelConfig,\n })\n const offCallbacks: (() => void)[] = [\n sentinel.on('reportEnd', ({ mod, outPayloads }) => {\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses: progress.witnesses,\n })\n setStatus(outPayloads?.length ? SentinelReportStatus.Succeeded : SentinelReportStatus.Failed)\n setReportingErrors([new Error(`Witness failed [${mod?.config?.name ?? mod.address}]`)])\n }\n }),\n sentinel.on('reportStart', () => {\n if (mounted()) {\n setProgress({ archivists: {}, witnesses: {} })\n setStatus(SentinelReportStatus.Started)\n }\n }),\n ]\n if (witnesses)\n for (const witness of witnesses) {\n offCallbacks.push(\n witness.on('observeEnd', ({ mod, outPayloads }) => {\n const witnesses = progress.witnesses ?? {}\n witnesses[witness.address] = {\n status: outPayloads?.length ? SentinelReportStatus.Succeeded : SentinelReportStatus.Failed,\n witness: asWitnessInstance(mod, () => `Module is not a witness [${mod.id}]`, { required: true }),\n }\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses,\n })\n }\n }),\n witness.on('observeStart', ({ mod }) => {\n const witnesses = progress.witnesses ?? {}\n witnesses[witness.address] = {\n status: SentinelReportStatus.Started,\n witness: asWitnessInstance(mod, () => `Module is not a witness [${mod.id}]`, { required: true }),\n }\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses,\n })\n }\n }),\n )\n }\n setSentinel(sentinel as MemorySentinel)\n return () => {\n // unsubscribe from events\n for (const callback of offCallbacks) {\n callback()\n }\n }\n },\n\n [account, archivist, witnesses],\n )\n\n useEffect(() => {\n setHistory(sentinel?.history as BoundWitness[])\n }, [sentinel])\n\n const value: SentinelContextState = useMemo(() => ({\n history, progress, provided: true, reportingErrors, sentinel, status,\n }), [history, progress, reportingErrors, sentinel, status])\n\n return !required || sentinel\n\n ? (\n <SentinelContext value={value}>\n {children}\n </SentinelContext>\n )\n : null\n}\n","import type { EnumValue } from '@xylabs/enum'\nimport { Enum } from '@xylabs/enum'\nimport type { ContextExState } from '@xylabs/react-shared'\nimport type { ArchivistModuleInstance } from '@xyo-network/archivist-model'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport type { SentinelModule } from '@xyo-network/sentinel-model'\nimport type { WitnessModule } from '@xyo-network/witness-model'\n\nexport const SentinelReportStatus = Enum({\n Idle: 'idle',\n Queued: 'queued',\n Started: 'started',\n Succeeded: 'succeeded',\n Failed: 'failed',\n})\n\nexport type SentinelReportStatus = EnumValue<typeof SentinelReportStatus>\n\nexport interface SentinelWitnessReportProgress {\n status: SentinelReportStatus\n witness: WitnessModule\n}\n\nexport interface SentinelArchivistApiReportProgress {\n archivist: ArchivistModuleInstance\n status: SentinelReportStatus\n}\n\nexport interface SentinelReportProgress {\n archivists?: Record<string, SentinelArchivistApiReportProgress>\n witnesses?: Record<string, SentinelWitnessReportProgress>\n}\n\nexport type SentinelContextState = ContextExState<{\n history?: BoundWitness[]\n progress?: SentinelReportProgress\n reportingErrors?: Error[]\n sentinel?: SentinelModule\n status?: SentinelReportStatus\n}>\n","import { useContextEx } from '@xylabs/react-shared'\n\nimport { SentinelContext } from './Context.ts'\n\nexport const useSentinelContext = () => {\n const {\n sentinel, history, progress, reportingErrors, status,\n } = useContextEx(SentinelContext, 'Sentinel')\n return {\n history, progress, reportingErrors, sentinel, status,\n }\n}\n","import type { ModuleFromNodeConfig } from '@xyo-network/react-node'\nimport { useModuleFromNode } from '@xyo-network/react-node'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport { asSentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useSentinelFromNode = (\n nameOrAddressOrInstance?: string | SentinelInstance,\n config?: ModuleFromNodeConfig,\n): [SentinelInstance | undefined, Error | undefined] => {\n const [mod, error] = useModuleFromNode(nameOrAddressOrInstance, config)\n const instance = asSentinelInstance(mod)\n if (mod && !instance) {\n const error = new Error(`Resolved module is not a SentinelInstance [${mod.config?.schema}:${mod.config?.name}:${mod.address}]`)\n console.error(error.message)\n return [undefined, error]\n }\n return [instance, error]\n}\n","import type { ModuleIdentifier } from '@xyo-network/module-model'\nimport type { ModuleFromNodeConfig } from '@xyo-network/react-node'\nimport { useModulesFromNode } from '@xyo-network/react-node'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport { isSentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useSentinelsFromNode = (\n ids?: ModuleIdentifier[],\n config?: ModuleFromNodeConfig,\n): [SentinelInstance[] | null | undefined, Error | undefined] => {\n const [modules, error] = useModulesFromNode(ids, config)\n if (error) {\n return [null, error]\n }\n return modules\n ? [\n // eslint-disable-next-line unicorn/no-array-reduce\n modules.reduce<SentinelInstance[]>((prev, mod) => {\n if (isSentinelInstance(mod)) {\n prev.push(mod)\n }\n return prev\n }, []),\n undefined,\n ]\n : [modules, error]\n}\n","import type { WeakModuleFromNodeConfig } from '@xyo-network/react-node'\nimport { useWeakModuleFromNode } from '@xyo-network/react-node'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport { isSentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useWeakSentinelFromNode = (\n nameOrAddressOrInstance?: string | SentinelInstance,\n config?: WeakModuleFromNodeConfig,\n): [WeakRef<SentinelInstance> | undefined, Error | undefined] => {\n return useWeakModuleFromNode<SentinelInstance>(nameOrAddressOrInstance, { identity: isSentinelInstance, ...config })\n}\n","import { exists } from '@xylabs/exists'\nimport type { ModuleIdentifier } from '@xyo-network/module-model'\nimport type { ModuleFromNodeConfig } from '@xyo-network/react-node'\nimport { useWeakModulesFromNode } from '@xyo-network/react-node'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport { asSentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useWeakSentinelsFromNode = (\n ids?: ModuleIdentifier[],\n config?: ModuleFromNodeConfig,\n): [WeakRef<SentinelInstance>[] | null | undefined, Error | undefined] => {\n const [modules, error] = useWeakModulesFromNode(ids, config)\n if (error) {\n return [null, error]\n }\n return [\n modules\n ?.map((mod) => {\n const instance = asSentinelInstance(mod?.deref())\n if (instance) {\n return new WeakRef(instance)\n }\n })\n .filter(exists) ?? [],\n undefined,\n ]\n}\n"],"mappings":";AACA,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAI3B,SAAgB,gBAAgB;;;ACLhC,SAAS,gBAAgB;AAEzB,SAAS,yBAAyB;AAc5B;AALC,IAAM,sBAA0D,CAAC;AAAA,EACtE;AAAA,EAAU;AAAA,EAAK,GAAG;AACpB,MAAM;AACJ,SACE,oBAAC,qBAAkB,KAAW,GAAG,OAC/B,8BAAC,YAAS,SAAS,MAAM,WAAW,GAAG,GAAG,MAAK,SAAQ,SAAQ,YAAW,oBAE1E,GACF;AAEJ;;;ACrBA,SAAS,mBAAmB;AAG5B,SAAS,yBAAyB;AAClC,SAAS,oBAAoB;AAcvB,SAEM,OAAAA,MAFN;AALC,IAAM,sBAA0D,CAAC;AAAA,EACtE;AAAA,EAAU;AAAA,EAAQ;AAAA,EAAK,GAAG;AAC5B,MAAM;AACJ,SACE,gBAAAA,KAAC,qBAAkB,KAAW,GAAG,OAC/B,+BAAC,eAAY,UAAS,QAAO,gBAAe,SAAQ,KAAK,GACtD;AAAA,aACG,gBAAAA,KAAC,gBAAa,OAAO,QAAQ,IAC7B;AAAA,IACH;AAAA,KACH,GACF;AAEJ;;;ACzBA,SAAS,wBAAwB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EtC,SAAS,sBAAAC,2BAA0B;AAE5B,IAAM,0BAA0B,CACrC,yBACA,WAC+D;AAC/D,SAAO,sBAAwC,yBAAyB,EAAE,UAAUA,qBAAoB,GAAG,OAAO,CAAC;AACrH;;;ACVA,SAAS,cAAc;AAGvB,SAAS,8BAA8B;AAEvC,SAAS,sBAAAC,2BAA0B;AAE5B,IAAM,2BAA2B,CACtC,KACA,WACwE;AACxE,QAAM,CAAC,SAAS,KAAK,IAAI,uBAAuB,KAAK,MAAM;AAC3D,MAAI,OAAO;AACT,WAAO,CAAC,MAAM,KAAK;AAAA,EACrB;AACA,SAAO;AAAA,IACL,SACI,IAAI,CAAC,QAAQ;AACb,YAAM,WAAWA,oBAAmB,KAAK,MAAM,CAAC;AAChD,UAAI,UAAU;AACZ,eAAO,IAAI,QAAQ,QAAQ;AAAA,MAC7B;AAAA,IACF,CAAC,EACA,OAAO,MAAM,KAAK,CAAC;AAAA,IACtB;AAAA,EACF;AACF;","names":["jsx","jsx","jsx","jsxs","useState","jsx","useState","sentinel","witnesses","error","isSentinelInstance","asSentinelInstance"]}
1
+ {"version":3,"sources":["../../src/components/Card/Card.tsx","../../src/components/Card/CardActions.tsx","../../src/components/Card/CardContent.tsx","../../src/components/Card/CardHeader.tsx","../../src/contexts/Context.ts","../../src/contexts/Provider.tsx","../../src/contexts/State.ts","../../src/contexts/use.ts","../../src/hooks/node/useSentinelFromNode.tsx","../../src/hooks/node/useSentinelsFromNode.tsx","../../src/hooks/node/useWeakSentinelFromNode.tsx","../../src/hooks/node/useWeakSentinelsFromNode.tsx"],"sourcesContent":["import type { CardProps } from '@mui/material'\nimport { Card } from '@mui/material'\nimport { usePromise } from '@xylabs/react-promise'\nimport type { Payload } from '@xyo-network/payload-model'\nimport type { ModuleRenderProps } from '@xyo-network/react-module'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport React, { useState } from 'react'\n\nimport { SentinelCardActions } from './CardActions.tsx'\nimport { SentinelCardContent } from './CardContent.tsx'\nimport { SentinelCardHeader } from './CardHeader.tsx'\n\nexport type SentinelCardProps = CardProps\n & ModuleRenderProps<SentinelInstance> & {\n inPayloads?: Payload[]\n }\n\nexport const SentinelCard: React.FC<SentinelCardProps> = ({\n children, inPayloads, mod, ...props\n}) => {\n const [retry, setRetry] = useState(-1)\n const [report] = usePromise(async () => {\n if (retry >= 0) {\n return await mod?.report(inPayloads)\n }\n }, [mod, retry, inPayloads])\n return (\n <Card {...props}>\n <SentinelCardHeader mod={mod} />\n <SentinelCardContent mod={mod} report={report} />\n {children}\n <SentinelCardActions mod={mod} onReport={() => setRetry(retry + 1)} />\n </Card>\n )\n}\n","import type { CardActionsProps } from '@mui/material'\nimport { ButtonEx } from '@xylabs/react-button'\nimport type { ModuleRenderProps } from '@xyo-network/react-module'\nimport { ModuleCardActions } from '@xyo-network/react-module'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport React from 'react'\n\nexport type SentinelCardActionsProps = ModuleRenderProps<SentinelInstance>\n & CardActionsProps & {\n onReport?: (mod?: SentinelInstance) => void\n }\n\nexport const SentinelCardActions: React.FC<SentinelCardActionsProps> = ({\n onReport, mod, ...props\n}) => {\n return (\n <ModuleCardActions mod={mod} {...props}>\n <ButtonEx onClick={() => onReport?.(mod)} size=\"small\" variant=\"outlined\">\n Report\n </ButtonEx>\n </ModuleCardActions>\n )\n}\n","import type { CardContentProps } from '@mui/material'\nimport { FlexGrowRow } from '@xylabs/react-flexbox'\nimport type { Payload } from '@xyo-network/payload-model'\nimport type { ModuleRenderProps } from '@xyo-network/react-module'\nimport { ModuleCardContent } from '@xyo-network/react-module'\nimport { JsonViewerEx } from '@xyo-network/react-payload-raw-info'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport React from 'react'\n\nexport type SentinelCardContentProps = ModuleRenderProps<SentinelInstance>\n & CardContentProps & {\n report?: Payload[]\n }\n\nexport const SentinelCardContent: React.FC<SentinelCardContentProps> = ({\n children, report, mod, ...props\n}) => {\n return (\n <ModuleCardContent mod={mod} {...props}>\n <FlexGrowRow flexWrap=\"wrap\" justifyContent=\"start\" gap={2}>\n {report\n ? <JsonViewerEx value={report} />\n : null}\n {children}\n </FlexGrowRow>\n </ModuleCardContent>\n )\n}\n","import type { CardHeaderProps } from '@mui/material'\nimport type { ModuleRenderProps } from '@xyo-network/react-module'\nimport { ModuleCardHeader } from '@xyo-network/react-module'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport React from 'react'\n\nexport const SentinelCardHeader: React.FC<ModuleRenderProps<SentinelInstance> & CardHeaderProps> = ({\n title, mod, ...props\n}) => {\n return <ModuleCardHeader mod={mod} title={title ?? mod?.config.name ?? 'Sentinel'} {...props} />\n}\n","import { createContextEx } from '@xylabs/react-shared'\n\nimport type { SentinelContextState } from './State.ts'\n\nexport const SentinelContext = createContextEx<SentinelContextState>()\n","import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport type { AccountInstance } from '@xyo-network/account-model'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport type { ModuleIdentifier } from '@xyo-network/module-model'\nimport { useWitnessesFromNode } from '@xyo-network/react-witness'\nimport { MemorySentinel } from '@xyo-network/sentinel-memory'\nimport type { SentinelConfig } from '@xyo-network/sentinel-model'\nimport { SentinelConfigSchema } from '@xyo-network/sentinel-model'\nimport type { WitnessInstance } from '@xyo-network/witness-model'\nimport { asWitnessInstance } from '@xyo-network/witness-model'\nimport type { PropsWithChildren } from 'react'\nimport React, {\n useEffect, useMemo, useState,\n} from 'react'\n\nimport { SentinelContext } from './Context.ts'\nimport type { SentinelContextState, SentinelReportProgress } from './State.ts'\nimport { SentinelReportStatus } from './State.ts'\n\nexport interface SentinelProviderProps {\n /** Account used by the sentinel for signing */\n account: AccountInstance\n /** @deprecated - sentinel no longer uses archive but relies on an archivist */\n archive?: string\n archivist?: string\n ids?: ModuleIdentifier[]\n name?: string\n required?: boolean\n witnesses?: WitnessInstance[]\n}\n\nexport const SentinelProvider: React.FC<PropsWithChildren<SentinelProviderProps>> = ({\n account, archivist, children, ids, name, required = false,\n}) => {\n const [sentinel, setSentinel] = useState<MemorySentinel>()\n const [history, setHistory] = useState<BoundWitness[]>()\n const [progress, setProgress] = useState<SentinelReportProgress>({})\n const [status, setStatus] = useState<SentinelReportStatus>(SentinelReportStatus.Idle)\n const [reportingErrors, setReportingErrors] = useState<Error[]>()\n const [witnesses] = useWitnessesFromNode(ids)\n\n useAsyncEffect(\n\n async (mounted) => {\n const sentinel = await MemorySentinel.create({\n account,\n config: {\n archivists: archivist ? [archivist] : undefined,\n name,\n\n schema: SentinelConfigSchema,\n synchronous: true,\n\n tasks: witnesses?.map(mod => ({ mod: mod.address })),\n } as SentinelConfig,\n })\n const offCallbacks: (() => void)[] = [\n sentinel.on('reportEnd', ({ mod, outPayloads }) => {\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses: progress.witnesses,\n })\n setStatus(outPayloads?.length ? SentinelReportStatus.Succeeded : SentinelReportStatus.Failed)\n setReportingErrors([new Error(`Witness failed [${mod?.config?.name ?? mod.address}]`)])\n }\n }),\n sentinel.on('reportStart', () => {\n if (mounted()) {\n setProgress({ archivists: {}, witnesses: {} })\n setStatus(SentinelReportStatus.Started)\n }\n }),\n ]\n if (witnesses)\n for (const witness of witnesses) {\n offCallbacks.push(\n witness.on('observeEnd', ({ mod, outPayloads }) => {\n const witnesses = progress.witnesses ?? {}\n witnesses[witness.address] = {\n status: outPayloads?.length ? SentinelReportStatus.Succeeded : SentinelReportStatus.Failed,\n witness: asWitnessInstance(mod, () => `Module is not a witness [${mod.id}]`, { required: true }),\n }\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses,\n })\n }\n }),\n witness.on('observeStart', ({ mod }) => {\n const witnesses = progress.witnesses ?? {}\n witnesses[witness.address] = {\n status: SentinelReportStatus.Started,\n witness: asWitnessInstance(mod, () => `Module is not a witness [${mod.id}]`, { required: true }),\n }\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses,\n })\n }\n }),\n )\n }\n setSentinel(sentinel as MemorySentinel)\n setHistory(sentinel?.history as BoundWitness[])\n return () => {\n // unsubscribe from events\n for (const callback of offCallbacks) {\n callback()\n }\n }\n },\n\n [account, archivist, witnesses],\n )\n\n const value: SentinelContextState = useMemo(() => ({\n history, progress, provided: true, reportingErrors, sentinel, status,\n }), [history, progress, reportingErrors, sentinel, status])\n\n return !required || sentinel\n\n ? (\n <SentinelContext value={value}>\n {children}\n </SentinelContext>\n )\n : null\n}\n","import type { ContextExState } from '@xylabs/react-shared'\nimport type { EnumValue } from '@xylabs/sdk-js'\nimport { Enum } from '@xylabs/sdk-js'\nimport type { ArchivistModuleInstance } from '@xyo-network/archivist-model'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport type { SentinelModule } from '@xyo-network/sentinel-model'\nimport type { WitnessModule } from '@xyo-network/witness-model'\n\nexport const SentinelReportStatus = Enum({\n Idle: 'idle',\n Queued: 'queued',\n Started: 'started',\n Succeeded: 'succeeded',\n Failed: 'failed',\n})\n\nexport type SentinelReportStatus = EnumValue<typeof SentinelReportStatus>\n\nexport interface SentinelWitnessReportProgress {\n status: SentinelReportStatus\n witness: WitnessModule\n}\n\nexport interface SentinelArchivistApiReportProgress {\n archivist: ArchivistModuleInstance\n status: SentinelReportStatus\n}\n\nexport interface SentinelReportProgress {\n archivists?: Record<string, SentinelArchivistApiReportProgress>\n witnesses?: Record<string, SentinelWitnessReportProgress>\n}\n\nexport type SentinelContextState = ContextExState<{\n history?: BoundWitness[]\n progress?: SentinelReportProgress\n reportingErrors?: Error[]\n sentinel?: SentinelModule\n status?: SentinelReportStatus\n}>\n","import { useContextEx } from '@xylabs/react-shared'\n\nimport { SentinelContext } from './Context.ts'\n\nexport const useSentinelContext = () => {\n const {\n sentinel, history, progress, reportingErrors, status,\n } = useContextEx(SentinelContext, 'Sentinel')\n return {\n history, progress, reportingErrors, sentinel, status,\n }\n}\n","import type { ModuleFromNodeConfig } from '@xyo-network/react-node'\nimport { useModuleFromNode } from '@xyo-network/react-node'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport { asSentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useSentinelFromNode = (\n nameOrAddressOrInstance?: string | SentinelInstance,\n config?: ModuleFromNodeConfig,\n): [SentinelInstance | undefined, Error | undefined] => {\n const [mod, error] = useModuleFromNode(nameOrAddressOrInstance, config)\n const instance = asSentinelInstance(mod)\n if (mod && !instance) {\n const error = new Error(`Resolved module is not a SentinelInstance [${mod.config?.schema}:${mod.config?.name}:${mod.address}]`)\n console.error(error.message)\n return [undefined, error]\n }\n return [instance, error]\n}\n","import type { ModuleIdentifier } from '@xyo-network/module-model'\nimport type { ModuleFromNodeConfig } from '@xyo-network/react-node'\nimport { useModulesFromNode } from '@xyo-network/react-node'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport { isSentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useSentinelsFromNode = (\n ids?: ModuleIdentifier[],\n config?: ModuleFromNodeConfig,\n): [SentinelInstance[] | null | undefined, Error | undefined] => {\n const [modules, error] = useModulesFromNode(ids, config)\n if (error) {\n return [null, error]\n }\n return modules\n ? [\n // eslint-disable-next-line unicorn/no-array-reduce\n modules.reduce<SentinelInstance[]>((prev, mod) => {\n if (isSentinelInstance(mod)) {\n prev.push(mod)\n }\n return prev\n }, []),\n undefined,\n ]\n : [modules, error]\n}\n","import type { WeakModuleFromNodeConfig } from '@xyo-network/react-node'\nimport { useWeakModuleFromNode } from '@xyo-network/react-node'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport { isSentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useWeakSentinelFromNode = (\n nameOrAddressOrInstance?: string | SentinelInstance,\n config?: WeakModuleFromNodeConfig,\n): [WeakRef<SentinelInstance> | undefined, Error | undefined] => {\n return useWeakModuleFromNode<SentinelInstance>(nameOrAddressOrInstance, { identity: isSentinelInstance, ...config })\n}\n","import { exists } from '@xylabs/sdk-js'\nimport type { ModuleIdentifier } from '@xyo-network/module-model'\nimport type { ModuleFromNodeConfig } from '@xyo-network/react-node'\nimport { useWeakModulesFromNode } from '@xyo-network/react-node'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport { asSentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useWeakSentinelsFromNode = (\n ids?: ModuleIdentifier[],\n config?: ModuleFromNodeConfig,\n): [WeakRef<SentinelInstance>[] | null | undefined, Error | undefined] => {\n const [modules, error] = useWeakModulesFromNode(ids, config)\n if (error) {\n return [null, error]\n }\n return [\n modules\n ?.map((mod) => {\n const instance = asSentinelInstance(mod?.deref())\n if (instance) {\n return new WeakRef(instance)\n }\n })\n .filter(exists) ?? [],\n undefined,\n ]\n}\n"],"mappings":";;;;AACA,SAASA,YAAY;AACrB,SAASC,kBAAkB;AAI3B,OAAOC,UAASC,gBAAgB;;;ACLhC,SAASC,gBAAgB;AAEzB,SAASC,yBAAyB;AAElC,OAAOC,WAAW;AAOX,IAAMC,sBAA0D,wBAAC,EACtEC,UAAUC,KAAK,GAAGC,MAAAA,MACnB;AACC,SACE,sBAAA,cAACC,mBAAAA;IAAkBF;IAAW,GAAGC;KAC/B,sBAAA,cAACE,UAAAA;IAASC,SAAS,6BAAML,WAAWC,GAAAA,GAAjB;IAAuBK,MAAK;IAAQC,SAAQ;KAAW,QAAA,CAAA;AAKhF,GAVuE;;;ACXvE,SAASC,mBAAmB;AAG5B,SAASC,yBAAyB;AAClC,SAASC,oBAAoB;AAE7B,OAAOC,YAAW;AAOX,IAAMC,sBAA0D,wBAAC,EACtEC,UAAUC,QAAQC,KAAK,GAAGC,MAAAA,MAC3B;AACC,SACE,gBAAAC,OAAA,cAACC,mBAAAA;IAAkBH;IAAW,GAAGC;KAC/B,gBAAAC,OAAA,cAACE,aAAAA;IAAYC,UAAS;IAAOC,gBAAe;IAAQC,KAAK;KACtDR,SACG,gBAAAG,OAAA,cAACM,cAAAA;IAAaC,OAAOV;OACr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,2BAA2B,wBACtCC,KACAC,WAAAA;AAEA,QAAM,CAACC,SAASC,KAAAA,IAASC,uBAAuBJ,KAAKC,MAAAA;AACrD,MAAIE,OAAO;AACT,WAAO;MAAC;MAAMA;;EAChB;AACA,SAAO;IACLD,SACIG,IAAI,CAACC,QAAAA;AACL,YAAMC,WAAWC,oBAAmBF,KAAKG,MAAAA,CAAAA;AACzC,UAAIF,UAAU;AACZ,eAAO,IAAIG,QAAQH,QAAAA;MACrB;IACF,CAAA,EACCI,OAAOC,MAAAA,KAAW,CAAA;IACrBC;;AAEJ,GAnBwC;","names":["Card","usePromise","React","useState","ButtonEx","ModuleCardActions","React","SentinelCardActions","onReport","mod","props","ModuleCardActions","ButtonEx","onClick","size","variant","FlexGrowRow","ModuleCardContent","JsonViewerEx","React","SentinelCardContent","children","report","mod","props","React","ModuleCardContent","FlexGrowRow","flexWrap","justifyContent","gap","JsonViewerEx","value","ModuleCardHeader","React","SentinelCardHeader","title","mod","props","React","ModuleCardHeader","config","name","SentinelCard","children","inPayloads","mod","props","retry","setRetry","useState","report","usePromise","React","Card","SentinelCardHeader","SentinelCardContent","SentinelCardActions","onReport","createContextEx","SentinelContext","useAsyncEffect","useWitnessesFromNode","MemorySentinel","SentinelConfigSchema","asWitnessInstance","React","useMemo","useState","Enum","SentinelReportStatus","Idle","Queued","Started","Succeeded","Failed","SentinelProvider","account","archivist","children","ids","name","required","sentinel","setSentinel","useState","history","setHistory","progress","setProgress","status","setStatus","SentinelReportStatus","Idle","reportingErrors","setReportingErrors","witnesses","useWitnessesFromNode","useAsyncEffect","mounted","MemorySentinel","create","config","archivists","undefined","schema","SentinelConfigSchema","synchronous","tasks","map","mod","address","offCallbacks","on","outPayloads","length","Succeeded","Failed","Error","Started","witness","push","asWitnessInstance","id","callback","value","useMemo","provided","React","SentinelContext","useContextEx","useSentinelContext","sentinel","history","progress","reportingErrors","status","useContextEx","SentinelContext","useModuleFromNode","asSentinelInstance","useSentinelFromNode","nameOrAddressOrInstance","config","mod","error","useModuleFromNode","instance","asSentinelInstance","Error","schema","name","address","console","message","undefined","useModulesFromNode","isSentinelInstance","useSentinelsFromNode","ids","config","modules","error","useModulesFromNode","reduce","prev","mod","isSentinelInstance","push","undefined","useWeakModuleFromNode","isSentinelInstance","useWeakSentinelFromNode","nameOrAddressOrInstance","config","useWeakModuleFromNode","identity","isSentinelInstance","exists","useWeakModulesFromNode","asSentinelInstance","useWeakSentinelsFromNode","ids","config","modules","error","useWeakModulesFromNode","map","mod","instance","asSentinelInstance","deref","WeakRef","filter","exists","undefined"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/react-sentinel",
3
- "version": "7.4.2",
3
+ "version": "7.5.1",
4
4
  "description": "Common React library for all XYO projects that use React",
5
5
  "keywords": [
6
6
  "xyo",
@@ -43,56 +43,57 @@
43
43
  "src"
44
44
  ],
45
45
  "dependencies": {
46
- "@xylabs/enum": "~5.0.50",
47
- "@xylabs/exists": "~5.0.50",
48
- "@xylabs/react-async-effect": "~7.1.8",
49
- "@xylabs/react-button": "~7.1.8",
50
- "@xylabs/react-flexbox": "~7.1.8",
51
- "@xylabs/react-promise": "~7.1.8",
52
- "@xylabs/react-shared": "~7.1.8",
53
- "@xyo-network/account-model": "~5.2.17",
54
- "@xyo-network/archivist-model": "~5.2.17",
55
- "@xyo-network/boundwitness-model": "~5.2.17",
56
- "@xyo-network/module-model": "~5.2.17",
57
- "@xyo-network/payload-model": "~5.2.17",
58
- "@xyo-network/react-module": "^7.4.2",
59
- "@xyo-network/react-node": "^7.4.2",
60
- "@xyo-network/react-payload-raw-info": "^7.4.2",
61
- "@xyo-network/react-witness": "^7.4.2",
62
- "@xyo-network/sentinel-memory": "~5.2.17",
63
- "@xyo-network/sentinel-model": "~5.2.17",
64
- "@xyo-network/witness-model": "~5.2.17"
46
+ "@xylabs/react-async-effect": "~7.1.12",
47
+ "@xylabs/react-button": "~7.1.12",
48
+ "@xylabs/react-flexbox": "~7.1.12",
49
+ "@xylabs/react-promise": "~7.1.12",
50
+ "@xylabs/react-shared": "~7.1.12",
51
+ "@xylabs/sdk-js": "~5.0.64",
52
+ "@xyo-network/account-model": "~5.3.2",
53
+ "@xyo-network/archivist-model": "~5.3.2",
54
+ "@xyo-network/boundwitness-model": "~5.3.2",
55
+ "@xyo-network/module-model": "~5.3.2",
56
+ "@xyo-network/payload-model": "~5.3.2",
57
+ "@xyo-network/react-module": "7.5.1",
58
+ "@xyo-network/react-node": "7.5.1",
59
+ "@xyo-network/react-payload-raw-info": "7.5.1",
60
+ "@xyo-network/react-witness": "7.5.1",
61
+ "@xyo-network/sentinel-memory": "~5.3.2",
62
+ "@xyo-network/sentinel-model": "~5.3.2",
63
+ "@xyo-network/witness-model": "~5.3.2"
65
64
  },
66
65
  "devDependencies": {
67
66
  "@emotion/react": "~11.14.0",
68
67
  "@emotion/styled": "~11.14.1",
69
- "@mui/icons-material": "~7.3.6",
70
- "@mui/material": "~7.3.6",
71
- "@storybook/react-vite": "~10.1.4",
72
- "@types/react": "^19.2.7",
73
- "@xylabs/ts-scripts-yarn3": "~7.2.8",
74
- "@xylabs/tsconfig": "~7.2.8",
75
- "@xylabs/tsconfig-dom": "~7.2.8",
76
- "@xylabs/tsconfig-react": "~7.2.8",
77
- "@xyo-network/account": "~5.2.17",
78
- "@xyo-network/evm-call-witness": "~5.2.4",
79
- "@xyo-network/manifest": "~5.2.17",
80
- "@xyo-network/module-factory-locator": "~5.2.17",
81
- "@xyo-network/wallet": "~5.2.17",
68
+ "@mui/icons-material": "~7.3.7",
69
+ "@mui/material": "~7.3.7",
70
+ "@storybook/react-vite": "~10.2.1",
71
+ "@types/react": "^19.2.10",
72
+ "@xylabs/ts-scripts-yarn3": "~7.3.2",
73
+ "@xylabs/tsconfig": "~7.3.2",
74
+ "@xylabs/tsconfig-dom": "~7.3.2",
75
+ "@xylabs/tsconfig-react": "~7.3.2",
76
+ "@xyo-network/account": "~5.3.2",
77
+ "@xyo-network/evm-call-witness": "~5.3.1",
78
+ "@xyo-network/manifest": "~5.3.2",
79
+ "@xyo-network/module-factory-locator": "~5.3.2",
80
+ "@xyo-network/wallet": "~5.3.2",
82
81
  "ethers": "~6.16.0",
83
- "react": "^19.2.1",
84
- "react-dom": "^19.2.1",
85
- "react-router-dom": "^7.10.0",
86
- "storybook": "~10.1.4",
82
+ "react": "^19.2.4",
83
+ "react-dom": "^19.2.4",
84
+ "react-router-dom": "^7.13.0",
85
+ "storybook": "~10.2.1",
87
86
  "typescript": "^5.9.3",
88
- "vite": "~7.2.6"
87
+ "vite": "~7.3.1",
88
+ "zod": "^4.3.6"
89
89
  },
90
90
  "peerDependencies": {
91
91
  "@mui/icons-material": ">=6 <8",
92
92
  "@mui/material": ">=6 <8",
93
93
  "ethers": "~6",
94
94
  "react": "^19",
95
- "react-dom": "^19"
95
+ "react-dom": "^19",
96
+ "zod": "^4"
96
97
  },
97
98
  "peerDependenciesMeta": {
98
99
  "ethers": {
@@ -103,4 +104,4 @@
103
104
  "access": "public"
104
105
  },
105
106
  "docs": "dist/docs.json"
106
- }
107
+ }
@@ -41,7 +41,7 @@ const loadFromManifest = async () => {
41
41
  { 'network.xyo.evm.interface': 'Erc1155' },
42
42
  )
43
43
 
44
- const manifest = new ManifestWrapper(NftSentinelManifest as PackageManifestPayload, wallet, locator)
44
+ const manifest = new ManifestWrapper(NftSentinelManifest as unknown as PackageManifestPayload, wallet, locator)
45
45
  const node = await manifest.loadNodeFromIndex(0)
46
46
  console.log(`node: ${(await node.resolve()).length}`)
47
47
  return node
@@ -104,6 +104,7 @@ export const SentinelProvider: React.FC<PropsWithChildren<SentinelProviderProps>
104
104
  )
105
105
  }
106
106
  setSentinel(sentinel as MemorySentinel)
107
+ setHistory(sentinel?.history as BoundWitness[])
107
108
  return () => {
108
109
  // unsubscribe from events
109
110
  for (const callback of offCallbacks) {
@@ -115,10 +116,6 @@ export const SentinelProvider: React.FC<PropsWithChildren<SentinelProviderProps>
115
116
  [account, archivist, witnesses],
116
117
  )
117
118
 
118
- useEffect(() => {
119
- setHistory(sentinel?.history as BoundWitness[])
120
- }, [sentinel])
121
-
122
119
  const value: SentinelContextState = useMemo(() => ({
123
120
  history, progress, provided: true, reportingErrors, sentinel, status,
124
121
  }), [history, progress, reportingErrors, sentinel, status])
@@ -1,6 +1,6 @@
1
- import type { EnumValue } from '@xylabs/enum'
2
- import { Enum } from '@xylabs/enum'
3
1
  import type { ContextExState } from '@xylabs/react-shared'
2
+ import type { EnumValue } from '@xylabs/sdk-js'
3
+ import { Enum } from '@xylabs/sdk-js'
4
4
  import type { ArchivistModuleInstance } from '@xyo-network/archivist-model'
5
5
  import type { BoundWitness } from '@xyo-network/boundwitness-model'
6
6
  import type { SentinelModule } from '@xyo-network/sentinel-model'
@@ -1,4 +1,4 @@
1
- import { exists } from '@xylabs/exists'
1
+ import { exists } from '@xylabs/sdk-js'
2
2
  import type { ModuleIdentifier } from '@xyo-network/module-model'
3
3
  import type { ModuleFromNodeConfig } from '@xyo-network/react-node'
4
4
  import { useWeakModulesFromNode } from '@xyo-network/react-node'