@xyo-network/diviner-address-chain-memory 2.75.0 → 2.75.3
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 +13 -0
- package/dist/browser/MemoryDiviner.d.cts.map +1 -0
- package/dist/browser/MemoryDiviner.js +2 -3
- package/dist/browser/MemoryDiviner.js.map +1 -1
- package/dist/browser/index.d.cts +2 -0
- package/dist/browser/index.d.cts.map +1 -0
- package/dist/browser/index.js +1 -44
- package/dist/browser/index.js.map +1 -1
- package/dist/docs.json +20002 -0
- package/dist/node/MemoryDiviner.d.cts +13 -0
- package/dist/node/MemoryDiviner.d.cts.map +1 -0
- package/dist/node/MemoryDiviner.js +5 -3
- package/dist/node/MemoryDiviner.js.map +1 -1
- package/dist/node/MemoryDiviner.mjs +4 -3
- package/dist/node/MemoryDiviner.mjs.map +1 -1
- package/dist/node/index.d.cts +2 -0
- package/dist/node/index.d.cts.map +1 -0
- package/dist/node/index.js +52 -3
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +44 -1
- package/dist/node/index.mjs.map +1 -1
- package/package.json +13 -13
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AddressChainDiviner } from '@xyo-network/diviner-address-chain-abstract';
|
|
2
|
+
import { AddressChainDivinerConfig } from '@xyo-network/diviner-address-chain-model';
|
|
3
|
+
import { DivinerParams } from '@xyo-network/diviner-model';
|
|
4
|
+
import { AnyConfigSchema } from '@xyo-network/module-model';
|
|
5
|
+
import { Payload } from '@xyo-network/payload-model';
|
|
6
|
+
export type MemoryAddressChainDivinerParams = DivinerParams<AnyConfigSchema<AddressChainDivinerConfig>>;
|
|
7
|
+
export declare class MemoryAddressChainDiviner<TParams extends MemoryAddressChainDivinerParams = MemoryAddressChainDivinerParams> extends AddressChainDiviner<TParams> {
|
|
8
|
+
static configSchemas: "network.xyo.diviner.address.chain.config"[];
|
|
9
|
+
get queryAddress(): string;
|
|
10
|
+
protected divineHandler(payloads?: Payload[]): Promise<Payload[]>;
|
|
11
|
+
private archivistFindHash;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=MemoryDiviner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MemoryDiviner.d.ts","sourceRoot":"","sources":["../../src/MemoryDiviner.ts"],"names":[],"mappings":"AAIA,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,WAEf;cAEwB,aAAa,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;YAqBlE,iBAAiB;CAUhC"}
|
|
@@ -16,6 +16,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/MemoryDiviner.ts
|
|
19
21
|
var MemoryDiviner_exports = {};
|
|
20
22
|
__export(MemoryDiviner_exports, {
|
|
21
23
|
MemoryAddressChainDiviner: () => MemoryAddressChainDiviner
|
|
@@ -25,14 +27,14 @@ var import_assert = require("@xylabs/assert");
|
|
|
25
27
|
var import_boundwitness_wrapper = require("@xyo-network/boundwitness-wrapper");
|
|
26
28
|
var import_diviner_address_chain_abstract = require("@xyo-network/diviner-address-chain-abstract");
|
|
27
29
|
var import_diviner_address_chain_model = require("@xyo-network/diviner-address-chain-model");
|
|
28
|
-
|
|
30
|
+
var MemoryAddressChainDiviner = class extends import_diviner_address_chain_abstract.AddressChainDiviner {
|
|
29
31
|
static configSchemas = [import_diviner_address_chain_model.AddressChainDivinerConfigSchema];
|
|
30
32
|
get queryAddress() {
|
|
31
33
|
return (0, import_assert.assertEx)(this.config.address, "Missing address");
|
|
32
34
|
}
|
|
33
35
|
async divineHandler(payloads) {
|
|
34
36
|
const result = [];
|
|
35
|
-
(0, import_assert.assertEx)(!payloads
|
|
37
|
+
(0, import_assert.assertEx)(!(payloads == null ? void 0 : payloads.length), "MemoryAddressChainDiviner.divine does not allow payloads to be sent");
|
|
36
38
|
try {
|
|
37
39
|
const archivistIn = await this.readArchivist();
|
|
38
40
|
const archivist = (0, import_assert.assertEx)(archivistIn, "Unable to resolve archivist");
|
|
@@ -60,7 +62,7 @@ class MemoryAddressChainDiviner extends import_diviner_address_chain_abstract.Ad
|
|
|
60
62
|
index++;
|
|
61
63
|
}
|
|
62
64
|
}
|
|
63
|
-
}
|
|
65
|
+
};
|
|
64
66
|
// Annotate the CommonJS export names for ESM import in node:
|
|
65
67
|
0 && (module.exports = {
|
|
66
68
|
MemoryAddressChainDiviner
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/MemoryDiviner.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport { ArchivistInstance } from '@xyo-network/archivist-model'\nimport { BoundWitness } 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.readArchivist()\n const archivist = assertEx(archivistIn, 'Unable to resolve archivist')\n let currentHash: string | null = assertEx(this.config.startHash, 'Missing startHash')\n while (currentHash && result.length < (this.config.maxResults ?? 1000)) {\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 }\n }\n } catch (ex) {\n console.log(ex)\n }\n return result\n }\n\n private async archivistFindHash(archivists: ArchivistInstance[], hash: string): Promise<BoundWitness | undefined> {\n let index = 0\n if (archivists[index]) {\n const result = (await archivists[index].get([hash])).pop() as BoundWitness\n if (result) {\n return result\n }\n index++\n }\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/MemoryDiviner.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport { ArchivistInstance } from '@xyo-network/archivist-model'\nimport { BoundWitness } 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.readArchivist()\n const archivist = assertEx(archivistIn, 'Unable to resolve archivist')\n let currentHash: string | null = assertEx(this.config.startHash, 'Missing startHash')\n while (currentHash && result.length < (this.config.maxResults ?? 1000)) {\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 }\n }\n } catch (ex) {\n console.log(ex)\n }\n return result\n }\n\n private async archivistFindHash(archivists: ArchivistInstance[], hash: string): Promise<BoundWitness | undefined> {\n let index = 0\n if (archivists[index]) {\n const result = (await archivists[index].get([hash])).pop() as BoundWitness\n if (result) {\n return result\n }\n index++\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAyB;AAGzB,kCAAoC;AACpC,4CAAoC;AACpC,yCAA2E;AASpE,IAAM,4BAAN,cAEG,0DAA6B;AAAA,EACrC,OAAgB,gBAAgB,CAAC,kEAA+B;AAAA,EAEhE,IAAI,eAAe;AACjB,eAAO,wBAAS,KAAK,OAAO,SAAS,iBAAiB;AAAA,EACxD;AAAA,EAEA,MAAyB,cAAc,UAA0C;AAC/E,UAAM,SAAoB,CAAC;AAC3B,gCAAS,EAAC,qCAAU,SAAQ,qEAAqE;AACjG,QAAI;AACF,YAAM,cAAc,MAAM,KAAK,cAAc;AAC7C,YAAM,gBAAY,wBAAS,aAAa,6BAA6B;AACrE,UAAI,kBAA6B,wBAAS,KAAK,OAAO,WAAW,mBAAmB;AACpF,aAAO,eAAe,OAAO,UAAU,KAAK,OAAO,cAAc,MAAO;AACtE,cAAM,YAAsC,MAAM,KAAK,kBAAkB,CAAC,SAAS,GAAG,WAAW;AACjG,cAAM,YAA6C,gDAAoB,SAAS,SAAS;AACzF,YAAI,WAAW;AACb,iBAAO,KAAK,UAAU,QAAQ,CAAC;AAC/B,wBAAc,UAAU,KAAK,KAAK,YAAY;AAAA,QAChD;AAAA,MACF;AAAA,IACF,SAAS,IAAI;AACX,cAAQ,IAAI,EAAE;AAAA,IAChB;AACA,WAAO;AAAA,EACT;AAAA,EAEA,MAAc,kBAAkB,YAAiC,MAAiD;AAChH,QAAI,QAAQ;AACZ,QAAI,WAAW,KAAK,GAAG;AACrB,YAAM,UAAU,MAAM,WAAW,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI;AACzD,UAAI,QAAQ;AACV,eAAO;AAAA,MACT;AACA;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
// src/MemoryDiviner.ts
|
|
1
2
|
import { assertEx } from "@xylabs/assert";
|
|
2
3
|
import { BoundWitnessWrapper } from "@xyo-network/boundwitness-wrapper";
|
|
3
4
|
import { AddressChainDiviner } from "@xyo-network/diviner-address-chain-abstract";
|
|
4
5
|
import { AddressChainDivinerConfigSchema } from "@xyo-network/diviner-address-chain-model";
|
|
5
|
-
|
|
6
|
+
var MemoryAddressChainDiviner = class extends AddressChainDiviner {
|
|
6
7
|
static configSchemas = [AddressChainDivinerConfigSchema];
|
|
7
8
|
get queryAddress() {
|
|
8
9
|
return assertEx(this.config.address, "Missing address");
|
|
9
10
|
}
|
|
10
11
|
async divineHandler(payloads) {
|
|
11
12
|
const result = [];
|
|
12
|
-
assertEx(!payloads
|
|
13
|
+
assertEx(!(payloads == null ? void 0 : payloads.length), "MemoryAddressChainDiviner.divine does not allow payloads to be sent");
|
|
13
14
|
try {
|
|
14
15
|
const archivistIn = await this.readArchivist();
|
|
15
16
|
const archivist = assertEx(archivistIn, "Unable to resolve archivist");
|
|
@@ -37,7 +38,7 @@ class MemoryAddressChainDiviner extends AddressChainDiviner {
|
|
|
37
38
|
index++;
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
|
-
}
|
|
41
|
+
};
|
|
41
42
|
export {
|
|
42
43
|
MemoryAddressChainDiviner
|
|
43
44
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/MemoryDiviner.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport { ArchivistInstance } from '@xyo-network/archivist-model'\nimport { BoundWitness } 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.readArchivist()\n const archivist = assertEx(archivistIn, 'Unable to resolve archivist')\n let currentHash: string | null = assertEx(this.config.startHash, 'Missing startHash')\n while (currentHash && result.length < (this.config.maxResults ?? 1000)) {\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 }\n }\n } catch (ex) {\n console.log(ex)\n }\n return result\n }\n\n private async archivistFindHash(archivists: ArchivistInstance[], hash: string): Promise<BoundWitness | undefined> {\n let index = 0\n if (archivists[index]) {\n const result = (await archivists[index].get([hash])).pop() as BoundWitness\n if (result) {\n return result\n }\n index++\n }\n }\n}\n"],"mappings":"AAAA,SAAS,gBAAgB;AAGzB,SAAS,2BAA2B;AACpC,SAAS,2BAA2B;AACpC,SAAoC,uCAAuC;AASpE,
|
|
1
|
+
{"version":3,"sources":["../../src/MemoryDiviner.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport { ArchivistInstance } from '@xyo-network/archivist-model'\nimport { BoundWitness } 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.readArchivist()\n const archivist = assertEx(archivistIn, 'Unable to resolve archivist')\n let currentHash: string | null = assertEx(this.config.startHash, 'Missing startHash')\n while (currentHash && result.length < (this.config.maxResults ?? 1000)) {\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 }\n }\n } catch (ex) {\n console.log(ex)\n }\n return result\n }\n\n private async archivistFindHash(archivists: ArchivistInstance[], hash: string): Promise<BoundWitness | undefined> {\n let index = 0\n if (archivists[index]) {\n const result = (await archivists[index].get([hash])).pop() as BoundWitness\n if (result) {\n return result\n }\n index++\n }\n }\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AAGzB,SAAS,2BAA2B;AACpC,SAAS,2BAA2B;AACpC,SAAoC,uCAAuC;AASpE,IAAM,4BAAN,cAEG,oBAA6B;AAAA,EACrC,OAAgB,gBAAgB,CAAC,+BAA+B;AAAA,EAEhE,IAAI,eAAe;AACjB,WAAO,SAAS,KAAK,OAAO,SAAS,iBAAiB;AAAA,EACxD;AAAA,EAEA,MAAyB,cAAc,UAA0C;AAC/E,UAAM,SAAoB,CAAC;AAC3B,aAAS,EAAC,qCAAU,SAAQ,qEAAqE;AACjG,QAAI;AACF,YAAM,cAAc,MAAM,KAAK,cAAc;AAC7C,YAAM,YAAY,SAAS,aAAa,6BAA6B;AACrE,UAAI,cAA6B,SAAS,KAAK,OAAO,WAAW,mBAAmB;AACpF,aAAO,eAAe,OAAO,UAAU,KAAK,OAAO,cAAc,MAAO;AACtE,cAAM,YAAsC,MAAM,KAAK,kBAAkB,CAAC,SAAS,GAAG,WAAW;AACjG,cAAM,YAA6C,oBAAoB,SAAS,SAAS;AACzF,YAAI,WAAW;AACb,iBAAO,KAAK,UAAU,QAAQ,CAAC;AAC/B,wBAAc,UAAU,KAAK,KAAK,YAAY;AAAA,QAChD;AAAA,MACF;AAAA,IACF,SAAS,IAAI;AACX,cAAQ,IAAI,EAAE;AAAA,IAChB;AACA,WAAO;AAAA,EACT;AAAA,EAEA,MAAc,kBAAkB,YAAiC,MAAiD;AAChH,QAAI,QAAQ;AACZ,QAAI,WAAW,KAAK,GAAG;AACrB,YAAM,UAAU,MAAM,WAAW,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI;AACzD,UAAI,QAAQ;AACV,eAAO;AAAA,MACT;AACA;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA"}
|
package/dist/node/index.js
CHANGED
|
@@ -3,6 +3,10 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
6
10
|
var __copyProps = (to, from, except, desc) => {
|
|
7
11
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
12
|
for (let key of __getOwnPropNames(from))
|
|
@@ -11,13 +15,58 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
11
15
|
}
|
|
12
16
|
return to;
|
|
13
17
|
};
|
|
14
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
16
21
|
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
MemoryAddressChainDiviner: () => MemoryAddressChainDiviner
|
|
24
|
+
});
|
|
17
25
|
module.exports = __toCommonJS(src_exports);
|
|
18
|
-
|
|
26
|
+
|
|
27
|
+
// src/MemoryDiviner.ts
|
|
28
|
+
var import_assert = require("@xylabs/assert");
|
|
29
|
+
var import_boundwitness_wrapper = require("@xyo-network/boundwitness-wrapper");
|
|
30
|
+
var import_diviner_address_chain_abstract = require("@xyo-network/diviner-address-chain-abstract");
|
|
31
|
+
var import_diviner_address_chain_model = require("@xyo-network/diviner-address-chain-model");
|
|
32
|
+
var MemoryAddressChainDiviner = class extends import_diviner_address_chain_abstract.AddressChainDiviner {
|
|
33
|
+
static configSchemas = [import_diviner_address_chain_model.AddressChainDivinerConfigSchema];
|
|
34
|
+
get queryAddress() {
|
|
35
|
+
return (0, import_assert.assertEx)(this.config.address, "Missing address");
|
|
36
|
+
}
|
|
37
|
+
async divineHandler(payloads) {
|
|
38
|
+
const result = [];
|
|
39
|
+
(0, import_assert.assertEx)(!(payloads == null ? void 0 : payloads.length), "MemoryAddressChainDiviner.divine does not allow payloads to be sent");
|
|
40
|
+
try {
|
|
41
|
+
const archivistIn = await this.readArchivist();
|
|
42
|
+
const archivist = (0, import_assert.assertEx)(archivistIn, "Unable to resolve archivist");
|
|
43
|
+
let currentHash = (0, import_assert.assertEx)(this.config.startHash, "Missing startHash");
|
|
44
|
+
while (currentHash && result.length < (this.config.maxResults ?? 1e3)) {
|
|
45
|
+
const bwPayload = await this.archivistFindHash([archivist], currentHash);
|
|
46
|
+
const bwWrapper = import_boundwitness_wrapper.BoundWitnessWrapper.tryParse(bwPayload);
|
|
47
|
+
if (bwWrapper) {
|
|
48
|
+
result.push(bwWrapper.payload());
|
|
49
|
+
currentHash = bwWrapper.prev(this.queryAddress);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
} catch (ex) {
|
|
53
|
+
console.log(ex);
|
|
54
|
+
}
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
async archivistFindHash(archivists, hash) {
|
|
58
|
+
let index = 0;
|
|
59
|
+
if (archivists[index]) {
|
|
60
|
+
const result = (await archivists[index].get([hash])).pop();
|
|
61
|
+
if (result) {
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
64
|
+
index++;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
19
68
|
// Annotate the CommonJS export names for ESM import in node:
|
|
20
69
|
0 && (module.exports = {
|
|
21
|
-
|
|
70
|
+
MemoryAddressChainDiviner
|
|
22
71
|
});
|
|
23
72
|
//# sourceMappingURL=index.js.map
|
package/dist/node/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from './MemoryDiviner'\n"],"mappings":"
|
|
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 } 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.readArchivist()\n const archivist = assertEx(archivistIn, 'Unable to resolve archivist')\n let currentHash: string | null = assertEx(this.config.startHash, 'Missing startHash')\n while (currentHash && result.length < (this.config.maxResults ?? 1000)) {\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 }\n }\n } catch (ex) {\n console.log(ex)\n }\n return result\n }\n\n private async archivistFindHash(archivists: ArchivistInstance[], hash: string): Promise<BoundWitness | undefined> {\n let index = 0\n if (archivists[index]) {\n const result = (await archivists[index].get([hash])).pop() as BoundWitness\n if (result) {\n return result\n }\n index++\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAAyB;AAGzB,kCAAoC;AACpC,4CAAoC;AACpC,yCAA2E;AASpE,IAAM,4BAAN,cAEG,0DAA6B;AAAA,EACrC,OAAgB,gBAAgB,CAAC,kEAA+B;AAAA,EAEhE,IAAI,eAAe;AACjB,eAAO,wBAAS,KAAK,OAAO,SAAS,iBAAiB;AAAA,EACxD;AAAA,EAEA,MAAyB,cAAc,UAA0C;AAC/E,UAAM,SAAoB,CAAC;AAC3B,gCAAS,EAAC,qCAAU,SAAQ,qEAAqE;AACjG,QAAI;AACF,YAAM,cAAc,MAAM,KAAK,cAAc;AAC7C,YAAM,gBAAY,wBAAS,aAAa,6BAA6B;AACrE,UAAI,kBAA6B,wBAAS,KAAK,OAAO,WAAW,mBAAmB;AACpF,aAAO,eAAe,OAAO,UAAU,KAAK,OAAO,cAAc,MAAO;AACtE,cAAM,YAAsC,MAAM,KAAK,kBAAkB,CAAC,SAAS,GAAG,WAAW;AACjG,cAAM,YAA6C,gDAAoB,SAAS,SAAS;AACzF,YAAI,WAAW;AACb,iBAAO,KAAK,UAAU,QAAQ,CAAC;AAC/B,wBAAc,UAAU,KAAK,KAAK,YAAY;AAAA,QAChD;AAAA,MACF;AAAA,IACF,SAAS,IAAI;AACX,cAAQ,IAAI,EAAE;AAAA,IAChB;AACA,WAAO;AAAA,EACT;AAAA,EAEA,MAAc,kBAAkB,YAAiC,MAAiD;AAChH,QAAI,QAAQ;AACZ,QAAI,WAAW,KAAK,GAAG;AACrB,YAAM,UAAU,MAAM,WAAW,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI;AACzD,UAAI,QAAQ;AACV,eAAO;AAAA,MACT;AACA;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
package/dist/node/index.mjs
CHANGED
|
@@ -1,2 +1,45 @@
|
|
|
1
|
-
|
|
1
|
+
// src/MemoryDiviner.ts
|
|
2
|
+
import { assertEx } from "@xylabs/assert";
|
|
3
|
+
import { BoundWitnessWrapper } from "@xyo-network/boundwitness-wrapper";
|
|
4
|
+
import { AddressChainDiviner } from "@xyo-network/diviner-address-chain-abstract";
|
|
5
|
+
import { AddressChainDivinerConfigSchema } from "@xyo-network/diviner-address-chain-model";
|
|
6
|
+
var MemoryAddressChainDiviner = class extends AddressChainDiviner {
|
|
7
|
+
static configSchemas = [AddressChainDivinerConfigSchema];
|
|
8
|
+
get queryAddress() {
|
|
9
|
+
return assertEx(this.config.address, "Missing address");
|
|
10
|
+
}
|
|
11
|
+
async divineHandler(payloads) {
|
|
12
|
+
const result = [];
|
|
13
|
+
assertEx(!(payloads == null ? void 0 : payloads.length), "MemoryAddressChainDiviner.divine does not allow payloads to be sent");
|
|
14
|
+
try {
|
|
15
|
+
const archivistIn = await this.readArchivist();
|
|
16
|
+
const archivist = assertEx(archivistIn, "Unable to resolve archivist");
|
|
17
|
+
let currentHash = assertEx(this.config.startHash, "Missing startHash");
|
|
18
|
+
while (currentHash && result.length < (this.config.maxResults ?? 1e3)) {
|
|
19
|
+
const bwPayload = await this.archivistFindHash([archivist], currentHash);
|
|
20
|
+
const bwWrapper = BoundWitnessWrapper.tryParse(bwPayload);
|
|
21
|
+
if (bwWrapper) {
|
|
22
|
+
result.push(bwWrapper.payload());
|
|
23
|
+
currentHash = bwWrapper.prev(this.queryAddress);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
} catch (ex) {
|
|
27
|
+
console.log(ex);
|
|
28
|
+
}
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
async archivistFindHash(archivists, hash) {
|
|
32
|
+
let index = 0;
|
|
33
|
+
if (archivists[index]) {
|
|
34
|
+
const result = (await archivists[index].get([hash])).pop();
|
|
35
|
+
if (result) {
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
index++;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
export {
|
|
43
|
+
MemoryAddressChainDiviner
|
|
44
|
+
};
|
|
2
45
|
//# sourceMappingURL=index.mjs.map
|
package/dist/node/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/
|
|
1
|
+
{"version":3,"sources":["../../src/MemoryDiviner.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport { ArchivistInstance } from '@xyo-network/archivist-model'\nimport { BoundWitness } 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.readArchivist()\n const archivist = assertEx(archivistIn, 'Unable to resolve archivist')\n let currentHash: string | null = assertEx(this.config.startHash, 'Missing startHash')\n while (currentHash && result.length < (this.config.maxResults ?? 1000)) {\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 }\n }\n } catch (ex) {\n console.log(ex)\n }\n return result\n }\n\n private async archivistFindHash(archivists: ArchivistInstance[], hash: string): Promise<BoundWitness | undefined> {\n let index = 0\n if (archivists[index]) {\n const result = (await archivists[index].get([hash])).pop() as BoundWitness\n if (result) {\n return result\n }\n index++\n }\n }\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AAGzB,SAAS,2BAA2B;AACpC,SAAS,2BAA2B;AACpC,SAAoC,uCAAuC;AASpE,IAAM,4BAAN,cAEG,oBAA6B;AAAA,EACrC,OAAgB,gBAAgB,CAAC,+BAA+B;AAAA,EAEhE,IAAI,eAAe;AACjB,WAAO,SAAS,KAAK,OAAO,SAAS,iBAAiB;AAAA,EACxD;AAAA,EAEA,MAAyB,cAAc,UAA0C;AAC/E,UAAM,SAAoB,CAAC;AAC3B,aAAS,EAAC,qCAAU,SAAQ,qEAAqE;AACjG,QAAI;AACF,YAAM,cAAc,MAAM,KAAK,cAAc;AAC7C,YAAM,YAAY,SAAS,aAAa,6BAA6B;AACrE,UAAI,cAA6B,SAAS,KAAK,OAAO,WAAW,mBAAmB;AACpF,aAAO,eAAe,OAAO,UAAU,KAAK,OAAO,cAAc,MAAO;AACtE,cAAM,YAAsC,MAAM,KAAK,kBAAkB,CAAC,SAAS,GAAG,WAAW;AACjG,cAAM,YAA6C,oBAAoB,SAAS,SAAS;AACzF,YAAI,WAAW;AACb,iBAAO,KAAK,UAAU,QAAQ,CAAC;AAC/B,wBAAc,UAAU,KAAK,KAAK,YAAY;AAAA,QAChD;AAAA,MACF;AAAA,IACF,SAAS,IAAI;AACX,cAAQ,IAAI,EAAE;AAAA,IAChB;AACA,WAAO;AAAA,EACT;AAAA,EAEA,MAAc,kBAAkB,YAAiC,MAAiD;AAChH,QAAI,QAAQ;AACZ,QAAI,WAAW,KAAK,GAAG;AACrB,YAAM,UAAU,MAAM,WAAW,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI;AACzD,UAAI,QAAQ;AACV,eAAO;AAAA,MACT;AACA;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -10,19 +10,19 @@
|
|
|
10
10
|
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/issues"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@xylabs/assert": "^2.
|
|
14
|
-
"@xyo-network/archivist-model": "~2.75.
|
|
15
|
-
"@xyo-network/boundwitness-model": "~2.75.
|
|
16
|
-
"@xyo-network/boundwitness-wrapper": "~2.75.
|
|
17
|
-
"@xyo-network/diviner-address-chain-abstract": "~2.75.
|
|
18
|
-
"@xyo-network/diviner-address-chain-model": "~2.75.
|
|
19
|
-
"@xyo-network/diviner-model": "~2.75.
|
|
20
|
-
"@xyo-network/module-model": "~2.75.
|
|
21
|
-
"@xyo-network/payload-model": "~2.75.
|
|
13
|
+
"@xylabs/assert": "^2.12.10",
|
|
14
|
+
"@xyo-network/archivist-model": "~2.75.3",
|
|
15
|
+
"@xyo-network/boundwitness-model": "~2.75.3",
|
|
16
|
+
"@xyo-network/boundwitness-wrapper": "~2.75.3",
|
|
17
|
+
"@xyo-network/diviner-address-chain-abstract": "~2.75.3",
|
|
18
|
+
"@xyo-network/diviner-address-chain-model": "~2.75.3",
|
|
19
|
+
"@xyo-network/diviner-model": "~2.75.3",
|
|
20
|
+
"@xyo-network/module-model": "~2.75.3",
|
|
21
|
+
"@xyo-network/payload-model": "~2.75.3"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@xylabs/ts-scripts-yarn3": "^3.0.
|
|
25
|
-
"@xylabs/tsconfig": "^3.0.
|
|
24
|
+
"@xylabs/ts-scripts-yarn3": "^3.0.77",
|
|
25
|
+
"@xylabs/tsconfig": "^3.0.77",
|
|
26
26
|
"typescript": "^5.2.2"
|
|
27
27
|
},
|
|
28
28
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
".": {
|
|
33
33
|
"browser": {
|
|
34
34
|
"require": {
|
|
35
|
-
"types": "./dist/browser/index.d.
|
|
35
|
+
"types": "./dist/browser/index.d.cts",
|
|
36
36
|
"default": "./dist/browser/index.cjs"
|
|
37
37
|
},
|
|
38
38
|
"import": {
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js.git"
|
|
69
69
|
},
|
|
70
70
|
"sideEffects": false,
|
|
71
|
-
"version": "2.75.
|
|
71
|
+
"version": "2.75.3"
|
|
72
72
|
}
|