@xyo-network/react-sentinel 3.0.0 → 3.0.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.
- package/dist/browser/index.mjs.map +1 -1
- package/package.json +28 -28
- package/src/components/Card/Card.stories.tsx +5 -3
- package/src/components/Card/Card.tsx +5 -4
- package/src/components/Card/CardActions.tsx +4 -3
- package/src/components/Card/CardContent.tsx +5 -4
- package/src/components/Card/CardHeader.tsx +4 -3
- package/src/contexts/Context.ts +1 -1
- package/src/contexts/Provider.tsx +10 -7
- package/src/contexts/State.ts +4 -4
- package/src/hooks/node/useSentinelFromNode.tsx +4 -2
- package/src/hooks/node/useSentinelsFromNode.tsx +5 -3
- package/src/hooks/node/useWeakSentinelFromNode.tsx +4 -2
- package/src/hooks/node/useWeakSentinelsFromNode.tsx +5 -3
- package/xy.config.ts +1 -1
|
@@ -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 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> = ({ 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'\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> = ({ 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'\nimport React from 'react'\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.ts'\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 React, { useEffect, useState } from 'react'\n\nimport { SentinelContext } from './Context.ts'\nimport { SentinelReportProgress, 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 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\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 offCallbacks.push(\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 )\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', ({ 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', ({ 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\n [account, archivist, witnesses],\n )\n\n useEffect(() => {\n setHistory(sentinel?.history as BoundWitness[])\n }, [sentinel])\n\n return !required || sentinel\n // eslint-disable-next-line @eslint-react/no-unstable-context-value\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.ts'\n\nexport const useSentinelContext = () => {\n const { sentinel, history, progress, reportingErrors, status } = useContextEx(SentinelContext, 'Sentinel')\n return { history, progress, reportingErrors, sentinel, status }\n}\n","import { 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 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'\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 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 { useWeakModuleFromNode, WeakModuleFromNodeConfig } from '@xyo-network/react-node'\nimport { isSentinelInstance, SentinelInstance } 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 { 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,SAASA,YAAuB;AAChC,SAASC,kBAAkB;AAI3B,OAAOC,UAASC,gBAAgB;;;ACJhC,SAASC,gBAAgB;AACzB,SAASC,yBAA4C;AAErD,OAAOC,WAAW;AAOX,IAAMC,sBAA0D,wBAAC,EAAE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MAAAA;AACpD,MAAIE,OAAO;AACT,WAAO;MAAC;MAAMA;;EAChB;AACA,SAAOD,UACH;;IAEEA,QAAQG,OAA2B,CAACC,MAAMC,QAAAA;AACxC,UAAIC,mBAAmBD,GAAAA,GAAM;AAC3BD,aAAKG,KAAKF,GAAAA;MACZ;AACA,aAAOD;IACT,GAAG,CAAA,CAAE;IACLI;MAEF;IAACR;IAASC;;AAChB,GApBoC;;;ACJpC,SAASQ,6BAAuD;AAChE,SAASC,sBAAAA,2BAA4C;AAE9C,IAAMC,0BAA0B,wBACrCC,yBACAC,WAAAA;AAEA,SAAOC,sBAAwCF,yBAAyB;IAAEG,UAAUC;IAAoB,GAAGH;EAAO,CAAA;AACpH,GALuC;;;ACHvC,SAASI,cAAc;AAEvB,SAA+BC,8BAA8B;AAC7D,SAASC,sBAAAA,2BAA4C;AAE9C,IAAMC,2BAA2B,wBACtCC,QACAC,WAAAA;AAEA,QAAM,CAACC,SAASC,KAAAA,IAASC,uBAAuBJ,QAAQC,MAAAA;AACxD,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,EACCP,OAAOW,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","useState","SentinelReportStatus","SentinelProvider","account","archivist","children","filter","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","push","on","outPayloads","length","Succeeded","Failed","Error","Started","witness","asWitnessInstance","id","callback","useEffect","React","SentinelContext","Provider","value","provided","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","filter","config","modules","error","useModulesFromNode","reduce","prev","mod","isSentinelInstance","push","undefined","useWeakModuleFromNode","isSentinelInstance","useWeakSentinelFromNode","nameOrAddressOrInstance","config","useWeakModuleFromNode","identity","isSentinelInstance","exists","useWeakModulesFromNode","asSentinelInstance","useWeakSentinelsFromNode","filter","config","modules","error","useWeakModulesFromNode","map","mod","instance","asSentinelInstance","deref","WeakRef","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> = ({ 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 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> = ({ 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 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> = ({ 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 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> = ({ 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 type { SentinelContextState } from './State.ts'\n\nexport const SentinelContext = createContextEx<SentinelContextState>()\n","/* eslint-disable unicorn/no-array-push-push */\nimport { useAsyncEffect } from '@xylabs/react-async-effect'\nimport type { WithChildren } from '@xylabs/react-shared'\nimport type { AccountInstance } from '@xyo-network/account-model'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport type { ModuleFilter } 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 React, { useEffect, useState } from 'react'\n\nimport { SentinelContext } from './Context.ts'\nimport type { 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 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\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 offCallbacks.push(\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 )\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', ({ 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', ({ 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\n [account, archivist, witnesses],\n )\n\n useEffect(() => {\n setHistory(sentinel?.history as BoundWitness[])\n }, [sentinel])\n\n return !required || sentinel\n // eslint-disable-next-line @eslint-react/no-unstable-context-value\n ? <SentinelContext.Provider value={{ history, progress, provided: true, reportingErrors, sentinel, status }}>{children}</SentinelContext.Provider>\n : null\n}\n","import type { ArchivistModule } 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 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.ts'\n\nexport const useSentinelContext = () => {\n const { sentinel, history, progress, reportingErrors, status } = useContextEx(SentinelContext, 'Sentinel')\n return { history, progress, reportingErrors, sentinel, status }\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 { ModuleFilter } 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 filter?: ModuleFilter,\n config?: ModuleFromNodeConfig,\n): [SentinelInstance[] | null | undefined, Error | undefined] => {\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 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 { ModuleFilter } 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 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":";;;;AACA,SAASA,YAAY;AACrB,SAASC,kBAAkB;AAI3B,OAAOC,UAASC,gBAAgB;;;ACLhC,SAASC,gBAAgB;AAEzB,SAASC,yBAAyB;AAElC,OAAOC,WAAW;AAOX,IAAMC,sBAA0D,wBAAC,EAAEC,UAAUC,KAAK,GAAGC,MAAAA,MAAO;AACjG,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,GARuE;;;ACXvE,SAASC,mBAAmB;AAG5B,SAASC,yBAAyB;AAClC,SAASC,oBAAoB;AAE7B,OAAOC,YAAW;AAOX,IAAMC,sBAA0D,wBAAC,EAAEC,UAAUC,QAAQC,KAAK,GAAGC,MAAAA,MAAO;AACzG,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,OA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AM,CAACC,SAASC,KAAAA,IAASC,uBAAuBJ,QAAQC,MAAAA;AACxD,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,EACCP,OAAOW,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","useState","SentinelReportStatus","SentinelProvider","account","archivist","children","filter","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","push","on","outPayloads","length","Succeeded","Failed","Error","Started","witness","asWitnessInstance","id","callback","useEffect","React","SentinelContext","Provider","value","provided","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","filter","config","modules","error","useModulesFromNode","reduce","prev","mod","isSentinelInstance","push","undefined","useWeakModuleFromNode","isSentinelInstance","useWeakSentinelFromNode","nameOrAddressOrInstance","config","useWeakModuleFromNode","identity","isSentinelInstance","exists","useWeakModulesFromNode","asSentinelInstance","useWeakSentinelsFromNode","filter","config","modules","error","useWeakModulesFromNode","map","mod","instance","asSentinelInstance","deref","WeakRef","exists","undefined"]}
|
package/package.json
CHANGED
|
@@ -7,37 +7,37 @@
|
|
|
7
7
|
},
|
|
8
8
|
"bugs": {
|
|
9
9
|
"email": "support@xyo.network",
|
|
10
|
-
"url": "https://github.com/XYOracleNetwork/sdk-xyo-react-js/issues"
|
|
10
|
+
"url": "git+https://github.com/XYOracleNetwork/sdk-xyo-react-js/issues"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@xylabs/exists": "^4.0.
|
|
14
|
-
"@xylabs/react-async-effect": "^4.0.
|
|
15
|
-
"@xylabs/react-button": "^4.0.
|
|
16
|
-
"@xylabs/react-flexbox": "^4.0.
|
|
17
|
-
"@xylabs/react-promise": "^4.0.
|
|
18
|
-
"@xylabs/react-shared": "^4.0.
|
|
19
|
-
"@xyo-network/account-model": "^3.0.
|
|
20
|
-
"@xyo-network/archivist-model": "^3.0.
|
|
21
|
-
"@xyo-network/boundwitness-model": "^3.0.
|
|
22
|
-
"@xyo-network/module-model": "^3.0.
|
|
23
|
-
"@xyo-network/payload-model": "^3.0.
|
|
24
|
-
"@xyo-network/react-module": "^3.0.
|
|
25
|
-
"@xyo-network/react-node": "^3.0.
|
|
26
|
-
"@xyo-network/react-payload-raw-info": "^3.0.
|
|
27
|
-
"@xyo-network/react-shared": "^3.0.
|
|
28
|
-
"@xyo-network/react-witness": "^3.0.
|
|
29
|
-
"@xyo-network/sentinel-memory": "^3.0.
|
|
30
|
-
"@xyo-network/sentinel-model": "^3.0.
|
|
31
|
-
"@xyo-network/witness-model": "^3.0.
|
|
13
|
+
"@xylabs/exists": "^4.0.2",
|
|
14
|
+
"@xylabs/react-async-effect": "^4.0.3",
|
|
15
|
+
"@xylabs/react-button": "^4.0.3",
|
|
16
|
+
"@xylabs/react-flexbox": "^4.0.3",
|
|
17
|
+
"@xylabs/react-promise": "^4.0.3",
|
|
18
|
+
"@xylabs/react-shared": "^4.0.3",
|
|
19
|
+
"@xyo-network/account-model": "^3.0.3",
|
|
20
|
+
"@xyo-network/archivist-model": "^3.0.3",
|
|
21
|
+
"@xyo-network/boundwitness-model": "^3.0.3",
|
|
22
|
+
"@xyo-network/module-model": "^3.0.3",
|
|
23
|
+
"@xyo-network/payload-model": "^3.0.3",
|
|
24
|
+
"@xyo-network/react-module": "^3.0.2",
|
|
25
|
+
"@xyo-network/react-node": "^3.0.2",
|
|
26
|
+
"@xyo-network/react-payload-raw-info": "^3.0.2",
|
|
27
|
+
"@xyo-network/react-shared": "^3.0.2",
|
|
28
|
+
"@xyo-network/react-witness": "^3.0.2",
|
|
29
|
+
"@xyo-network/sentinel-memory": "^3.0.3",
|
|
30
|
+
"@xyo-network/sentinel-model": "^3.0.3",
|
|
31
|
+
"@xyo-network/witness-model": "^3.0.3"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@storybook/react": "^8.2.9",
|
|
35
|
-
"@xylabs/ts-scripts-yarn3": "^4.0.0-rc.
|
|
36
|
-
"@xylabs/tsconfig-react": "^4.0.0-rc.
|
|
37
|
-
"@xyo-network/account": "^3.0.
|
|
38
|
-
"@xyo-network/evm-call-witness": "^3.0.
|
|
39
|
-
"@xyo-network/manifest": "^3.0.
|
|
40
|
-
"@xyo-network/module-factory-locator": "^3.0.
|
|
35
|
+
"@xylabs/ts-scripts-yarn3": "^4.0.0-rc.20",
|
|
36
|
+
"@xylabs/tsconfig-react": "^4.0.0-rc.20",
|
|
37
|
+
"@xyo-network/account": "^3.0.3",
|
|
38
|
+
"@xyo-network/evm-call-witness": "^3.0.3",
|
|
39
|
+
"@xyo-network/manifest": "^3.0.3",
|
|
40
|
+
"@xyo-network/module-factory-locator": "^3.0.3",
|
|
41
41
|
"ethers": "^6.13.2",
|
|
42
42
|
"typescript": "^5.5.4"
|
|
43
43
|
},
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
},
|
|
84
84
|
"repository": {
|
|
85
85
|
"type": "git",
|
|
86
|
-
"url": "https://github.com/XYOracleNetwork/sdk-xyo-react-js.git"
|
|
86
|
+
"url": "git+https://github.com/XYOracleNetwork/sdk-xyo-react-js.git"
|
|
87
87
|
},
|
|
88
88
|
"scripts": {
|
|
89
89
|
"lint-pkg": "npmPkgJsonLint .",
|
|
@@ -91,6 +91,6 @@
|
|
|
91
91
|
},
|
|
92
92
|
"sideEffects": false,
|
|
93
93
|
"types": "dist/browser/index.d.ts",
|
|
94
|
-
"version": "3.0.
|
|
94
|
+
"version": "3.0.2",
|
|
95
95
|
"type": "module"
|
|
96
96
|
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { Meta, StoryFn } from '@storybook/react'
|
|
1
|
+
import type { Meta, StoryFn } from '@storybook/react'
|
|
2
2
|
import { FlexCol } from '@xylabs/react-flexbox'
|
|
3
3
|
import { usePromise } from '@xylabs/react-promise'
|
|
4
4
|
import { HDWallet } from '@xyo-network/account'
|
|
5
5
|
import { EvmCallDiviner, EvmCallWitness, EvmCallWitnessConfigSchema } from '@xyo-network/evm-call-witness'
|
|
6
|
-
import {
|
|
6
|
+
import type { PackageManifestPayload } from '@xyo-network/manifest'
|
|
7
|
+
import { ManifestWrapper } from '@xyo-network/manifest'
|
|
7
8
|
import { ModuleFactoryLocator } from '@xyo-network/module-factory-locator'
|
|
8
9
|
import { ModuleFactory } from '@xyo-network/module-model'
|
|
9
|
-
import {
|
|
10
|
+
import type { ReportEndEventArgs } from '@xyo-network/sentinel-model'
|
|
11
|
+
import { asSentinelInstance } from '@xyo-network/sentinel-model'
|
|
10
12
|
import { InfuraProvider } from 'ethers'
|
|
11
13
|
import React from 'react'
|
|
12
14
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { CardProps } from '@mui/material'
|
|
2
|
+
import { Card } from '@mui/material'
|
|
2
3
|
import { usePromise } from '@xylabs/react-promise'
|
|
3
|
-
import { Payload } from '@xyo-network/payload-model'
|
|
4
|
-
import { ModuleRenderProps } from '@xyo-network/react-module'
|
|
5
|
-
import { SentinelInstance } from '@xyo-network/sentinel-model'
|
|
4
|
+
import type { Payload } from '@xyo-network/payload-model'
|
|
5
|
+
import type { ModuleRenderProps } from '@xyo-network/react-module'
|
|
6
|
+
import type { SentinelInstance } from '@xyo-network/sentinel-model'
|
|
6
7
|
import React, { useState } from 'react'
|
|
7
8
|
|
|
8
9
|
import { SentinelCardActions } from './CardActions.tsx'
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { CardActionsProps } from '@mui/material'
|
|
1
|
+
import type { CardActionsProps } from '@mui/material'
|
|
2
2
|
import { ButtonEx } from '@xylabs/react-button'
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import type { ModuleRenderProps } from '@xyo-network/react-module'
|
|
4
|
+
import { ModuleCardActions } from '@xyo-network/react-module'
|
|
5
|
+
import type { SentinelInstance } from '@xyo-network/sentinel-model'
|
|
5
6
|
import React from 'react'
|
|
6
7
|
|
|
7
8
|
export type SentinelCardActionsProps = ModuleRenderProps<SentinelInstance> &
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { CardContentProps } from '@mui/material'
|
|
1
|
+
import type { CardContentProps } from '@mui/material'
|
|
2
2
|
import { FlexGrowRow } from '@xylabs/react-flexbox'
|
|
3
|
-
import { Payload } from '@xyo-network/payload-model'
|
|
4
|
-
import {
|
|
3
|
+
import type { Payload } from '@xyo-network/payload-model'
|
|
4
|
+
import type { ModuleRenderProps } from '@xyo-network/react-module'
|
|
5
|
+
import { ModuleCardContent } from '@xyo-network/react-module'
|
|
5
6
|
import { JsonViewerEx } from '@xyo-network/react-payload-raw-info'
|
|
6
|
-
import { SentinelInstance } from '@xyo-network/sentinel-model'
|
|
7
|
+
import type { SentinelInstance } from '@xyo-network/sentinel-model'
|
|
7
8
|
import React from 'react'
|
|
8
9
|
|
|
9
10
|
export type SentinelCardContentProps = ModuleRenderProps<SentinelInstance> &
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { CardHeaderProps } from '@mui/material'
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { CardHeaderProps } from '@mui/material'
|
|
2
|
+
import type { ModuleRenderProps } from '@xyo-network/react-module'
|
|
3
|
+
import { ModuleCardHeader } from '@xyo-network/react-module'
|
|
4
|
+
import type { SentinelInstance } from '@xyo-network/sentinel-model'
|
|
4
5
|
import React from 'react'
|
|
5
6
|
|
|
6
7
|
export const SentinelCardHeader: React.FC<ModuleRenderProps<SentinelInstance> & CardHeaderProps> = ({ title, mod, ...props }) => {
|
package/src/contexts/Context.ts
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
/* eslint-disable unicorn/no-array-push-push */
|
|
2
2
|
import { useAsyncEffect } from '@xylabs/react-async-effect'
|
|
3
|
-
import { WithChildren } from '@xylabs/react-shared'
|
|
4
|
-
import { AccountInstance } from '@xyo-network/account-model'
|
|
5
|
-
import { BoundWitness } from '@xyo-network/boundwitness-model'
|
|
6
|
-
import { ModuleFilter } from '@xyo-network/module-model'
|
|
3
|
+
import type { WithChildren } from '@xylabs/react-shared'
|
|
4
|
+
import type { AccountInstance } from '@xyo-network/account-model'
|
|
5
|
+
import type { BoundWitness } from '@xyo-network/boundwitness-model'
|
|
6
|
+
import type { ModuleFilter } from '@xyo-network/module-model'
|
|
7
7
|
import { useWitnessesFromNode } from '@xyo-network/react-witness'
|
|
8
8
|
import { MemorySentinel } from '@xyo-network/sentinel-memory'
|
|
9
|
-
import { SentinelConfig
|
|
10
|
-
import {
|
|
9
|
+
import type { SentinelConfig } from '@xyo-network/sentinel-model'
|
|
10
|
+
import { SentinelConfigSchema } from '@xyo-network/sentinel-model'
|
|
11
|
+
import type { WitnessInstance } from '@xyo-network/witness-model'
|
|
12
|
+
import { asWitnessInstance } from '@xyo-network/witness-model'
|
|
11
13
|
import React, { useEffect, useState } from 'react'
|
|
12
14
|
|
|
13
15
|
import { SentinelContext } from './Context.ts'
|
|
14
|
-
import { SentinelReportProgress
|
|
16
|
+
import type { SentinelReportProgress } from './State.ts'
|
|
17
|
+
import { SentinelReportStatus } from './State.ts'
|
|
15
18
|
|
|
16
19
|
export interface SentinelProviderProps {
|
|
17
20
|
/** Account used by the sentinel for signing */
|
package/src/contexts/State.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ArchivistModule } from '@xyo-network/archivist-model'
|
|
2
|
-
import { BoundWitness } from '@xyo-network/boundwitness-model'
|
|
3
|
-
import { SentinelModule } from '@xyo-network/sentinel-model'
|
|
4
|
-
import { WitnessModule } from '@xyo-network/witness-model'
|
|
1
|
+
import type { ArchivistModule } from '@xyo-network/archivist-model'
|
|
2
|
+
import type { BoundWitness } from '@xyo-network/boundwitness-model'
|
|
3
|
+
import type { SentinelModule } from '@xyo-network/sentinel-model'
|
|
4
|
+
import type { WitnessModule } from '@xyo-network/witness-model'
|
|
5
5
|
|
|
6
6
|
export enum SentinelReportStatus {
|
|
7
7
|
Idle = 'idle',
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { ModuleFromNodeConfig
|
|
2
|
-
import {
|
|
1
|
+
import type { ModuleFromNodeConfig } from '@xyo-network/react-node'
|
|
2
|
+
import { useModuleFromNode } from '@xyo-network/react-node'
|
|
3
|
+
import type { SentinelInstance } from '@xyo-network/sentinel-model'
|
|
4
|
+
import { asSentinelInstance } from '@xyo-network/sentinel-model'
|
|
3
5
|
|
|
4
6
|
export const useSentinelFromNode = (
|
|
5
7
|
nameOrAddressOrInstance?: string | SentinelInstance,
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { ModuleFilter } from '@xyo-network/module-model'
|
|
2
|
-
import { ModuleFromNodeConfig
|
|
3
|
-
import {
|
|
1
|
+
import type { ModuleFilter } from '@xyo-network/module-model'
|
|
2
|
+
import type { ModuleFromNodeConfig } from '@xyo-network/react-node'
|
|
3
|
+
import { useModulesFromNode } from '@xyo-network/react-node'
|
|
4
|
+
import type { SentinelInstance } from '@xyo-network/sentinel-model'
|
|
5
|
+
import { isSentinelInstance } from '@xyo-network/sentinel-model'
|
|
4
6
|
|
|
5
7
|
export const useSentinelsFromNode = (
|
|
6
8
|
filter?: ModuleFilter,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { WeakModuleFromNodeConfig } from '@xyo-network/react-node'
|
|
2
|
+
import { useWeakModuleFromNode } from '@xyo-network/react-node'
|
|
3
|
+
import type { SentinelInstance } from '@xyo-network/sentinel-model'
|
|
4
|
+
import { isSentinelInstance } from '@xyo-network/sentinel-model'
|
|
3
5
|
|
|
4
6
|
export const useWeakSentinelFromNode = (
|
|
5
7
|
nameOrAddressOrInstance?: string | SentinelInstance,
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { exists } from '@xylabs/exists'
|
|
2
|
-
import { ModuleFilter } from '@xyo-network/module-model'
|
|
3
|
-
import { ModuleFromNodeConfig
|
|
4
|
-
import {
|
|
2
|
+
import type { ModuleFilter } from '@xyo-network/module-model'
|
|
3
|
+
import type { ModuleFromNodeConfig } from '@xyo-network/react-node'
|
|
4
|
+
import { useWeakModulesFromNode } from '@xyo-network/react-node'
|
|
5
|
+
import type { SentinelInstance } from '@xyo-network/sentinel-model'
|
|
6
|
+
import { asSentinelInstance } from '@xyo-network/sentinel-model'
|
|
5
7
|
|
|
6
8
|
export const useWeakSentinelsFromNode = (
|
|
7
9
|
filter?: ModuleFilter,
|
package/xy.config.ts
CHANGED