@xyo-network/diviner-address-chain-memory 2.72.8 → 2.73.0
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/{types/MemoryDiviner.d.ts → index.d.mts} +5 -3
- package/dist/index.d.ts +15 -0
- package/dist/index.js +72 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +45 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +37 -24
- package/tsup.config.ts +16 -0
- package/dist/cjs/MemoryDiviner.js +0 -52
- package/dist/cjs/MemoryDiviner.js.map +0 -1
- package/dist/cjs/index.js +0 -5
- package/dist/cjs/index.js.map +0 -1
- package/dist/docs.json +0 -20094
- package/dist/esm/MemoryDiviner.js +0 -42
- package/dist/esm/MemoryDiviner.js.map +0 -1
- package/dist/esm/index.js +0 -2
- package/dist/esm/index.js.map +0 -1
- package/dist/types/MemoryDiviner.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -2
- package/dist/types/index.d.ts.map +0 -1
|
@@ -3,11 +3,13 @@ import { AddressChainDivinerConfig } from '@xyo-network/diviner-address-chain-mo
|
|
|
3
3
|
import { DivinerParams } from '@xyo-network/diviner-model';
|
|
4
4
|
import { AnyConfigSchema } from '@xyo-network/module-model';
|
|
5
5
|
import { Payload } from '@xyo-network/payload-model';
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
|
|
7
|
+
type MemoryAddressChainDivinerParams = DivinerParams<AnyConfigSchema<AddressChainDivinerConfig>>;
|
|
8
|
+
declare class MemoryAddressChainDiviner<TParams extends MemoryAddressChainDivinerParams = MemoryAddressChainDivinerParams> extends AddressChainDiviner<TParams> {
|
|
8
9
|
static configSchemas: "network.xyo.diviner.address.chain.config"[];
|
|
9
10
|
get queryAddress(): string;
|
|
10
11
|
protected divineHandler(payloads?: Payload[]): Promise<Payload[]>;
|
|
11
12
|
private archivistFindHash;
|
|
12
13
|
}
|
|
13
|
-
|
|
14
|
+
|
|
15
|
+
export { MemoryAddressChainDiviner, MemoryAddressChainDivinerParams };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
|
|
7
|
+
type MemoryAddressChainDivinerParams = DivinerParams<AnyConfigSchema<AddressChainDivinerConfig>>;
|
|
8
|
+
declare class MemoryAddressChainDiviner<TParams extends MemoryAddressChainDivinerParams = MemoryAddressChainDivinerParams> extends AddressChainDiviner<TParams> {
|
|
9
|
+
static configSchemas: "network.xyo.diviner.address.chain.config"[];
|
|
10
|
+
get queryAddress(): string;
|
|
11
|
+
protected divineHandler(payloads?: Payload[]): Promise<Payload[]>;
|
|
12
|
+
private archivistFindHash;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { MemoryAddressChainDiviner, MemoryAddressChainDivinerParams };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
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
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
MemoryAddressChainDiviner: () => MemoryAddressChainDiviner
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(src_exports);
|
|
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?.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
|
+
};
|
|
68
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
69
|
+
0 && (module.exports = {
|
|
70
|
+
MemoryAddressChainDiviner
|
|
71
|
+
});
|
|
72
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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 } 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,CAAC,UAAU,QAAQ,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/index.mjs
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
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?.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
|
+
};
|
|
45
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +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,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,CAAC,UAAU,QAAQ,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,43 +10,57 @@
|
|
|
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.
|
|
15
|
-
"@xyo-network/boundwitness-model": "~2.
|
|
16
|
-
"@xyo-network/boundwitness-wrapper": "~2.
|
|
17
|
-
"@xyo-network/diviner-address-chain-abstract": "~2.
|
|
18
|
-
"@xyo-network/diviner-address-chain-model": "~2.
|
|
19
|
-
"@xyo-network/diviner-model": "~2.
|
|
20
|
-
"@xyo-network/module-model": "~2.
|
|
21
|
-
"@xyo-network/payload-model": "~2.
|
|
13
|
+
"@xylabs/assert": "^2.10.7",
|
|
14
|
+
"@xyo-network/archivist-model": "~2.73.0",
|
|
15
|
+
"@xyo-network/boundwitness-model": "~2.73.0",
|
|
16
|
+
"@xyo-network/boundwitness-wrapper": "~2.73.0",
|
|
17
|
+
"@xyo-network/diviner-address-chain-abstract": "~2.73.0",
|
|
18
|
+
"@xyo-network/diviner-address-chain-model": "~2.73.0",
|
|
19
|
+
"@xyo-network/diviner-model": "~2.73.0",
|
|
20
|
+
"@xyo-network/module-model": "~2.73.0",
|
|
21
|
+
"@xyo-network/payload-model": "~2.73.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@xylabs/ts-scripts-yarn3": "^2.19.
|
|
25
|
-
"@xylabs/tsconfig": "^2.19.
|
|
24
|
+
"@xylabs/ts-scripts-yarn3": "^2.19.5",
|
|
25
|
+
"@xylabs/tsconfig": "^2.19.5",
|
|
26
|
+
"publint": "^0.2.2",
|
|
27
|
+
"tsup": "^7.2.0",
|
|
26
28
|
"typescript": "^5.2.2"
|
|
27
29
|
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"package-compile": "tsup && publint",
|
|
32
|
+
"package-recompile": "tsup && publint"
|
|
33
|
+
},
|
|
28
34
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
29
|
-
"browser": "dist/esm/index.js",
|
|
30
35
|
"docs": "dist/docs.json",
|
|
36
|
+
"types": "dist/index.d.ts",
|
|
31
37
|
"exports": {
|
|
32
38
|
".": {
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
},
|
|
37
|
-
"browser": {
|
|
38
|
-
"import": "./dist/esm/index.js",
|
|
39
|
-
"require": "./dist/cjs/index.js"
|
|
39
|
+
"require": {
|
|
40
|
+
"types": "./dist/index.d.ts",
|
|
41
|
+
"default": "./dist/index.js"
|
|
40
42
|
},
|
|
41
|
-
"
|
|
43
|
+
"import": {
|
|
44
|
+
"types": "./dist/index.d.mts",
|
|
45
|
+
"default": "./dist/index.mjs"
|
|
46
|
+
}
|
|
42
47
|
},
|
|
43
48
|
"./dist/docs.json": {
|
|
44
49
|
"default": "./dist/docs.json"
|
|
45
50
|
},
|
|
51
|
+
"./cjs": {
|
|
52
|
+
"default": "./dist/index.js"
|
|
53
|
+
},
|
|
54
|
+
"./docs": {
|
|
55
|
+
"default": "./dist/docs.json"
|
|
56
|
+
},
|
|
57
|
+
"./esm": {
|
|
58
|
+
"default": "./dist/index.mjs"
|
|
59
|
+
},
|
|
46
60
|
"./package.json": "./package.json"
|
|
47
61
|
},
|
|
48
|
-
"main": "dist/
|
|
49
|
-
"module": "dist/
|
|
62
|
+
"main": "dist/index.js",
|
|
63
|
+
"module": "dist/index.mjs",
|
|
50
64
|
"homepage": "https://xyo.network",
|
|
51
65
|
"license": "LGPL-3.0",
|
|
52
66
|
"publishConfig": {
|
|
@@ -57,6 +71,5 @@
|
|
|
57
71
|
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js.git"
|
|
58
72
|
},
|
|
59
73
|
"sideEffects": false,
|
|
60
|
-
"
|
|
61
|
-
"version": "2.72.8"
|
|
74
|
+
"version": "2.73.0"
|
|
62
75
|
}
|
package/tsup.config.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { defineConfig } from 'tsup'
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line import/no-default-export
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
bundle: true,
|
|
6
|
+
cjsInterop: true,
|
|
7
|
+
clean: true,
|
|
8
|
+
dts: {
|
|
9
|
+
entry: ['src/index.ts'],
|
|
10
|
+
},
|
|
11
|
+
entry: ['src/index.ts'],
|
|
12
|
+
format: ['cjs', 'esm'],
|
|
13
|
+
sourcemap: true,
|
|
14
|
+
splitting: false,
|
|
15
|
+
tsconfig: 'tsconfig.json',
|
|
16
|
+
})
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MemoryAddressChainDiviner = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const assert_1 = require("@xylabs/assert");
|
|
6
|
-
const boundwitness_wrapper_1 = require("@xyo-network/boundwitness-wrapper");
|
|
7
|
-
const diviner_address_chain_abstract_1 = require("@xyo-network/diviner-address-chain-abstract");
|
|
8
|
-
const diviner_address_chain_model_1 = require("@xyo-network/diviner-address-chain-model");
|
|
9
|
-
class MemoryAddressChainDiviner extends diviner_address_chain_abstract_1.AddressChainDiviner {
|
|
10
|
-
get queryAddress() {
|
|
11
|
-
return (0, assert_1.assertEx)(this.config.address, 'Missing address');
|
|
12
|
-
}
|
|
13
|
-
divineHandler(payloads) {
|
|
14
|
-
var _a;
|
|
15
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
const result = [];
|
|
17
|
-
(0, assert_1.assertEx)(!(payloads === null || payloads === void 0 ? void 0 : payloads.length), 'MemoryAddressChainDiviner.divine does not allow payloads to be sent');
|
|
18
|
-
try {
|
|
19
|
-
const archivistIn = yield this.readArchivist();
|
|
20
|
-
const archivist = (0, assert_1.assertEx)(archivistIn, 'Unable to resolve archivist');
|
|
21
|
-
let currentHash = (0, assert_1.assertEx)(this.config.startHash, 'Missing startHash');
|
|
22
|
-
while (currentHash && result.length < ((_a = this.config.maxResults) !== null && _a !== void 0 ? _a : 1000)) {
|
|
23
|
-
const bwPayload = yield this.archivistFindHash([archivist], currentHash);
|
|
24
|
-
const bwWrapper = boundwitness_wrapper_1.BoundWitnessWrapper.tryParse(bwPayload);
|
|
25
|
-
if (bwWrapper) {
|
|
26
|
-
result.push(bwWrapper.payload());
|
|
27
|
-
currentHash = bwWrapper.prev(this.queryAddress);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
catch (ex) {
|
|
32
|
-
console.log(ex);
|
|
33
|
-
}
|
|
34
|
-
return result;
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
archivistFindHash(archivists, hash) {
|
|
38
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
let index = 0;
|
|
40
|
-
if (archivists[index]) {
|
|
41
|
-
const result = (yield archivists[index].get([hash])).pop();
|
|
42
|
-
if (result) {
|
|
43
|
-
return result;
|
|
44
|
-
}
|
|
45
|
-
index++;
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
exports.MemoryAddressChainDiviner = MemoryAddressChainDiviner;
|
|
51
|
-
MemoryAddressChainDiviner.configSchemas = [diviner_address_chain_model_1.AddressChainDivinerConfigSchema];
|
|
52
|
-
//# sourceMappingURL=MemoryDiviner.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MemoryDiviner.js","sourceRoot":"","sources":["../../src/MemoryDiviner.ts"],"names":[],"mappings":";;;;AAAA,2CAAyC;AAGzC,4EAAuE;AACvE,gGAAiF;AACjF,0FAAqH;AASrH,MAAa,yBAEX,SAAQ,oDAA4B;IAGpC,IAAI,YAAY;QACd,OAAO,IAAA,iBAAQ,EAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAA;IACzD,CAAC;IAEwB,aAAa,CAAC,QAAoB;;;YACzD,MAAM,MAAM,GAAc,EAAE,CAAA;YAC5B,IAAA,iBAAQ,EAAC,CAAC,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,MAAM,CAAA,EAAE,qEAAqE,CAAC,CAAA;YAClG,IAAI;gBACF,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,aAAa,EAAE,CAAA;gBAC9C,MAAM,SAAS,GAAG,IAAA,iBAAQ,EAAC,WAAW,EAAE,6BAA6B,CAAC,CAAA;gBACtE,IAAI,WAAW,GAAkB,IAAA,iBAAQ,EAAC,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAA;gBACrF,OAAO,WAAW,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,MAAA,IAAI,CAAC,MAAM,CAAC,UAAU,mCAAI,IAAI,CAAC,EAAE;oBACtE,MAAM,SAAS,GAA6B,MAAM,IAAI,CAAC,iBAAiB,CAAC,CAAC,SAAS,CAAC,EAAE,WAAW,CAAC,CAAA;oBAClG,MAAM,SAAS,GAAoC,0CAAmB,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAA;oBAC1F,IAAI,SAAS,EAAE;wBACb,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,CAAA;wBAChC,WAAW,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;qBAChD;iBACF;aACF;YAAC,OAAO,EAAE,EAAE;gBACX,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;aAChB;YACD,OAAO,MAAM,CAAA;;KACd;IAEa,iBAAiB,CAAC,UAA+B,EAAE,IAAY;;YAC3E,IAAI,KAAK,GAAG,CAAC,CAAA;YACb,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE;gBACrB,MAAM,MAAM,GAAG,CAAC,MAAM,UAAU,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,EAAkB,CAAA;gBAC1E,IAAI,MAAM,EAAE;oBACV,OAAO,MAAM,CAAA;iBACd;gBACD,KAAK,EAAE,CAAA;aACR;QACH,CAAC;KAAA;;AAvCH,8DAwCC;AArCiB,uCAAa,GAAG,CAAC,6DAA+B,CAAC,CAAA"}
|
package/dist/cjs/index.js
DELETED
package/dist/cjs/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,0DAA+B"}
|