@xyo-network/react-sentinel 2.64.0-rc.7 → 2.64.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.
Files changed (118) hide show
  1. package/dist/browser/contexts/Context.cjs +28 -0
  2. package/dist/{node/contexts/Context.mjs.map → browser/contexts/Context.cjs.map} +1 -1
  3. package/dist/browser/contexts/Context.d.cts +4 -0
  4. package/dist/browser/contexts/Context.d.cts.map +1 -0
  5. package/dist/browser/contexts/Provider.cjs +124 -0
  6. package/dist/browser/contexts/Provider.cjs.map +1 -0
  7. package/dist/browser/contexts/Provider.d.cts +18 -0
  8. package/dist/browser/contexts/Provider.d.cts.map +1 -0
  9. package/dist/browser/contexts/State.cjs +34 -0
  10. package/dist/{node/contexts/State.mjs.map → browser/contexts/State.cjs.map} +1 -1
  11. package/dist/browser/contexts/State.d.cts +31 -0
  12. package/dist/browser/contexts/State.d.cts.map +1 -0
  13. package/dist/browser/contexts/index.cjs +146 -0
  14. package/dist/browser/contexts/index.cjs.map +1 -0
  15. package/dist/browser/contexts/index.d.cts +5 -0
  16. package/dist/browser/contexts/index.d.cts.map +1 -0
  17. package/dist/browser/contexts/use.cjs +37 -0
  18. package/dist/browser/contexts/use.cjs.map +1 -0
  19. package/dist/browser/contexts/use.d.cts +78 -0
  20. package/dist/browser/contexts/use.d.cts.map +1 -0
  21. package/dist/browser/hooks/index.cjs +64 -0
  22. package/dist/browser/hooks/index.cjs.map +1 -0
  23. package/dist/browser/hooks/index.d.cts +2 -0
  24. package/dist/browser/hooks/index.d.cts.map +1 -0
  25. package/dist/browser/hooks/node/index.cjs +64 -0
  26. package/dist/browser/hooks/node/index.cjs.map +1 -0
  27. package/dist/browser/hooks/node/index.d.cts +3 -0
  28. package/dist/browser/hooks/node/index.d.cts.map +1 -0
  29. package/dist/browser/hooks/node/useSentinelFromNode.cjs +38 -0
  30. package/dist/{node/hooks/node/useSentinelFromNode.mjs.map → browser/hooks/node/useSentinelFromNode.cjs.map} +1 -1
  31. package/dist/browser/hooks/node/useSentinelFromNode.d.cts +4 -0
  32. package/dist/browser/hooks/node/useSentinelFromNode.d.cts.map +1 -0
  33. package/dist/browser/hooks/node/useSentinelsFromNode.cjs +47 -0
  34. package/dist/{node/hooks/node/useSentinelsFromNode.mjs.map → browser/hooks/node/useSentinelsFromNode.cjs.map} +1 -1
  35. package/dist/browser/hooks/node/useSentinelsFromNode.d.cts +5 -0
  36. package/dist/browser/hooks/node/useSentinelsFromNode.d.cts.map +1 -0
  37. package/dist/browser/index.cjs +185 -0
  38. package/dist/browser/index.cjs.map +1 -0
  39. package/dist/browser/index.d.cts +3 -0
  40. package/dist/browser/index.d.cts.map +1 -0
  41. package/dist/docs.json +2133 -0
  42. package/dist/node/contexts/Context.cjs +32 -0
  43. package/dist/node/contexts/Context.cjs.map +1 -0
  44. package/dist/node/contexts/Context.d.cts +4 -0
  45. package/dist/node/contexts/Context.d.cts.map +1 -0
  46. package/dist/node/contexts/Context.js +5 -28
  47. package/dist/node/contexts/Context.js.map +1 -1
  48. package/dist/node/contexts/Provider.cjs +129 -0
  49. package/dist/node/contexts/Provider.cjs.map +1 -0
  50. package/dist/node/contexts/Provider.d.cts +18 -0
  51. package/dist/node/contexts/Provider.d.cts.map +1 -0
  52. package/dist/node/contexts/Provider.js +40 -58
  53. package/dist/node/contexts/Provider.js.map +1 -1
  54. package/dist/node/contexts/State.cjs +38 -0
  55. package/dist/node/contexts/State.cjs.map +1 -0
  56. package/dist/node/contexts/State.d.cts +31 -0
  57. package/dist/node/contexts/State.d.cts.map +1 -0
  58. package/dist/node/contexts/State.js +3 -26
  59. package/dist/node/contexts/State.js.map +1 -1
  60. package/dist/node/contexts/index.cjs +154 -0
  61. package/dist/node/contexts/index.cjs.map +1 -0
  62. package/dist/node/contexts/index.d.cts +5 -0
  63. package/dist/node/contexts/index.d.cts.map +1 -0
  64. package/dist/node/contexts/index.js +122 -27
  65. package/dist/node/contexts/index.js.map +1 -1
  66. package/dist/node/contexts/use.cjs +41 -0
  67. package/dist/node/contexts/use.cjs.map +1 -0
  68. package/dist/node/contexts/use.d.cts +78 -0
  69. package/dist/node/contexts/use.d.cts.map +1 -0
  70. package/dist/node/contexts/use.js +12 -30
  71. package/dist/node/contexts/use.js.map +1 -1
  72. package/dist/node/hooks/index.cjs +70 -0
  73. package/dist/node/hooks/index.cjs.map +1 -0
  74. package/dist/node/hooks/index.d.cts +2 -0
  75. package/dist/node/hooks/index.d.cts.map +1 -0
  76. package/dist/node/hooks/index.js +39 -20
  77. package/dist/node/hooks/index.js.map +1 -1
  78. package/dist/node/hooks/node/index.cjs +70 -0
  79. package/dist/node/hooks/node/index.cjs.map +1 -0
  80. package/dist/node/hooks/node/index.d.cts +3 -0
  81. package/dist/node/hooks/node/index.d.cts.map +1 -0
  82. package/dist/node/hooks/node/index.js +39 -22
  83. package/dist/node/hooks/node/index.js.map +1 -1
  84. package/dist/node/hooks/node/useSentinelFromNode.cjs +43 -0
  85. package/dist/node/hooks/node/useSentinelFromNode.cjs.map +1 -0
  86. package/dist/node/hooks/node/useSentinelFromNode.d.cts +4 -0
  87. package/dist/node/hooks/node/useSentinelFromNode.d.cts.map +1 -0
  88. package/dist/node/hooks/node/useSentinelFromNode.js +11 -33
  89. package/dist/node/hooks/node/useSentinelFromNode.js.map +1 -1
  90. package/dist/node/hooks/node/useSentinelsFromNode.cjs +51 -0
  91. package/dist/node/hooks/node/useSentinelsFromNode.cjs.map +1 -0
  92. package/dist/node/hooks/node/useSentinelsFromNode.d.cts +5 -0
  93. package/dist/node/hooks/node/useSentinelsFromNode.d.cts.map +1 -0
  94. package/dist/node/hooks/node/useSentinelsFromNode.js +10 -33
  95. package/dist/node/hooks/node/useSentinelsFromNode.js.map +1 -1
  96. package/dist/node/index.cjs +196 -0
  97. package/dist/node/index.cjs.map +1 -0
  98. package/dist/node/index.d.cts +3 -0
  99. package/dist/node/index.d.cts.map +1 -0
  100. package/dist/node/index.js +161 -22
  101. package/dist/node/index.js.map +1 -1
  102. package/package.json +24 -24
  103. package/dist/node/contexts/Context.mjs +0 -6
  104. package/dist/node/contexts/Provider.mjs +0 -98
  105. package/dist/node/contexts/Provider.mjs.map +0 -1
  106. package/dist/node/contexts/State.mjs +0 -12
  107. package/dist/node/contexts/index.mjs +0 -5
  108. package/dist/node/contexts/index.mjs.map +0 -1
  109. package/dist/node/contexts/use.mjs +0 -10
  110. package/dist/node/contexts/use.mjs.map +0 -1
  111. package/dist/node/hooks/index.mjs +0 -2
  112. package/dist/node/hooks/index.mjs.map +0 -1
  113. package/dist/node/hooks/node/index.mjs +0 -3
  114. package/dist/node/hooks/node/index.mjs.map +0 -1
  115. package/dist/node/hooks/node/useSentinelFromNode.mjs +0 -16
  116. package/dist/node/hooks/node/useSentinelsFromNode.mjs +0 -25
  117. package/dist/node/index.mjs +0 -3
  118. package/dist/node/index.mjs.map +0 -1
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/contexts/Context.ts
21
+ var Context_exports = {};
22
+ __export(Context_exports, {
23
+ SentinelContext: () => SentinelContext
24
+ });
25
+ module.exports = __toCommonJS(Context_exports);
26
+ var import_react_shared = require("@xyo-network/react-shared");
27
+ var SentinelContext = (0, import_react_shared.createContextEx)();
28
+ //# sourceMappingURL=Context.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/contexts/Context.ts"],"sourcesContent":["import { createContextEx } from '@xyo-network/react-shared'\n\nimport { SentinelContextState } from './State'\n\nexport const SentinelContext = createContextEx<SentinelContextState>()\n"],"mappings":"AAAA,SAAS,uBAAuB;AAIzB,MAAM,kBAAkB,gBAAsC;","names":[]}
1
+ {"version":3,"sources":["../../../src/contexts/Context.ts"],"sourcesContent":["import { createContextEx } from '@xyo-network/react-shared'\n\nimport { SentinelContextState } from './State'\n\nexport const SentinelContext = createContextEx<SentinelContextState>()\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAgC;AAIzB,IAAM,sBAAkB,qCAAsC;","names":[]}
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { SentinelContextState } from './State';
3
+ export declare const SentinelContext: import("react").Context<SentinelContextState & import("@xyo-network/react-shared").ContextExState>;
4
+ //# sourceMappingURL=Context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../../src/contexts/Context.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAE9C,eAAO,MAAM,eAAe,oGAA0C,CAAA"}
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/contexts/Provider.tsx
21
+ var Provider_exports = {};
22
+ __export(Provider_exports, {
23
+ SentinelProvider: () => SentinelProvider
24
+ });
25
+ module.exports = __toCommonJS(Provider_exports);
26
+ var import_react_async_effect = require("@xylabs/react-async-effect");
27
+ var import_react_witness = require("@xyo-network/react-witness");
28
+ var import_sentinel = require("@xyo-network/sentinel");
29
+ var import_react = require("react");
30
+
31
+ // src/contexts/Context.ts
32
+ var import_react_shared = require("@xyo-network/react-shared");
33
+ var SentinelContext = (0, import_react_shared.createContextEx)();
34
+
35
+ // src/contexts/Provider.tsx
36
+ var import_jsx_runtime = require("react/jsx-runtime");
37
+ var SentinelProvider = ({ account, archivist, children, filter, name, required = false }) => {
38
+ const [sentinel, setSentinel] = (0, import_react.useState)();
39
+ const [history, setHistory] = (0, import_react.useState)();
40
+ const [progress, setProgress] = (0, import_react.useState)({});
41
+ const [status, setStatus] = (0, import_react.useState)("idle" /* Idle */);
42
+ const [reportingErrors, setReportingErrors] = (0, import_react.useState)();
43
+ const [witnesses] = (0, import_react_witness.useWitnessesFromNode)(filter);
44
+ (0, import_react_async_effect.useAsyncEffect)(
45
+ // eslint-disable-next-line react-hooks/exhaustive-deps
46
+ async (mounted) => {
47
+ const sentinel2 = await import_sentinel.MemorySentinel.create({
48
+ account,
49
+ config: {
50
+ archivists: archivist ? [archivist] : void 0,
51
+ name,
52
+ schema: import_sentinel.SentinelConfigSchema,
53
+ witnesses: witnesses?.map((module2) => module2.address)
54
+ }
55
+ });
56
+ const offCallbacks = [];
57
+ offCallbacks.push(
58
+ sentinel2.on("reportEnd", ({ module: module2, outPayloads }) => {
59
+ if (mounted()) {
60
+ setProgress({
61
+ archivists: progress.archivists,
62
+ witnesses: progress.witnesses
63
+ });
64
+ setStatus(outPayloads?.length ? "succeeded" /* Succeeded */ : "failed" /* Failed */);
65
+ setReportingErrors([Error(`Witness failed [${module2?.config?.name ?? module2.address}]`)]);
66
+ }
67
+ })
68
+ );
69
+ offCallbacks.push(
70
+ sentinel2.on("reportStart", () => {
71
+ if (mounted()) {
72
+ setProgress({ archivists: {}, witnesses: {} });
73
+ setStatus("started" /* Started */);
74
+ }
75
+ })
76
+ );
77
+ witnesses?.forEach((witness) => {
78
+ offCallbacks.push(
79
+ witness.on("observeEnd", ({ module: module2, outPayloads }) => {
80
+ const witnesses2 = progress.witnesses ?? {};
81
+ witnesses2[witness.address] = {
82
+ status: outPayloads?.length ? "succeeded" /* Succeeded */ : "failed" /* Failed */,
83
+ witness: module2
84
+ };
85
+ if (mounted()) {
86
+ setProgress({
87
+ archivists: progress.archivists,
88
+ witnesses: witnesses2
89
+ });
90
+ }
91
+ })
92
+ );
93
+ offCallbacks.push(
94
+ witness.on("observeStart", ({ module: module2 }) => {
95
+ const witnesses2 = progress.witnesses ?? {};
96
+ witnesses2[witness.address] = {
97
+ status: "started" /* Started */,
98
+ witness: module2
99
+ };
100
+ if (mounted()) {
101
+ setProgress({
102
+ archivists: progress.archivists,
103
+ witnesses: witnesses2
104
+ });
105
+ }
106
+ })
107
+ );
108
+ });
109
+ setSentinel(sentinel2);
110
+ return () => {
111
+ offCallbacks.forEach((callback) => {
112
+ callback();
113
+ });
114
+ };
115
+ },
116
+ // eslint-disable-next-line react-hooks/exhaustive-deps
117
+ [account, archivist, witnesses]
118
+ );
119
+ (0, import_react.useEffect)(() => {
120
+ setHistory(sentinel?.history);
121
+ }, [sentinel]);
122
+ return !required || sentinel ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SentinelContext.Provider, { value: { history, progress, provided: true, reportingErrors, sentinel, status }, children }) : null;
123
+ };
124
+ //# sourceMappingURL=Provider.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/contexts/Provider.tsx","../../../src/contexts/Context.ts"],"sourcesContent":["import { 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'\nimport { useWitnessesFromNode } from '@xyo-network/react-witness'\nimport { MemorySentinel, SentinelConfig, SentinelConfigSchema } from '@xyo-network/sentinel'\nimport { WitnessInstance } from '@xyo-network/witness'\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 witnesses: witnesses?.map((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([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 witnesses?.forEach((witness) => {\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: module,\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: module,\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 offCallbacks.forEach((callback) => {\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 { createContextEx } from '@xyo-network/react-shared'\n\nimport { SentinelContextState } from './State'\n\nexport const SentinelContext = createContextEx<SentinelContextState>()\n"],"mappings":"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","names":["sentinel","module","witnesses"]}
@@ -0,0 +1,18 @@
1
+ /// <reference types="react" />
2
+ import { WithChildren } from '@xylabs/react-shared';
3
+ import { AccountInstance } from '@xyo-network/account-model';
4
+ import { ModuleFilter } from '@xyo-network/module';
5
+ import { WitnessInstance } from '@xyo-network/witness';
6
+ export interface SentinelProviderProps {
7
+ /** Account used by the sentinel for signing */
8
+ account: AccountInstance;
9
+ /** @deprecated - sentinel no longer uses archive but relies on an archivist */
10
+ archive?: string;
11
+ archivist?: string;
12
+ filter?: ModuleFilter;
13
+ name?: string;
14
+ required?: boolean;
15
+ witnesses?: WitnessInstance[];
16
+ }
17
+ export declare const SentinelProvider: React.FC<WithChildren<SentinelProviderProps>>;
18
+ //# sourceMappingURL=Provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../src/contexts/Provider.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAGlD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAMtD,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,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB,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,YAAY,CAAC,qBAAqB,CAAC,CA6F1E,CAAA"}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/contexts/State.ts
21
+ var State_exports = {};
22
+ __export(State_exports, {
23
+ SentinelReportStatus: () => SentinelReportStatus
24
+ });
25
+ module.exports = __toCommonJS(State_exports);
26
+ var SentinelReportStatus = /* @__PURE__ */ ((SentinelReportStatus2) => {
27
+ SentinelReportStatus2["Idle"] = "idle";
28
+ SentinelReportStatus2["Queued"] = "queued";
29
+ SentinelReportStatus2["Started"] = "started";
30
+ SentinelReportStatus2["Succeeded"] = "succeeded";
31
+ SentinelReportStatus2["Failed"] = "failed";
32
+ return SentinelReportStatus2;
33
+ })(SentinelReportStatus || {});
34
+ //# sourceMappingURL=State.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/contexts/State.ts"],"sourcesContent":["import { ArchivistModule } from '@xyo-network/archivist'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { SentinelModule } from '@xyo-network/sentinel'\nimport { WitnessModule } from '@xyo-network/witness'\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"],"mappings":"AAKO,IAAK,uBAAL,kBAAKA,0BAAL;AACL,EAAAA,sBAAA,UAAO;AACP,EAAAA,sBAAA,YAAS;AACT,EAAAA,sBAAA,aAAU;AACV,EAAAA,sBAAA,eAAY;AACZ,EAAAA,sBAAA,YAAS;AALC,SAAAA;AAAA,GAAA;","names":["SentinelReportStatus"]}
1
+ {"version":3,"sources":["../../../src/contexts/State.ts"],"sourcesContent":["import { ArchivistModule } from '@xyo-network/archivist'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { SentinelModule } from '@xyo-network/sentinel'\nimport { WitnessModule } from '@xyo-network/witness'\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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKO,IAAK,uBAAL,kBAAKA,0BAAL;AACL,EAAAA,sBAAA,UAAO;AACP,EAAAA,sBAAA,YAAS;AACT,EAAAA,sBAAA,aAAU;AACV,EAAAA,sBAAA,eAAY;AACZ,EAAAA,sBAAA,YAAS;AALC,SAAAA;AAAA,GAAA;","names":["SentinelReportStatus"]}
@@ -0,0 +1,31 @@
1
+ import { ArchivistModule } from '@xyo-network/archivist';
2
+ import { BoundWitness } from '@xyo-network/boundwitness-model';
3
+ import { SentinelModule } from '@xyo-network/sentinel';
4
+ import { WitnessModule } from '@xyo-network/witness';
5
+ export declare enum SentinelReportStatus {
6
+ Idle = "idle",
7
+ Queued = "queued",
8
+ Started = "started",
9
+ Succeeded = "succeeded",
10
+ Failed = "failed"
11
+ }
12
+ export interface SentinelWitnessReportProgress {
13
+ status: SentinelReportStatus;
14
+ witness: WitnessModule;
15
+ }
16
+ export interface SentinelArchivistApiReportProgress {
17
+ archivist: ArchivistModule;
18
+ status: SentinelReportStatus;
19
+ }
20
+ export interface SentinelReportProgress {
21
+ archivists?: Record<string, SentinelArchivistApiReportProgress>;
22
+ witnesses?: Record<string, SentinelWitnessReportProgress>;
23
+ }
24
+ export interface SentinelContextState {
25
+ history?: BoundWitness[];
26
+ progress?: SentinelReportProgress;
27
+ reportingErrors?: Error[];
28
+ sentinel?: SentinelModule;
29
+ status?: SentinelReportStatus;
30
+ }
31
+ //# sourceMappingURL=State.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"State.d.ts","sourceRoot":"","sources":["../../../src/contexts/State.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAEpD,oBAAY,oBAAoB;IAC9B,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,SAAS,cAAc;IACvB,MAAM,WAAW;CAClB;AAED,MAAM,WAAW,6BAA6B;IAC5C,MAAM,EAAE,oBAAoB,CAAA;IAC5B,OAAO,EAAE,aAAa,CAAA;CACvB;AAED,MAAM,WAAW,kCAAkC;IACjD,SAAS,EAAE,eAAe,CAAA;IAC1B,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,WAAW,oBAAoB;IACnC,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"}
@@ -0,0 +1,146 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/contexts/index.ts
21
+ var contexts_exports = {};
22
+ __export(contexts_exports, {
23
+ SentinelContext: () => SentinelContext,
24
+ SentinelProvider: () => SentinelProvider,
25
+ SentinelReportStatus: () => SentinelReportStatus,
26
+ useSentinelContext: () => useSentinelContext
27
+ });
28
+ module.exports = __toCommonJS(contexts_exports);
29
+
30
+ // src/contexts/Context.ts
31
+ var import_react_shared = require("@xyo-network/react-shared");
32
+ var SentinelContext = (0, import_react_shared.createContextEx)();
33
+
34
+ // src/contexts/Provider.tsx
35
+ var import_react_async_effect = require("@xylabs/react-async-effect");
36
+ var import_react_witness = require("@xyo-network/react-witness");
37
+ var import_sentinel = require("@xyo-network/sentinel");
38
+ var import_react = require("react");
39
+
40
+ // src/contexts/State.ts
41
+ var SentinelReportStatus = /* @__PURE__ */ ((SentinelReportStatus2) => {
42
+ SentinelReportStatus2["Idle"] = "idle";
43
+ SentinelReportStatus2["Queued"] = "queued";
44
+ SentinelReportStatus2["Started"] = "started";
45
+ SentinelReportStatus2["Succeeded"] = "succeeded";
46
+ SentinelReportStatus2["Failed"] = "failed";
47
+ return SentinelReportStatus2;
48
+ })(SentinelReportStatus || {});
49
+
50
+ // src/contexts/Provider.tsx
51
+ var import_jsx_runtime = require("react/jsx-runtime");
52
+ var SentinelProvider = ({ account, archivist, children, filter, name, required = false }) => {
53
+ const [sentinel, setSentinel] = (0, import_react.useState)();
54
+ const [history, setHistory] = (0, import_react.useState)();
55
+ const [progress, setProgress] = (0, import_react.useState)({});
56
+ const [status, setStatus] = (0, import_react.useState)("idle" /* Idle */);
57
+ const [reportingErrors, setReportingErrors] = (0, import_react.useState)();
58
+ const [witnesses] = (0, import_react_witness.useWitnessesFromNode)(filter);
59
+ (0, import_react_async_effect.useAsyncEffect)(
60
+ // eslint-disable-next-line react-hooks/exhaustive-deps
61
+ async (mounted) => {
62
+ const sentinel2 = await import_sentinel.MemorySentinel.create({
63
+ account,
64
+ config: {
65
+ archivists: archivist ? [archivist] : void 0,
66
+ name,
67
+ schema: import_sentinel.SentinelConfigSchema,
68
+ witnesses: witnesses?.map((module2) => module2.address)
69
+ }
70
+ });
71
+ const offCallbacks = [];
72
+ offCallbacks.push(
73
+ sentinel2.on("reportEnd", ({ module: module2, outPayloads }) => {
74
+ if (mounted()) {
75
+ setProgress({
76
+ archivists: progress.archivists,
77
+ witnesses: progress.witnesses
78
+ });
79
+ setStatus(outPayloads?.length ? "succeeded" /* Succeeded */ : "failed" /* Failed */);
80
+ setReportingErrors([Error(`Witness failed [${module2?.config?.name ?? module2.address}]`)]);
81
+ }
82
+ })
83
+ );
84
+ offCallbacks.push(
85
+ sentinel2.on("reportStart", () => {
86
+ if (mounted()) {
87
+ setProgress({ archivists: {}, witnesses: {} });
88
+ setStatus("started" /* Started */);
89
+ }
90
+ })
91
+ );
92
+ witnesses?.forEach((witness) => {
93
+ offCallbacks.push(
94
+ witness.on("observeEnd", ({ module: module2, outPayloads }) => {
95
+ const witnesses2 = progress.witnesses ?? {};
96
+ witnesses2[witness.address] = {
97
+ status: outPayloads?.length ? "succeeded" /* Succeeded */ : "failed" /* Failed */,
98
+ witness: module2
99
+ };
100
+ if (mounted()) {
101
+ setProgress({
102
+ archivists: progress.archivists,
103
+ witnesses: witnesses2
104
+ });
105
+ }
106
+ })
107
+ );
108
+ offCallbacks.push(
109
+ witness.on("observeStart", ({ module: module2 }) => {
110
+ const witnesses2 = progress.witnesses ?? {};
111
+ witnesses2[witness.address] = {
112
+ status: "started" /* Started */,
113
+ witness: module2
114
+ };
115
+ if (mounted()) {
116
+ setProgress({
117
+ archivists: progress.archivists,
118
+ witnesses: witnesses2
119
+ });
120
+ }
121
+ })
122
+ );
123
+ });
124
+ setSentinel(sentinel2);
125
+ return () => {
126
+ offCallbacks.forEach((callback) => {
127
+ callback();
128
+ });
129
+ };
130
+ },
131
+ // eslint-disable-next-line react-hooks/exhaustive-deps
132
+ [account, archivist, witnesses]
133
+ );
134
+ (0, import_react.useEffect)(() => {
135
+ setHistory(sentinel?.history);
136
+ }, [sentinel]);
137
+ return !required || sentinel ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SentinelContext.Provider, { value: { history, progress, provided: true, reportingErrors, sentinel, status }, children }) : null;
138
+ };
139
+
140
+ // src/contexts/use.ts
141
+ var import_react_shared2 = require("@xyo-network/react-shared");
142
+ var useSentinelContext = () => {
143
+ const { sentinel, history, progress, reportingErrors, status } = (0, import_react_shared2.useContextEx)(SentinelContext, "Sentinel");
144
+ return { history, progress, reportingErrors, sentinel, status };
145
+ };
146
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/contexts/index.ts","../../../src/contexts/Context.ts","../../../src/contexts/Provider.tsx","../../../src/contexts/State.ts","../../../src/contexts/use.ts"],"sourcesContent":["export * from './Context'\nexport * from './Provider'\nexport * from './State'\nexport * from './use'\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { SentinelContextState } from './State'\n\nexport const SentinelContext = createContextEx<SentinelContextState>()\n","import { 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'\nimport { useWitnessesFromNode } from '@xyo-network/react-witness'\nimport { MemorySentinel, SentinelConfig, SentinelConfigSchema } from '@xyo-network/sentinel'\nimport { WitnessInstance } from '@xyo-network/witness'\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 witnesses: witnesses?.map((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([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 witnesses?.forEach((witness) => {\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: module,\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: module,\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 offCallbacks.forEach((callback) => {\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'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { SentinelModule } from '@xyo-network/sentinel'\nimport { WitnessModule } from '@xyo-network/witness'\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"],"mappings":"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","names":["SentinelReportStatus","sentinel","module","witnesses","import_react_shared"]}
@@ -0,0 +1,5 @@
1
+ export * from './Context';
2
+ export * from './Provider';
3
+ export * from './State';
4
+ export * from './use';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/contexts/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA;AACvB,cAAc,OAAO,CAAA"}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/contexts/use.ts
21
+ var use_exports = {};
22
+ __export(use_exports, {
23
+ useSentinelContext: () => useSentinelContext
24
+ });
25
+ module.exports = __toCommonJS(use_exports);
26
+ var import_react_shared2 = require("@xyo-network/react-shared");
27
+
28
+ // src/contexts/Context.ts
29
+ var import_react_shared = require("@xyo-network/react-shared");
30
+ var SentinelContext = (0, import_react_shared.createContextEx)();
31
+
32
+ // src/contexts/use.ts
33
+ var useSentinelContext = () => {
34
+ const { sentinel, history, progress, reportingErrors, status } = (0, import_react_shared2.useContextEx)(SentinelContext, "Sentinel");
35
+ return { history, progress, reportingErrors, sentinel, status };
36
+ };
37
+ //# sourceMappingURL=use.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/contexts/use.ts","../../../src/contexts/Context.ts"],"sourcesContent":["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","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { SentinelContextState } from './State'\n\nexport const SentinelContext = createContextEx<SentinelContextState>()\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,uBAA6B;;;ACA7B,0BAAgC;AAIzB,IAAM,sBAAkB,qCAAsC;;;ADA9D,IAAM,qBAAqB,MAAM;AACtC,QAAM,EAAE,UAAU,SAAS,UAAU,iBAAiB,OAAO,QAAI,mCAAa,iBAAiB,UAAU;AACzG,SAAO,EAAE,SAAS,UAAU,iBAAiB,UAAU,OAAO;AAChE;","names":["import_react_shared"]}
@@ -0,0 +1,78 @@
1
+ export declare const useSentinelContext: () => {
2
+ history: (import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & import("@xyo-network/boundwitness-model").BoundWitnessFields & {
3
+ schema: "network.xyo.boundwitness";
4
+ })[] | undefined;
5
+ progress: import("./State").SentinelReportProgress | undefined;
6
+ reportingErrors: Error[] | undefined;
7
+ sentinel: import("@xyo-network/sentinel-model").SentinelModule<import("@xyo-network/core").BaseParamsFields & {
8
+ account?: import("@xyo-network/account-model").AccountInstance | "random" | undefined;
9
+ config: import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & Omit<{
10
+ accountDerivationPath?: string | undefined;
11
+ readonly archivist?: import("@xyo-network/module-model").ArchivistModuleConfig | undefined;
12
+ readonly labels?: import("@xyo-network/module-model").Labels | undefined;
13
+ readonly name?: string | undefined;
14
+ readonly paging?: Record<string, {
15
+ size?: number | undefined;
16
+ }> | undefined;
17
+ readonly security?: {
18
+ readonly allowAnonymous?: boolean | undefined;
19
+ readonly allowed?: Record<string, (string | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
20
+ readonly disallowed?: Record<string, string[]> | undefined;
21
+ } | undefined;
22
+ readonly sign?: boolean | undefined;
23
+ readonly storeQueries?: boolean | undefined;
24
+ readonly timestamp?: boolean | undefined;
25
+ } & Omit<import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & Omit<{
26
+ accountDerivationPath?: string | undefined;
27
+ readonly archivist?: import("@xyo-network/module-model").ArchivistModuleConfig | undefined;
28
+ readonly labels?: import("@xyo-network/module-model").Labels | undefined;
29
+ readonly name?: string | undefined;
30
+ readonly paging?: Record<string, {
31
+ size?: number | undefined;
32
+ }> | undefined;
33
+ readonly security?: {
34
+ readonly allowAnonymous?: boolean | undefined;
35
+ readonly allowed?: Record<string, (string | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
36
+ readonly disallowed?: Record<string, string[]> | undefined;
37
+ } | undefined;
38
+ readonly sign?: boolean | undefined;
39
+ readonly storeQueries?: boolean | undefined;
40
+ readonly timestamp?: boolean | undefined;
41
+ } & import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & Omit<{
42
+ accountDerivationPath?: string | undefined;
43
+ readonly archivist?: import("@xyo-network/module-model").ArchivistModuleConfig | undefined;
44
+ readonly labels?: import("@xyo-network/module-model").Labels | undefined;
45
+ readonly name?: string | undefined;
46
+ readonly paging?: Record<string, {
47
+ size?: number | undefined;
48
+ }> | undefined;
49
+ readonly security?: {
50
+ readonly allowAnonymous?: boolean | undefined;
51
+ readonly allowed?: Record<string, (string | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
52
+ readonly disallowed?: Record<string, string[]> | undefined;
53
+ } | undefined;
54
+ readonly sign?: boolean | undefined;
55
+ readonly storeQueries?: boolean | undefined;
56
+ readonly timestamp?: boolean | undefined;
57
+ } & {
58
+ archivists?: string[] | undefined;
59
+ schema: string;
60
+ } & import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & {
61
+ schema: "network.xyo.module.config";
62
+ }, "schema"> & {
63
+ schema: "network.xyo.module.config";
64
+ } & {
65
+ witnesses?: string[] | undefined;
66
+ }, "schema"> & {
67
+ schema: "network.xyo.sentinel.config";
68
+ }, "schema"> & {
69
+ schema: string;
70
+ }, "schema"> & {
71
+ schema: string;
72
+ };
73
+ ephemeralQueryAccountEnabled?: boolean | undefined;
74
+ wallet?: import("@xyo-network/wallet-model").WalletInstance | undefined;
75
+ }> | undefined;
76
+ status: import("./State").SentinelReportStatus | undefined;
77
+ };
78
+ //# sourceMappingURL=use.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use.d.ts","sourceRoot":"","sources":["../../../src/contexts/use.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAG9B,CAAA"}