@xyo-network/react-sentinel 2.75.7 → 2.76.0
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.
- package/dist/browser/components/Card/CardActions.d.cts +1 -1
- package/dist/browser/components/Card/CardActions.d.cts.map +1 -1
- package/dist/browser/components/Card/CardActions.d.mts +1 -1
- package/dist/browser/components/Card/CardActions.d.mts.map +1 -1
- package/dist/browser/components/Card/CardActions.d.ts +1 -1
- package/dist/browser/components/Card/CardActions.d.ts.map +1 -1
- package/dist/browser/contexts/Provider.d.cts.map +1 -1
- package/dist/browser/contexts/Provider.d.mts.map +1 -1
- package/dist/browser/contexts/Provider.d.ts.map +1 -1
- package/dist/browser/index.cjs +29 -28
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.js +29 -28
- package/dist/browser/index.js.map +1 -1
- package/dist/neutral/components/Card/Card.d.cts +10 -0
- package/dist/neutral/components/Card/Card.d.cts.map +1 -0
- package/dist/neutral/components/Card/Card.d.mts +10 -0
- package/dist/neutral/components/Card/Card.d.mts.map +1 -0
- package/dist/neutral/components/Card/Card.d.ts +10 -0
- package/dist/neutral/components/Card/Card.d.ts.map +1 -0
- package/dist/neutral/components/Card/CardActions.d.cts +9 -0
- package/dist/neutral/components/Card/CardActions.d.cts.map +1 -0
- package/dist/neutral/components/Card/CardActions.d.mts +9 -0
- package/dist/neutral/components/Card/CardActions.d.mts.map +1 -0
- package/dist/neutral/components/Card/CardActions.d.ts +9 -0
- package/dist/neutral/components/Card/CardActions.d.ts.map +1 -0
- package/dist/neutral/components/Card/CardContent.d.cts +10 -0
- package/dist/neutral/components/Card/CardContent.d.cts.map +1 -0
- package/dist/neutral/components/Card/CardContent.d.mts +10 -0
- package/dist/neutral/components/Card/CardContent.d.mts.map +1 -0
- package/dist/neutral/components/Card/CardContent.d.ts +10 -0
- package/dist/neutral/components/Card/CardContent.d.ts.map +1 -0
- package/dist/neutral/components/Card/CardHeader.d.cts +6 -0
- package/dist/neutral/components/Card/CardHeader.d.cts.map +1 -0
- package/dist/neutral/components/Card/CardHeader.d.mts +6 -0
- package/dist/neutral/components/Card/CardHeader.d.mts.map +1 -0
- package/dist/neutral/components/Card/CardHeader.d.ts +6 -0
- package/dist/neutral/components/Card/CardHeader.d.ts.map +1 -0
- package/dist/neutral/components/Card/index.d.cts +4 -0
- package/dist/neutral/components/Card/index.d.cts.map +1 -0
- package/dist/neutral/components/Card/index.d.mts +4 -0
- package/dist/neutral/components/Card/index.d.mts.map +1 -0
- package/dist/neutral/components/Card/index.d.ts +4 -0
- package/dist/neutral/components/Card/index.d.ts.map +1 -0
- package/dist/neutral/components/index.d.cts +2 -0
- package/dist/neutral/components/index.d.cts.map +1 -0
- package/dist/neutral/components/index.d.mts +2 -0
- package/dist/neutral/components/index.d.mts.map +1 -0
- package/dist/neutral/components/index.d.ts +2 -0
- package/dist/neutral/components/index.d.ts.map +1 -0
- package/dist/neutral/contexts/Context.d.cts +4 -0
- package/dist/neutral/contexts/Context.d.cts.map +1 -0
- package/dist/neutral/contexts/Context.d.mts +4 -0
- package/dist/neutral/contexts/Context.d.mts.map +1 -0
- package/dist/neutral/contexts/Context.d.ts +4 -0
- package/dist/neutral/contexts/Context.d.ts.map +1 -0
- package/dist/neutral/contexts/Provider.d.cts +18 -0
- package/dist/neutral/contexts/Provider.d.cts.map +1 -0
- package/dist/neutral/contexts/Provider.d.mts +18 -0
- package/dist/neutral/contexts/Provider.d.mts.map +1 -0
- package/dist/neutral/contexts/Provider.d.ts +18 -0
- package/dist/neutral/contexts/Provider.d.ts.map +1 -0
- package/dist/neutral/contexts/State.d.cts +31 -0
- package/dist/neutral/contexts/State.d.cts.map +1 -0
- package/dist/neutral/contexts/State.d.mts +31 -0
- package/dist/neutral/contexts/State.d.mts.map +1 -0
- package/dist/neutral/contexts/State.d.ts +31 -0
- package/dist/neutral/contexts/State.d.ts.map +1 -0
- package/dist/neutral/contexts/index.d.cts +5 -0
- package/dist/neutral/contexts/index.d.cts.map +1 -0
- package/dist/neutral/contexts/index.d.mts +5 -0
- package/dist/neutral/contexts/index.d.mts.map +1 -0
- package/dist/neutral/contexts/index.d.ts +5 -0
- package/dist/neutral/contexts/index.d.ts.map +1 -0
- package/dist/neutral/contexts/use.d.cts +38 -0
- package/dist/neutral/contexts/use.d.cts.map +1 -0
- package/dist/neutral/contexts/use.d.mts +38 -0
- package/dist/neutral/contexts/use.d.mts.map +1 -0
- package/dist/neutral/contexts/use.d.ts +38 -0
- package/dist/neutral/contexts/use.d.ts.map +1 -0
- package/dist/neutral/hooks/index.d.cts +2 -0
- package/dist/neutral/hooks/index.d.cts.map +1 -0
- package/dist/neutral/hooks/index.d.mts +2 -0
- package/dist/neutral/hooks/index.d.mts.map +1 -0
- package/dist/neutral/hooks/index.d.ts +2 -0
- package/dist/neutral/hooks/index.d.ts.map +1 -0
- package/dist/neutral/hooks/node/index.d.cts +5 -0
- package/dist/neutral/hooks/node/index.d.cts.map +1 -0
- package/dist/neutral/hooks/node/index.d.mts +5 -0
- package/dist/neutral/hooks/node/index.d.mts.map +1 -0
- package/dist/neutral/hooks/node/index.d.ts +5 -0
- package/dist/neutral/hooks/node/index.d.ts.map +1 -0
- package/dist/neutral/hooks/node/useSentinelFromNode.d.cts +4 -0
- package/dist/neutral/hooks/node/useSentinelFromNode.d.cts.map +1 -0
- package/dist/neutral/hooks/node/useSentinelFromNode.d.mts +4 -0
- package/dist/neutral/hooks/node/useSentinelFromNode.d.mts.map +1 -0
- package/dist/neutral/hooks/node/useSentinelFromNode.d.ts +4 -0
- package/dist/neutral/hooks/node/useSentinelFromNode.d.ts.map +1 -0
- package/dist/neutral/hooks/node/useSentinelsFromNode.d.cts +5 -0
- package/dist/neutral/hooks/node/useSentinelsFromNode.d.cts.map +1 -0
- package/dist/neutral/hooks/node/useSentinelsFromNode.d.mts +5 -0
- package/dist/neutral/hooks/node/useSentinelsFromNode.d.mts.map +1 -0
- package/dist/neutral/hooks/node/useSentinelsFromNode.d.ts +5 -0
- package/dist/neutral/hooks/node/useSentinelsFromNode.d.ts.map +1 -0
- package/dist/neutral/hooks/node/useWeakSentinelFromNode.d.cts +4 -0
- package/dist/neutral/hooks/node/useWeakSentinelFromNode.d.cts.map +1 -0
- package/dist/neutral/hooks/node/useWeakSentinelFromNode.d.mts +4 -0
- package/dist/neutral/hooks/node/useWeakSentinelFromNode.d.mts.map +1 -0
- package/dist/neutral/hooks/node/useWeakSentinelFromNode.d.ts +4 -0
- package/dist/neutral/hooks/node/useWeakSentinelFromNode.d.ts.map +1 -0
- package/dist/neutral/hooks/node/useWeakSentinelsFromNode.d.cts +5 -0
- package/dist/neutral/hooks/node/useWeakSentinelsFromNode.d.cts.map +1 -0
- package/dist/neutral/hooks/node/useWeakSentinelsFromNode.d.mts +5 -0
- package/dist/neutral/hooks/node/useWeakSentinelsFromNode.d.mts.map +1 -0
- package/dist/neutral/hooks/node/useWeakSentinelsFromNode.d.ts +5 -0
- package/dist/neutral/hooks/node/useWeakSentinelsFromNode.d.ts.map +1 -0
- package/dist/neutral/index.cjs +268 -0
- package/dist/neutral/index.cjs.map +1 -0
- package/dist/neutral/index.d.cts +4 -0
- package/dist/neutral/index.d.cts.map +1 -0
- package/dist/neutral/index.d.mts +4 -0
- package/dist/neutral/index.d.mts.map +1 -0
- package/dist/neutral/index.d.ts +4 -0
- package/dist/neutral/index.d.ts.map +1 -0
- package/dist/neutral/index.js +245 -0
- package/dist/neutral/index.js.map +1 -0
- package/dist/node/components/Card/CardActions.d.cts +1 -1
- package/dist/node/components/Card/CardActions.d.cts.map +1 -1
- package/dist/node/components/Card/CardActions.d.mts +1 -1
- package/dist/node/components/Card/CardActions.d.mts.map +1 -1
- package/dist/node/components/Card/CardActions.d.ts +1 -1
- package/dist/node/components/Card/CardActions.d.ts.map +1 -1
- package/dist/node/contexts/Provider.d.cts.map +1 -1
- package/dist/node/contexts/Provider.d.mts.map +1 -1
- package/dist/node/contexts/Provider.d.ts.map +1 -1
- package/dist/node/index.cjs +29 -28
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.js +29 -28
- package/dist/node/index.js.map +1 -1
- package/package.json +20 -20
- package/src/components/Card/Card.stories.tsx +2 -2
- package/src/components/Card/Card.tsx +6 -6
- package/src/components/Card/CardActions.tsx +4 -4
- package/src/components/Card/CardContent.tsx +2 -2
- package/src/components/Card/CardHeader.tsx +2 -2
- package/src/contexts/Provider.tsx +8 -7
- package/src/hooks/node/useSentinelFromNode.tsx +4 -4
- package/src/hooks/node/useSentinelsFromNode.tsx +3 -3
- package/src/hooks/node/useWeakSentinelsFromNode.tsx +2 -2
package/dist/node/index.js
CHANGED
|
@@ -7,8 +7,8 @@ import { useState } from "react";
|
|
|
7
7
|
import { ButtonEx } from "@xylabs/react-button";
|
|
8
8
|
import { ModuleCardActions } from "@xyo-network/react-module";
|
|
9
9
|
import { jsx } from "react/jsx-runtime";
|
|
10
|
-
var SentinelCardActions = ({ onReport,
|
|
11
|
-
return /* @__PURE__ */ jsx(ModuleCardActions, {
|
|
10
|
+
var SentinelCardActions = ({ onReport, mod, ...props }) => {
|
|
11
|
+
return /* @__PURE__ */ jsx(ModuleCardActions, { mod, ...props, children: /* @__PURE__ */ jsx(ButtonEx, { onClick: () => onReport == null ? void 0 : onReport(mod), size: "small", variant: "outlined", children: "Report" }) });
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
// src/components/Card/CardContent.tsx
|
|
@@ -16,8 +16,8 @@ import { FlexGrowRow } from "@xylabs/react-flexbox";
|
|
|
16
16
|
import { ModuleCardContent } from "@xyo-network/react-module";
|
|
17
17
|
import { JsonViewerEx } from "@xyo-network/react-payload-raw-info";
|
|
18
18
|
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
19
|
-
var SentinelCardContent = ({ children, report,
|
|
20
|
-
return /* @__PURE__ */ jsx2(ModuleCardContent, {
|
|
19
|
+
var SentinelCardContent = ({ children, report, mod, ...props }) => {
|
|
20
|
+
return /* @__PURE__ */ jsx2(ModuleCardContent, { mod, ...props, children: /* @__PURE__ */ jsxs(FlexGrowRow, { flexWrap: "wrap", justifyContent: "start", gap: 2, children: [
|
|
21
21
|
report ? /* @__PURE__ */ jsx2(JsonViewerEx, { value: report }) : null,
|
|
22
22
|
children
|
|
23
23
|
] }) });
|
|
@@ -26,24 +26,24 @@ var SentinelCardContent = ({ children, report, module, ...props }) => {
|
|
|
26
26
|
// src/components/Card/CardHeader.tsx
|
|
27
27
|
import { ModuleCardHeader } from "@xyo-network/react-module";
|
|
28
28
|
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
29
|
-
var SentinelCardHeader = ({ title,
|
|
30
|
-
return /* @__PURE__ */ jsx3(ModuleCardHeader, {
|
|
29
|
+
var SentinelCardHeader = ({ title, mod, ...props }) => {
|
|
30
|
+
return /* @__PURE__ */ jsx3(ModuleCardHeader, { mod, title: title ?? (mod == null ? void 0 : mod.config.name) ?? "Sentinel", ...props });
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
// src/components/Card/Card.tsx
|
|
34
34
|
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
35
|
-
var SentinelCard = ({ children, inPayloads,
|
|
35
|
+
var SentinelCard = ({ children, inPayloads, mod, ...props }) => {
|
|
36
36
|
const [retry, setRetry] = useState(-1);
|
|
37
37
|
const [report] = usePromise(async () => {
|
|
38
38
|
if (retry >= 0) {
|
|
39
|
-
return await (
|
|
39
|
+
return await (mod == null ? void 0 : mod.report(inPayloads));
|
|
40
40
|
}
|
|
41
|
-
}, [
|
|
41
|
+
}, [mod, retry, inPayloads]);
|
|
42
42
|
return /* @__PURE__ */ jsxs2(Card, { ...props, children: [
|
|
43
|
-
/* @__PURE__ */ jsx4(SentinelCardHeader, {
|
|
44
|
-
/* @__PURE__ */ jsx4(SentinelCardContent, {
|
|
43
|
+
/* @__PURE__ */ jsx4(SentinelCardHeader, { mod }),
|
|
44
|
+
/* @__PURE__ */ jsx4(SentinelCardContent, { mod, report }),
|
|
45
45
|
children,
|
|
46
|
-
/* @__PURE__ */ jsx4(SentinelCardActions, {
|
|
46
|
+
/* @__PURE__ */ jsx4(SentinelCardActions, { mod, onReport: () => setRetry(retry + 1) })
|
|
47
47
|
] });
|
|
48
48
|
};
|
|
49
49
|
|
|
@@ -88,12 +88,13 @@ var SentinelProvider = ({ account, archivist, children, filter, name, required =
|
|
|
88
88
|
name,
|
|
89
89
|
schema: SentinelConfigSchema,
|
|
90
90
|
synchronous: true,
|
|
91
|
-
|
|
91
|
+
// eslint-disable-next-line id-denylist
|
|
92
|
+
tasks: witnesses == null ? void 0 : witnesses.map((mod) => ({ module: mod.address }))
|
|
92
93
|
}
|
|
93
94
|
});
|
|
94
95
|
const offCallbacks = [];
|
|
95
96
|
offCallbacks.push(
|
|
96
|
-
sentinel2.on("reportEnd", ({ module, outPayloads }) => {
|
|
97
|
+
sentinel2.on("reportEnd", ({ module: mod, outPayloads }) => {
|
|
97
98
|
var _a;
|
|
98
99
|
if (mounted()) {
|
|
99
100
|
setProgress({
|
|
@@ -101,7 +102,7 @@ var SentinelProvider = ({ account, archivist, children, filter, name, required =
|
|
|
101
102
|
witnesses: progress.witnesses
|
|
102
103
|
});
|
|
103
104
|
setStatus((outPayloads == null ? void 0 : outPayloads.length) ? "succeeded" /* Succeeded */ : "failed" /* Failed */);
|
|
104
|
-
setReportingErrors([new Error(`Witness failed [${((_a =
|
|
105
|
+
setReportingErrors([new Error(`Witness failed [${((_a = mod == null ? void 0 : mod.config) == null ? void 0 : _a.name) ?? mod.address}]`)]);
|
|
105
106
|
}
|
|
106
107
|
})
|
|
107
108
|
);
|
|
@@ -116,11 +117,11 @@ var SentinelProvider = ({ account, archivist, children, filter, name, required =
|
|
|
116
117
|
if (witnesses)
|
|
117
118
|
for (const witness of witnesses) {
|
|
118
119
|
offCallbacks.push(
|
|
119
|
-
witness.on("observeEnd", ({ module, outPayloads }) => {
|
|
120
|
+
witness.on("observeEnd", ({ module: mod, outPayloads }) => {
|
|
120
121
|
const witnesses2 = progress.witnesses ?? {};
|
|
121
122
|
witnesses2[witness.address] = {
|
|
122
123
|
status: (outPayloads == null ? void 0 : outPayloads.length) ? "succeeded" /* Succeeded */ : "failed" /* Failed */,
|
|
123
|
-
witness: asWitnessInstance(
|
|
124
|
+
witness: asWitnessInstance(mod, () => `Module is not a witness [${mod.id}]`)
|
|
124
125
|
};
|
|
125
126
|
if (mounted()) {
|
|
126
127
|
setProgress({
|
|
@@ -131,11 +132,11 @@ var SentinelProvider = ({ account, archivist, children, filter, name, required =
|
|
|
131
132
|
})
|
|
132
133
|
);
|
|
133
134
|
offCallbacks.push(
|
|
134
|
-
witness.on("observeStart", ({ module }) => {
|
|
135
|
+
witness.on("observeStart", ({ module: mod }) => {
|
|
135
136
|
const witnesses2 = progress.witnesses ?? {};
|
|
136
137
|
witnesses2[witness.address] = {
|
|
137
138
|
status: "started" /* Started */,
|
|
138
|
-
witness: asWitnessInstance(
|
|
139
|
+
witness: asWitnessInstance(mod, () => `Module is not a witness [${mod.id}]`)
|
|
139
140
|
};
|
|
140
141
|
if (mounted()) {
|
|
141
142
|
setProgress({
|
|
@@ -174,10 +175,10 @@ import { useModuleFromNode } from "@xyo-network/react-node";
|
|
|
174
175
|
import { asSentinelInstance } from "@xyo-network/sentinel-model";
|
|
175
176
|
var useSentinelFromNode = (nameOrAddressOrInstance, config) => {
|
|
176
177
|
var _a, _b;
|
|
177
|
-
const [
|
|
178
|
-
const instance = asSentinelInstance(
|
|
179
|
-
if (
|
|
180
|
-
const error2 = new Error(`Resolved module is not a SentinelInstance [${(_a =
|
|
178
|
+
const [mod, error] = useModuleFromNode(nameOrAddressOrInstance, config);
|
|
179
|
+
const instance = asSentinelInstance(mod);
|
|
180
|
+
if (mod && !instance) {
|
|
181
|
+
const error2 = new Error(`Resolved module is not a SentinelInstance [${(_a = mod.config) == null ? void 0 : _a.schema}:${(_b = mod.config) == null ? void 0 : _b.name}:${mod.address}]`);
|
|
181
182
|
console.error(error2.message);
|
|
182
183
|
return [void 0, error2];
|
|
183
184
|
}
|
|
@@ -194,9 +195,9 @@ var useSentinelsFromNode = (filter, config) => {
|
|
|
194
195
|
}
|
|
195
196
|
return modules ? [
|
|
196
197
|
// eslint-disable-next-line unicorn/no-array-reduce
|
|
197
|
-
modules.reduce((prev,
|
|
198
|
-
if (isSentinelInstance(
|
|
199
|
-
prev.push(
|
|
198
|
+
modules.reduce((prev, mod) => {
|
|
199
|
+
if (isSentinelInstance(mod)) {
|
|
200
|
+
prev.push(mod);
|
|
200
201
|
}
|
|
201
202
|
return prev;
|
|
202
203
|
}, []),
|
|
@@ -221,8 +222,8 @@ var useWeakSentinelsFromNode = (filter, config) => {
|
|
|
221
222
|
return [null, error];
|
|
222
223
|
}
|
|
223
224
|
return [
|
|
224
|
-
(modules == null ? void 0 : modules.map((
|
|
225
|
-
const instance = asSentinelInstance2(
|
|
225
|
+
(modules == null ? void 0 : modules.map((mod) => {
|
|
226
|
+
const instance = asSentinelInstance2(mod == null ? void 0 : mod.deref());
|
|
226
227
|
if (instance) {
|
|
227
228
|
return new WeakRef(instance);
|
|
228
229
|
}
|
package/dist/node/index.js.map
CHANGED
|
@@ -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 { Card, CardProps } from '@mui/material'\nimport { usePromise } from '@xylabs/react-promise'\nimport { Payload } from '@xyo-network/payload-model'\nimport { ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\nimport { useState } from 'react'\n\nimport { SentinelCardActions } from './CardActions'\nimport { SentinelCardContent } from './CardContent'\nimport { SentinelCardHeader } from './CardHeader'\n\nexport type SentinelCardProps = CardProps &\n ModuleRenderProps<SentinelInstance> & {\n inPayloads?: Payload[]\n }\n\nexport const SentinelCard: React.FC<SentinelCardProps> = ({ children, inPayloads, module, ...props }) => {\n const [retry, setRetry] = useState(-1)\n const [report] = usePromise(async () => {\n if (retry >= 0) {\n return await module?.report(inPayloads)\n }\n }, [module, retry, inPayloads])\n return (\n <Card {...props}>\n <SentinelCardHeader module={module} />\n <SentinelCardContent module={module} report={report} />\n {children}\n <SentinelCardActions module={module} onReport={() => setRetry(retry + 1)} />\n </Card>\n )\n}\n","import { CardActionsProps } from '@mui/material'\nimport { ButtonEx } from '@xylabs/react-button'\nimport { ModuleCardActions, ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport type SentinelCardActionsProps = ModuleRenderProps<SentinelInstance> &\n CardActionsProps & {\n onReport?: (module?: SentinelInstance) => void\n }\n\nexport const SentinelCardActions: React.FC<SentinelCardActionsProps> = ({ onReport, module, ...props }) => {\n return (\n <ModuleCardActions module={module} {...props}>\n <ButtonEx onClick={() => onReport?.(module)} size={'small'} variant={'outlined'}>\n Report\n </ButtonEx>\n </ModuleCardActions>\n )\n}\n","import { CardContentProps } from '@mui/material'\nimport { FlexGrowRow } from '@xylabs/react-flexbox'\nimport { Payload } from '@xyo-network/payload-model'\nimport { ModuleCardContent, ModuleRenderProps } from '@xyo-network/react-module'\nimport { JsonViewerEx } from '@xyo-network/react-payload-raw-info'\nimport { 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> = ({ children, report, module, ...props }) => {\n return (\n <ModuleCardContent module={module} {...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 { CardHeaderProps } from '@mui/material'\nimport { ModuleCardHeader, ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const SentinelCardHeader: React.FC<ModuleRenderProps<SentinelInstance> & CardHeaderProps> = ({ title, module, ...props }) => {\n return <ModuleCardHeader module={module} title={title ?? module?.config.name ?? 'Sentinel'} {...props} />\n}\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { SentinelContextState } from './State'\n\nexport const SentinelContext = createContextEx<SentinelContextState>()\n","/* eslint-disable unicorn/no-array-push-push */\nimport { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { WithChildren } from '@xylabs/react-shared'\nimport { AccountInstance } from '@xyo-network/account-model'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { ModuleFilter } from '@xyo-network/module-model'\nimport { useWitnessesFromNode } from '@xyo-network/react-witness'\nimport { MemorySentinel } from '@xyo-network/sentinel-memory'\nimport { SentinelConfig, SentinelConfigSchema } from '@xyo-network/sentinel-model'\nimport { asWitnessInstance, WitnessInstance } from '@xyo-network/witness-model'\nimport { useEffect, useState } from 'react'\n\nimport { SentinelContext } from './Context'\nimport { SentinelReportProgress, SentinelReportStatus } from './State'\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 filter?: ModuleFilter\n name?: string\n required?: boolean\n witnesses?: WitnessInstance[]\n}\n\nexport const SentinelProvider: React.FC<WithChildren<SentinelProviderProps>> = ({ account, archivist, children, filter, name, required = false }) => {\n const [sentinel, setSentinel] = useState<MemorySentinel>()\n const [history, setHistory] = useState<BoundWitness[]>()\n const [progress, setProgress] = useState<SentinelReportProgress>({})\n const [status, setStatus] = useState(SentinelReportStatus.Idle)\n const [reportingErrors, setReportingErrors] = useState<Error[]>()\n const [witnesses] = useWitnessesFromNode(filter)\n\n useAsyncEffect(\n // eslint-disable-next-line react-hooks/exhaustive-deps\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 tasks: witnesses?.map((module) => ({ module: module.address })),\n } as SentinelConfig,\n })\n const offCallbacks: (() => void)[] = []\n offCallbacks.push(\n sentinel.on('reportEnd', ({ module, 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 [${module?.config?.name ?? module.address}]`)])\n }\n }),\n )\n offCallbacks.push(\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', ({ module, outPayloads }) => {\n const witnesses = progress.witnesses ?? {}\n witnesses[witness.address] = {\n status: outPayloads?.length ? SentinelReportStatus.Succeeded : SentinelReportStatus.Failed,\n witness: asWitnessInstance(module, () => `Module is not a witness [${module.id}]`),\n }\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses,\n })\n }\n }),\n )\n offCallbacks.push(\n witness.on('observeStart', ({ module }) => {\n const witnesses = progress.witnesses ?? {}\n witnesses[witness.address] = {\n status: SentinelReportStatus.Started,\n witness: asWitnessInstance(module, () => `Module is not a witness [${module.id}]`),\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 // eslint-disable-next-line react-hooks/exhaustive-deps\n [account, archivist, witnesses],\n )\n\n useEffect(() => {\n setHistory(sentinel?.history as BoundWitness[])\n }, [sentinel])\n\n return !required || sentinel ?\n <SentinelContext.Provider value={{ history, progress, provided: true, reportingErrors, sentinel, status }}>{children}</SentinelContext.Provider>\n : null\n}\n","import { ArchivistModule } from '@xyo-network/archivist-model'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { SentinelModule } from '@xyo-network/sentinel-model'\nimport { WitnessModule } from '@xyo-network/witness-model'\n\nexport enum SentinelReportStatus {\n Idle = 'idle',\n Queued = 'queued',\n Started = 'started',\n Succeeded = 'succeeded',\n Failed = 'failed',\n}\n\nexport interface SentinelWitnessReportProgress {\n status: SentinelReportStatus\n witness: WitnessModule\n}\n\nexport interface SentinelArchivistApiReportProgress {\n archivist: ArchivistModule\n status: SentinelReportStatus\n}\n\nexport interface SentinelReportProgress {\n archivists?: Record<string, SentinelArchivistApiReportProgress>\n witnesses?: Record<string, SentinelWitnessReportProgress>\n}\n\nexport interface SentinelContextState {\n history?: BoundWitness[]\n progress?: SentinelReportProgress\n reportingErrors?: Error[]\n sentinel?: SentinelModule\n status?: SentinelReportStatus\n}\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { SentinelContext } from './Context'\n\nexport const useSentinelContext = () => {\n const { sentinel, history, progress, reportingErrors, status } = useContextEx(SentinelContext, 'Sentinel')\n return { history, progress, reportingErrors, sentinel, status }\n}\n","// eslint-disable-next-line import/no-deprecated\nimport { ModuleFromNodeConfig, useModuleFromNode } from '@xyo-network/react-node'\nimport { asSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useSentinelFromNode = (\n nameOrAddressOrInstance?: string | SentinelInstance,\n config?: ModuleFromNodeConfig,\n): [SentinelInstance | undefined, Error | undefined] => {\n // eslint-disable-next-line deprecation/deprecation, import/no-deprecated\n const [module, error] = useModuleFromNode(nameOrAddressOrInstance, config)\n const instance = asSentinelInstance(module)\n if (module && !instance) {\n const error = new Error(`Resolved module is not a SentinelInstance [${module.config?.schema}:${module.config?.name}:${module.address}]`)\n console.error(error.message)\n return [undefined, error]\n }\n return [instance, error]\n}\n","import { ModuleFilter } from '@xyo-network/module-model'\n// eslint-disable-next-line import/no-deprecated\nimport { ModuleFromNodeConfig, useModulesFromNode } from '@xyo-network/react-node'\nimport { isSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useSentinelsFromNode = (\n filter?: ModuleFilter,\n config?: ModuleFromNodeConfig,\n): [SentinelInstance[] | null | undefined, Error | undefined] => {\n // eslint-disable-next-line deprecation/deprecation, import/no-deprecated\n const [modules, error] = useModulesFromNode(filter, 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, module) => {\n if (isSentinelInstance(module)) {\n prev.push(module)\n }\n return prev\n }, []),\n undefined,\n ]\n : [modules, error]\n}\n","import { ModuleFromNodeConfig, useWeakModuleFromNode } from '@xyo-network/react-node'\nimport { isSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useWeakSentinelFromNode = (\n nameOrAddressOrInstance?: string | SentinelInstance,\n config?: ModuleFromNodeConfig,\n): [WeakRef<SentinelInstance> | undefined, Error | undefined] => {\n return useWeakModuleFromNode<SentinelInstance>(nameOrAddressOrInstance, { identity: isSentinelInstance, ...config })\n}\n","import { exists } from '@xylabs/exists'\nimport { ModuleFilter } from '@xyo-network/module-model'\nimport { ModuleFromNodeConfig, useWeakModulesFromNode } from '@xyo-network/react-node'\nimport { asSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useWeakSentinelsFromNode = (\n filter?: ModuleFilter,\n config?: ModuleFromNodeConfig,\n): [WeakRef<SentinelInstance>[] | null | undefined, Error | undefined] => {\n const [modules, error] = useWeakModulesFromNode(filter, config)\n if (error) {\n return [null, error]\n }\n return [\n modules\n ?.map((module) => {\n const instance = asSentinelInstance(module?.deref())\n if (instance) {\n return new WeakRef(instance)\n }\n })\n .filter(exists) ?? [],\n undefined,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AAK;AACzB;;;ACfA,SAA+B,0BAA0B;AACzD,SAAS,0BAA4C;AAE9C,IAAM,uBAAuB,CAClC,QACA,WAC+D;AAE/D,QAAM,CAAC,SAAS,KAAK,IAAI,mBAAmB,QAAQ,MAAM;AAC1D,MAAI,OAAO;AACT,WAAO,CAAC,MAAM,KAAK;AAAA,EACrB;AACA,SAAO,UACH;AAAA;AAAA,IAEE,QAAQ,OAA2B,CAAC,MAAM,WAAW;AACnD,UAAI,mBAAmB,MAAM,GAAG;AAC9B,aAAK,KAAK,MAAM;AAAA,MAClB;AACA,aAAO;AAAA,IACT,GAAG,CAAC,CAAC;AAAA,IACL;AAAA,EACF,IACA,CAAC,SAAS,KAAK;AACrB;;;AC1BA,SAA+B,6BAA6B;AAC5D,SAAS,sBAAAC,2BAA4C;AAE9C,IAAM,0BAA0B,CACrC,yBACA,WAC+D;AAC/D,SAAO,sBAAwC,yBAAyB,EAAE,UAAUA,qBAAoB,GAAG,OAAO,CAAC;AACrH;;;ACRA,SAAS,cAAc;AAEvB,SAA+B,8BAA8B;AAC7D,SAAS,sBAAAC,2BAA4C;AAE9C,IAAM,2BAA2B,CACtC,QACA,WACwE;AACxE,QAAM,CAAC,SAAS,KAAK,IAAI,uBAAuB,QAAQ,MAAM;AAC9D,MAAI,OAAO;AACT,WAAO,CAAC,MAAM,KAAK;AAAA,EACrB;AACA,SAAO;AAAA,KACL,mCACI,IAAI,CAAC,WAAW;AAChB,YAAM,WAAWA,oBAAmB,iCAAQ,OAAO;AACnD,UAAI,UAAU;AACZ,eAAO,IAAI,QAAQ,QAAQ;AAAA,MAC7B;AAAA,IACF,GACC,OAAO,YAAW,CAAC;AAAA,IACtB;AAAA,EACF;AACF;","names":["jsx","jsx","jsx","jsxs","useState","SentinelReportStatus","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 { Card, CardProps } from '@mui/material'\nimport { usePromise } from '@xylabs/react-promise'\nimport { Payload } from '@xyo-network/payload-model'\nimport { ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\nimport { useState } from 'react'\n\nimport { SentinelCardActions } from './CardActions'\nimport { SentinelCardContent } from './CardContent'\nimport { SentinelCardHeader } from './CardHeader'\n\nexport type SentinelCardProps = CardProps &\n ModuleRenderProps<SentinelInstance> & {\n inPayloads?: Payload[]\n }\n\nexport const SentinelCard: React.FC<SentinelCardProps> = ({ children, inPayloads, mod, ...props }) => {\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 { CardActionsProps } from '@mui/material'\nimport { ButtonEx } from '@xylabs/react-button'\nimport { ModuleCardActions, ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport type SentinelCardActionsProps = ModuleRenderProps<SentinelInstance> &\n CardActionsProps & {\n onReport?: (mod?: SentinelInstance) => void\n }\n\nexport const SentinelCardActions: React.FC<SentinelCardActionsProps> = ({ onReport, mod, ...props }) => {\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 { CardContentProps } from '@mui/material'\nimport { FlexGrowRow } from '@xylabs/react-flexbox'\nimport { Payload } from '@xyo-network/payload-model'\nimport { ModuleCardContent, ModuleRenderProps } from '@xyo-network/react-module'\nimport { JsonViewerEx } from '@xyo-network/react-payload-raw-info'\nimport { 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> = ({ children, report, mod, ...props }) => {\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 { CardHeaderProps } from '@mui/material'\nimport { ModuleCardHeader, ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const SentinelCardHeader: React.FC<ModuleRenderProps<SentinelInstance> & CardHeaderProps> = ({ title, mod, ...props }) => {\n return <ModuleCardHeader mod={mod} title={title ?? mod?.config.name ?? 'Sentinel'} {...props} />\n}\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { SentinelContextState } from './State'\n\nexport const SentinelContext = createContextEx<SentinelContextState>()\n","/* eslint-disable unicorn/no-array-push-push */\nimport { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { WithChildren } from '@xylabs/react-shared'\nimport { AccountInstance } from '@xyo-network/account-model'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { ModuleFilter } from '@xyo-network/module-model'\nimport { useWitnessesFromNode } from '@xyo-network/react-witness'\nimport { MemorySentinel } from '@xyo-network/sentinel-memory'\nimport { SentinelConfig, SentinelConfigSchema } from '@xyo-network/sentinel-model'\nimport { asWitnessInstance, WitnessInstance } from '@xyo-network/witness-model'\nimport { useEffect, useState } from 'react'\n\nimport { SentinelContext } from './Context'\nimport { SentinelReportProgress, SentinelReportStatus } from './State'\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 filter?: ModuleFilter\n name?: string\n required?: boolean\n witnesses?: WitnessInstance[]\n}\n\nexport const SentinelProvider: React.FC<WithChildren<SentinelProviderProps>> = ({ account, archivist, children, filter, name, required = false }) => {\n const [sentinel, setSentinel] = useState<MemorySentinel>()\n const [history, setHistory] = useState<BoundWitness[]>()\n const [progress, setProgress] = useState<SentinelReportProgress>({})\n const [status, setStatus] = useState(SentinelReportStatus.Idle)\n const [reportingErrors, setReportingErrors] = useState<Error[]>()\n const [witnesses] = useWitnessesFromNode(filter)\n\n useAsyncEffect(\n // eslint-disable-next-line react-hooks/exhaustive-deps\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 // eslint-disable-next-line id-denylist\n tasks: witnesses?.map((mod) => ({ module: mod.address })),\n } as SentinelConfig,\n })\n const offCallbacks: (() => void)[] = []\n offCallbacks.push(\n sentinel.on('reportEnd', ({ module: 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 )\n offCallbacks.push(\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', ({ module: 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}]`),\n }\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses,\n })\n }\n }),\n )\n offCallbacks.push(\n witness.on('observeStart', ({ module: 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}]`),\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 // eslint-disable-next-line react-hooks/exhaustive-deps\n [account, archivist, witnesses],\n )\n\n useEffect(() => {\n setHistory(sentinel?.history as BoundWitness[])\n }, [sentinel])\n\n return !required || sentinel ?\n <SentinelContext.Provider value={{ history, progress, provided: true, reportingErrors, sentinel, status }}>{children}</SentinelContext.Provider>\n : null\n}\n","import { ArchivistModule } from '@xyo-network/archivist-model'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { SentinelModule } from '@xyo-network/sentinel-model'\nimport { WitnessModule } from '@xyo-network/witness-model'\n\nexport enum SentinelReportStatus {\n Idle = 'idle',\n Queued = 'queued',\n Started = 'started',\n Succeeded = 'succeeded',\n Failed = 'failed',\n}\n\nexport interface SentinelWitnessReportProgress {\n status: SentinelReportStatus\n witness: WitnessModule\n}\n\nexport interface SentinelArchivistApiReportProgress {\n archivist: ArchivistModule\n status: SentinelReportStatus\n}\n\nexport interface SentinelReportProgress {\n archivists?: Record<string, SentinelArchivistApiReportProgress>\n witnesses?: Record<string, SentinelWitnessReportProgress>\n}\n\nexport interface SentinelContextState {\n history?: BoundWitness[]\n progress?: SentinelReportProgress\n reportingErrors?: Error[]\n sentinel?: SentinelModule\n status?: SentinelReportStatus\n}\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { SentinelContext } from './Context'\n\nexport const useSentinelContext = () => {\n const { sentinel, history, progress, reportingErrors, status } = useContextEx(SentinelContext, 'Sentinel')\n return { history, progress, reportingErrors, sentinel, status }\n}\n","// eslint-disable-next-line import/no-deprecated\nimport { ModuleFromNodeConfig, useModuleFromNode } from '@xyo-network/react-node'\nimport { asSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useSentinelFromNode = (\n nameOrAddressOrInstance?: string | SentinelInstance,\n config?: ModuleFromNodeConfig,\n): [SentinelInstance | undefined, Error | undefined] => {\n // eslint-disable-next-line deprecation/deprecation, import/no-deprecated\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 { ModuleFilter } from '@xyo-network/module-model'\n// eslint-disable-next-line import/no-deprecated\nimport { ModuleFromNodeConfig, useModulesFromNode } from '@xyo-network/react-node'\nimport { isSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useSentinelsFromNode = (\n filter?: ModuleFilter,\n config?: ModuleFromNodeConfig,\n): [SentinelInstance[] | null | undefined, Error | undefined] => {\n // eslint-disable-next-line deprecation/deprecation, import/no-deprecated\n const [modules, error] = useModulesFromNode(filter, 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 { ModuleFromNodeConfig, useWeakModuleFromNode } from '@xyo-network/react-node'\nimport { isSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useWeakSentinelFromNode = (\n nameOrAddressOrInstance?: string | SentinelInstance,\n config?: ModuleFromNodeConfig,\n): [WeakRef<SentinelInstance> | undefined, Error | undefined] => {\n return useWeakModuleFromNode<SentinelInstance>(nameOrAddressOrInstance, { identity: isSentinelInstance, ...config })\n}\n","import { exists } from '@xylabs/exists'\nimport { ModuleFilter } from '@xyo-network/module-model'\nimport { ModuleFromNodeConfig, useWeakModulesFromNode } from '@xyo-network/react-node'\nimport { asSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useWeakSentinelsFromNode = (\n filter?: ModuleFilter,\n config?: ModuleFromNodeConfig,\n): [WeakRef<SentinelInstance>[] | null | undefined, Error | undefined] => {\n const [modules, error] = useWeakModulesFromNode(filter, 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":";AAAA,SAAS,YAAuB;AAChC,SAAS,kBAAkB;AAI3B,SAAS,gBAAgB;;;ACJzB,SAAS,gBAAgB;AACzB,SAAS,yBAA4C;AAW/C;AAHC,IAAM,sBAA0D,CAAC,EAAE,UAAU,KAAK,GAAG,MAAM,MAAM;AACtG,SACE,oBAAC,qBAAkB,KAAW,GAAG,OAC/B,8BAAC,YAAS,SAAS,MAAM,qCAAW,MAAM,MAAM,SAAS,SAAS,YAAY,oBAE9E,GACF;AAEJ;;;ACjBA,SAAS,mBAAmB;AAE5B,SAAS,yBAA4C;AACrD,SAAS,oBAAoB;AAYvB,SAEI,OAAAA,MAFJ;AAHC,IAAM,sBAA0D,CAAC,EAAE,UAAU,QAAQ,KAAK,GAAG,MAAM,MAAM;AAC9G,SACE,gBAAAA,KAAC,qBAAkB,KAAW,GAAG,OAC/B,+BAAC,eAAY,UAAS,QAAO,gBAAe,SAAQ,KAAK,GACtD;AAAA,aACC,gBAAAA,KAAC,gBAAa,OAAO,QAAQ,IAC7B;AAAA,IACD;AAAA,KACH,GACF;AAEJ;;;ACvBA,SAAS,wBAA2C;AAI3C,gBAAAC,YAAA;AADF,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WACwE;AACxE,QAAM,CAAC,SAAS,KAAK,IAAI,uBAAuB,QAAQ,MAAM;AAC9D,MAAI,OAAO;AACT,WAAO,CAAC,MAAM,KAAK;AAAA,EACrB;AACA,SAAO;AAAA,KACL,mCACI,IAAI,CAAC,QAAQ;AACb,YAAM,WAAWA,oBAAmB,2BAAK,OAAO;AAChD,UAAI,UAAU;AACZ,eAAO,IAAI,QAAQ,QAAQ;AAAA,MAC7B;AAAA,IACF,GACC,OAAO,YAAW,CAAC;AAAA,IACtB;AAAA,EACF;AACF;","names":["jsx","jsx","jsx","jsxs","useState","SentinelReportStatus","jsx","useState","sentinel","witnesses","error","isSentinelInstance","asSentinelInstance"]}
|
package/package.json
CHANGED
|
@@ -10,34 +10,34 @@
|
|
|
10
10
|
"url": "https://github.com/XYOracleNetwork/sdk-xyo-react-js/issues"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@xylabs/exists": "^3.
|
|
13
|
+
"@xylabs/exists": "^3.3.2",
|
|
14
14
|
"@xylabs/react-async-effect": "^3.1.7",
|
|
15
15
|
"@xylabs/react-button": "^3.1.7",
|
|
16
16
|
"@xylabs/react-flexbox": "^3.1.7",
|
|
17
17
|
"@xylabs/react-promise": "^3.1.7",
|
|
18
18
|
"@xylabs/react-shared": "^3.1.7",
|
|
19
|
-
"@xyo-network/account-model": "^2.99.
|
|
20
|
-
"@xyo-network/archivist-model": "^2.99.
|
|
21
|
-
"@xyo-network/boundwitness-model": "^2.99.
|
|
22
|
-
"@xyo-network/module-model": "^2.99.
|
|
23
|
-
"@xyo-network/payload-model": "^2.99.
|
|
24
|
-
"@xyo-network/react-module": "~2.
|
|
25
|
-
"@xyo-network/react-node": "~2.
|
|
26
|
-
"@xyo-network/react-payload-raw-info": "~2.
|
|
27
|
-
"@xyo-network/react-shared": "~2.
|
|
28
|
-
"@xyo-network/react-witness": "~2.
|
|
29
|
-
"@xyo-network/sentinel-memory": "^2.99.
|
|
30
|
-
"@xyo-network/sentinel-model": "^2.99.
|
|
31
|
-
"@xyo-network/witness-model": "^2.99.
|
|
19
|
+
"@xyo-network/account-model": "^2.99.3",
|
|
20
|
+
"@xyo-network/archivist-model": "^2.99.3",
|
|
21
|
+
"@xyo-network/boundwitness-model": "^2.99.3",
|
|
22
|
+
"@xyo-network/module-model": "^2.99.3",
|
|
23
|
+
"@xyo-network/payload-model": "^2.99.3",
|
|
24
|
+
"@xyo-network/react-module": "~2.76.0",
|
|
25
|
+
"@xyo-network/react-node": "~2.76.0",
|
|
26
|
+
"@xyo-network/react-payload-raw-info": "~2.76.0",
|
|
27
|
+
"@xyo-network/react-shared": "~2.76.0",
|
|
28
|
+
"@xyo-network/react-witness": "~2.76.0",
|
|
29
|
+
"@xyo-network/sentinel-memory": "^2.99.3",
|
|
30
|
+
"@xyo-network/sentinel-model": "^2.99.3",
|
|
31
|
+
"@xyo-network/witness-model": "^2.99.3"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@storybook/react": "^7.6.19",
|
|
35
|
-
"@xylabs/ts-scripts-yarn3": "^3.
|
|
36
|
-
"@xylabs/tsconfig-react": "^3.
|
|
37
|
-
"@xyo-network/account": "^2.99.
|
|
35
|
+
"@xylabs/ts-scripts-yarn3": "^3.10.0",
|
|
36
|
+
"@xylabs/tsconfig-react": "^3.10.0",
|
|
37
|
+
"@xyo-network/account": "^2.99.3",
|
|
38
38
|
"@xyo-network/evm-call-witness": "^2.94.3",
|
|
39
|
-
"@xyo-network/manifest": "^2.99.
|
|
40
|
-
"@xyo-network/module-factory-locator": "^2.99.
|
|
39
|
+
"@xyo-network/manifest": "^2.99.3",
|
|
40
|
+
"@xyo-network/module-factory-locator": "^2.99.3",
|
|
41
41
|
"ethers": "^6.12.1",
|
|
42
42
|
"typescript": "^5.4.5"
|
|
43
43
|
},
|
|
@@ -101,6 +101,6 @@
|
|
|
101
101
|
},
|
|
102
102
|
"sideEffects": false,
|
|
103
103
|
"types": "dist/browser/index.d.ts",
|
|
104
|
-
"version": "2.
|
|
104
|
+
"version": "2.76.0",
|
|
105
105
|
"type": "module"
|
|
106
106
|
}
|
|
@@ -80,7 +80,7 @@ const NftSentinelTemplate: StoryFn<typeof SentinelCard> = () => {
|
|
|
80
80
|
|
|
81
81
|
return (
|
|
82
82
|
<FlexCol gap={2}>
|
|
83
|
-
<SentinelCard
|
|
83
|
+
<SentinelCard mod={sentinel} inPayloads={inPayloads} />
|
|
84
84
|
</FlexCol>
|
|
85
85
|
)
|
|
86
86
|
}
|
|
@@ -130,7 +130,7 @@ const NftTokensSentinelTemplate: StoryFn<typeof SentinelCard> = () => {
|
|
|
130
130
|
|
|
131
131
|
return (
|
|
132
132
|
<FlexCol gap={2}>
|
|
133
|
-
<SentinelCard
|
|
133
|
+
<SentinelCard mod={contractSentinel} inPayloads={inPayloads} />
|
|
134
134
|
{/*tokens ? <JsonViewerEx value={tokens} /> : null*/}
|
|
135
135
|
</FlexCol>
|
|
136
136
|
)
|
|
@@ -14,19 +14,19 @@ export type SentinelCardProps = CardProps &
|
|
|
14
14
|
inPayloads?: Payload[]
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export const SentinelCard: React.FC<SentinelCardProps> = ({ children, inPayloads,
|
|
17
|
+
export const SentinelCard: React.FC<SentinelCardProps> = ({ children, inPayloads, mod, ...props }) => {
|
|
18
18
|
const [retry, setRetry] = useState(-1)
|
|
19
19
|
const [report] = usePromise(async () => {
|
|
20
20
|
if (retry >= 0) {
|
|
21
|
-
return await
|
|
21
|
+
return await mod?.report(inPayloads)
|
|
22
22
|
}
|
|
23
|
-
}, [
|
|
23
|
+
}, [mod, retry, inPayloads])
|
|
24
24
|
return (
|
|
25
25
|
<Card {...props}>
|
|
26
|
-
<SentinelCardHeader
|
|
27
|
-
<SentinelCardContent
|
|
26
|
+
<SentinelCardHeader mod={mod} />
|
|
27
|
+
<SentinelCardContent mod={mod} report={report} />
|
|
28
28
|
{children}
|
|
29
|
-
<SentinelCardActions
|
|
29
|
+
<SentinelCardActions mod={mod} onReport={() => setRetry(retry + 1)} />
|
|
30
30
|
</Card>
|
|
31
31
|
)
|
|
32
32
|
}
|
|
@@ -5,13 +5,13 @@ import { SentinelInstance } from '@xyo-network/sentinel-model'
|
|
|
5
5
|
|
|
6
6
|
export type SentinelCardActionsProps = ModuleRenderProps<SentinelInstance> &
|
|
7
7
|
CardActionsProps & {
|
|
8
|
-
onReport?: (
|
|
8
|
+
onReport?: (mod?: SentinelInstance) => void
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export const SentinelCardActions: React.FC<SentinelCardActionsProps> = ({ onReport,
|
|
11
|
+
export const SentinelCardActions: React.FC<SentinelCardActionsProps> = ({ onReport, mod, ...props }) => {
|
|
12
12
|
return (
|
|
13
|
-
<ModuleCardActions
|
|
14
|
-
<ButtonEx onClick={() => onReport?.(
|
|
13
|
+
<ModuleCardActions mod={mod} {...props}>
|
|
14
|
+
<ButtonEx onClick={() => onReport?.(mod)} size={'small'} variant={'outlined'}>
|
|
15
15
|
Report
|
|
16
16
|
</ButtonEx>
|
|
17
17
|
</ModuleCardActions>
|
|
@@ -11,9 +11,9 @@ export type SentinelCardContentProps = ModuleRenderProps<SentinelInstance> &
|
|
|
11
11
|
report?: Payload[]
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export const SentinelCardContent: React.FC<SentinelCardContentProps> = ({ children, report,
|
|
14
|
+
export const SentinelCardContent: React.FC<SentinelCardContentProps> = ({ children, report, mod, ...props }) => {
|
|
15
15
|
return (
|
|
16
|
-
<ModuleCardContent
|
|
16
|
+
<ModuleCardContent mod={mod} {...props}>
|
|
17
17
|
<FlexGrowRow flexWrap="wrap" justifyContent="start" gap={2}>
|
|
18
18
|
{report ?
|
|
19
19
|
<JsonViewerEx value={report} />
|
|
@@ -2,6 +2,6 @@ import { CardHeaderProps } from '@mui/material'
|
|
|
2
2
|
import { ModuleCardHeader, ModuleRenderProps } from '@xyo-network/react-module'
|
|
3
3
|
import { SentinelInstance } from '@xyo-network/sentinel-model'
|
|
4
4
|
|
|
5
|
-
export const SentinelCardHeader: React.FC<ModuleRenderProps<SentinelInstance> & CardHeaderProps> = ({ title,
|
|
6
|
-
return <ModuleCardHeader
|
|
5
|
+
export const SentinelCardHeader: React.FC<ModuleRenderProps<SentinelInstance> & CardHeaderProps> = ({ title, mod, ...props }) => {
|
|
6
|
+
return <ModuleCardHeader mod={mod} title={title ?? mod?.config.name ?? 'Sentinel'} {...props} />
|
|
7
7
|
}
|
|
@@ -44,19 +44,20 @@ export const SentinelProvider: React.FC<WithChildren<SentinelProviderProps>> = (
|
|
|
44
44
|
|
|
45
45
|
schema: SentinelConfigSchema,
|
|
46
46
|
synchronous: true,
|
|
47
|
-
|
|
47
|
+
// eslint-disable-next-line id-denylist
|
|
48
|
+
tasks: witnesses?.map((mod) => ({ module: mod.address })),
|
|
48
49
|
} as SentinelConfig,
|
|
49
50
|
})
|
|
50
51
|
const offCallbacks: (() => void)[] = []
|
|
51
52
|
offCallbacks.push(
|
|
52
|
-
sentinel.on('reportEnd', ({ module, outPayloads }) => {
|
|
53
|
+
sentinel.on('reportEnd', ({ module: mod, outPayloads }) => {
|
|
53
54
|
if (mounted()) {
|
|
54
55
|
setProgress({
|
|
55
56
|
archivists: progress.archivists,
|
|
56
57
|
witnesses: progress.witnesses,
|
|
57
58
|
})
|
|
58
59
|
setStatus(outPayloads?.length ? SentinelReportStatus.Succeeded : SentinelReportStatus.Failed)
|
|
59
|
-
setReportingErrors([new Error(`Witness failed [${
|
|
60
|
+
setReportingErrors([new Error(`Witness failed [${mod?.config?.name ?? mod.address}]`)])
|
|
60
61
|
}
|
|
61
62
|
}),
|
|
62
63
|
)
|
|
@@ -71,11 +72,11 @@ export const SentinelProvider: React.FC<WithChildren<SentinelProviderProps>> = (
|
|
|
71
72
|
if (witnesses)
|
|
72
73
|
for (const witness of witnesses) {
|
|
73
74
|
offCallbacks.push(
|
|
74
|
-
witness.on('observeEnd', ({ module, outPayloads }) => {
|
|
75
|
+
witness.on('observeEnd', ({ module: mod, outPayloads }) => {
|
|
75
76
|
const witnesses = progress.witnesses ?? {}
|
|
76
77
|
witnesses[witness.address] = {
|
|
77
78
|
status: outPayloads?.length ? SentinelReportStatus.Succeeded : SentinelReportStatus.Failed,
|
|
78
|
-
witness: asWitnessInstance(
|
|
79
|
+
witness: asWitnessInstance(mod, () => `Module is not a witness [${mod.id}]`),
|
|
79
80
|
}
|
|
80
81
|
if (mounted()) {
|
|
81
82
|
setProgress({
|
|
@@ -86,11 +87,11 @@ export const SentinelProvider: React.FC<WithChildren<SentinelProviderProps>> = (
|
|
|
86
87
|
}),
|
|
87
88
|
)
|
|
88
89
|
offCallbacks.push(
|
|
89
|
-
witness.on('observeStart', ({ module }) => {
|
|
90
|
+
witness.on('observeStart', ({ module: mod }) => {
|
|
90
91
|
const witnesses = progress.witnesses ?? {}
|
|
91
92
|
witnesses[witness.address] = {
|
|
92
93
|
status: SentinelReportStatus.Started,
|
|
93
|
-
witness: asWitnessInstance(
|
|
94
|
+
witness: asWitnessInstance(mod, () => `Module is not a witness [${mod.id}]`),
|
|
94
95
|
}
|
|
95
96
|
if (mounted()) {
|
|
96
97
|
setProgress({
|
|
@@ -7,10 +7,10 @@ export const useSentinelFromNode = (
|
|
|
7
7
|
config?: ModuleFromNodeConfig,
|
|
8
8
|
): [SentinelInstance | undefined, Error | undefined] => {
|
|
9
9
|
// eslint-disable-next-line deprecation/deprecation, import/no-deprecated
|
|
10
|
-
const [
|
|
11
|
-
const instance = asSentinelInstance(
|
|
12
|
-
if (
|
|
13
|
-
const error = new Error(`Resolved module is not a SentinelInstance [${
|
|
10
|
+
const [mod, error] = useModuleFromNode(nameOrAddressOrInstance, config)
|
|
11
|
+
const instance = asSentinelInstance(mod)
|
|
12
|
+
if (mod && !instance) {
|
|
13
|
+
const error = new Error(`Resolved module is not a SentinelInstance [${mod.config?.schema}:${mod.config?.name}:${mod.address}]`)
|
|
14
14
|
console.error(error.message)
|
|
15
15
|
return [undefined, error]
|
|
16
16
|
}
|
|
@@ -15,9 +15,9 @@ export const useSentinelsFromNode = (
|
|
|
15
15
|
return modules ?
|
|
16
16
|
[
|
|
17
17
|
// eslint-disable-next-line unicorn/no-array-reduce
|
|
18
|
-
modules.reduce<SentinelInstance[]>((prev,
|
|
19
|
-
if (isSentinelInstance(
|
|
20
|
-
prev.push(
|
|
18
|
+
modules.reduce<SentinelInstance[]>((prev, mod) => {
|
|
19
|
+
if (isSentinelInstance(mod)) {
|
|
20
|
+
prev.push(mod)
|
|
21
21
|
}
|
|
22
22
|
return prev
|
|
23
23
|
}, []),
|
|
@@ -13,8 +13,8 @@ export const useWeakSentinelsFromNode = (
|
|
|
13
13
|
}
|
|
14
14
|
return [
|
|
15
15
|
modules
|
|
16
|
-
?.map((
|
|
17
|
-
const instance = asSentinelInstance(
|
|
16
|
+
?.map((mod) => {
|
|
17
|
+
const instance = asSentinelInstance(mod?.deref())
|
|
18
18
|
if (instance) {
|
|
19
19
|
return new WeakRef(instance)
|
|
20
20
|
}
|