@xyo-network/diviner-address-chain-memory 2.91.0 → 2.91.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/MemoryDiviner.d.cts.map +1 -1
- package/dist/browser/MemoryDiviner.d.mts.map +1 -1
- package/dist/browser/MemoryDiviner.d.ts.map +1 -1
- package/dist/browser/index.cjs +1 -1
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +1 -1
- package/dist/node/MemoryDiviner.d.cts.map +1 -1
- package/dist/node/MemoryDiviner.d.mts.map +1 -1
- package/dist/node/MemoryDiviner.d.ts.map +1 -1
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.js +1 -1
- package/dist/node/index.js.map +1 -1
- package/package.json +18 -17
- package/src/MemoryDiviner.ts +4 -3
|
@@ -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,EAAE,yBAAyB,EAAmC,MAAM,0CAA0C,CAAA;AACrH,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAIpD,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,OAAgB,aAAa,+CAAoC;IAEjE,IAAI,YAAY,sBAEf;cAEwB,aAAa,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;YA0BlE,iBAAiB;CAWhC"}
|
|
@@ -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,EAAE,yBAAyB,EAAmC,MAAM,0CAA0C,CAAA;AACrH,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAIpD,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,OAAgB,aAAa,+CAAoC;IAEjE,IAAI,YAAY,sBAEf;cAEwB,aAAa,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;YA0BlE,iBAAiB;CAWhC"}
|
|
@@ -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,EAAE,yBAAyB,EAAmC,MAAM,0CAA0C,CAAA;AACrH,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAIpD,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,OAAgB,aAAa,+CAAoC;IAEjE,IAAI,YAAY,sBAEf;cAEwB,aAAa,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;YA0BlE,iBAAiB;CAWhC"}
|
package/dist/browser/index.cjs
CHANGED
|
@@ -53,7 +53,7 @@ var MemoryAddressChainDiviner = class extends import_diviner_address_chain_abstr
|
|
|
53
53
|
const bwPayload = await this.archivistFindHash([
|
|
54
54
|
archivist
|
|
55
55
|
], currentHash);
|
|
56
|
-
const bwWrapper =
|
|
56
|
+
const bwWrapper = import_boundwitness_wrapper.BoundWitnessWrapper.tryParse(bwPayload);
|
|
57
57
|
if (bwWrapper) {
|
|
58
58
|
result.push(bwWrapper.payload);
|
|
59
59
|
currentHash = bwWrapper.prev(this.queryAddress);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/MemoryDiviner.ts"],"sourcesContent":["export * from './MemoryDiviner'\n","import { assertEx } from '@xylabs/assert'\nimport { ArchivistInstance } from '@xyo-network/archivist-model'\nimport { BoundWitness, isBoundWitnessWithMeta } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessWrapper } from '@xyo-network/boundwitness-wrapper'\nimport { AddressChainDiviner } from '@xyo-network/diviner-address-chain-abstract'\nimport { AddressChainDivinerConfig, AddressChainDivinerConfigSchema } from '@xyo-network/diviner-address-chain-model'\nimport { DivinerParams } from '@xyo-network/diviner-model'\nimport { AnyConfigSchema } from '@xyo-network/module-model'\nimport { Payload } 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 configSchemas = [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, 'MemoryAddressChainDiviner.divine does not allow payloads to be sent')\n try {\n const archivistIn = await this.getArchivist()\n const archivist = assertEx(archivistIn, 'Unable to resolve archivist')\n let currentHash:
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/MemoryDiviner.ts"],"sourcesContent":["export * from './MemoryDiviner'\n","import { assertEx } from '@xylabs/assert'\nimport { Hash } from '@xylabs/hex'\nimport { ArchivistInstance } from '@xyo-network/archivist-model'\nimport { BoundWitness, isBoundWitnessWithMeta } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessWrapper } from '@xyo-network/boundwitness-wrapper'\nimport { AddressChainDiviner } from '@xyo-network/diviner-address-chain-abstract'\nimport { AddressChainDivinerConfig, AddressChainDivinerConfigSchema } from '@xyo-network/diviner-address-chain-model'\nimport { DivinerParams } from '@xyo-network/diviner-model'\nimport { AnyConfigSchema } from '@xyo-network/module-model'\nimport { Payload } 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 configSchemas = [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, 'MemoryAddressChainDiviner.divine does not allow payloads to be sent')\n try {\n const archivistIn = await this.getArchivist()\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])).filter(isBoundWitnessWithMeta).pop()\n if (result) {\n return result\n }\n index++\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;ACAA,oBAAyB;AAGzB,gCAAqD;AACrD,kCAAoC;AACpC,4CAAoC;AACpC,yCAA2E;AASpE,IAAMA,4BAAN,cAEGC,0DAAAA;EAjBV,OAiBUA;;;EACR,OAAgBC,gBAAgB;IAACC;;EAEjC,IAAIC,eAAe;AACjB,eAAOC,wBAAS,KAAKC,OAAOC,SAAS,iBAAA;EACvC;EAEA,MAAyBC,cAAcC,UAA0C;AAC/E,UAAMC,SAAoB,CAAA;AAC1BL,gCAAS,CAACI,UAAUE,QAAQ,qEAAA;AAC5B,QAAI;AACF,YAAMC,cAAc,MAAM,KAAKC,aAAY;AAC3C,YAAMC,gBAAYT,wBAASO,aAAa,6BAAA;AACxC,UAAIG,kBAA2BV,wBAAS,KAAKC,OAAOU,WAAW,mBAAA;AAC/D,aAAOD,eAAeL,OAAOC,UAAU,KAAKL,OAAOW,cAAc,MAAO;AACtEC,gBAAQC,IAAI,gBAAgBJ,WAAAA,EAAa;AACzC,cAAMK,YAAsC,MAAM,KAAKC,kBAAkB;UAACP;WAAYC,WAAAA;AACtF,cAAMO,YAA6CC,gDAAoBC,SAASJ,SAAAA;AAChF,YAAIE,WAAW;AACbZ,iBAAOe,KAAKH,UAAUI,OAAO;AAC7BX,wBAAcO,UAAUK,KAAK,KAAKvB,YAAY;QAChD,OAAO;AAELc,kBAAQC,IAAI,+BAA+BJ,WAAAA,GAAc;AACzDA,wBAAc;QAChB;MACF;IACF,SAASa,IAAI;AACXV,cAAQC,IAAIS,EAAAA;IACd;AACA,WAAOlB;EACT;EAEA,MAAcW,kBAAkBQ,YAAiCC,MAA+C;AAC9GZ,YAAQC,IAAI,mBAAA;AACZ,QAAIY,QAAQ;AACZ,QAAIF,WAAWE,KAAAA,GAAQ;AACrB,YAAMrB,UAAU,MAAMmB,WAAWE,KAAAA,EAAOC,IAAI;QAACF;OAAK,GAAGG,OAAOC,gDAAAA,EAAwBC,IAAG;AACvF,UAAIzB,QAAQ;AACV,eAAOA;MACT;AACAqB;IACF;EACF;AACF;","names":["MemoryAddressChainDiviner","AddressChainDiviner","configSchemas","AddressChainDivinerConfigSchema","queryAddress","assertEx","config","address","divineHandler","payloads","result","length","archivistIn","getArchivist","archivist","currentHash","startHash","maxResults","console","log","bwPayload","archivistFindHash","bwWrapper","BoundWitnessWrapper","tryParse","push","payload","prev","ex","archivists","hash","index","get","filter","isBoundWitnessWithMeta","pop"]}
|
package/dist/browser/index.js
CHANGED
|
@@ -29,7 +29,7 @@ var MemoryAddressChainDiviner = class extends AddressChainDiviner {
|
|
|
29
29
|
const bwPayload = await this.archivistFindHash([
|
|
30
30
|
archivist
|
|
31
31
|
], currentHash);
|
|
32
|
-
const bwWrapper =
|
|
32
|
+
const bwWrapper = BoundWitnessWrapper.tryParse(bwPayload);
|
|
33
33
|
if (bwWrapper) {
|
|
34
34
|
result.push(bwWrapper.payload);
|
|
35
35
|
currentHash = bwWrapper.prev(this.queryAddress);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/MemoryDiviner.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport { ArchivistInstance } from '@xyo-network/archivist-model'\nimport { BoundWitness, isBoundWitnessWithMeta } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessWrapper } from '@xyo-network/boundwitness-wrapper'\nimport { AddressChainDiviner } from '@xyo-network/diviner-address-chain-abstract'\nimport { AddressChainDivinerConfig, AddressChainDivinerConfigSchema } from '@xyo-network/diviner-address-chain-model'\nimport { DivinerParams } from '@xyo-network/diviner-model'\nimport { AnyConfigSchema } from '@xyo-network/module-model'\nimport { Payload } 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 configSchemas = [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, 'MemoryAddressChainDiviner.divine does not allow payloads to be sent')\n try {\n const archivistIn = await this.getArchivist()\n const archivist = assertEx(archivistIn, 'Unable to resolve archivist')\n let currentHash:
|
|
1
|
+
{"version":3,"sources":["../../src/MemoryDiviner.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport { Hash } from '@xylabs/hex'\nimport { ArchivistInstance } from '@xyo-network/archivist-model'\nimport { BoundWitness, isBoundWitnessWithMeta } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessWrapper } from '@xyo-network/boundwitness-wrapper'\nimport { AddressChainDiviner } from '@xyo-network/diviner-address-chain-abstract'\nimport { AddressChainDivinerConfig, AddressChainDivinerConfigSchema } from '@xyo-network/diviner-address-chain-model'\nimport { DivinerParams } from '@xyo-network/diviner-model'\nimport { AnyConfigSchema } from '@xyo-network/module-model'\nimport { Payload } 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 configSchemas = [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, 'MemoryAddressChainDiviner.divine does not allow payloads to be sent')\n try {\n const archivistIn = await this.getArchivist()\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])).filter(isBoundWitnessWithMeta).pop()\n if (result) {\n return result\n }\n index++\n }\n }\n}\n"],"mappings":";;;;AAAA,SAASA,gBAAgB;AAGzB,SAAuBC,8BAA8B;AACrD,SAASC,2BAA2B;AACpC,SAASC,2BAA2B;AACpC,SAAoCC,uCAAuC;AASpE,IAAMC,4BAAN,cAEGC,oBAAAA;EAjBV,OAiBUA;;;EACR,OAAgBC,gBAAgB;IAACC;;EAEjC,IAAIC,eAAe;AACjB,WAAOC,SAAS,KAAKC,OAAOC,SAAS,iBAAA;EACvC;EAEA,MAAyBC,cAAcC,UAA0C;AAC/E,UAAMC,SAAoB,CAAA;AAC1BL,aAAS,CAACI,UAAUE,QAAQ,qEAAA;AAC5B,QAAI;AACF,YAAMC,cAAc,MAAM,KAAKC,aAAY;AAC3C,YAAMC,YAAYT,SAASO,aAAa,6BAAA;AACxC,UAAIG,cAA2BV,SAAS,KAAKC,OAAOU,WAAW,mBAAA;AAC/D,aAAOD,eAAeL,OAAOC,UAAU,KAAKL,OAAOW,cAAc,MAAO;AACtEC,gBAAQC,IAAI,gBAAgBJ,WAAAA,EAAa;AACzC,cAAMK,YAAsC,MAAM,KAAKC,kBAAkB;UAACP;WAAYC,WAAAA;AACtF,cAAMO,YAA6CC,oBAAoBC,SAASJ,SAAAA;AAChF,YAAIE,WAAW;AACbZ,iBAAOe,KAAKH,UAAUI,OAAO;AAC7BX,wBAAcO,UAAUK,KAAK,KAAKvB,YAAY;QAChD,OAAO;AAELc,kBAAQC,IAAI,+BAA+BJ,WAAAA,GAAc;AACzDA,wBAAc;QAChB;MACF;IACF,SAASa,IAAI;AACXV,cAAQC,IAAIS,EAAAA;IACd;AACA,WAAOlB;EACT;EAEA,MAAcW,kBAAkBQ,YAAiCC,MAA+C;AAC9GZ,YAAQC,IAAI,mBAAA;AACZ,QAAIY,QAAQ;AACZ,QAAIF,WAAWE,KAAAA,GAAQ;AACrB,YAAMrB,UAAU,MAAMmB,WAAWE,KAAAA,EAAOC,IAAI;QAACF;OAAK,GAAGG,OAAOC,sBAAAA,EAAwBC,IAAG;AACvF,UAAIzB,QAAQ;AACV,eAAOA;MACT;AACAqB;IACF;EACF;AACF;","names":["assertEx","isBoundWitnessWithMeta","BoundWitnessWrapper","AddressChainDiviner","AddressChainDivinerConfigSchema","MemoryAddressChainDiviner","AddressChainDiviner","configSchemas","AddressChainDivinerConfigSchema","queryAddress","assertEx","config","address","divineHandler","payloads","result","length","archivistIn","getArchivist","archivist","currentHash","startHash","maxResults","console","log","bwPayload","archivistFindHash","bwWrapper","BoundWitnessWrapper","tryParse","push","payload","prev","ex","archivists","hash","index","get","filter","isBoundWitnessWithMeta","pop"]}
|
|
@@ -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,EAAE,yBAAyB,EAAmC,MAAM,0CAA0C,CAAA;AACrH,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAIpD,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,OAAgB,aAAa,+CAAoC;IAEjE,IAAI,YAAY,sBAEf;cAEwB,aAAa,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;YA0BlE,iBAAiB;CAWhC"}
|
|
@@ -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,EAAE,yBAAyB,EAAmC,MAAM,0CAA0C,CAAA;AACrH,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAIpD,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,OAAgB,aAAa,+CAAoC;IAEjE,IAAI,YAAY,sBAEf;cAEwB,aAAa,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;YA0BlE,iBAAiB;CAWhC"}
|
|
@@ -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,EAAE,yBAAyB,EAAmC,MAAM,0CAA0C,CAAA;AACrH,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAIpD,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,OAAgB,aAAa,+CAAoC;IAEjE,IAAI,YAAY,sBAEf;cAEwB,aAAa,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;YA0BlE,iBAAiB;CAWhC"}
|
package/dist/node/index.cjs
CHANGED
|
@@ -52,7 +52,7 @@ var _MemoryAddressChainDiviner = class _MemoryAddressChainDiviner extends import
|
|
|
52
52
|
const bwPayload = await this.archivistFindHash([
|
|
53
53
|
archivist
|
|
54
54
|
], currentHash);
|
|
55
|
-
const bwWrapper =
|
|
55
|
+
const bwWrapper = import_boundwitness_wrapper.BoundWitnessWrapper.tryParse(bwPayload);
|
|
56
56
|
if (bwWrapper) {
|
|
57
57
|
result.push(bwWrapper.payload);
|
|
58
58
|
currentHash = bwWrapper.prev(this.queryAddress);
|
package/dist/node/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/MemoryDiviner.ts"],"sourcesContent":["export * from './MemoryDiviner'\n","import { assertEx } from '@xylabs/assert'\nimport { ArchivistInstance } from '@xyo-network/archivist-model'\nimport { BoundWitness, isBoundWitnessWithMeta } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessWrapper } from '@xyo-network/boundwitness-wrapper'\nimport { AddressChainDiviner } from '@xyo-network/diviner-address-chain-abstract'\nimport { AddressChainDivinerConfig, AddressChainDivinerConfigSchema } from '@xyo-network/diviner-address-chain-model'\nimport { DivinerParams } from '@xyo-network/diviner-model'\nimport { AnyConfigSchema } from '@xyo-network/module-model'\nimport { Payload } 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 configSchemas = [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, 'MemoryAddressChainDiviner.divine does not allow payloads to be sent')\n try {\n const archivistIn = await this.getArchivist()\n const archivist = assertEx(archivistIn, 'Unable to resolve archivist')\n let currentHash:
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/MemoryDiviner.ts"],"sourcesContent":["export * from './MemoryDiviner'\n","import { assertEx } from '@xylabs/assert'\nimport { Hash } from '@xylabs/hex'\nimport { ArchivistInstance } from '@xyo-network/archivist-model'\nimport { BoundWitness, isBoundWitnessWithMeta } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessWrapper } from '@xyo-network/boundwitness-wrapper'\nimport { AddressChainDiviner } from '@xyo-network/diviner-address-chain-abstract'\nimport { AddressChainDivinerConfig, AddressChainDivinerConfigSchema } from '@xyo-network/diviner-address-chain-model'\nimport { DivinerParams } from '@xyo-network/diviner-model'\nimport { AnyConfigSchema } from '@xyo-network/module-model'\nimport { Payload } 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 configSchemas = [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, 'MemoryAddressChainDiviner.divine does not allow payloads to be sent')\n try {\n const archivistIn = await this.getArchivist()\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])).filter(isBoundWitnessWithMeta).pop()\n if (result) {\n return result\n }\n index++\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;ACAA,oBAAyB;AAGzB,gCAAqD;AACrD,kCAAoC;AACpC,4CAAoC;AACpC,yCAA2E;AASpE,IAAMA,6BAAN,MAAMA,mCAEHC,0DAAAA;EAGR,IAAIC,eAAe;AACjB,eAAOC,wBAAS,KAAKC,OAAOC,SAAS,iBAAA;EACvC;EAEA,MAAyBC,cAAcC,UAA0C;AAC/E,UAAMC,SAAoB,CAAA;AAC1BL,gCAAS,EAACI,qCAAUE,SAAQ,qEAAA;AAC5B,QAAI;AACF,YAAMC,cAAc,MAAM,KAAKC,aAAY;AAC3C,YAAMC,gBAAYT,wBAASO,aAAa,6BAAA;AACxC,UAAIG,kBAA2BV,wBAAS,KAAKC,OAAOU,WAAW,mBAAA;AAC/D,aAAOD,eAAeL,OAAOC,UAAU,KAAKL,OAAOW,cAAc,MAAO;AACtEC,gBAAQC,IAAI,gBAAgBJ,WAAAA,EAAa;AACzC,cAAMK,YAAsC,MAAM,KAAKC,kBAAkB;UAACP;WAAYC,WAAAA;AACtF,cAAMO,YAA6CC,gDAAoBC,SAASJ,SAAAA;AAChF,YAAIE,WAAW;AACbZ,iBAAOe,KAAKH,UAAUI,OAAO;AAC7BX,wBAAcO,UAAUK,KAAK,KAAKvB,YAAY;QAChD,OAAO;AAELc,kBAAQC,IAAI,+BAA+BJ,WAAAA,GAAc;AACzDA,wBAAc;QAChB;MACF;IACF,SAASa,IAAI;AACXV,cAAQC,IAAIS,EAAAA;IACd;AACA,WAAOlB;EACT;EAEA,MAAcW,kBAAkBQ,YAAiCC,MAA+C;AAC9GZ,YAAQC,IAAI,mBAAA;AACZ,QAAIY,QAAQ;AACZ,QAAIF,WAAWE,KAAAA,GAAQ;AACrB,YAAMrB,UAAU,MAAMmB,WAAWE,KAAAA,EAAOC,IAAI;QAACF;OAAK,GAAGG,OAAOC,gDAAAA,EAAwBC,IAAG;AACvF,UAAIzB,QAAQ;AACV,eAAOA;MACT;AACAqB;IACF;EACF;AACF;AA5CU5B;AACR,cAHWD,4BAGKkC,iBAAgB;EAACC;;AAH5B,IAAMnC,4BAAN;","names":["MemoryAddressChainDiviner","AddressChainDiviner","queryAddress","assertEx","config","address","divineHandler","payloads","result","length","archivistIn","getArchivist","archivist","currentHash","startHash","maxResults","console","log","bwPayload","archivistFindHash","bwWrapper","BoundWitnessWrapper","tryParse","push","payload","prev","ex","archivists","hash","index","get","filter","isBoundWitnessWithMeta","pop","configSchemas","AddressChainDivinerConfigSchema"]}
|
package/dist/node/index.js
CHANGED
|
@@ -28,7 +28,7 @@ var _MemoryAddressChainDiviner = class _MemoryAddressChainDiviner extends Addres
|
|
|
28
28
|
const bwPayload = await this.archivistFindHash([
|
|
29
29
|
archivist
|
|
30
30
|
], currentHash);
|
|
31
|
-
const bwWrapper =
|
|
31
|
+
const bwWrapper = BoundWitnessWrapper.tryParse(bwPayload);
|
|
32
32
|
if (bwWrapper) {
|
|
33
33
|
result.push(bwWrapper.payload);
|
|
34
34
|
currentHash = bwWrapper.prev(this.queryAddress);
|
package/dist/node/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/MemoryDiviner.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport { ArchivistInstance } from '@xyo-network/archivist-model'\nimport { BoundWitness, isBoundWitnessWithMeta } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessWrapper } from '@xyo-network/boundwitness-wrapper'\nimport { AddressChainDiviner } from '@xyo-network/diviner-address-chain-abstract'\nimport { AddressChainDivinerConfig, AddressChainDivinerConfigSchema } from '@xyo-network/diviner-address-chain-model'\nimport { DivinerParams } from '@xyo-network/diviner-model'\nimport { AnyConfigSchema } from '@xyo-network/module-model'\nimport { Payload } 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 configSchemas = [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, 'MemoryAddressChainDiviner.divine does not allow payloads to be sent')\n try {\n const archivistIn = await this.getArchivist()\n const archivist = assertEx(archivistIn, 'Unable to resolve archivist')\n let currentHash:
|
|
1
|
+
{"version":3,"sources":["../../src/MemoryDiviner.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport { Hash } from '@xylabs/hex'\nimport { ArchivistInstance } from '@xyo-network/archivist-model'\nimport { BoundWitness, isBoundWitnessWithMeta } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessWrapper } from '@xyo-network/boundwitness-wrapper'\nimport { AddressChainDiviner } from '@xyo-network/diviner-address-chain-abstract'\nimport { AddressChainDivinerConfig, AddressChainDivinerConfigSchema } from '@xyo-network/diviner-address-chain-model'\nimport { DivinerParams } from '@xyo-network/diviner-model'\nimport { AnyConfigSchema } from '@xyo-network/module-model'\nimport { Payload } 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 configSchemas = [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, 'MemoryAddressChainDiviner.divine does not allow payloads to be sent')\n try {\n const archivistIn = await this.getArchivist()\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])).filter(isBoundWitnessWithMeta).pop()\n if (result) {\n return result\n }\n index++\n }\n }\n}\n"],"mappings":";;;;;;;;;AAAA,SAASA,gBAAgB;AAGzB,SAAuBC,8BAA8B;AACrD,SAASC,2BAA2B;AACpC,SAASC,2BAA2B;AACpC,SAAoCC,uCAAuC;AASpE,IAAMC,6BAAN,MAAMA,mCAEHC,oBAAAA;EAGR,IAAIC,eAAe;AACjB,WAAOC,SAAS,KAAKC,OAAOC,SAAS,iBAAA;EACvC;EAEA,MAAyBC,cAAcC,UAA0C;AAC/E,UAAMC,SAAoB,CAAA;AAC1BL,aAAS,EAACI,qCAAUE,SAAQ,qEAAA;AAC5B,QAAI;AACF,YAAMC,cAAc,MAAM,KAAKC,aAAY;AAC3C,YAAMC,YAAYT,SAASO,aAAa,6BAAA;AACxC,UAAIG,cAA2BV,SAAS,KAAKC,OAAOU,WAAW,mBAAA;AAC/D,aAAOD,eAAeL,OAAOC,UAAU,KAAKL,OAAOW,cAAc,MAAO;AACtEC,gBAAQC,IAAI,gBAAgBJ,WAAAA,EAAa;AACzC,cAAMK,YAAsC,MAAM,KAAKC,kBAAkB;UAACP;WAAYC,WAAAA;AACtF,cAAMO,YAA6CC,oBAAoBC,SAASJ,SAAAA;AAChF,YAAIE,WAAW;AACbZ,iBAAOe,KAAKH,UAAUI,OAAO;AAC7BX,wBAAcO,UAAUK,KAAK,KAAKvB,YAAY;QAChD,OAAO;AAELc,kBAAQC,IAAI,+BAA+BJ,WAAAA,GAAc;AACzDA,wBAAc;QAChB;MACF;IACF,SAASa,IAAI;AACXV,cAAQC,IAAIS,EAAAA;IACd;AACA,WAAOlB;EACT;EAEA,MAAcW,kBAAkBQ,YAAiCC,MAA+C;AAC9GZ,YAAQC,IAAI,mBAAA;AACZ,QAAIY,QAAQ;AACZ,QAAIF,WAAWE,KAAAA,GAAQ;AACrB,YAAMrB,UAAU,MAAMmB,WAAWE,KAAAA,EAAOC,IAAI;QAACF;OAAK,GAAGG,OAAOC,sBAAAA,EAAwBC,IAAG;AACvF,UAAIzB,QAAQ;AACV,eAAOA;MACT;AACAqB;IACF;EACF;AACF;AA5CU5B;AACR,cAHWD,4BAGKkC,iBAAgB;EAACC;;AAH5B,IAAMnC,4BAAN;","names":["assertEx","isBoundWitnessWithMeta","BoundWitnessWrapper","AddressChainDiviner","AddressChainDivinerConfigSchema","MemoryAddressChainDiviner","AddressChainDiviner","queryAddress","assertEx","config","address","divineHandler","payloads","result","length","archivistIn","getArchivist","archivist","currentHash","startHash","maxResults","console","log","bwPayload","archivistFindHash","bwWrapper","BoundWitnessWrapper","tryParse","push","payload","prev","ex","archivists","hash","index","get","filter","isBoundWitnessWithMeta","pop","configSchemas","AddressChainDivinerConfigSchema"]}
|
package/package.json
CHANGED
|
@@ -10,26 +10,27 @@
|
|
|
10
10
|
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/issues"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@xylabs/assert": "^3.0.
|
|
14
|
-
"@
|
|
15
|
-
"@xyo-network/
|
|
16
|
-
"@xyo-network/boundwitness-
|
|
17
|
-
"@xyo-network/
|
|
18
|
-
"@xyo-network/diviner-address-chain-
|
|
19
|
-
"@xyo-network/diviner-model": "~2.91.
|
|
20
|
-
"@xyo-network/
|
|
21
|
-
"@xyo-network/
|
|
13
|
+
"@xylabs/assert": "^3.0.3",
|
|
14
|
+
"@xylabs/hex": "^3.0.3",
|
|
15
|
+
"@xyo-network/archivist-model": "~2.91.2",
|
|
16
|
+
"@xyo-network/boundwitness-model": "~2.91.2",
|
|
17
|
+
"@xyo-network/boundwitness-wrapper": "~2.91.2",
|
|
18
|
+
"@xyo-network/diviner-address-chain-abstract": "~2.91.2",
|
|
19
|
+
"@xyo-network/diviner-address-chain-model": "~2.91.2",
|
|
20
|
+
"@xyo-network/diviner-model": "~2.91.2",
|
|
21
|
+
"@xyo-network/module-model": "~2.91.2",
|
|
22
|
+
"@xyo-network/payload-model": "~2.91.2"
|
|
22
23
|
},
|
|
23
24
|
"devDependencies": {
|
|
24
25
|
"@xylabs/ts-scripts-yarn3": "^3.4.1",
|
|
25
26
|
"@xylabs/tsconfig": "^3.4.1",
|
|
26
|
-
"@xyo-network/account": "~2.91.
|
|
27
|
-
"@xyo-network/archivist-memory": "~2.91.
|
|
28
|
-
"@xyo-network/archivist-wrapper": "~2.91.
|
|
29
|
-
"@xyo-network/node-memory": "~2.91.
|
|
30
|
-
"@xyo-network/node-model": "~2.91.
|
|
31
|
-
"@xyo-network/payload-builder": "~2.91.
|
|
32
|
-
"@xyo-network/payload-wrapper": "~2.91.
|
|
27
|
+
"@xyo-network/account": "~2.91.2",
|
|
28
|
+
"@xyo-network/archivist-memory": "~2.91.2",
|
|
29
|
+
"@xyo-network/archivist-wrapper": "~2.91.2",
|
|
30
|
+
"@xyo-network/node-memory": "~2.91.2",
|
|
31
|
+
"@xyo-network/node-model": "~2.91.2",
|
|
32
|
+
"@xyo-network/payload-builder": "~2.91.2",
|
|
33
|
+
"@xyo-network/payload-wrapper": "~2.91.2",
|
|
33
34
|
"typescript": "^5.3.3"
|
|
34
35
|
},
|
|
35
36
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
@@ -71,6 +72,6 @@
|
|
|
71
72
|
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js.git"
|
|
72
73
|
},
|
|
73
74
|
"sideEffects": false,
|
|
74
|
-
"version": "2.91.
|
|
75
|
+
"version": "2.91.2",
|
|
75
76
|
"type": "module"
|
|
76
77
|
}
|
package/src/MemoryDiviner.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { assertEx } from '@xylabs/assert'
|
|
2
|
+
import { Hash } from '@xylabs/hex'
|
|
2
3
|
import { ArchivistInstance } from '@xyo-network/archivist-model'
|
|
3
4
|
import { BoundWitness, isBoundWitnessWithMeta } from '@xyo-network/boundwitness-model'
|
|
4
5
|
import { BoundWitnessWrapper } from '@xyo-network/boundwitness-wrapper'
|
|
@@ -27,11 +28,11 @@ export class MemoryAddressChainDiviner<
|
|
|
27
28
|
try {
|
|
28
29
|
const archivistIn = await this.getArchivist()
|
|
29
30
|
const archivist = assertEx(archivistIn, 'Unable to resolve archivist')
|
|
30
|
-
let currentHash:
|
|
31
|
+
let currentHash: Hash | null = assertEx(this.config.startHash, 'Missing startHash')
|
|
31
32
|
while (currentHash && result.length < (this.config.maxResults ?? 1000)) {
|
|
32
33
|
console.log(`currentHash: ${currentHash}`)
|
|
33
34
|
const bwPayload: BoundWitness | undefined = await this.archivistFindHash([archivist], currentHash)
|
|
34
|
-
const bwWrapper: BoundWitnessWrapper | undefined =
|
|
35
|
+
const bwWrapper: BoundWitnessWrapper | undefined = BoundWitnessWrapper.tryParse(bwPayload)
|
|
35
36
|
if (bwWrapper) {
|
|
36
37
|
result.push(bwWrapper.payload)
|
|
37
38
|
currentHash = bwWrapper.prev(this.queryAddress)
|
|
@@ -47,7 +48,7 @@ export class MemoryAddressChainDiviner<
|
|
|
47
48
|
return result
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
private async archivistFindHash(archivists: ArchivistInstance[], hash:
|
|
51
|
+
private async archivistFindHash(archivists: ArchivistInstance[], hash: Hash): Promise<BoundWitness | undefined> {
|
|
51
52
|
console.log('archivistFindHash')
|
|
52
53
|
let index = 0
|
|
53
54
|
if (archivists[index]) {
|