@xyo-network/diviner 2.51.9 → 2.52.0-rc.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/cjs/AbstractDiviner.js +6 -6
- package/dist/cjs/AbstractDiviner.js.map +1 -1
- package/dist/cjs/AddressChain/Config.js.map +1 -1
- package/dist/cjs/AddressChain/MemoryDiviner.js +6 -5
- package/dist/cjs/AddressChain/MemoryDiviner.js.map +1 -1
- package/dist/cjs/AddressHistory/Config.js.map +1 -1
- package/dist/cjs/AddressHistory/MemoryDiviner.js +6 -5
- package/dist/cjs/AddressHistory/MemoryDiviner.js.map +1 -1
- package/dist/cjs/AddressSpace/MemoryAddressSpaceDiviner.js +1 -1
- package/dist/cjs/AddressSpace/MemoryAddressSpaceDiviner.js.map +1 -1
- package/dist/cjs/IdentityDiviner.js +7 -5
- package/dist/cjs/IdentityDiviner.js.map +1 -1
- package/dist/cjs/Payload/AbstractPayloadDiviner.js.map +1 -1
- package/dist/cjs/Payload/Archivist/Diviner.js +1 -1
- package/dist/cjs/Payload/Archivist/Diviner.js.map +1 -1
- package/dist/cjs/Payload/Huri/Diviner.js.map +1 -1
- package/dist/docs.json +86141 -50054
- package/dist/esm/AbstractDiviner.js +10 -8
- package/dist/esm/AbstractDiviner.js.map +1 -1
- package/dist/esm/AddressChain/Config.js.map +1 -1
- package/dist/esm/AddressChain/MemoryDiviner.js +6 -5
- package/dist/esm/AddressChain/MemoryDiviner.js.map +1 -1
- package/dist/esm/AddressHistory/Config.js.map +1 -1
- package/dist/esm/AddressHistory/MemoryDiviner.js +6 -5
- package/dist/esm/AddressHistory/MemoryDiviner.js.map +1 -1
- package/dist/esm/AddressSpace/MemoryAddressSpaceDiviner.js +1 -1
- package/dist/esm/AddressSpace/MemoryAddressSpaceDiviner.js.map +1 -1
- package/dist/esm/IdentityDiviner.js +8 -4
- package/dist/esm/IdentityDiviner.js.map +1 -1
- package/dist/esm/Payload/AbstractPayloadDiviner.js.map +1 -1
- package/dist/esm/Payload/Archivist/Diviner.js +1 -1
- package/dist/esm/Payload/Archivist/Diviner.js.map +1 -1
- package/dist/esm/Payload/Huri/Diviner.js.map +1 -1
- package/dist/types/AbstractDiviner.d.ts +26 -7
- package/dist/types/AbstractDiviner.d.ts.map +1 -1
- package/dist/types/AddressChain/Config.d.ts +3 -4
- package/dist/types/AddressChain/Config.d.ts.map +1 -1
- package/dist/types/AddressChain/MemoryDiviner.d.ts +7 -4
- package/dist/types/AddressChain/MemoryDiviner.d.ts.map +1 -1
- package/dist/types/AddressHistory/Config.d.ts +2 -3
- package/dist/types/AddressHistory/Config.d.ts.map +1 -1
- package/dist/types/AddressHistory/MemoryDiviner.d.ts +8 -5
- package/dist/types/AddressHistory/MemoryDiviner.d.ts.map +1 -1
- package/dist/types/AddressSpace/MemoryAddressSpaceDiviner.d.ts +8 -8
- package/dist/types/AddressSpace/MemoryAddressSpaceDiviner.d.ts.map +1 -1
- package/dist/types/IdentityDiviner.d.ts +28 -5
- package/dist/types/IdentityDiviner.d.ts.map +1 -1
- package/dist/types/Payload/AbstractPayloadDiviner.d.ts +2 -1
- package/dist/types/Payload/AbstractPayloadDiviner.d.ts.map +1 -1
- package/dist/types/Payload/Archivist/Config.d.ts +1 -1
- package/dist/types/Payload/Archivist/Config.d.ts.map +1 -1
- package/dist/types/Payload/Archivist/Diviner.d.ts +5 -4
- package/dist/types/Payload/Archivist/Diviner.d.ts.map +1 -1
- package/dist/types/Payload/Huri/Config.d.ts +1 -1
- package/dist/types/Payload/Huri/Config.d.ts.map +1 -1
- package/dist/types/Payload/Huri/Diviner.d.ts +5 -4
- package/dist/types/Payload/Huri/Diviner.d.ts.map +1 -1
- package/package.json +17 -17
- package/src/AbstractDiviner.ts +7 -16
- package/src/AddressChain/Config.ts +6 -10
- package/src/AddressChain/MemoryDiviner.ts +21 -8
- package/src/AddressHistory/Config.ts +4 -8
- package/src/AddressHistory/MemoryDiviner.ts +22 -9
- package/src/AddressSpace/MemoryAddressSpaceDiviner.ts +21 -15
- package/src/IdentityDiviner.ts +10 -6
- package/src/Payload/AbstractPayloadDiviner.ts +3 -1
- package/src/Payload/Archivist/Config.ts +0 -1
- package/src/Payload/Archivist/Diviner.ts +10 -6
- package/src/Payload/Huri/Config.ts +0 -1
- package/src/Payload/Huri/Diviner.ts +8 -5
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DivinerParams } from '@xyo-network/diviner-model';
|
|
2
|
+
import { AnyConfigSchema } from '@xyo-network/module';
|
|
2
3
|
import { XyoPayload } from '@xyo-network/payload-model';
|
|
3
|
-
import { DivinerParams } from '../../AbstractDiviner';
|
|
4
4
|
import { AbstractPayloadDiviner } from '../AbstractPayloadDiviner';
|
|
5
5
|
import { XyoHuriPayloadDivinerConfig, XyoHuriPayloadDivinerConfigSchema } from './Config';
|
|
6
|
-
export
|
|
6
|
+
export type HuriPayloadDivinerParams<TConfig extends AnyConfigSchema<XyoHuriPayloadDivinerConfig> = AnyConfigSchema<XyoHuriPayloadDivinerConfig>> = DivinerParams<TConfig>;
|
|
7
|
+
export declare class HuriPayloadDiviner<TParams extends HuriPayloadDivinerParams = HuriPayloadDivinerParams> extends AbstractPayloadDiviner<TParams> {
|
|
7
8
|
static configSchema: XyoHuriPayloadDivinerConfigSchema;
|
|
8
9
|
protected get options(): import("@xyo-network/huri").HuriOptions | undefined;
|
|
9
|
-
static create(params?:
|
|
10
|
+
static create<TParams extends HuriPayloadDivinerParams>(params?: HuriPayloadDivinerParams): Promise<HuriPayloadDiviner<TParams>>;
|
|
10
11
|
divine(payloads?: XyoPayload[]): Promise<XyoPayload[]>;
|
|
11
12
|
}
|
|
12
13
|
//# sourceMappingURL=Diviner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Diviner.d.ts","sourceRoot":"","sources":["../../../../src/Payload/Huri/Diviner.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Diviner.d.ts","sourceRoot":"","sources":["../../../../src/Payload/Huri/Diviner.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAE1D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AAGvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAA;AAElE,OAAO,EAAE,2BAA2B,EAAE,iCAAiC,EAAE,MAAM,UAAU,CAAA;AAEzF,MAAM,MAAM,wBAAwB,CAAC,OAAO,SAAS,eAAe,CAAC,2BAA2B,CAAC,GAAG,eAAe,CAAC,2BAA2B,CAAC,IAC9I,aAAa,CAAC,OAAO,CAAC,CAAA;AAExB,qBAAa,kBAAkB,CAAC,OAAO,SAAS,wBAAwB,GAAG,wBAAwB,CAAE,SAAQ,sBAAsB,CAAC,OAAO,CAAC;IAC1I,OAAgB,YAAY,EAAE,iCAAiC,CAAA;IAE/D,SAAS,KAAK,OAAO,wDAEpB;WAEqB,MAAM,CAAC,OAAO,SAAS,wBAAwB,EAAE,MAAM,CAAC,EAAE,wBAAwB;IAIzF,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;CAYtE"}
|
package/package.json
CHANGED
|
@@ -12,22 +12,21 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@xylabs/assert": "^2.7.4",
|
|
14
14
|
"@xylabs/promise": "^2.7.4",
|
|
15
|
-
"@xyo-network/account": "^2.
|
|
16
|
-
"@xyo-network/address-payload-plugin": "^2.
|
|
17
|
-
"@xyo-network/archivist": "^2.
|
|
18
|
-
"@xyo-network/archivist-wrapper": "^2.
|
|
19
|
-
"@xyo-network/boundwitness-model": "^2.
|
|
20
|
-
"@xyo-network/boundwitness-wrapper": "^2.
|
|
21
|
-
"@xyo-network/
|
|
22
|
-
"@xyo-network/diviner-
|
|
23
|
-
"@xyo-network/
|
|
24
|
-
"@xyo-network/
|
|
25
|
-
"@xyo-network/module": "^2.
|
|
26
|
-
"@xyo-network/
|
|
27
|
-
"@xyo-network/payload-
|
|
28
|
-
"@xyo-network/payload-
|
|
29
|
-
"@xyo-network/
|
|
30
|
-
"@xyo-network/promise": "^2.51.9",
|
|
15
|
+
"@xyo-network/account": "^2.52.0-rc.2",
|
|
16
|
+
"@xyo-network/address-payload-plugin": "^2.52.0-rc.2",
|
|
17
|
+
"@xyo-network/archivist": "^2.52.0-rc.2",
|
|
18
|
+
"@xyo-network/archivist-wrapper": "^2.52.0-rc.2",
|
|
19
|
+
"@xyo-network/boundwitness-model": "^2.52.0-rc.2",
|
|
20
|
+
"@xyo-network/boundwitness-wrapper": "^2.52.0-rc.2",
|
|
21
|
+
"@xyo-network/diviner-model": "^2.52.0-rc.2",
|
|
22
|
+
"@xyo-network/diviner-wrapper": "^2.52.0-rc.2",
|
|
23
|
+
"@xyo-network/huri": "^2.52.0-rc.2",
|
|
24
|
+
"@xyo-network/module": "^2.52.0-rc.2",
|
|
25
|
+
"@xyo-network/module-model": "^2.52.0-rc.2",
|
|
26
|
+
"@xyo-network/payload-builder": "^2.52.0-rc.2",
|
|
27
|
+
"@xyo-network/payload-model": "^2.52.0-rc.2",
|
|
28
|
+
"@xyo-network/payload-wrapper": "^2.52.0-rc.2",
|
|
29
|
+
"@xyo-network/promise": "^2.52.0-rc.2",
|
|
31
30
|
"lodash": "^4.17.21"
|
|
32
31
|
},
|
|
33
32
|
"devDependencies": {
|
|
@@ -69,5 +68,6 @@
|
|
|
69
68
|
},
|
|
70
69
|
"sideEffects": false,
|
|
71
70
|
"types": "dist/types/index.d.ts",
|
|
72
|
-
"version": "2.
|
|
71
|
+
"version": "2.52.0-rc.2",
|
|
72
|
+
"stableVersion": "2.51.9"
|
|
73
73
|
}
|
package/src/AbstractDiviner.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { assertEx } from '@xylabs/assert'
|
|
2
2
|
import { Account } from '@xyo-network/account'
|
|
3
|
-
import {
|
|
4
|
-
import { DivinerConfig, DivinerModule, XyoDivinerDivineQuerySchema, XyoDivinerQuery } from '@xyo-network/diviner-model'
|
|
3
|
+
import { DivinerModule, DivinerParams, XyoDivinerConfigSchema, XyoDivinerDivineQuerySchema, XyoDivinerQuery } from '@xyo-network/diviner-model'
|
|
5
4
|
import {
|
|
6
5
|
AbstractModule,
|
|
6
|
+
creatableModule,
|
|
7
7
|
ModuleConfig,
|
|
8
|
-
ModuleParams,
|
|
9
8
|
ModuleQueryResult,
|
|
10
9
|
QueryBoundWitnessWrapper,
|
|
11
10
|
XyoErrorBuilder,
|
|
@@ -15,28 +14,20 @@ import { XyoPayload } from '@xyo-network/payload-model'
|
|
|
15
14
|
import { PayloadWrapper } from '@xyo-network/payload-wrapper'
|
|
16
15
|
import { Promisable } from '@xyo-network/promise'
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
TConfig,
|
|
20
|
-
TAdditional
|
|
21
|
-
>
|
|
22
|
-
|
|
17
|
+
@creatableModule()
|
|
23
18
|
export abstract class AbstractDiviner<TParams extends DivinerParams = DivinerParams>
|
|
24
19
|
extends AbstractModule<TParams>
|
|
25
|
-
implements DivinerModule<TParams
|
|
20
|
+
implements DivinerModule<TParams>
|
|
26
21
|
{
|
|
27
|
-
static override configSchema: string
|
|
22
|
+
static override configSchema: string = XyoDivinerConfigSchema
|
|
28
23
|
static targetSchema: string
|
|
29
24
|
|
|
30
25
|
override get queries(): string[] {
|
|
31
26
|
return [XyoDivinerDivineQuerySchema, ...super.queries]
|
|
32
27
|
}
|
|
33
28
|
|
|
34
|
-
|
|
35
|
-
return
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
static override async create(params?: Partial<ModuleParams<DivinerConfig>>): Promise<AbstractDiviner> {
|
|
39
|
-
return (await super.create(params)) as AbstractDiviner
|
|
29
|
+
static override async create<TParams extends DivinerParams = DivinerParams>(params?: TParams) {
|
|
30
|
+
return (await super.create(params)) as DivinerModule
|
|
40
31
|
}
|
|
41
32
|
|
|
42
33
|
override async query<T extends XyoQueryBoundWitness = XyoQueryBoundWitness, TConfig extends ModuleConfig = ModuleConfig>(
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { XyoBoundWitness } from '@xyo-network/boundwitness-model'
|
|
2
1
|
import { DivinerConfig } from '@xyo-network/diviner-model'
|
|
3
2
|
|
|
4
3
|
import { AddressChainSchema } from './Diviner'
|
|
@@ -6,12 +5,9 @@ import { AddressChainSchema } from './Diviner'
|
|
|
6
5
|
export type AddressChainDivinerConfigSchema = `${AddressChainSchema}.config`
|
|
7
6
|
export const AddressChainDivinerConfigSchema: AddressChainDivinerConfigSchema = `${AddressChainSchema}.config`
|
|
8
7
|
|
|
9
|
-
export type AddressChainDivinerConfig = DivinerConfig<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
startHash: string
|
|
16
|
-
}
|
|
17
|
-
>
|
|
8
|
+
export type AddressChainDivinerConfig = DivinerConfig<{
|
|
9
|
+
address?: string
|
|
10
|
+
maxResults?: number
|
|
11
|
+
schema: AddressChainDivinerConfigSchema
|
|
12
|
+
startHash?: string
|
|
13
|
+
}>
|
|
@@ -3,34 +3,47 @@ import { ArchivistGetQuerySchema } from '@xyo-network/archivist'
|
|
|
3
3
|
import { ArchivistWrapper } from '@xyo-network/archivist-wrapper'
|
|
4
4
|
import { XyoBoundWitness } from '@xyo-network/boundwitness-model'
|
|
5
5
|
import { BoundWitnessWrapper } from '@xyo-network/boundwitness-wrapper'
|
|
6
|
-
import {
|
|
6
|
+
import { DivinerParams } from '@xyo-network/diviner-model'
|
|
7
|
+
import { AnyConfigSchema } from '@xyo-network/module'
|
|
7
8
|
import { XyoPayload } from '@xyo-network/payload-model'
|
|
8
9
|
|
|
9
|
-
import { AbstractDiviner
|
|
10
|
+
import { AbstractDiviner } from '../AbstractDiviner'
|
|
10
11
|
import { AddressChainDivinerConfig, AddressChainDivinerConfigSchema } from './Config'
|
|
11
12
|
import { AddressChainDiviner } from './Diviner'
|
|
12
13
|
|
|
13
14
|
// This diviner returns the most recent boundwitness signed by the address that can be found
|
|
14
15
|
// if multiple broken chains are found, all the heads are returned
|
|
15
16
|
|
|
16
|
-
export
|
|
17
|
+
export type MemoryAddressChainDivinerParams = DivinerParams<AnyConfigSchema<AddressChainDivinerConfig>>
|
|
18
|
+
|
|
19
|
+
export class MemoryAddressChainDiviner<TParams extends MemoryAddressChainDivinerParams>
|
|
20
|
+
extends AbstractDiviner<TParams>
|
|
21
|
+
implements AddressChainDiviner
|
|
22
|
+
{
|
|
17
23
|
static override configSchema = AddressChainDivinerConfigSchema
|
|
18
24
|
|
|
19
|
-
|
|
20
|
-
return (
|
|
25
|
+
get queryAddress() {
|
|
26
|
+
return assertEx(this.config.address, 'Missing address')
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static override async create<TParams extends MemoryAddressChainDivinerParams>(params?: TParams) {
|
|
30
|
+
return (await super.create(params)) as MemoryAddressChainDiviner<TParams>
|
|
21
31
|
}
|
|
22
32
|
|
|
23
33
|
async divine(payloads?: XyoPayload[]): Promise<XyoPayload[]> {
|
|
24
34
|
const result: XyoPayload[] = []
|
|
25
35
|
assertEx(!payloads?.length, 'MemoryAddressChainDiviner.divine does not allow payloads to be sent')
|
|
26
|
-
const archivists =
|
|
27
|
-
|
|
36
|
+
const archivists =
|
|
37
|
+
(await this.resolve({ query: [[ArchivistGetQuerySchema]] }))?.map(
|
|
38
|
+
(archivist) => new ArchivistWrapper({ account: this.account, module: archivist }),
|
|
39
|
+
) ?? []
|
|
40
|
+
let currentHash: string | null = assertEx(this.config.startHash, 'Missing startHash')
|
|
28
41
|
while (currentHash && result.length < (this.config.maxResults ?? 1000)) {
|
|
29
42
|
const bwPayload: XyoBoundWitness | undefined = await this.archivistFindHash(archivists, currentHash)
|
|
30
43
|
const bw: BoundWitnessWrapper | undefined = BoundWitnessWrapper.parse(bwPayload)
|
|
31
44
|
if (bw) {
|
|
32
45
|
result.push(bw)
|
|
33
|
-
currentHash = bw.prev(this.
|
|
46
|
+
currentHash = bw.prev(this.queryAddress)
|
|
34
47
|
}
|
|
35
48
|
}
|
|
36
49
|
return result
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { XyoBoundWitness } from '@xyo-network/boundwitness-model'
|
|
2
1
|
import { DivinerConfig } from '@xyo-network/diviner-model'
|
|
3
2
|
|
|
4
3
|
import { AddressHistorySchema } from './Diviner'
|
|
@@ -6,10 +5,7 @@ import { AddressHistorySchema } from './Diviner'
|
|
|
6
5
|
export type AddressHistoryDivinerConfigSchema = `${AddressHistorySchema}.config`
|
|
7
6
|
export const AddressHistoryDivinerConfigSchema: AddressHistoryDivinerConfigSchema = `${AddressHistorySchema}.config`
|
|
8
7
|
|
|
9
|
-
export type AddressHistoryDivinerConfig = DivinerConfig<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
schema: AddressHistoryDivinerConfigSchema
|
|
14
|
-
}
|
|
15
|
-
>
|
|
8
|
+
export type AddressHistoryDivinerConfig = DivinerConfig<{
|
|
9
|
+
address?: string
|
|
10
|
+
schema: AddressHistoryDivinerConfigSchema
|
|
11
|
+
}>
|
|
@@ -3,27 +3,40 @@ import { ArchivistGetQuerySchema } from '@xyo-network/archivist'
|
|
|
3
3
|
import { ArchivistWrapper } from '@xyo-network/archivist-wrapper'
|
|
4
4
|
import { XyoBoundWitness, XyoBoundWitnessSchema } from '@xyo-network/boundwitness-model'
|
|
5
5
|
import { BoundWitnessWrapper } from '@xyo-network/boundwitness-wrapper'
|
|
6
|
-
import {
|
|
6
|
+
import { DivinerParams } from '@xyo-network/diviner-model'
|
|
7
|
+
import { AnyConfigSchema } from '@xyo-network/module-model'
|
|
7
8
|
import { XyoPayload } from '@xyo-network/payload-model'
|
|
8
9
|
import { PayloadWrapper } from '@xyo-network/payload-wrapper'
|
|
9
10
|
|
|
10
|
-
import { AbstractDiviner
|
|
11
|
+
import { AbstractDiviner } from '../AbstractDiviner'
|
|
11
12
|
import { AddressHistoryDivinerConfig, AddressHistoryDivinerConfigSchema } from './Config'
|
|
12
13
|
import { AddressHistoryDiviner } from './Diviner'
|
|
13
14
|
|
|
14
15
|
// This diviner returns the most recent boundwitness signed by the address that can be found
|
|
15
16
|
// if multiple broken chains are found, all the heads are returned
|
|
16
17
|
|
|
17
|
-
export
|
|
18
|
-
static override configSchema = AddressHistoryDivinerConfigSchema
|
|
18
|
+
export type MemoryAddressHistoryDivinerParams = DivinerParams<AnyConfigSchema<AddressHistoryDivinerConfig>>
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
export class MemoryAddressHistoryDiviner<TParams extends MemoryAddressHistoryDivinerParams>
|
|
21
|
+
extends AbstractDiviner<TParams>
|
|
22
|
+
implements AddressHistoryDiviner
|
|
23
|
+
{
|
|
24
|
+
static override configSchema: string = AddressHistoryDivinerConfigSchema
|
|
25
|
+
|
|
26
|
+
get queryAddress() {
|
|
27
|
+
return assertEx(this.config.address, 'Missing address')
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static override async create<TParams extends MemoryAddressHistoryDivinerParams>(params?: TParams) {
|
|
31
|
+
return (await super.create(params)) as MemoryAddressHistoryDiviner<TParams>
|
|
22
32
|
}
|
|
23
33
|
|
|
24
34
|
async divine(payloads?: XyoPayload[]): Promise<XyoPayload[]> {
|
|
25
35
|
assertEx(!payloads?.length, 'MemoryAddressHistoryDiviner.divine does not allow payloads to be sent')
|
|
26
|
-
const archivists =
|
|
36
|
+
const archivists =
|
|
37
|
+
(await this.resolve({ query: [[ArchivistGetQuerySchema]] }))?.map(
|
|
38
|
+
(archivist) => new ArchivistWrapper({ account: this.account, module: archivist }),
|
|
39
|
+
) ?? []
|
|
27
40
|
assertEx(archivists.length > 0, 'Did not find any archivists')
|
|
28
41
|
const bwLists = (
|
|
29
42
|
await Promise.all(
|
|
@@ -36,7 +49,7 @@ export class MemoryAddressHistoryDiviner extends AbstractDiviner<DivinerParams<A
|
|
|
36
49
|
|
|
37
50
|
const bwRecords = this.buildWrapperRecords(bwLists)
|
|
38
51
|
|
|
39
|
-
const chains = Object.values(this.buildAddressChains(this.
|
|
52
|
+
const chains = Object.values(this.buildAddressChains(this.queryAddress, bwRecords))
|
|
40
53
|
|
|
41
54
|
//return the heads of each chain (get the last bw on each chain)
|
|
42
55
|
return chains.map((chain) => assertEx(PayloadWrapper.unwrap(chain.shift())))
|
|
@@ -66,7 +79,7 @@ export class MemoryAddressHistoryDiviner extends AbstractDiviner<DivinerParams<A
|
|
|
66
79
|
//build object with hashes as keys and wrappers as values
|
|
67
80
|
private buildWrapperRecords(lists: XyoBoundWitness[]) {
|
|
68
81
|
return lists
|
|
69
|
-
.filter((bw) => bw.addresses.includes(this.
|
|
82
|
+
.filter((bw) => bw.addresses.includes(this.queryAddress))
|
|
70
83
|
.reduce<Record<string, BoundWitnessWrapper>>((bwRecords, bw) => {
|
|
71
84
|
const wrapper = new BoundWitnessWrapper(bw)
|
|
72
85
|
bwRecords[wrapper.hash] = wrapper
|
|
@@ -3,34 +3,38 @@ import { AddressSchema } from '@xyo-network/address-payload-plugin'
|
|
|
3
3
|
import { ArchivistGetQuerySchema, ArchivistModule } from '@xyo-network/archivist'
|
|
4
4
|
import { ArchivistWrapper } from '@xyo-network/archivist-wrapper'
|
|
5
5
|
import { XyoBoundWitness, XyoBoundWitnessSchema } from '@xyo-network/boundwitness-model'
|
|
6
|
-
import { DivinerConfig } from '@xyo-network/diviner-model'
|
|
7
|
-
import {
|
|
6
|
+
import { DivinerConfig, DivinerParams } from '@xyo-network/diviner-model'
|
|
7
|
+
import { AnyConfigSchema } from '@xyo-network/module'
|
|
8
8
|
import { XyoPayloadBuilder } from '@xyo-network/payload-builder'
|
|
9
9
|
import { XyoPayload } from '@xyo-network/payload-model'
|
|
10
10
|
|
|
11
|
-
import { AbstractDiviner
|
|
11
|
+
import { AbstractDiviner } from '../AbstractDiviner'
|
|
12
12
|
import { AddressSpaceDiviner, AddressSpaceSchema } from './AddressSpaceDiviner'
|
|
13
13
|
|
|
14
14
|
export type MemoryAddressSpaceDivinerConfigSchema = `${AddressSpaceSchema}.memory.config`
|
|
15
15
|
export const MemoryAddressSpaceDivinerConfigSchema: MemoryAddressSpaceDivinerConfigSchema = `${AddressSpaceSchema}.memory.config`
|
|
16
16
|
|
|
17
|
-
export type MemoryAddressSpaceDivinerConfig = DivinerConfig<
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
>
|
|
17
|
+
export type MemoryAddressSpaceDivinerConfig = DivinerConfig<{
|
|
18
|
+
address?: string
|
|
19
|
+
archivists?: string[]
|
|
20
|
+
schema: MemoryAddressSpaceDivinerConfigSchema
|
|
21
|
+
}>
|
|
22
|
+
|
|
23
|
+
export type MemoryAddressSpaceDivinerParams<
|
|
24
|
+
TConfig extends AnyConfigSchema<MemoryAddressSpaceDivinerConfig> = AnyConfigSchema<MemoryAddressSpaceDivinerConfig>,
|
|
25
|
+
> = DivinerParams<TConfig>
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
28
|
* This Diviner returns the list of all addresses encountered for the reachable archivists
|
|
28
29
|
*/
|
|
29
|
-
export class MemoryAddressSpaceDiviner extends
|
|
30
|
+
export class MemoryAddressSpaceDiviner<TParams extends MemoryAddressSpaceDivinerParams>
|
|
31
|
+
extends AbstractDiviner<TParams>
|
|
32
|
+
implements AddressSpaceDiviner
|
|
33
|
+
{
|
|
30
34
|
static override configSchema = MemoryAddressSpaceDivinerConfigSchema
|
|
31
35
|
|
|
32
|
-
static override async create(params?:
|
|
33
|
-
return (await super.create(params)) as MemoryAddressSpaceDiviner
|
|
36
|
+
static override async create<TParams extends MemoryAddressSpaceDivinerParams>(params?: TParams) {
|
|
37
|
+
return (await super.create(params)) as MemoryAddressSpaceDiviner<TParams>
|
|
34
38
|
}
|
|
35
39
|
|
|
36
40
|
async divine(payloads?: XyoPayload[]): Promise<XyoPayload[]> {
|
|
@@ -59,7 +63,9 @@ export class MemoryAddressSpaceDiviner extends AbstractDiviner<DivinerParams<Mem
|
|
|
59
63
|
return await this.resolve<ArchivistModule>({ address: this.config.archivists })
|
|
60
64
|
} else {
|
|
61
65
|
//get all reachable archivists
|
|
62
|
-
return (await this.resolve<ArchivistModule>({ query: [[ArchivistGetQuerySchema]] })).map(
|
|
66
|
+
return (await this.resolve<ArchivistModule>({ query: [[ArchivistGetQuerySchema]] })).map(
|
|
67
|
+
(archivist) => new ArchivistWrapper({ account: this.account, module: archivist }),
|
|
68
|
+
)
|
|
63
69
|
}
|
|
64
70
|
}
|
|
65
71
|
}
|
package/src/IdentityDiviner.ts
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ArchivistParams } from '@xyo-network/archivist'
|
|
2
|
+
import { DivinerConfig, DivinerModule } from '@xyo-network/diviner-model'
|
|
3
|
+
import { creatableModule } from '@xyo-network/module'
|
|
4
|
+
import { AnyConfigSchema } from '@xyo-network/module-model'
|
|
3
5
|
import { XyoPayloads } from '@xyo-network/payload-model'
|
|
4
6
|
import { Promisable } from '@xyo-network/promise'
|
|
5
7
|
|
|
6
8
|
import { AbstractDiviner } from './AbstractDiviner'
|
|
7
9
|
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
+
export type IdentityDivinerParams<TConfig extends AnyConfigSchema<DivinerConfig> = AnyConfigSchema<DivinerConfig>> = ArchivistParams<TConfig>
|
|
11
|
+
|
|
12
|
+
@creatableModule()
|
|
13
|
+
export class IdentityDiviner<TParams extends IdentityDivinerParams> extends AbstractDiviner<TParams> {
|
|
10
14
|
static override targetSchema = 'network.xyo.test'
|
|
11
15
|
|
|
12
|
-
static override async create(params?:
|
|
13
|
-
return (await super.create(params)) as
|
|
16
|
+
static override async create<TParams extends IdentityDivinerParams>(params?: TParams) {
|
|
17
|
+
return (await super.create(params)) as DivinerModule
|
|
14
18
|
}
|
|
15
19
|
|
|
16
20
|
override divine(payloads: XyoPayloads): Promisable<XyoPayloads> {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DivinerParams } from '@xyo-network/diviner-model'
|
|
2
|
+
|
|
3
|
+
import { AbstractDiviner } from '../AbstractDiviner'
|
|
2
4
|
|
|
3
5
|
export abstract class AbstractPayloadDiviner<P extends DivinerParams = DivinerParams> extends AbstractDiviner<P> {}
|
|
@@ -5,7 +5,6 @@ export type XyoArchivistPayloadDivinerConfigSchema = 'network.xyo.diviner.payloa
|
|
|
5
5
|
export const XyoArchivistPayloadDivinerConfigSchema: XyoArchivistPayloadDivinerConfigSchema = 'network.xyo.diviner.payload.archivist.config'
|
|
6
6
|
|
|
7
7
|
export type XyoArchivistPayloadDivinerConfig<T extends XyoPayload = XyoPayload> = DivinerConfig<
|
|
8
|
-
XyoPayload,
|
|
9
8
|
T & {
|
|
10
9
|
archivist?: string
|
|
11
10
|
schema: XyoArchivistPayloadDivinerConfigSchema
|
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
import { assertEx } from '@xylabs/assert'
|
|
2
2
|
import { ArchivistGetQuery, ArchivistGetQuerySchema, ArchivistModule } from '@xyo-network/archivist'
|
|
3
3
|
import { ArchivistWrapper } from '@xyo-network/archivist-wrapper'
|
|
4
|
+
import { DivinerParams } from '@xyo-network/diviner-model'
|
|
4
5
|
import { Huri } from '@xyo-network/huri'
|
|
5
|
-
import {
|
|
6
|
+
import { AnyConfigSchema } from '@xyo-network/module-model'
|
|
6
7
|
import { XyoPayload } from '@xyo-network/payload-model'
|
|
7
8
|
import { PayloadWrapper } from '@xyo-network/payload-wrapper'
|
|
8
9
|
|
|
9
|
-
import { DivinerParams } from '../../AbstractDiviner'
|
|
10
10
|
import { AbstractPayloadDiviner } from '../AbstractPayloadDiviner'
|
|
11
11
|
import { XyoHuriPayload, XyoHuriSchema } from '../XyoHuriPayload'
|
|
12
12
|
import { XyoArchivistPayloadDivinerConfig, XyoArchivistPayloadDivinerConfigSchema } from './Config'
|
|
13
13
|
|
|
14
|
-
export
|
|
14
|
+
export type ArchivistPayloadDivinerParams<
|
|
15
|
+
TConfig extends AnyConfigSchema<XyoArchivistPayloadDivinerConfig> = AnyConfigSchema<XyoArchivistPayloadDivinerConfig>,
|
|
16
|
+
> = DivinerParams<TConfig>
|
|
17
|
+
|
|
18
|
+
export class ArchivistPayloadDiviner<TParams extends ArchivistPayloadDivinerParams> extends AbstractPayloadDiviner<TParams> {
|
|
15
19
|
static override configSchema: XyoArchivistPayloadDivinerConfigSchema
|
|
16
20
|
|
|
17
|
-
static override async create(params?:
|
|
18
|
-
return (await super.create(params)) as ArchivistPayloadDiviner
|
|
21
|
+
static override async create<TParams extends ArchivistPayloadDivinerParams>(params?: TParams) {
|
|
22
|
+
return (await super.create(params)) as ArchivistPayloadDiviner<TParams>
|
|
19
23
|
}
|
|
20
24
|
|
|
21
25
|
async divine(payloads?: XyoPayload[]): Promise<XyoPayload[]> {
|
|
@@ -40,7 +44,7 @@ export class ArchivistPayloadDiviner extends AbstractPayloadDiviner<DivinerParam
|
|
|
40
44
|
? ((await this.resolve({ address: [configArchivistAddress] })) as unknown as ArchivistModule[]).shift() ?? null
|
|
41
45
|
: null
|
|
42
46
|
if (resolvedArchivist) {
|
|
43
|
-
return resolvedArchivist ? new ArchivistWrapper(resolvedArchivist) : null
|
|
47
|
+
return resolvedArchivist ? new ArchivistWrapper({ account: this.account, module: resolvedArchivist }) : null
|
|
44
48
|
}
|
|
45
49
|
}
|
|
46
50
|
return null
|
|
@@ -6,7 +6,6 @@ export type XyoHuriPayloadDivinerConfigSchema = 'network.xyo.diviner.payload.hur
|
|
|
6
6
|
export const XyoHuriPayloadDivinerConfigSchema: XyoHuriPayloadDivinerConfigSchema = 'network.xyo.diviner.payload.huri.config'
|
|
7
7
|
|
|
8
8
|
export type XyoHuriPayloadDivinerConfig<T extends XyoPayload = XyoPayload> = DivinerConfig<
|
|
9
|
-
XyoPayload,
|
|
10
9
|
T & {
|
|
11
10
|
options?: HuriOptions
|
|
12
11
|
schema: XyoHuriPayloadDivinerConfigSchema
|
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
import { assertEx } from '@xylabs/assert'
|
|
2
2
|
import { fulfilled } from '@xylabs/promise'
|
|
3
|
+
import { DivinerParams } from '@xyo-network/diviner-model'
|
|
3
4
|
import { Huri } from '@xyo-network/huri'
|
|
4
|
-
import {
|
|
5
|
+
import { AnyConfigSchema } from '@xyo-network/module'
|
|
5
6
|
import { XyoPayload } from '@xyo-network/payload-model'
|
|
6
7
|
import compact from 'lodash/compact'
|
|
7
8
|
|
|
8
|
-
import { DivinerParams } from '../../AbstractDiviner'
|
|
9
9
|
import { AbstractPayloadDiviner } from '../AbstractPayloadDiviner'
|
|
10
10
|
import { XyoHuriPayload, XyoHuriSchema } from '../XyoHuriPayload'
|
|
11
11
|
import { XyoHuriPayloadDivinerConfig, XyoHuriPayloadDivinerConfigSchema } from './Config'
|
|
12
12
|
|
|
13
|
-
export
|
|
13
|
+
export type HuriPayloadDivinerParams<TConfig extends AnyConfigSchema<XyoHuriPayloadDivinerConfig> = AnyConfigSchema<XyoHuriPayloadDivinerConfig>> =
|
|
14
|
+
DivinerParams<TConfig>
|
|
15
|
+
|
|
16
|
+
export class HuriPayloadDiviner<TParams extends HuriPayloadDivinerParams = HuriPayloadDivinerParams> extends AbstractPayloadDiviner<TParams> {
|
|
14
17
|
static override configSchema: XyoHuriPayloadDivinerConfigSchema
|
|
15
18
|
|
|
16
19
|
protected get options() {
|
|
17
20
|
return this.config?.options
|
|
18
21
|
}
|
|
19
22
|
|
|
20
|
-
static override async create(params?:
|
|
21
|
-
return (await super.create(params)) as HuriPayloadDiviner
|
|
23
|
+
static override async create<TParams extends HuriPayloadDivinerParams>(params?: HuriPayloadDivinerParams) {
|
|
24
|
+
return (await super.create(params)) as HuriPayloadDiviner<TParams>
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
override async divine(payloads?: XyoPayload[]): Promise<XyoPayload[]> {
|