@xyo-network/diviner-address-chain-memory 5.2.5 → 5.2.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.
|
@@ -2,7 +2,7 @@ import { AddressChainDiviner } from '@xyo-network/diviner-address-chain-abstract
|
|
|
2
2
|
import type { AddressChainDivinerConfig } from '@xyo-network/diviner-address-chain-model';
|
|
3
3
|
import type { DivinerParams } from '@xyo-network/diviner-model';
|
|
4
4
|
import type { AnyConfigSchema } from '@xyo-network/module-model';
|
|
5
|
-
import type
|
|
5
|
+
import { type Payload, type Schema } from '@xyo-network/payload-model';
|
|
6
6
|
export type MemoryAddressChainDivinerParams = DivinerParams<AnyConfigSchema<AddressChainDivinerConfig>>;
|
|
7
7
|
export declare class MemoryAddressChainDiviner<TParams extends MemoryAddressChainDivinerParams = MemoryAddressChainDivinerParams> extends AddressChainDiviner<TParams> {
|
|
8
8
|
static readonly configSchemas: Schema[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemoryDiviner.d.ts","sourceRoot":"","sources":["../../src/MemoryDiviner.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MemoryDiviner.d.ts","sourceRoot":"","sources":["../../src/MemoryDiviner.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAA;AACjF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,0CAA0C,CAAA;AAEzF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EACU,KAAK,OAAO,EAAE,KAAK,MAAM,EACzC,MAAM,4BAA4B,CAAA;AAInC,MAAM,MAAM,+BAA+B,GAAG,aAAa,CAAC,eAAe,CAAC,yBAAyB,CAAC,CAAC,CAAA;AAEvG,qBAAa,yBAAyB,CACpC,OAAO,SAAS,+BAA+B,GAAG,+BAA+B,CACjF,SAAQ,mBAAmB,CAAC,OAAO,CAAC;IACpC,gBAAyB,aAAa,EAAE,MAAM,EAAE,CAA4D;IAC5G,gBAAyB,mBAAmB,EAAE,MAAM,CAAkC;IAEtF,IAAI,YAAY,kCAEf;cAEwB,aAAa,CAAC,QAAQ,GAAE,OAAO,EAAO,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;YA0BtE,iBAAiB;CAWhC"}
|
package/dist/neutral/index.mjs
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
// src/MemoryDiviner.ts
|
|
2
2
|
import { assertEx } from "@xylabs/assert";
|
|
3
|
-
import {
|
|
3
|
+
import { isBoundWitness } from "@xyo-network/boundwitness-model";
|
|
4
4
|
import { BoundWitnessWrapper } from "@xyo-network/boundwitness-wrapper";
|
|
5
5
|
import { AddressChainDiviner } from "@xyo-network/diviner-address-chain-abstract";
|
|
6
6
|
import { AddressChainDivinerConfigSchema } from "@xyo-network/diviner-address-chain-model";
|
|
7
|
+
import {
|
|
8
|
+
isStorageMeta
|
|
9
|
+
} from "@xyo-network/payload-model";
|
|
7
10
|
var MemoryAddressChainDiviner = class extends AddressChainDiviner {
|
|
8
11
|
static configSchemas = [...super.configSchemas, AddressChainDivinerConfigSchema];
|
|
9
12
|
static defaultConfigSchema = AddressChainDivinerConfigSchema;
|
|
@@ -36,7 +39,7 @@ var MemoryAddressChainDiviner = class extends AddressChainDiviner {
|
|
|
36
39
|
async archivistFindHash(archivists, hash) {
|
|
37
40
|
let index = 0;
|
|
38
41
|
if (archivists[index]) {
|
|
39
|
-
const result = (await archivists[index].get([hash])).findLast(
|
|
42
|
+
const result = (await archivists[index].get([hash])).findLast((x) => isBoundWitness(x) && isStorageMeta(x));
|
|
40
43
|
if (result) {
|
|
41
44
|
return result;
|
|
42
45
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/MemoryDiviner.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport type { Hash } from '@xylabs/hex'\nimport type { ArchivistInstance } from '@xyo-network/archivist-model'\nimport type
|
|
1
|
+
{"version":3,"sources":["../../src/MemoryDiviner.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport type { Hash } from '@xylabs/hex'\nimport type { ArchivistInstance } from '@xyo-network/archivist-model'\nimport { type BoundWitness, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessWrapper } from '@xyo-network/boundwitness-wrapper'\nimport { AddressChainDiviner } from '@xyo-network/diviner-address-chain-abstract'\nimport type { AddressChainDivinerConfig } from '@xyo-network/diviner-address-chain-model'\nimport { AddressChainDivinerConfigSchema } from '@xyo-network/diviner-address-chain-model'\nimport type { DivinerParams } from '@xyo-network/diviner-model'\nimport type { AnyConfigSchema } from '@xyo-network/module-model'\nimport {\n isStorageMeta, type Payload, type Schema,\n} from '@xyo-network/payload-model'\n\n// This diviner returns the most recent boundwitness signed by the address that can be found\n// if multiple broken chains are found, all the heads are returned\nexport type MemoryAddressChainDivinerParams = DivinerParams<AnyConfigSchema<AddressChainDivinerConfig>>\n\nexport class MemoryAddressChainDiviner<\n TParams extends MemoryAddressChainDivinerParams = MemoryAddressChainDivinerParams,\n> extends AddressChainDiviner<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, AddressChainDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = AddressChainDivinerConfigSchema\n\n get queryAddress() {\n return assertEx(this.config.address, () => 'Missing address')\n }\n\n protected override async divineHandler(payloads: Payload[] = []): Promise<Payload[]> {\n const result: Payload[] = []\n assertEx(payloads.length === 0, () => 'MemoryAddressChainDiviner.divine does not allow payloads to be sent')\n try {\n const archivistIn = await this.archivistInstance()\n const archivist = assertEx(archivistIn, () => 'Unable to resolve archivist')\n let currentHash: Hash | null = assertEx(this.config.startHash, () => 'Missing startHash')\n while (currentHash && result.length < (this.config.maxResults ?? 1000)) {\n // console.log(`currentHash: ${currentHash}`)\n const bwPayload: BoundWitness | undefined = await this.archivistFindHash([archivist], currentHash)\n const bwWrapper: BoundWitnessWrapper | undefined = BoundWitnessWrapper.tryParse(bwPayload)\n if (bwWrapper) {\n result.push(bwWrapper.payload)\n currentHash = bwWrapper.prev(this.queryAddress)\n } else {\n // was not a bound witness - bail\n console.log(`Hash is not a BoundWitness [${currentHash}]`)\n currentHash = null\n }\n }\n } catch (ex) {\n console.log(ex)\n }\n return result\n }\n\n private async archivistFindHash(archivists: ArchivistInstance[], hash: Hash): Promise<BoundWitness | undefined> {\n // console.log('archivistFindHash')\n let index = 0\n if (archivists[index]) {\n const result = (await archivists[index].get([hash])).findLast(x => isBoundWitness(x) && isStorageMeta(x)) as BoundWitness | undefined\n if (result) {\n return result\n }\n index++\n }\n }\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AAGzB,SAA4B,sBAAsB;AAClD,SAAS,2BAA2B;AACpC,SAAS,2BAA2B;AAEpC,SAAS,uCAAuC;AAGhD;AAAA,EACE;AAAA,OACK;AAMA,IAAM,4BAAN,cAEG,oBAA6B;AAAA,EACrC,OAAyB,gBAA0B,CAAC,GAAG,MAAM,eAAe,+BAA+B;AAAA,EAC3G,OAAyB,sBAA8B;AAAA,EAEvD,IAAI,eAAe;AACjB,WAAO,SAAS,KAAK,OAAO,SAAS,MAAM,iBAAiB;AAAA,EAC9D;AAAA,EAEA,MAAyB,cAAc,WAAsB,CAAC,GAAuB;AACnF,UAAM,SAAoB,CAAC;AAC3B,aAAS,SAAS,WAAW,GAAG,MAAM,qEAAqE;AAC3G,QAAI;AACF,YAAM,cAAc,MAAM,KAAK,kBAAkB;AACjD,YAAM,YAAY,SAAS,aAAa,MAAM,6BAA6B;AAC3E,UAAI,cAA2B,SAAS,KAAK,OAAO,WAAW,MAAM,mBAAmB;AACxF,aAAO,eAAe,OAAO,UAAU,KAAK,OAAO,cAAc,MAAO;AAEtE,cAAM,YAAsC,MAAM,KAAK,kBAAkB,CAAC,SAAS,GAAG,WAAW;AACjG,cAAM,YAA6C,oBAAoB,SAAS,SAAS;AACzF,YAAI,WAAW;AACb,iBAAO,KAAK,UAAU,OAAO;AAC7B,wBAAc,UAAU,KAAK,KAAK,YAAY;AAAA,QAChD,OAAO;AAEL,kBAAQ,IAAI,+BAA+B,WAAW,GAAG;AACzD,wBAAc;AAAA,QAChB;AAAA,MACF;AAAA,IACF,SAAS,IAAI;AACX,cAAQ,IAAI,EAAE;AAAA,IAChB;AACA,WAAO;AAAA,EACT;AAAA,EAEA,MAAc,kBAAkB,YAAiC,MAA+C;AAE9G,QAAI,QAAQ;AACZ,QAAI,WAAW,KAAK,GAAG;AACrB,YAAM,UAAU,MAAM,WAAW,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,SAAS,OAAK,eAAe,CAAC,KAAK,cAAc,CAAC,CAAC;AACxG,UAAI,QAAQ;AACV,eAAO;AAAA,MACT;AACA;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/diviner-address-chain-memory",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.7",
|
|
4
4
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -36,32 +36,32 @@
|
|
|
36
36
|
"!**/*.test.*"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@xylabs/assert": "~5.0.
|
|
40
|
-
"@xyo-network/boundwitness-model": "~5.2.
|
|
41
|
-
"@xyo-network/boundwitness-wrapper": "~5.2.
|
|
42
|
-
"@xyo-network/diviner-address-chain-abstract": "~5.2.
|
|
43
|
-
"@xyo-network/diviner-address-chain-model": "~5.2.
|
|
44
|
-
"@xyo-network/diviner-model": "~5.2.
|
|
45
|
-
"@xyo-network/module-model": "~5.2.
|
|
46
|
-
"@xyo-network/payload-model": "~5.2.
|
|
39
|
+
"@xylabs/assert": "~5.0.42",
|
|
40
|
+
"@xyo-network/boundwitness-model": "~5.2.7",
|
|
41
|
+
"@xyo-network/boundwitness-wrapper": "~5.2.7",
|
|
42
|
+
"@xyo-network/diviner-address-chain-abstract": "~5.2.7",
|
|
43
|
+
"@xyo-network/diviner-address-chain-model": "~5.2.7",
|
|
44
|
+
"@xyo-network/diviner-model": "~5.2.7",
|
|
45
|
+
"@xyo-network/module-model": "~5.2.7",
|
|
46
|
+
"@xyo-network/payload-model": "~5.2.7"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@xylabs/array": "~5.0.
|
|
50
|
-
"@xylabs/delay": "~5.0.
|
|
51
|
-
"@xylabs/hex": "~5.0.
|
|
49
|
+
"@xylabs/array": "~5.0.42",
|
|
50
|
+
"@xylabs/delay": "~5.0.42",
|
|
51
|
+
"@xylabs/hex": "~5.0.42",
|
|
52
52
|
"@xylabs/ts-scripts-yarn3": "~7.2.8",
|
|
53
53
|
"@xylabs/tsconfig": "~7.2.8",
|
|
54
|
-
"@xylabs/vitest-extended": "~5.0.
|
|
55
|
-
"@xyo-network/account": "~5.2.
|
|
56
|
-
"@xyo-network/archivist-memory": "~5.2.
|
|
57
|
-
"@xyo-network/archivist-model": "~5.2.
|
|
58
|
-
"@xyo-network/archivist-wrapper": "~5.2.
|
|
59
|
-
"@xyo-network/node-memory": "~5.2.
|
|
60
|
-
"@xyo-network/node-model": "~5.2.
|
|
61
|
-
"@xyo-network/payload-builder": "~5.2.
|
|
62
|
-
"@xyo-network/payload-wrapper": "~5.2.
|
|
54
|
+
"@xylabs/vitest-extended": "~5.0.42",
|
|
55
|
+
"@xyo-network/account": "~5.2.7",
|
|
56
|
+
"@xyo-network/archivist-memory": "~5.2.7",
|
|
57
|
+
"@xyo-network/archivist-model": "~5.2.7",
|
|
58
|
+
"@xyo-network/archivist-wrapper": "~5.2.7",
|
|
59
|
+
"@xyo-network/node-memory": "~5.2.7",
|
|
60
|
+
"@xyo-network/node-model": "~5.2.7",
|
|
61
|
+
"@xyo-network/payload-builder": "~5.2.7",
|
|
62
|
+
"@xyo-network/payload-wrapper": "~5.2.7",
|
|
63
63
|
"typescript": "~5.9.3",
|
|
64
|
-
"vitest": "~4.0.
|
|
64
|
+
"vitest": "~4.0.12"
|
|
65
65
|
},
|
|
66
66
|
"publishConfig": {
|
|
67
67
|
"access": "public"
|
package/src/MemoryDiviner.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { assertEx } from '@xylabs/assert'
|
|
2
2
|
import type { Hash } from '@xylabs/hex'
|
|
3
3
|
import type { ArchivistInstance } from '@xyo-network/archivist-model'
|
|
4
|
-
import type
|
|
5
|
-
import { isBoundWitnessWithStorageMeta } from '@xyo-network/boundwitness-model'
|
|
4
|
+
import { type BoundWitness, isBoundWitness } from '@xyo-network/boundwitness-model'
|
|
6
5
|
import { BoundWitnessWrapper } from '@xyo-network/boundwitness-wrapper'
|
|
7
6
|
import { AddressChainDiviner } from '@xyo-network/diviner-address-chain-abstract'
|
|
8
7
|
import type { AddressChainDivinerConfig } from '@xyo-network/diviner-address-chain-model'
|
|
9
8
|
import { AddressChainDivinerConfigSchema } from '@xyo-network/diviner-address-chain-model'
|
|
10
9
|
import type { DivinerParams } from '@xyo-network/diviner-model'
|
|
11
10
|
import type { AnyConfigSchema } from '@xyo-network/module-model'
|
|
12
|
-
import
|
|
11
|
+
import {
|
|
12
|
+
isStorageMeta, type Payload, type Schema,
|
|
13
|
+
} from '@xyo-network/payload-model'
|
|
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
|
|
@@ -55,7 +56,7 @@ export class MemoryAddressChainDiviner<
|
|
|
55
56
|
// console.log('archivistFindHash')
|
|
56
57
|
let index = 0
|
|
57
58
|
if (archivists[index]) {
|
|
58
|
-
const result = (await archivists[index].get([hash])).findLast(
|
|
59
|
+
const result = (await archivists[index].get([hash])).findLast(x => isBoundWitness(x) && isStorageMeta(x)) as BoundWitness | undefined
|
|
59
60
|
if (result) {
|
|
60
61
|
return result
|
|
61
62
|
}
|