@xyo-network/react-sentinel 7.5.0 → 7.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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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;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,KAAK,EAAE,CAAA;IACzB,QAAQ,CAAC,EAAE,cAAc,CAAA;IACzB,MAAM,CAAC,EAAE,oBAAoB,CAAA;CAC9B,CAAC,CAAA"}
@@ -83,10 +83,10 @@ import { useWitnessesFromNode } from "@xyo-network/react-witness";
83
83
  import { MemorySentinel } from "@xyo-network/sentinel-memory";
84
84
  import { SentinelConfigSchema } from "@xyo-network/sentinel-model";
85
85
  import { asWitnessInstance } from "@xyo-network/witness-model";
86
- import React5, { useEffect, useMemo, useState as useState2 } from "react";
86
+ import React5, { useMemo, useState as useState2 } from "react";
87
87
 
88
88
  // src/contexts/State.ts
89
- import { Enum } from "@xylabs/enum";
89
+ import { Enum } from "@xylabs/sdk-js";
90
90
  var SentinelReportStatus = Enum({
91
91
  Idle: "idle",
92
92
  Queued: "queued",
@@ -173,6 +173,7 @@ var SentinelProvider = /* @__PURE__ */ __name(({ account, archivist, children, i
173
173
  }));
174
174
  }
175
175
  setSentinel(sentinel2);
176
+ setHistory(sentinel2?.history);
176
177
  return () => {
177
178
  for (const callback of offCallbacks) {
178
179
  callback();
@@ -183,11 +184,6 @@ var SentinelProvider = /* @__PURE__ */ __name(({ account, archivist, children, i
183
184
  archivist,
184
185
  witnesses
185
186
  ]);
186
- useEffect(() => {
187
- setHistory(sentinel?.history);
188
- }, [
189
- sentinel
190
- ]);
191
187
  const value = useMemo(() => ({
192
188
  history,
193
189
  progress,
@@ -277,7 +273,7 @@ var useWeakSentinelFromNode = /* @__PURE__ */ __name((nameOrAddressOrInstance, c
277
273
  }, "useWeakSentinelFromNode");
278
274
 
279
275
  // src/hooks/node/useWeakSentinelsFromNode.tsx
280
- import { exists } from "@xylabs/exists";
276
+ import { exists } from "@xylabs/sdk-js";
281
277
  import { useWeakModulesFromNode } from "@xyo-network/react-node";
282
278
  import { asSentinelInstance as asSentinelInstance2 } from "@xyo-network/sentinel-model";
283
279
  var useWeakSentinelsFromNode = /* @__PURE__ */ __name((ids, config) => {
@@ -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,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;OACrB,MACHD,QAAAA,CAAAA;AAIT,GAbuE;;;ACZvE,SAASY,wBAAwB;AAEjC,O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C,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","useEffect","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","useEffect","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"]}
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;OACrB,MACHD,QAAAA,CAAAA;AAIT,GAbuE;;;ACZvE,SAASY,wBAAwB;AAEjC,OAAOC,YAAW;AAEX,IAAMC,qBAAsF,wBAAC,EAClGC,OAAOC,KAAK,GAAGC,MAAAA,MAChB;AACC,SAAO,gBAAAC,OAAA,cAACC,kBAAAA;IAAiBH;IAAUD,OAAOA,SAASC,KAAKI,OAAOC,QAAQ;IAAa,GAAGJ;;AACzF,GAJmG;;;AHW5F,IAAMK,eAA4C,wBAAC,EACxDC,UAAUC,YAAYC,KAAK,G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AW,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.5.0",
3
+ "version": "7.5.2",
4
4
  "description": "Common React library for all XYO projects that use React",
5
5
  "keywords": [
6
6
  "xyo",
@@ -43,22 +43,21 @@
43
43
  "src"
44
44
  ],
45
45
  "dependencies": {
46
- "@xylabs/enum": "~5.0.64",
47
- "@xylabs/exists": "~5.0.64",
48
- "@xylabs/react-async-effect": "~7.1.9",
49
- "@xylabs/react-button": "~7.1.9",
50
- "@xylabs/react-flexbox": "~7.1.9",
51
- "@xylabs/react-promise": "~7.1.9",
52
- "@xylabs/react-shared": "~7.1.9",
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",
53
52
  "@xyo-network/account-model": "~5.3.2",
54
53
  "@xyo-network/archivist-model": "~5.3.2",
55
54
  "@xyo-network/boundwitness-model": "~5.3.2",
56
55
  "@xyo-network/module-model": "~5.3.2",
57
56
  "@xyo-network/payload-model": "~5.3.2",
58
- "@xyo-network/react-module": "7.5.0",
59
- "@xyo-network/react-node": "7.5.0",
60
- "@xyo-network/react-payload-raw-info": "7.5.0",
61
- "@xyo-network/react-witness": "7.5.0",
57
+ "@xyo-network/react-module": "7.5.2",
58
+ "@xyo-network/react-node": "7.5.2",
59
+ "@xyo-network/react-payload-raw-info": "7.5.2",
60
+ "@xyo-network/react-witness": "7.5.2",
62
61
  "@xyo-network/sentinel-memory": "~5.3.2",
63
62
  "@xyo-network/sentinel-model": "~5.3.2",
64
63
  "@xyo-network/witness-model": "~5.3.2"
@@ -85,7 +84,8 @@
85
84
  "react-router-dom": "^7.13.0",
86
85
  "storybook": "~10.2.1",
87
86
  "typescript": "^5.9.3",
88
- "vite": "~7.3.1"
87
+ "vite": "~7.3.1",
88
+ "zod": "^4.3.6"
89
89
  },
90
90
  "peerDependencies": {
91
91
  "@mui/icons-material": ">=6 <8",
@@ -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'