@xyo-network/react-sentinel 2.46.6 → 2.46.7
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/cjs/contexts/Provider.js +8 -8
- package/dist/cjs/contexts/Provider.js.map +1 -1
- package/dist/docs.json +347 -102
- package/dist/esm/contexts/Provider.js +8 -8
- package/dist/esm/contexts/Provider.js.map +1 -1
- package/dist/types/contexts/Provider.d.ts.map +1 -1
- package/dist/types/contexts/State.d.ts +2 -2
- package/dist/types/contexts/State.d.ts.map +1 -1
- package/dist/types/contexts/use.d.ts +2 -2
- package/dist/types/hooks/useSentinel.d.ts +38 -1
- package/dist/types/hooks/useSentinel.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/contexts/Provider.tsx +12 -11
- package/src/contexts/State.ts +2 -2
|
@@ -15,7 +15,7 @@ export const SentinelProvider = ({ account, archivist, children, name, witnesses
|
|
|
15
15
|
useAsyncEffect(
|
|
16
16
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
17
17
|
async (mounted) => {
|
|
18
|
-
const witnessModules = await node?.resolve({ address: witnesses });
|
|
18
|
+
const witnessModules = (await node?.resolve({ address: witnesses }));
|
|
19
19
|
const sentinel = await MemorySentinel.create({
|
|
20
20
|
account,
|
|
21
21
|
config: {
|
|
@@ -26,7 +26,7 @@ export const SentinelProvider = ({ account, archivist, children, name, witnesses
|
|
|
26
26
|
},
|
|
27
27
|
});
|
|
28
28
|
const offCallbacks = [];
|
|
29
|
-
offCallbacks.push(sentinel.on('
|
|
29
|
+
offCallbacks.push(sentinel.on('reportEnd', ({ errors }) => {
|
|
30
30
|
if (mounted()) {
|
|
31
31
|
setProgress({
|
|
32
32
|
archivists: progress.archivists,
|
|
@@ -36,18 +36,18 @@ export const SentinelProvider = ({ account, archivist, children, name, witnesses
|
|
|
36
36
|
setReportingErrors(errors);
|
|
37
37
|
}
|
|
38
38
|
}));
|
|
39
|
-
offCallbacks.push(sentinel.on('
|
|
39
|
+
offCallbacks.push(sentinel.on('reportStart', () => {
|
|
40
40
|
if (mounted()) {
|
|
41
41
|
setProgress({ archivists: {}, witnesses: {} });
|
|
42
42
|
setStatus(SentinelReportStatus.Started);
|
|
43
43
|
}
|
|
44
44
|
}));
|
|
45
45
|
witnessModules?.forEach((witness) => {
|
|
46
|
-
offCallbacks.push(witness.on('
|
|
46
|
+
offCallbacks.push(witness.on('reportEnd', ({ module, errors }) => {
|
|
47
47
|
const witnesses = progress.witnesses ?? {};
|
|
48
48
|
witnesses[witness.address] = {
|
|
49
|
-
status:
|
|
50
|
-
witness,
|
|
49
|
+
status: errors?.length ? SentinelReportStatus.Failed : SentinelReportStatus.Succeeded,
|
|
50
|
+
witness: module,
|
|
51
51
|
};
|
|
52
52
|
if (mounted()) {
|
|
53
53
|
setProgress({
|
|
@@ -56,11 +56,11 @@ export const SentinelProvider = ({ account, archivist, children, name, witnesses
|
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
}));
|
|
59
|
-
offCallbacks.push(witness.on('
|
|
59
|
+
offCallbacks.push(witness.on('reportStart', ({ module }) => {
|
|
60
60
|
const witnesses = progress.witnesses ?? {};
|
|
61
61
|
witnesses[witness.address] = {
|
|
62
62
|
status: SentinelReportStatus.Started,
|
|
63
|
-
witness,
|
|
63
|
+
witness: module,
|
|
64
64
|
};
|
|
65
65
|
if (mounted()) {
|
|
66
66
|
setProgress({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Provider.js","sourceRoot":"","sources":["../../../src/contexts/Provider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAgB,MAAM,sBAAsB,CAAA;AAGnE,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AACjD,OAAO,EAAE,cAAc,EAAkB,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"Provider.js","sourceRoot":"","sources":["../../../src/contexts/Provider.tsx"],"names":[],"mappings":";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AAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAG,QAAQ,GAA4B,CACjJ,CAAC,CAAC,CAAC,IAAI,CAAA;AACV,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../src/contexts/Provider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkB,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../src/contexts/Provider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkB,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAU5D,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,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;CACrB;AAED,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,qBAAqB,CAAC,CAqG1E,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ArchivistModule } from '@xyo-network/archivist';
|
|
2
|
-
import {
|
|
2
|
+
import { BoundWitness } from '@xyo-network/boundwitness-model';
|
|
3
3
|
import { SentinelModule } from '@xyo-network/sentinel';
|
|
4
4
|
import { WitnessModule } from '@xyo-network/witness';
|
|
5
5
|
export declare enum SentinelReportStatus {
|
|
@@ -22,7 +22,7 @@ export interface SentinelReportProgress {
|
|
|
22
22
|
witnesses?: Record<string, SentinelWitnessReportProgress>;
|
|
23
23
|
}
|
|
24
24
|
export interface SentinelContextState {
|
|
25
|
-
history?:
|
|
25
|
+
history?: BoundWitness[];
|
|
26
26
|
progress?: SentinelReportProgress;
|
|
27
27
|
reportingErrors?: Error[];
|
|
28
28
|
sentinel?: SentinelModule;
|
|
@@ -1 +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,
|
|
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"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const useSentinelContext: () => {
|
|
2
|
-
history: (import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & import("@xyo-network/boundwitness-model").
|
|
2
|
+
history: (import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & import("@xyo-network/boundwitness-model").BoundWitnessFields & {
|
|
3
3
|
schema: "network.xyo.boundwitness";
|
|
4
4
|
})[] | undefined;
|
|
5
5
|
progress: import("./State").SentinelReportProgress | undefined;
|
|
@@ -41,7 +41,7 @@ export declare const useSentinelContext: () => {
|
|
|
41
41
|
schema: string;
|
|
42
42
|
}, "schema">, "schema"> & {
|
|
43
43
|
schema: string;
|
|
44
|
-
}, "schema">, import("@xyo-network/sentinel").SentinelModuleEventData
|
|
44
|
+
}, "schema">, undefined>, import("@xyo-network/sentinel").SentinelModuleEventData> | undefined;
|
|
45
45
|
status: import("./State").SentinelReportStatus | undefined;
|
|
46
46
|
};
|
|
47
47
|
//# sourceMappingURL=use.d.ts.map
|
|
@@ -1,3 +1,40 @@
|
|
|
1
1
|
import { SentinelWrapper } from '@xyo-network/sentinel';
|
|
2
|
-
export declare const useSentinel: (nameOrAddress?: string | undefined, account?: import("@xyo-network/account-model").AccountInstance | undefined, spinCheck?: boolean | undefined) => [SentinelWrapper
|
|
2
|
+
export declare const useSentinel: (nameOrAddress?: string | undefined, account?: import("@xyo-network/account-model").AccountInstance | undefined, spinCheck?: boolean | undefined) => [SentinelWrapper<import("@xyo-network/sentinel").SentinelModule<import("@xyo-network/sentinel").SentinelParams<import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & {
|
|
3
|
+
name?: string | undefined;
|
|
4
|
+
schema: string;
|
|
5
|
+
security?: {
|
|
6
|
+
allowAnonymous?: boolean | undefined;
|
|
7
|
+
allowed?: Record<string, (string | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
8
|
+
disallowed?: Record<string, string[]> | undefined;
|
|
9
|
+
} | undefined;
|
|
10
|
+
storeQueries?: boolean | undefined;
|
|
11
|
+
} & Omit<Omit<import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & {
|
|
12
|
+
name?: string | undefined;
|
|
13
|
+
schema: "network.xyo.node.sentinel";
|
|
14
|
+
security?: {
|
|
15
|
+
allowAnonymous?: boolean | undefined;
|
|
16
|
+
allowed?: Record<string, (string | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
17
|
+
disallowed?: Record<string, string[]> | undefined;
|
|
18
|
+
} | undefined;
|
|
19
|
+
storeQueries?: boolean | undefined;
|
|
20
|
+
} & Omit<import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & {
|
|
21
|
+
name?: string | undefined;
|
|
22
|
+
schema: string;
|
|
23
|
+
security?: {
|
|
24
|
+
allowAnonymous?: boolean | undefined;
|
|
25
|
+
allowed?: Record<string, (string | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
26
|
+
disallowed?: Record<string, string[]> | undefined;
|
|
27
|
+
} | undefined;
|
|
28
|
+
storeQueries?: boolean | undefined;
|
|
29
|
+
} & Omit<{
|
|
30
|
+
archivists?: string[] | undefined;
|
|
31
|
+
schema: string;
|
|
32
|
+
}, "schema"> & {
|
|
33
|
+
schema: "network.xyo.node.sentinel";
|
|
34
|
+
witnesses?: string[] | undefined;
|
|
35
|
+
} & {
|
|
36
|
+
schema: string;
|
|
37
|
+
}, "schema">, "schema"> & {
|
|
38
|
+
schema: string;
|
|
39
|
+
}, "schema">, undefined>, import("@xyo-network/sentinel").SentinelModuleEventData>> | undefined, Error | undefined];
|
|
3
40
|
//# sourceMappingURL=useSentinel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSentinel.d.ts","sourceRoot":"","sources":["../../../src/hooks/useSentinel.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"useSentinel.d.ts","sourceRoot":"","sources":["../../../src/hooks/useSentinel.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mHAA2D,CAAA"}
|
package/package.json
CHANGED
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@xylabs/react-shared": "^2.16.11",
|
|
14
|
-
"@xyo-network/account-model": "^2.
|
|
15
|
-
"@xyo-network/archivist": "^2.
|
|
16
|
-
"@xyo-network/boundwitness-model": "^2.
|
|
17
|
-
"@xyo-network/react-node": "^2.46.
|
|
18
|
-
"@xyo-network/react-shared": "^2.46.
|
|
19
|
-
"@xyo-network/sentinel": "^2.
|
|
20
|
-
"@xyo-network/witness": "^2.
|
|
14
|
+
"@xyo-network/account-model": "^2.53.2",
|
|
15
|
+
"@xyo-network/archivist": "^2.53.2",
|
|
16
|
+
"@xyo-network/boundwitness-model": "^2.53.2",
|
|
17
|
+
"@xyo-network/react-node": "^2.46.7",
|
|
18
|
+
"@xyo-network/react-shared": "^2.46.7",
|
|
19
|
+
"@xyo-network/sentinel": "^2.53.2",
|
|
20
|
+
"@xyo-network/witness": "^2.53.2"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@xylabs/ts-scripts-yarn3": "^2.16.1",
|
|
@@ -76,5 +76,5 @@
|
|
|
76
76
|
},
|
|
77
77
|
"sideEffects": false,
|
|
78
78
|
"types": "dist/types/index.d.ts",
|
|
79
|
-
"version": "2.46.
|
|
79
|
+
"version": "2.46.7"
|
|
80
80
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { useAsyncEffect, WithChildren } from '@xylabs/react-shared'
|
|
2
2
|
import { AccountInstance } from '@xyo-network/account-model'
|
|
3
|
-
import {
|
|
3
|
+
import { BoundWitness } from '@xyo-network/boundwitness-model'
|
|
4
4
|
import { useNode } from '@xyo-network/react-node'
|
|
5
5
|
import { MemorySentinel, SentinelConfig, SentinelConfigSchema } from '@xyo-network/sentinel'
|
|
6
|
+
import { WitnessModule } from '@xyo-network/witness'
|
|
6
7
|
import { useEffect, useState } from 'react'
|
|
7
8
|
|
|
8
9
|
import { SentinelContext } from './Context'
|
|
@@ -29,7 +30,7 @@ export const SentinelProvider: React.FC<WithChildren<SentinelProviderProps>> = (
|
|
|
29
30
|
}) => {
|
|
30
31
|
const [node] = useNode()
|
|
31
32
|
const [sentinel, setSentinel] = useState<MemorySentinel>()
|
|
32
|
-
const [history, setHistory] = useState<
|
|
33
|
+
const [history, setHistory] = useState<BoundWitness[]>()
|
|
33
34
|
const [progress, setProgress] = useState<SentinelReportProgress>({})
|
|
34
35
|
const [status, setStatus] = useState(SentinelReportStatus.Idle)
|
|
35
36
|
const [reportingErrors, setReportingErrors] = useState<Error[]>()
|
|
@@ -37,7 +38,7 @@ export const SentinelProvider: React.FC<WithChildren<SentinelProviderProps>> = (
|
|
|
37
38
|
useAsyncEffect(
|
|
38
39
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
39
40
|
async (mounted) => {
|
|
40
|
-
const witnessModules = await node?.resolve({ address: witnesses })
|
|
41
|
+
const witnessModules = (await node?.resolve({ address: witnesses })) as WitnessModule[]
|
|
41
42
|
const sentinel = await MemorySentinel.create({
|
|
42
43
|
account,
|
|
43
44
|
config: {
|
|
@@ -50,7 +51,7 @@ export const SentinelProvider: React.FC<WithChildren<SentinelProviderProps>> = (
|
|
|
50
51
|
})
|
|
51
52
|
const offCallbacks: (() => void)[] = []
|
|
52
53
|
offCallbacks.push(
|
|
53
|
-
sentinel.on('
|
|
54
|
+
sentinel.on('reportEnd', ({ errors }) => {
|
|
54
55
|
if (mounted()) {
|
|
55
56
|
setProgress({
|
|
56
57
|
archivists: progress.archivists,
|
|
@@ -62,7 +63,7 @@ export const SentinelProvider: React.FC<WithChildren<SentinelProviderProps>> = (
|
|
|
62
63
|
}),
|
|
63
64
|
)
|
|
64
65
|
offCallbacks.push(
|
|
65
|
-
sentinel.on('
|
|
66
|
+
sentinel.on('reportStart', () => {
|
|
66
67
|
if (mounted()) {
|
|
67
68
|
setProgress({ archivists: {}, witnesses: {} })
|
|
68
69
|
setStatus(SentinelReportStatus.Started)
|
|
@@ -71,11 +72,11 @@ export const SentinelProvider: React.FC<WithChildren<SentinelProviderProps>> = (
|
|
|
71
72
|
)
|
|
72
73
|
witnessModules?.forEach((witness) => {
|
|
73
74
|
offCallbacks.push(
|
|
74
|
-
witness.on('
|
|
75
|
+
witness.on('reportEnd', ({ module, errors }) => {
|
|
75
76
|
const witnesses = progress.witnesses ?? {}
|
|
76
77
|
witnesses[witness.address] = {
|
|
77
|
-
status:
|
|
78
|
-
witness,
|
|
78
|
+
status: errors?.length ? SentinelReportStatus.Failed : SentinelReportStatus.Succeeded,
|
|
79
|
+
witness: module,
|
|
79
80
|
}
|
|
80
81
|
if (mounted()) {
|
|
81
82
|
setProgress({
|
|
@@ -86,11 +87,11 @@ export const SentinelProvider: React.FC<WithChildren<SentinelProviderProps>> = (
|
|
|
86
87
|
}),
|
|
87
88
|
)
|
|
88
89
|
offCallbacks.push(
|
|
89
|
-
witness.on('
|
|
90
|
+
witness.on('reportStart', ({ module }) => {
|
|
90
91
|
const witnesses = progress.witnesses ?? {}
|
|
91
92
|
witnesses[witness.address] = {
|
|
92
93
|
status: SentinelReportStatus.Started,
|
|
93
|
-
witness,
|
|
94
|
+
witness: module,
|
|
94
95
|
}
|
|
95
96
|
if (mounted()) {
|
|
96
97
|
setProgress({
|
|
@@ -114,7 +115,7 @@ export const SentinelProvider: React.FC<WithChildren<SentinelProviderProps>> = (
|
|
|
114
115
|
)
|
|
115
116
|
|
|
116
117
|
useEffect(() => {
|
|
117
|
-
setHistory(sentinel?.history as
|
|
118
|
+
setHistory(sentinel?.history as BoundWitness[])
|
|
118
119
|
}, [sentinel])
|
|
119
120
|
|
|
120
121
|
return !required || sentinel ? (
|
package/src/contexts/State.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ArchivistModule } from '@xyo-network/archivist'
|
|
2
|
-
import {
|
|
2
|
+
import { BoundWitness } from '@xyo-network/boundwitness-model'
|
|
3
3
|
import { SentinelModule } from '@xyo-network/sentinel'
|
|
4
4
|
import { WitnessModule } from '@xyo-network/witness'
|
|
5
5
|
|
|
@@ -27,7 +27,7 @@ export interface SentinelReportProgress {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
export interface SentinelContextState {
|
|
30
|
-
history?:
|
|
30
|
+
history?: BoundWitness[]
|
|
31
31
|
progress?: SentinelReportProgress
|
|
32
32
|
reportingErrors?: Error[]
|
|
33
33
|
sentinel?: SentinelModule
|