@xyo-network/diviner-address-chain-memory 2.106.0 → 2.107.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/browser/index.cjs +1 -85
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.js +1 -64
- package/dist/browser/index.js.map +1 -1
- package/dist/neutral/index.cjs +1 -85
- package/dist/neutral/index.cjs.map +1 -1
- package/dist/neutral/index.js +1 -64
- package/dist/neutral/index.js.map +1 -1
- package/dist/node/index.cjs +1 -93
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.js +1 -68
- package/dist/node/index.js.map +1 -1
- package/package.json +19 -19
- package/src/MemoryDiviner.ts +1 -1
package/dist/browser/index.cjs
CHANGED
|
@@ -1,86 +1,2 @@
|
|
|
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 __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
|
|
21
|
-
// src/index.ts
|
|
22
|
-
var src_exports = {};
|
|
23
|
-
__export(src_exports, {
|
|
24
|
-
MemoryAddressChainDiviner: () => MemoryAddressChainDiviner
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(src_exports);
|
|
27
|
-
|
|
28
|
-
// src/MemoryDiviner.ts
|
|
29
|
-
var import_assert = require("@xylabs/assert");
|
|
30
|
-
var import_boundwitness_model = require("@xyo-network/boundwitness-model");
|
|
31
|
-
var import_boundwitness_wrapper = require("@xyo-network/boundwitness-wrapper");
|
|
32
|
-
var import_diviner_address_chain_abstract = require("@xyo-network/diviner-address-chain-abstract");
|
|
33
|
-
var import_diviner_address_chain_model = require("@xyo-network/diviner-address-chain-model");
|
|
34
|
-
var MemoryAddressChainDiviner = class extends import_diviner_address_chain_abstract.AddressChainDiviner {
|
|
35
|
-
static {
|
|
36
|
-
__name(this, "MemoryAddressChainDiviner");
|
|
37
|
-
}
|
|
38
|
-
static configSchemas = [
|
|
39
|
-
...super.configSchemas,
|
|
40
|
-
import_diviner_address_chain_model.AddressChainDivinerConfigSchema
|
|
41
|
-
];
|
|
42
|
-
static defaultConfigSchema = import_diviner_address_chain_model.AddressChainDivinerConfigSchema;
|
|
43
|
-
get queryAddress() {
|
|
44
|
-
return (0, import_assert.assertEx)(this.config.address, () => "Missing address");
|
|
45
|
-
}
|
|
46
|
-
async divineHandler(payloads) {
|
|
47
|
-
const result = [];
|
|
48
|
-
(0, import_assert.assertEx)(!payloads?.length, () => "MemoryAddressChainDiviner.divine does not allow payloads to be sent");
|
|
49
|
-
try {
|
|
50
|
-
const archivistIn = await this.archivistInstance();
|
|
51
|
-
const archivist = (0, import_assert.assertEx)(archivistIn, () => "Unable to resolve archivist");
|
|
52
|
-
let currentHash = (0, import_assert.assertEx)(this.config.startHash, () => "Missing startHash");
|
|
53
|
-
while (currentHash && result.length < (this.config.maxResults ?? 1e3)) {
|
|
54
|
-
console.log(`currentHash: ${currentHash}`);
|
|
55
|
-
const bwPayload = await this.archivistFindHash([
|
|
56
|
-
archivist
|
|
57
|
-
], currentHash);
|
|
58
|
-
const bwWrapper = import_boundwitness_wrapper.BoundWitnessWrapper.tryParse(bwPayload);
|
|
59
|
-
if (bwWrapper) {
|
|
60
|
-
result.push(bwWrapper.payload);
|
|
61
|
-
currentHash = bwWrapper.prev(this.queryAddress);
|
|
62
|
-
} else {
|
|
63
|
-
console.log(`Hash is not a BoundWitness [${currentHash}]`);
|
|
64
|
-
currentHash = null;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
} catch (ex) {
|
|
68
|
-
console.log(ex);
|
|
69
|
-
}
|
|
70
|
-
return result;
|
|
71
|
-
}
|
|
72
|
-
async archivistFindHash(archivists, hash) {
|
|
73
|
-
console.log("archivistFindHash");
|
|
74
|
-
let index = 0;
|
|
75
|
-
if (archivists[index]) {
|
|
76
|
-
const result = (await archivists[index].get([
|
|
77
|
-
hash
|
|
78
|
-
])).filter(import_boundwitness_model.isBoundWitnessWithMeta).pop();
|
|
79
|
-
if (result) {
|
|
80
|
-
return result;
|
|
81
|
-
}
|
|
82
|
-
index++;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
};
|
|
1
|
+
"use strict";var o=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var l=(t,s)=>o(t,"name",{value:s,configurable:!0});var H=(t,s)=>{for(var i in s)o(t,i,{get:s[i],enumerable:!0})},w=(t,s,i,e)=>{if(s&&typeof s=="object"||typeof s=="function")for(let a of v(s))!y.call(t,a)&&a!==i&&o(t,a,{get:()=>s[a],enumerable:!(e=p(s,a))||e.enumerable});return t};var x=t=>w(o({},"__esModule",{value:!0}),t);var W={};H(W,{MemoryAddressChainDiviner:()=>d});module.exports=x(W);var r=require("@xylabs/assert"),f=require("@xyo-network/boundwitness-model"),g=require("@xyo-network/boundwitness-wrapper"),u=require("@xyo-network/diviner-address-chain-abstract"),h=require("@xyo-network/diviner-address-chain-model");var d=class extends u.AddressChainDiviner{static{l(this,"MemoryAddressChainDiviner")}static configSchemas=[...super.configSchemas,h.AddressChainDivinerConfigSchema];static defaultConfigSchema=h.AddressChainDivinerConfigSchema;get queryAddress(){return(0,r.assertEx)(this.config.address,()=>"Missing address")}async divineHandler(s){let i=[];(0,r.assertEx)(!s?.length,()=>"MemoryAddressChainDiviner.divine does not allow payloads to be sent");try{let e=await this.archivistInstance(),a=(0,r.assertEx)(e,()=>"Unable to resolve archivist"),n=(0,r.assertEx)(this.config.startHash,()=>"Missing startHash");for(;n&&i.length<(this.config.maxResults??1e3);){console.log(`currentHash: ${n}`);let m=await this.archivistFindHash([a],n),c=g.BoundWitnessWrapper.tryParse(m);c?(i.push(c.payload),n=c.prev(this.queryAddress)):(console.log(`Hash is not a BoundWitness [${n}]`),n=null)}}catch(e){console.log(e)}return i}async archivistFindHash(s,i){console.log("archivistFindHash");let e=0;if(s[e]){let a=(await s[e].get([i])).findLast(f.isBoundWitnessWithMeta);if(a)return a;e++}}};
|
|
86
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
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, Schema } from '@xyo-network/payload-model'\n\n// This diviner returns the most recent boundwitness signed by the address that can be found\n// if multiple broken chains are found, all the heads are returned\nexport type MemoryAddressChainDivinerParams = DivinerParams<AnyConfigSchema<AddressChainDivinerConfig>>\n\nexport class MemoryAddressChainDiviner<\n TParams extends MemoryAddressChainDivinerParams = MemoryAddressChainDivinerParams,\n> extends AddressChainDiviner<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, AddressChainDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = AddressChainDivinerConfigSchema\n\n get queryAddress() {\n return assertEx(this.config.address, () => 'Missing address')\n }\n\n protected override async divineHandler(payloads?: Payload[]): Promise<Payload[]> {\n const result: Payload[] = []\n assertEx(!payloads?.length, () => 'MemoryAddressChainDiviner.divine does not allow payloads to be sent')\n try {\n const archivistIn = await this.archivistInstance()\n const archivist = assertEx(archivistIn, () => 'Unable to resolve archivist')\n let currentHash: Hash | null = assertEx(this.config.startHash, () => 'Missing startHash')\n while (currentHash && result.length < (this.config.maxResults ?? 1000)) {\n console.log(`currentHash: ${currentHash}`)\n const bwPayload: BoundWitness | undefined = await this.archivistFindHash([archivist], currentHash)\n const bwWrapper: BoundWitnessWrapper | undefined = BoundWitnessWrapper.tryParse(bwPayload)\n if (bwWrapper) {\n result.push(bwWrapper.payload)\n currentHash = bwWrapper.prev(this.queryAddress)\n } else {\n //was not a bound witness - bail\n console.log(`Hash is not a BoundWitness [${currentHash}]`)\n currentHash = null\n }\n }\n } catch (ex) {\n console.log(ex)\n }\n return result\n }\n\n private async archivistFindHash(archivists: ArchivistInstance[], hash: Hash): Promise<BoundWitness | undefined> {\n console.log('archivistFindHash')\n let index = 0\n if (archivists[index]) {\n const result = (await archivists[index].get([hash])).
|
|
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, Schema } from '@xyo-network/payload-model'\n\n// This diviner returns the most recent boundwitness signed by the address that can be found\n// if multiple broken chains are found, all the heads are returned\nexport type MemoryAddressChainDivinerParams = DivinerParams<AnyConfigSchema<AddressChainDivinerConfig>>\n\nexport class MemoryAddressChainDiviner<\n TParams extends MemoryAddressChainDivinerParams = MemoryAddressChainDivinerParams,\n> extends AddressChainDiviner<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, AddressChainDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = AddressChainDivinerConfigSchema\n\n get queryAddress() {\n return assertEx(this.config.address, () => 'Missing address')\n }\n\n protected override async divineHandler(payloads?: Payload[]): Promise<Payload[]> {\n const result: Payload[] = []\n assertEx(!payloads?.length, () => 'MemoryAddressChainDiviner.divine does not allow payloads to be sent')\n try {\n const archivistIn = await this.archivistInstance()\n const archivist = assertEx(archivistIn, () => 'Unable to resolve archivist')\n let currentHash: Hash | null = assertEx(this.config.startHash, () => 'Missing startHash')\n while (currentHash && result.length < (this.config.maxResults ?? 1000)) {\n console.log(`currentHash: ${currentHash}`)\n const bwPayload: BoundWitness | undefined = await this.archivistFindHash([archivist], currentHash)\n const bwWrapper: BoundWitnessWrapper | undefined = BoundWitnessWrapper.tryParse(bwPayload)\n if (bwWrapper) {\n result.push(bwWrapper.payload)\n currentHash = bwWrapper.prev(this.queryAddress)\n } else {\n //was not a bound witness - bail\n console.log(`Hash is not a BoundWitness [${currentHash}]`)\n currentHash = null\n }\n }\n } catch (ex) {\n console.log(ex)\n }\n return result\n }\n\n private async archivistFindHash(archivists: ArchivistInstance[], hash: Hash): Promise<BoundWitness | undefined> {\n console.log('archivistFindHash')\n let index = 0\n if (archivists[index]) {\n const result = (await archivists[index].get([hash])).findLast(isBoundWitnessWithMeta)\n if (result) {\n return result\n }\n index++\n }\n }\n}\n"],"mappings":"4dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,+BAAAE,IAAA,eAAAC,EAAAH,GCAA,IAAAI,EAAyB,0BAGzBC,EAAqD,2CACrDC,EAAoC,6CACpCC,EAAoC,uDACpCC,EAA2E,oDASpE,IAAMC,EAAN,cAEGC,qBAAAA,CAjBV,MAiBUA,CAAAA,EAAAA,kCACR,OAAyBC,cAA0B,IAAI,MAAMA,cAAeC,mCAC5E,OAAyBC,oBAA8BD,kCAEvD,IAAIE,cAAe,CACjB,SAAOC,YAAS,KAAKC,OAAOC,QAAS,IAAM,iBAAA,CAC7C,CAEA,MAAyBC,cAAcC,EAA0C,CAC/E,IAAMC,EAAoB,CAAA,KAC1BL,YAAS,CAACI,GAAUE,OAAQ,IAAM,qEAAA,EAClC,GAAI,CACF,IAAMC,EAAc,MAAM,KAAKC,kBAAiB,EAC1CC,KAAYT,YAASO,EAAa,IAAM,6BAAA,EAC1CG,KAA2BV,YAAS,KAAKC,OAAOU,UAAW,IAAM,mBAAA,EACrE,KAAOD,GAAeL,EAAOC,QAAU,KAAKL,OAAOW,YAAc,MAAO,CACtEC,QAAQC,IAAI,gBAAgBJ,CAAAA,EAAa,EACzC,IAAMK,EAAsC,MAAM,KAAKC,kBAAkB,CAACP,GAAYC,CAAAA,EAChFO,EAA6CC,sBAAoBC,SAASJ,CAAAA,EAC5EE,GACFZ,EAAOe,KAAKH,EAAUI,OAAO,EAC7BX,EAAcO,EAAUK,KAAK,KAAKvB,YAAY,IAG9Cc,QAAQC,IAAI,+BAA+BJ,CAAAA,GAAc,EACzDA,EAAc,KAElB,CACF,OAASa,EAAI,CACXV,QAAQC,IAAIS,CAAAA,CACd,CACA,OAAOlB,CACT,CAEA,MAAcW,kBAAkBQ,EAAiCC,EAA+C,CAC9GZ,QAAQC,IAAI,mBAAA,EACZ,IAAIY,EAAQ,EACZ,GAAIF,EAAWE,CAAAA,EAAQ,CACrB,IAAMrB,GAAU,MAAMmB,EAAWE,CAAAA,EAAOC,IAAI,CAACF,EAAK,GAAGG,SAASC,wBAAAA,EAC9D,GAAIxB,EACF,OAAOA,EAETqB,GACF,CACF,CACF","names":["src_exports","__export","MemoryAddressChainDiviner","__toCommonJS","import_assert","import_boundwitness_model","import_boundwitness_wrapper","import_diviner_address_chain_abstract","import_diviner_address_chain_model","MemoryAddressChainDiviner","AddressChainDiviner","configSchemas","AddressChainDivinerConfigSchema","defaultConfigSchema","queryAddress","assertEx","config","address","divineHandler","payloads","result","length","archivistIn","archivistInstance","archivist","currentHash","startHash","maxResults","console","log","bwPayload","archivistFindHash","bwWrapper","BoundWitnessWrapper","tryParse","push","payload","prev","ex","archivists","hash","index","get","findLast","isBoundWitnessWithMeta"]}
|
package/dist/browser/index.js
CHANGED
|
@@ -1,65 +1,2 @@
|
|
|
1
|
-
var
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
|
-
// src/MemoryDiviner.ts
|
|
5
|
-
import { assertEx } from "@xylabs/assert";
|
|
6
|
-
import { isBoundWitnessWithMeta } from "@xyo-network/boundwitness-model";
|
|
7
|
-
import { BoundWitnessWrapper } from "@xyo-network/boundwitness-wrapper";
|
|
8
|
-
import { AddressChainDiviner } from "@xyo-network/diviner-address-chain-abstract";
|
|
9
|
-
import { AddressChainDivinerConfigSchema } from "@xyo-network/diviner-address-chain-model";
|
|
10
|
-
var MemoryAddressChainDiviner = class extends AddressChainDiviner {
|
|
11
|
-
static {
|
|
12
|
-
__name(this, "MemoryAddressChainDiviner");
|
|
13
|
-
}
|
|
14
|
-
static configSchemas = [
|
|
15
|
-
...super.configSchemas,
|
|
16
|
-
AddressChainDivinerConfigSchema
|
|
17
|
-
];
|
|
18
|
-
static defaultConfigSchema = AddressChainDivinerConfigSchema;
|
|
19
|
-
get queryAddress() {
|
|
20
|
-
return assertEx(this.config.address, () => "Missing address");
|
|
21
|
-
}
|
|
22
|
-
async divineHandler(payloads) {
|
|
23
|
-
const result = [];
|
|
24
|
-
assertEx(!payloads?.length, () => "MemoryAddressChainDiviner.divine does not allow payloads to be sent");
|
|
25
|
-
try {
|
|
26
|
-
const archivistIn = await this.archivistInstance();
|
|
27
|
-
const archivist = assertEx(archivistIn, () => "Unable to resolve archivist");
|
|
28
|
-
let currentHash = assertEx(this.config.startHash, () => "Missing startHash");
|
|
29
|
-
while (currentHash && result.length < (this.config.maxResults ?? 1e3)) {
|
|
30
|
-
console.log(`currentHash: ${currentHash}`);
|
|
31
|
-
const bwPayload = await this.archivistFindHash([
|
|
32
|
-
archivist
|
|
33
|
-
], currentHash);
|
|
34
|
-
const bwWrapper = BoundWitnessWrapper.tryParse(bwPayload);
|
|
35
|
-
if (bwWrapper) {
|
|
36
|
-
result.push(bwWrapper.payload);
|
|
37
|
-
currentHash = bwWrapper.prev(this.queryAddress);
|
|
38
|
-
} else {
|
|
39
|
-
console.log(`Hash is not a BoundWitness [${currentHash}]`);
|
|
40
|
-
currentHash = null;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
} catch (ex) {
|
|
44
|
-
console.log(ex);
|
|
45
|
-
}
|
|
46
|
-
return result;
|
|
47
|
-
}
|
|
48
|
-
async archivistFindHash(archivists, hash) {
|
|
49
|
-
console.log("archivistFindHash");
|
|
50
|
-
let index = 0;
|
|
51
|
-
if (archivists[index]) {
|
|
52
|
-
const result = (await archivists[index].get([
|
|
53
|
-
hash
|
|
54
|
-
])).filter(isBoundWitnessWithMeta).pop();
|
|
55
|
-
if (result) {
|
|
56
|
-
return result;
|
|
57
|
-
}
|
|
58
|
-
index++;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
export {
|
|
63
|
-
MemoryAddressChainDiviner
|
|
64
|
-
};
|
|
1
|
+
var f=Object.defineProperty;var c=(o,t)=>f(o,"name",{value:t,configurable:!0});import{assertEx as n}from"@xylabs/assert";import{isBoundWitnessWithMeta as g}from"@xyo-network/boundwitness-model";import{BoundWitnessWrapper as u}from"@xyo-network/boundwitness-wrapper";import{AddressChainDiviner as m}from"@xyo-network/diviner-address-chain-abstract";import{AddressChainDivinerConfigSchema as h}from"@xyo-network/diviner-address-chain-model";var d=class extends m{static{c(this,"MemoryAddressChainDiviner")}static configSchemas=[...super.configSchemas,h];static defaultConfigSchema=h;get queryAddress(){return n(this.config.address,()=>"Missing address")}async divineHandler(t){let e=[];n(!t?.length,()=>"MemoryAddressChainDiviner.divine does not allow payloads to be sent");try{let s=await this.archivistInstance(),a=n(s,()=>"Unable to resolve archivist"),i=n(this.config.startHash,()=>"Missing startHash");for(;i&&e.length<(this.config.maxResults??1e3);){console.log(`currentHash: ${i}`);let l=await this.archivistFindHash([a],i),r=u.tryParse(l);r?(e.push(r.payload),i=r.prev(this.queryAddress)):(console.log(`Hash is not a BoundWitness [${i}]`),i=null)}}catch(s){console.log(s)}return e}async archivistFindHash(t,e){console.log("archivistFindHash");let s=0;if(t[s]){let a=(await t[s].get([e])).findLast(g);if(a)return a;s++}}};export{d as MemoryAddressChainDiviner};
|
|
65
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
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, Schema } from '@xyo-network/payload-model'\n\n// This diviner returns the most recent boundwitness signed by the address that can be found\n// if multiple broken chains are found, all the heads are returned\nexport type MemoryAddressChainDivinerParams = DivinerParams<AnyConfigSchema<AddressChainDivinerConfig>>\n\nexport class MemoryAddressChainDiviner<\n TParams extends MemoryAddressChainDivinerParams = MemoryAddressChainDivinerParams,\n> extends AddressChainDiviner<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, AddressChainDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = AddressChainDivinerConfigSchema\n\n get queryAddress() {\n return assertEx(this.config.address, () => 'Missing address')\n }\n\n protected override async divineHandler(payloads?: Payload[]): Promise<Payload[]> {\n const result: Payload[] = []\n assertEx(!payloads?.length, () => 'MemoryAddressChainDiviner.divine does not allow payloads to be sent')\n try {\n const archivistIn = await this.archivistInstance()\n const archivist = assertEx(archivistIn, () => 'Unable to resolve archivist')\n let currentHash: Hash | null = assertEx(this.config.startHash, () => 'Missing startHash')\n while (currentHash && result.length < (this.config.maxResults ?? 1000)) {\n console.log(`currentHash: ${currentHash}`)\n const bwPayload: BoundWitness | undefined = await this.archivistFindHash([archivist], currentHash)\n const bwWrapper: BoundWitnessWrapper | undefined = BoundWitnessWrapper.tryParse(bwPayload)\n if (bwWrapper) {\n result.push(bwWrapper.payload)\n currentHash = bwWrapper.prev(this.queryAddress)\n } else {\n //was not a bound witness - bail\n console.log(`Hash is not a BoundWitness [${currentHash}]`)\n currentHash = null\n }\n }\n } catch (ex) {\n console.log(ex)\n }\n return result\n }\n\n private async archivistFindHash(archivists: ArchivistInstance[], hash: Hash): Promise<BoundWitness | undefined> {\n console.log('archivistFindHash')\n let index = 0\n if (archivists[index]) {\n const result = (await archivists[index].get([hash])).
|
|
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, Schema } from '@xyo-network/payload-model'\n\n// This diviner returns the most recent boundwitness signed by the address that can be found\n// if multiple broken chains are found, all the heads are returned\nexport type MemoryAddressChainDivinerParams = DivinerParams<AnyConfigSchema<AddressChainDivinerConfig>>\n\nexport class MemoryAddressChainDiviner<\n TParams extends MemoryAddressChainDivinerParams = MemoryAddressChainDivinerParams,\n> extends AddressChainDiviner<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, AddressChainDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = AddressChainDivinerConfigSchema\n\n get queryAddress() {\n return assertEx(this.config.address, () => 'Missing address')\n }\n\n protected override async divineHandler(payloads?: Payload[]): Promise<Payload[]> {\n const result: Payload[] = []\n assertEx(!payloads?.length, () => 'MemoryAddressChainDiviner.divine does not allow payloads to be sent')\n try {\n const archivistIn = await this.archivistInstance()\n const archivist = assertEx(archivistIn, () => 'Unable to resolve archivist')\n let currentHash: Hash | null = assertEx(this.config.startHash, () => 'Missing startHash')\n while (currentHash && result.length < (this.config.maxResults ?? 1000)) {\n console.log(`currentHash: ${currentHash}`)\n const bwPayload: BoundWitness | undefined = await this.archivistFindHash([archivist], currentHash)\n const bwWrapper: BoundWitnessWrapper | undefined = BoundWitnessWrapper.tryParse(bwPayload)\n if (bwWrapper) {\n result.push(bwWrapper.payload)\n currentHash = bwWrapper.prev(this.queryAddress)\n } else {\n //was not a bound witness - bail\n console.log(`Hash is not a BoundWitness [${currentHash}]`)\n currentHash = null\n }\n }\n } catch (ex) {\n console.log(ex)\n }\n return result\n }\n\n private async archivistFindHash(archivists: ArchivistInstance[], hash: Hash): Promise<BoundWitness | undefined> {\n console.log('archivistFindHash')\n let index = 0\n if (archivists[index]) {\n const result = (await archivists[index].get([hash])).findLast(isBoundWitnessWithMeta)\n if (result) {\n return result\n }\n index++\n }\n }\n}\n"],"mappings":"+EAAA,OAASA,YAAAA,MAAgB,iBAGzB,OAAuBC,0BAAAA,MAA8B,kCACrD,OAASC,uBAAAA,MAA2B,oCACpC,OAASC,uBAAAA,MAA2B,8CACpC,OAAoCC,mCAAAA,MAAuC,2CASpE,IAAMC,EAAN,cAEGC,CAAAA,CAjBV,MAiBUA,CAAAA,EAAAA,kCACR,OAAyBC,cAA0B,IAAI,MAAMA,cAAeC,GAC5E,OAAyBC,oBAA8BD,EAEvD,IAAIE,cAAe,CACjB,OAAOC,EAAS,KAAKC,OAAOC,QAAS,IAAM,iBAAA,CAC7C,CAEA,MAAyBC,cAAcC,EAA0C,CAC/E,IAAMC,EAAoB,CAAA,EAC1BL,EAAS,CAACI,GAAUE,OAAQ,IAAM,qEAAA,EAClC,GAAI,CACF,IAAMC,EAAc,MAAM,KAAKC,kBAAiB,EAC1CC,EAAYT,EAASO,EAAa,IAAM,6BAAA,EAC1CG,EAA2BV,EAAS,KAAKC,OAAOU,UAAW,IAAM,mBAAA,EACrE,KAAOD,GAAeL,EAAOC,QAAU,KAAKL,OAAOW,YAAc,MAAO,CACtEC,QAAQC,IAAI,gBAAgBJ,CAAAA,EAAa,EACzC,IAAMK,EAAsC,MAAM,KAAKC,kBAAkB,CAACP,GAAYC,CAAAA,EAChFO,EAA6CC,EAAoBC,SAASJ,CAAAA,EAC5EE,GACFZ,EAAOe,KAAKH,EAAUI,OAAO,EAC7BX,EAAcO,EAAUK,KAAK,KAAKvB,YAAY,IAG9Cc,QAAQC,IAAI,+BAA+BJ,CAAAA,GAAc,EACzDA,EAAc,KAElB,CACF,OAASa,EAAI,CACXV,QAAQC,IAAIS,CAAAA,CACd,CACA,OAAOlB,CACT,CAEA,MAAcW,kBAAkBQ,EAAiCC,EAA+C,CAC9GZ,QAAQC,IAAI,mBAAA,EACZ,IAAIY,EAAQ,EACZ,GAAIF,EAAWE,CAAAA,EAAQ,CACrB,IAAMrB,GAAU,MAAMmB,EAAWE,CAAAA,EAAOC,IAAI,CAACF,EAAK,GAAGG,SAASC,CAAAA,EAC9D,GAAIxB,EACF,OAAOA,EAETqB,GACF,CACF,CACF","names":["assertEx","isBoundWitnessWithMeta","BoundWitnessWrapper","AddressChainDiviner","AddressChainDivinerConfigSchema","MemoryAddressChainDiviner","AddressChainDiviner","configSchemas","AddressChainDivinerConfigSchema","defaultConfigSchema","queryAddress","assertEx","config","address","divineHandler","payloads","result","length","archivistIn","archivistInstance","archivist","currentHash","startHash","maxResults","console","log","bwPayload","archivistFindHash","bwWrapper","BoundWitnessWrapper","tryParse","push","payload","prev","ex","archivists","hash","index","get","findLast","isBoundWitnessWithMeta"]}
|
package/dist/neutral/index.cjs
CHANGED
|
@@ -1,86 +1,2 @@
|
|
|
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 __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
|
|
21
|
-
// src/index.ts
|
|
22
|
-
var src_exports = {};
|
|
23
|
-
__export(src_exports, {
|
|
24
|
-
MemoryAddressChainDiviner: () => MemoryAddressChainDiviner
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(src_exports);
|
|
27
|
-
|
|
28
|
-
// src/MemoryDiviner.ts
|
|
29
|
-
var import_assert = require("@xylabs/assert");
|
|
30
|
-
var import_boundwitness_model = require("@xyo-network/boundwitness-model");
|
|
31
|
-
var import_boundwitness_wrapper = require("@xyo-network/boundwitness-wrapper");
|
|
32
|
-
var import_diviner_address_chain_abstract = require("@xyo-network/diviner-address-chain-abstract");
|
|
33
|
-
var import_diviner_address_chain_model = require("@xyo-network/diviner-address-chain-model");
|
|
34
|
-
var MemoryAddressChainDiviner = class extends import_diviner_address_chain_abstract.AddressChainDiviner {
|
|
35
|
-
static {
|
|
36
|
-
__name(this, "MemoryAddressChainDiviner");
|
|
37
|
-
}
|
|
38
|
-
static configSchemas = [
|
|
39
|
-
...super.configSchemas,
|
|
40
|
-
import_diviner_address_chain_model.AddressChainDivinerConfigSchema
|
|
41
|
-
];
|
|
42
|
-
static defaultConfigSchema = import_diviner_address_chain_model.AddressChainDivinerConfigSchema;
|
|
43
|
-
get queryAddress() {
|
|
44
|
-
return (0, import_assert.assertEx)(this.config.address, () => "Missing address");
|
|
45
|
-
}
|
|
46
|
-
async divineHandler(payloads) {
|
|
47
|
-
const result = [];
|
|
48
|
-
(0, import_assert.assertEx)(!payloads?.length, () => "MemoryAddressChainDiviner.divine does not allow payloads to be sent");
|
|
49
|
-
try {
|
|
50
|
-
const archivistIn = await this.archivistInstance();
|
|
51
|
-
const archivist = (0, import_assert.assertEx)(archivistIn, () => "Unable to resolve archivist");
|
|
52
|
-
let currentHash = (0, import_assert.assertEx)(this.config.startHash, () => "Missing startHash");
|
|
53
|
-
while (currentHash && result.length < (this.config.maxResults ?? 1e3)) {
|
|
54
|
-
console.log(`currentHash: ${currentHash}`);
|
|
55
|
-
const bwPayload = await this.archivistFindHash([
|
|
56
|
-
archivist
|
|
57
|
-
], currentHash);
|
|
58
|
-
const bwWrapper = import_boundwitness_wrapper.BoundWitnessWrapper.tryParse(bwPayload);
|
|
59
|
-
if (bwWrapper) {
|
|
60
|
-
result.push(bwWrapper.payload);
|
|
61
|
-
currentHash = bwWrapper.prev(this.queryAddress);
|
|
62
|
-
} else {
|
|
63
|
-
console.log(`Hash is not a BoundWitness [${currentHash}]`);
|
|
64
|
-
currentHash = null;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
} catch (ex) {
|
|
68
|
-
console.log(ex);
|
|
69
|
-
}
|
|
70
|
-
return result;
|
|
71
|
-
}
|
|
72
|
-
async archivistFindHash(archivists, hash) {
|
|
73
|
-
console.log("archivistFindHash");
|
|
74
|
-
let index = 0;
|
|
75
|
-
if (archivists[index]) {
|
|
76
|
-
const result = (await archivists[index].get([
|
|
77
|
-
hash
|
|
78
|
-
])).filter(import_boundwitness_model.isBoundWitnessWithMeta).pop();
|
|
79
|
-
if (result) {
|
|
80
|
-
return result;
|
|
81
|
-
}
|
|
82
|
-
index++;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
};
|
|
1
|
+
"use strict";var o=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var l=(t,s)=>o(t,"name",{value:s,configurable:!0});var H=(t,s)=>{for(var i in s)o(t,i,{get:s[i],enumerable:!0})},w=(t,s,i,e)=>{if(s&&typeof s=="object"||typeof s=="function")for(let a of v(s))!y.call(t,a)&&a!==i&&o(t,a,{get:()=>s[a],enumerable:!(e=p(s,a))||e.enumerable});return t};var x=t=>w(o({},"__esModule",{value:!0}),t);var W={};H(W,{MemoryAddressChainDiviner:()=>d});module.exports=x(W);var r=require("@xylabs/assert"),f=require("@xyo-network/boundwitness-model"),g=require("@xyo-network/boundwitness-wrapper"),u=require("@xyo-network/diviner-address-chain-abstract"),h=require("@xyo-network/diviner-address-chain-model");var d=class extends u.AddressChainDiviner{static{l(this,"MemoryAddressChainDiviner")}static configSchemas=[...super.configSchemas,h.AddressChainDivinerConfigSchema];static defaultConfigSchema=h.AddressChainDivinerConfigSchema;get queryAddress(){return(0,r.assertEx)(this.config.address,()=>"Missing address")}async divineHandler(s){let i=[];(0,r.assertEx)(!s?.length,()=>"MemoryAddressChainDiviner.divine does not allow payloads to be sent");try{let e=await this.archivistInstance(),a=(0,r.assertEx)(e,()=>"Unable to resolve archivist"),n=(0,r.assertEx)(this.config.startHash,()=>"Missing startHash");for(;n&&i.length<(this.config.maxResults??1e3);){console.log(`currentHash: ${n}`);let m=await this.archivistFindHash([a],n),c=g.BoundWitnessWrapper.tryParse(m);c?(i.push(c.payload),n=c.prev(this.queryAddress)):(console.log(`Hash is not a BoundWitness [${n}]`),n=null)}}catch(e){console.log(e)}return i}async archivistFindHash(s,i){console.log("archivistFindHash");let e=0;if(s[e]){let a=(await s[e].get([i])).findLast(f.isBoundWitnessWithMeta);if(a)return a;e++}}};
|
|
86
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
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, Schema } from '@xyo-network/payload-model'\n\n// This diviner returns the most recent boundwitness signed by the address that can be found\n// if multiple broken chains are found, all the heads are returned\nexport type MemoryAddressChainDivinerParams = DivinerParams<AnyConfigSchema<AddressChainDivinerConfig>>\n\nexport class MemoryAddressChainDiviner<\n TParams extends MemoryAddressChainDivinerParams = MemoryAddressChainDivinerParams,\n> extends AddressChainDiviner<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, AddressChainDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = AddressChainDivinerConfigSchema\n\n get queryAddress() {\n return assertEx(this.config.address, () => 'Missing address')\n }\n\n protected override async divineHandler(payloads?: Payload[]): Promise<Payload[]> {\n const result: Payload[] = []\n assertEx(!payloads?.length, () => 'MemoryAddressChainDiviner.divine does not allow payloads to be sent')\n try {\n const archivistIn = await this.archivistInstance()\n const archivist = assertEx(archivistIn, () => 'Unable to resolve archivist')\n let currentHash: Hash | null = assertEx(this.config.startHash, () => 'Missing startHash')\n while (currentHash && result.length < (this.config.maxResults ?? 1000)) {\n console.log(`currentHash: ${currentHash}`)\n const bwPayload: BoundWitness | undefined = await this.archivistFindHash([archivist], currentHash)\n const bwWrapper: BoundWitnessWrapper | undefined = BoundWitnessWrapper.tryParse(bwPayload)\n if (bwWrapper) {\n result.push(bwWrapper.payload)\n currentHash = bwWrapper.prev(this.queryAddress)\n } else {\n //was not a bound witness - bail\n console.log(`Hash is not a BoundWitness [${currentHash}]`)\n currentHash = null\n }\n }\n } catch (ex) {\n console.log(ex)\n }\n return result\n }\n\n private async archivistFindHash(archivists: ArchivistInstance[], hash: Hash): Promise<BoundWitness | undefined> {\n console.log('archivistFindHash')\n let index = 0\n if (archivists[index]) {\n const result = (await archivists[index].get([hash])).
|
|
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, Schema } from '@xyo-network/payload-model'\n\n// This diviner returns the most recent boundwitness signed by the address that can be found\n// if multiple broken chains are found, all the heads are returned\nexport type MemoryAddressChainDivinerParams = DivinerParams<AnyConfigSchema<AddressChainDivinerConfig>>\n\nexport class MemoryAddressChainDiviner<\n TParams extends MemoryAddressChainDivinerParams = MemoryAddressChainDivinerParams,\n> extends AddressChainDiviner<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, AddressChainDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = AddressChainDivinerConfigSchema\n\n get queryAddress() {\n return assertEx(this.config.address, () => 'Missing address')\n }\n\n protected override async divineHandler(payloads?: Payload[]): Promise<Payload[]> {\n const result: Payload[] = []\n assertEx(!payloads?.length, () => 'MemoryAddressChainDiviner.divine does not allow payloads to be sent')\n try {\n const archivistIn = await this.archivistInstance()\n const archivist = assertEx(archivistIn, () => 'Unable to resolve archivist')\n let currentHash: Hash | null = assertEx(this.config.startHash, () => 'Missing startHash')\n while (currentHash && result.length < (this.config.maxResults ?? 1000)) {\n console.log(`currentHash: ${currentHash}`)\n const bwPayload: BoundWitness | undefined = await this.archivistFindHash([archivist], currentHash)\n const bwWrapper: BoundWitnessWrapper | undefined = BoundWitnessWrapper.tryParse(bwPayload)\n if (bwWrapper) {\n result.push(bwWrapper.payload)\n currentHash = bwWrapper.prev(this.queryAddress)\n } else {\n //was not a bound witness - bail\n console.log(`Hash is not a BoundWitness [${currentHash}]`)\n currentHash = null\n }\n }\n } catch (ex) {\n console.log(ex)\n }\n return result\n }\n\n private async archivistFindHash(archivists: ArchivistInstance[], hash: Hash): Promise<BoundWitness | undefined> {\n console.log('archivistFindHash')\n let index = 0\n if (archivists[index]) {\n const result = (await archivists[index].get([hash])).findLast(isBoundWitnessWithMeta)\n if (result) {\n return result\n }\n index++\n }\n }\n}\n"],"mappings":"4dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,+BAAAE,IAAA,eAAAC,EAAAH,GCAA,IAAAI,EAAyB,0BAGzBC,EAAqD,2CACrDC,EAAoC,6CACpCC,EAAoC,uDACpCC,EAA2E,oDASpE,IAAMC,EAAN,cAEGC,qBAAAA,CAjBV,MAiBUA,CAAAA,EAAAA,kCACR,OAAyBC,cAA0B,IAAI,MAAMA,cAAeC,mCAC5E,OAAyBC,oBAA8BD,kCAEvD,IAAIE,cAAe,CACjB,SAAOC,YAAS,KAAKC,OAAOC,QAAS,IAAM,iBAAA,CAC7C,CAEA,MAAyBC,cAAcC,EAA0C,CAC/E,IAAMC,EAAoB,CAAA,KAC1BL,YAAS,CAACI,GAAUE,OAAQ,IAAM,qEAAA,EAClC,GAAI,CACF,IAAMC,EAAc,MAAM,KAAKC,kBAAiB,EAC1CC,KAAYT,YAASO,EAAa,IAAM,6BAAA,EAC1CG,KAA2BV,YAAS,KAAKC,OAAOU,UAAW,IAAM,mBAAA,EACrE,KAAOD,GAAeL,EAAOC,QAAU,KAAKL,OAAOW,YAAc,MAAO,CACtEC,QAAQC,IAAI,gBAAgBJ,CAAAA,EAAa,EACzC,IAAMK,EAAsC,MAAM,KAAKC,kBAAkB,CAACP,GAAYC,CAAAA,EAChFO,EAA6CC,sBAAoBC,SAASJ,CAAAA,EAC5EE,GACFZ,EAAOe,KAAKH,EAAUI,OAAO,EAC7BX,EAAcO,EAAUK,KAAK,KAAKvB,YAAY,IAG9Cc,QAAQC,IAAI,+BAA+BJ,CAAAA,GAAc,EACzDA,EAAc,KAElB,CACF,OAASa,EAAI,CACXV,QAAQC,IAAIS,CAAAA,CACd,CACA,OAAOlB,CACT,CAEA,MAAcW,kBAAkBQ,EAAiCC,EAA+C,CAC9GZ,QAAQC,IAAI,mBAAA,EACZ,IAAIY,EAAQ,EACZ,GAAIF,EAAWE,CAAAA,EAAQ,CACrB,IAAMrB,GAAU,MAAMmB,EAAWE,CAAAA,EAAOC,IAAI,CAACF,EAAK,GAAGG,SAASC,wBAAAA,EAC9D,GAAIxB,EACF,OAAOA,EAETqB,GACF,CACF,CACF","names":["src_exports","__export","MemoryAddressChainDiviner","__toCommonJS","import_assert","import_boundwitness_model","import_boundwitness_wrapper","import_diviner_address_chain_abstract","import_diviner_address_chain_model","MemoryAddressChainDiviner","AddressChainDiviner","configSchemas","AddressChainDivinerConfigSchema","defaultConfigSchema","queryAddress","assertEx","config","address","divineHandler","payloads","result","length","archivistIn","archivistInstance","archivist","currentHash","startHash","maxResults","console","log","bwPayload","archivistFindHash","bwWrapper","BoundWitnessWrapper","tryParse","push","payload","prev","ex","archivists","hash","index","get","findLast","isBoundWitnessWithMeta"]}
|
package/dist/neutral/index.js
CHANGED
|
@@ -1,65 +1,2 @@
|
|
|
1
|
-
var
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
|
-
// src/MemoryDiviner.ts
|
|
5
|
-
import { assertEx } from "@xylabs/assert";
|
|
6
|
-
import { isBoundWitnessWithMeta } from "@xyo-network/boundwitness-model";
|
|
7
|
-
import { BoundWitnessWrapper } from "@xyo-network/boundwitness-wrapper";
|
|
8
|
-
import { AddressChainDiviner } from "@xyo-network/diviner-address-chain-abstract";
|
|
9
|
-
import { AddressChainDivinerConfigSchema } from "@xyo-network/diviner-address-chain-model";
|
|
10
|
-
var MemoryAddressChainDiviner = class extends AddressChainDiviner {
|
|
11
|
-
static {
|
|
12
|
-
__name(this, "MemoryAddressChainDiviner");
|
|
13
|
-
}
|
|
14
|
-
static configSchemas = [
|
|
15
|
-
...super.configSchemas,
|
|
16
|
-
AddressChainDivinerConfigSchema
|
|
17
|
-
];
|
|
18
|
-
static defaultConfigSchema = AddressChainDivinerConfigSchema;
|
|
19
|
-
get queryAddress() {
|
|
20
|
-
return assertEx(this.config.address, () => "Missing address");
|
|
21
|
-
}
|
|
22
|
-
async divineHandler(payloads) {
|
|
23
|
-
const result = [];
|
|
24
|
-
assertEx(!payloads?.length, () => "MemoryAddressChainDiviner.divine does not allow payloads to be sent");
|
|
25
|
-
try {
|
|
26
|
-
const archivistIn = await this.archivistInstance();
|
|
27
|
-
const archivist = assertEx(archivistIn, () => "Unable to resolve archivist");
|
|
28
|
-
let currentHash = assertEx(this.config.startHash, () => "Missing startHash");
|
|
29
|
-
while (currentHash && result.length < (this.config.maxResults ?? 1e3)) {
|
|
30
|
-
console.log(`currentHash: ${currentHash}`);
|
|
31
|
-
const bwPayload = await this.archivistFindHash([
|
|
32
|
-
archivist
|
|
33
|
-
], currentHash);
|
|
34
|
-
const bwWrapper = BoundWitnessWrapper.tryParse(bwPayload);
|
|
35
|
-
if (bwWrapper) {
|
|
36
|
-
result.push(bwWrapper.payload);
|
|
37
|
-
currentHash = bwWrapper.prev(this.queryAddress);
|
|
38
|
-
} else {
|
|
39
|
-
console.log(`Hash is not a BoundWitness [${currentHash}]`);
|
|
40
|
-
currentHash = null;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
} catch (ex) {
|
|
44
|
-
console.log(ex);
|
|
45
|
-
}
|
|
46
|
-
return result;
|
|
47
|
-
}
|
|
48
|
-
async archivistFindHash(archivists, hash) {
|
|
49
|
-
console.log("archivistFindHash");
|
|
50
|
-
let index = 0;
|
|
51
|
-
if (archivists[index]) {
|
|
52
|
-
const result = (await archivists[index].get([
|
|
53
|
-
hash
|
|
54
|
-
])).filter(isBoundWitnessWithMeta).pop();
|
|
55
|
-
if (result) {
|
|
56
|
-
return result;
|
|
57
|
-
}
|
|
58
|
-
index++;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
export {
|
|
63
|
-
MemoryAddressChainDiviner
|
|
64
|
-
};
|
|
1
|
+
var f=Object.defineProperty;var c=(o,t)=>f(o,"name",{value:t,configurable:!0});import{assertEx as n}from"@xylabs/assert";import{isBoundWitnessWithMeta as g}from"@xyo-network/boundwitness-model";import{BoundWitnessWrapper as u}from"@xyo-network/boundwitness-wrapper";import{AddressChainDiviner as m}from"@xyo-network/diviner-address-chain-abstract";import{AddressChainDivinerConfigSchema as h}from"@xyo-network/diviner-address-chain-model";var d=class extends m{static{c(this,"MemoryAddressChainDiviner")}static configSchemas=[...super.configSchemas,h];static defaultConfigSchema=h;get queryAddress(){return n(this.config.address,()=>"Missing address")}async divineHandler(t){let e=[];n(!t?.length,()=>"MemoryAddressChainDiviner.divine does not allow payloads to be sent");try{let s=await this.archivistInstance(),a=n(s,()=>"Unable to resolve archivist"),i=n(this.config.startHash,()=>"Missing startHash");for(;i&&e.length<(this.config.maxResults??1e3);){console.log(`currentHash: ${i}`);let l=await this.archivistFindHash([a],i),r=u.tryParse(l);r?(e.push(r.payload),i=r.prev(this.queryAddress)):(console.log(`Hash is not a BoundWitness [${i}]`),i=null)}}catch(s){console.log(s)}return e}async archivistFindHash(t,e){console.log("archivistFindHash");let s=0;if(t[s]){let a=(await t[s].get([e])).findLast(g);if(a)return a;s++}}};export{d as MemoryAddressChainDiviner};
|
|
65
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
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, Schema } from '@xyo-network/payload-model'\n\n// This diviner returns the most recent boundwitness signed by the address that can be found\n// if multiple broken chains are found, all the heads are returned\nexport type MemoryAddressChainDivinerParams = DivinerParams<AnyConfigSchema<AddressChainDivinerConfig>>\n\nexport class MemoryAddressChainDiviner<\n TParams extends MemoryAddressChainDivinerParams = MemoryAddressChainDivinerParams,\n> extends AddressChainDiviner<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, AddressChainDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = AddressChainDivinerConfigSchema\n\n get queryAddress() {\n return assertEx(this.config.address, () => 'Missing address')\n }\n\n protected override async divineHandler(payloads?: Payload[]): Promise<Payload[]> {\n const result: Payload[] = []\n assertEx(!payloads?.length, () => 'MemoryAddressChainDiviner.divine does not allow payloads to be sent')\n try {\n const archivistIn = await this.archivistInstance()\n const archivist = assertEx(archivistIn, () => 'Unable to resolve archivist')\n let currentHash: Hash | null = assertEx(this.config.startHash, () => 'Missing startHash')\n while (currentHash && result.length < (this.config.maxResults ?? 1000)) {\n console.log(`currentHash: ${currentHash}`)\n const bwPayload: BoundWitness | undefined = await this.archivistFindHash([archivist], currentHash)\n const bwWrapper: BoundWitnessWrapper | undefined = BoundWitnessWrapper.tryParse(bwPayload)\n if (bwWrapper) {\n result.push(bwWrapper.payload)\n currentHash = bwWrapper.prev(this.queryAddress)\n } else {\n //was not a bound witness - bail\n console.log(`Hash is not a BoundWitness [${currentHash}]`)\n currentHash = null\n }\n }\n } catch (ex) {\n console.log(ex)\n }\n return result\n }\n\n private async archivistFindHash(archivists: ArchivistInstance[], hash: Hash): Promise<BoundWitness | undefined> {\n console.log('archivistFindHash')\n let index = 0\n if (archivists[index]) {\n const result = (await archivists[index].get([hash])).
|
|
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, Schema } from '@xyo-network/payload-model'\n\n// This diviner returns the most recent boundwitness signed by the address that can be found\n// if multiple broken chains are found, all the heads are returned\nexport type MemoryAddressChainDivinerParams = DivinerParams<AnyConfigSchema<AddressChainDivinerConfig>>\n\nexport class MemoryAddressChainDiviner<\n TParams extends MemoryAddressChainDivinerParams = MemoryAddressChainDivinerParams,\n> extends AddressChainDiviner<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, AddressChainDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = AddressChainDivinerConfigSchema\n\n get queryAddress() {\n return assertEx(this.config.address, () => 'Missing address')\n }\n\n protected override async divineHandler(payloads?: Payload[]): Promise<Payload[]> {\n const result: Payload[] = []\n assertEx(!payloads?.length, () => 'MemoryAddressChainDiviner.divine does not allow payloads to be sent')\n try {\n const archivistIn = await this.archivistInstance()\n const archivist = assertEx(archivistIn, () => 'Unable to resolve archivist')\n let currentHash: Hash | null = assertEx(this.config.startHash, () => 'Missing startHash')\n while (currentHash && result.length < (this.config.maxResults ?? 1000)) {\n console.log(`currentHash: ${currentHash}`)\n const bwPayload: BoundWitness | undefined = await this.archivistFindHash([archivist], currentHash)\n const bwWrapper: BoundWitnessWrapper | undefined = BoundWitnessWrapper.tryParse(bwPayload)\n if (bwWrapper) {\n result.push(bwWrapper.payload)\n currentHash = bwWrapper.prev(this.queryAddress)\n } else {\n //was not a bound witness - bail\n console.log(`Hash is not a BoundWitness [${currentHash}]`)\n currentHash = null\n }\n }\n } catch (ex) {\n console.log(ex)\n }\n return result\n }\n\n private async archivistFindHash(archivists: ArchivistInstance[], hash: Hash): Promise<BoundWitness | undefined> {\n console.log('archivistFindHash')\n let index = 0\n if (archivists[index]) {\n const result = (await archivists[index].get([hash])).findLast(isBoundWitnessWithMeta)\n if (result) {\n return result\n }\n index++\n }\n }\n}\n"],"mappings":"+EAAA,OAASA,YAAAA,MAAgB,iBAGzB,OAAuBC,0BAAAA,MAA8B,kCACrD,OAASC,uBAAAA,MAA2B,oCACpC,OAASC,uBAAAA,MAA2B,8CACpC,OAAoCC,mCAAAA,MAAuC,2CASpE,IAAMC,EAAN,cAEGC,CAAAA,CAjBV,MAiBUA,CAAAA,EAAAA,kCACR,OAAyBC,cAA0B,IAAI,MAAMA,cAAeC,GAC5E,OAAyBC,oBAA8BD,EAEvD,IAAIE,cAAe,CACjB,OAAOC,EAAS,KAAKC,OAAOC,QAAS,IAAM,iBAAA,CAC7C,CAEA,MAAyBC,cAAcC,EAA0C,CAC/E,IAAMC,EAAoB,CAAA,EAC1BL,EAAS,CAACI,GAAUE,OAAQ,IAAM,qEAAA,EAClC,GAAI,CACF,IAAMC,EAAc,MAAM,KAAKC,kBAAiB,EAC1CC,EAAYT,EAASO,EAAa,IAAM,6BAAA,EAC1CG,EAA2BV,EAAS,KAAKC,OAAOU,UAAW,IAAM,mBAAA,EACrE,KAAOD,GAAeL,EAAOC,QAAU,KAAKL,OAAOW,YAAc,MAAO,CACtEC,QAAQC,IAAI,gBAAgBJ,CAAAA,EAAa,EACzC,IAAMK,EAAsC,MAAM,KAAKC,kBAAkB,CAACP,GAAYC,CAAAA,EAChFO,EAA6CC,EAAoBC,SAASJ,CAAAA,EAC5EE,GACFZ,EAAOe,KAAKH,EAAUI,OAAO,EAC7BX,EAAcO,EAAUK,KAAK,KAAKvB,YAAY,IAG9Cc,QAAQC,IAAI,+BAA+BJ,CAAAA,GAAc,EACzDA,EAAc,KAElB,CACF,OAASa,EAAI,CACXV,QAAQC,IAAIS,CAAAA,CACd,CACA,OAAOlB,CACT,CAEA,MAAcW,kBAAkBQ,EAAiCC,EAA+C,CAC9GZ,QAAQC,IAAI,mBAAA,EACZ,IAAIY,EAAQ,EACZ,GAAIF,EAAWE,CAAAA,EAAQ,CACrB,IAAMrB,GAAU,MAAMmB,EAAWE,CAAAA,EAAOC,IAAI,CAACF,EAAK,GAAGG,SAASC,CAAAA,EAC9D,GAAIxB,EACF,OAAOA,EAETqB,GACF,CACF,CACF","names":["assertEx","isBoundWitnessWithMeta","BoundWitnessWrapper","AddressChainDiviner","AddressChainDivinerConfigSchema","MemoryAddressChainDiviner","AddressChainDiviner","configSchemas","AddressChainDivinerConfigSchema","defaultConfigSchema","queryAddress","assertEx","config","address","divineHandler","payloads","result","length","archivistIn","archivistInstance","archivist","currentHash","startHash","maxResults","console","log","bwPayload","archivistFindHash","bwWrapper","BoundWitnessWrapper","tryParse","push","payload","prev","ex","archivists","hash","index","get","findLast","isBoundWitnessWithMeta"]}
|
package/dist/node/index.cjs
CHANGED
|
@@ -1,94 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __reflectGet = Reflect.get;
|
|
8
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
10
|
-
var __export = (target, all) => {
|
|
11
|
-
for (var name in all)
|
|
12
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
13
|
-
};
|
|
14
|
-
var __copyProps = (to, from, except, desc) => {
|
|
15
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
-
for (let key of __getOwnPropNames(from))
|
|
17
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
24
|
-
var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
|
|
25
|
-
|
|
26
|
-
// src/index.ts
|
|
27
|
-
var src_exports = {};
|
|
28
|
-
__export(src_exports, {
|
|
29
|
-
MemoryAddressChainDiviner: () => MemoryAddressChainDiviner
|
|
30
|
-
});
|
|
31
|
-
module.exports = __toCommonJS(src_exports);
|
|
32
|
-
|
|
33
|
-
// src/MemoryDiviner.ts
|
|
34
|
-
var import_assert = require("@xylabs/assert");
|
|
35
|
-
var import_boundwitness_model = require("@xyo-network/boundwitness-model");
|
|
36
|
-
var import_boundwitness_wrapper = require("@xyo-network/boundwitness-wrapper");
|
|
37
|
-
var import_diviner_address_chain_abstract = require("@xyo-network/diviner-address-chain-abstract");
|
|
38
|
-
var import_diviner_address_chain_model = require("@xyo-network/diviner-address-chain-model");
|
|
39
|
-
var _MemoryAddressChainDiviner = class _MemoryAddressChainDiviner extends import_diviner_address_chain_abstract.AddressChainDiviner {
|
|
40
|
-
get queryAddress() {
|
|
41
|
-
return (0, import_assert.assertEx)(this.config.address, () => "Missing address");
|
|
42
|
-
}
|
|
43
|
-
async divineHandler(payloads) {
|
|
44
|
-
const result = [];
|
|
45
|
-
(0, import_assert.assertEx)(!(payloads == null ? void 0 : payloads.length), () => "MemoryAddressChainDiviner.divine does not allow payloads to be sent");
|
|
46
|
-
try {
|
|
47
|
-
const archivistIn = await this.archivistInstance();
|
|
48
|
-
const archivist = (0, import_assert.assertEx)(archivistIn, () => "Unable to resolve archivist");
|
|
49
|
-
let currentHash = (0, import_assert.assertEx)(this.config.startHash, () => "Missing startHash");
|
|
50
|
-
while (currentHash && result.length < (this.config.maxResults ?? 1e3)) {
|
|
51
|
-
console.log(`currentHash: ${currentHash}`);
|
|
52
|
-
const bwPayload = await this.archivistFindHash([
|
|
53
|
-
archivist
|
|
54
|
-
], currentHash);
|
|
55
|
-
const bwWrapper = import_boundwitness_wrapper.BoundWitnessWrapper.tryParse(bwPayload);
|
|
56
|
-
if (bwWrapper) {
|
|
57
|
-
result.push(bwWrapper.payload);
|
|
58
|
-
currentHash = bwWrapper.prev(this.queryAddress);
|
|
59
|
-
} else {
|
|
60
|
-
console.log(`Hash is not a BoundWitness [${currentHash}]`);
|
|
61
|
-
currentHash = null;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
} catch (ex) {
|
|
65
|
-
console.log(ex);
|
|
66
|
-
}
|
|
67
|
-
return result;
|
|
68
|
-
}
|
|
69
|
-
async archivistFindHash(archivists, hash) {
|
|
70
|
-
console.log("archivistFindHash");
|
|
71
|
-
let index = 0;
|
|
72
|
-
if (archivists[index]) {
|
|
73
|
-
const result = (await archivists[index].get([
|
|
74
|
-
hash
|
|
75
|
-
])).filter(import_boundwitness_model.isBoundWitnessWithMeta).pop();
|
|
76
|
-
if (result) {
|
|
77
|
-
return result;
|
|
78
|
-
}
|
|
79
|
-
index++;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
__name(_MemoryAddressChainDiviner, "MemoryAddressChainDiviner");
|
|
84
|
-
__publicField(_MemoryAddressChainDiviner, "configSchemas", [
|
|
85
|
-
...__superGet(_MemoryAddressChainDiviner, _MemoryAddressChainDiviner, "configSchemas"),
|
|
86
|
-
import_diviner_address_chain_model.AddressChainDivinerConfigSchema
|
|
87
|
-
]);
|
|
88
|
-
__publicField(_MemoryAddressChainDiviner, "defaultConfigSchema", import_diviner_address_chain_model.AddressChainDivinerConfigSchema);
|
|
89
|
-
var MemoryAddressChainDiviner = _MemoryAddressChainDiviner;
|
|
90
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
91
|
-
0 && (module.exports = {
|
|
92
|
-
MemoryAddressChainDiviner
|
|
93
|
-
});
|
|
1
|
+
"use strict";var r=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var W=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty;var S=Reflect.get;var B=(s,t,i)=>t in s?r(s,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):s[t]=i;var u=(s,t)=>r(s,"name",{value:t,configurable:!0});var F=(s,t)=>{for(var i in t)r(s,i,{get:t[i],enumerable:!0})},q=(s,t,i,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of x(t))!b.call(s,n)&&n!==i&&r(s,n,{get:()=>t[n],enumerable:!(e=w(t,n))||e.enumerable});return s};var I=s=>q(r({},"__esModule",{value:!0}),s);var l=(s,t,i)=>B(s,typeof t!="symbol"?t+"":t,i);var d=(s,t,i)=>S(W(s),i,t);var P={};F(P,{MemoryAddressChainDiviner:()=>g});module.exports=I(P);var c=require("@xylabs/assert"),p=require("@xyo-network/boundwitness-model"),m=require("@xyo-network/boundwitness-wrapper"),H=require("@xyo-network/diviner-address-chain-abstract"),f=require("@xyo-network/diviner-address-chain-model");var a=class a extends H.AddressChainDiviner{get queryAddress(){return(0,c.assertEx)(this.config.address,()=>"Missing address")}async divineHandler(t){let i=[];(0,c.assertEx)(!(t!=null&&t.length),()=>"MemoryAddressChainDiviner.divine does not allow payloads to be sent");try{let e=await this.archivistInstance(),n=(0,c.assertEx)(e,()=>"Unable to resolve archivist"),o=(0,c.assertEx)(this.config.startHash,()=>"Missing startHash");for(;o&&i.length<(this.config.maxResults??1e3);){console.log(`currentHash: ${o}`);let v=await this.archivistFindHash([n],o),h=m.BoundWitnessWrapper.tryParse(v);h?(i.push(h.payload),o=h.prev(this.queryAddress)):(console.log(`Hash is not a BoundWitness [${o}]`),o=null)}}catch(e){console.log(e)}return i}async archivistFindHash(t,i){console.log("archivistFindHash");let e=0;if(t[e]){let n=(await t[e].get([i])).findLast(p.isBoundWitnessWithMeta);if(n)return n;e++}}};u(a,"MemoryAddressChainDiviner"),l(a,"configSchemas",[...d(a,a,"configSchemas"),f.AddressChainDivinerConfigSchema]),l(a,"defaultConfigSchema",f.AddressChainDivinerConfigSchema);var g=a;0&&(module.exports={MemoryAddressChainDiviner});
|
|
94
2
|
//# sourceMappingURL=index.cjs.map
|
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 { 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, Schema } from '@xyo-network/payload-model'\n\n// This diviner returns the most recent boundwitness signed by the address that can be found\n// if multiple broken chains are found, all the heads are returned\nexport type MemoryAddressChainDivinerParams = DivinerParams<AnyConfigSchema<AddressChainDivinerConfig>>\n\nexport class MemoryAddressChainDiviner<\n TParams extends MemoryAddressChainDivinerParams = MemoryAddressChainDivinerParams,\n> extends AddressChainDiviner<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, AddressChainDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = AddressChainDivinerConfigSchema\n\n get queryAddress() {\n return assertEx(this.config.address, () => 'Missing address')\n }\n\n protected override async divineHandler(payloads?: Payload[]): Promise<Payload[]> {\n const result: Payload[] = []\n assertEx(!payloads?.length, () => 'MemoryAddressChainDiviner.divine does not allow payloads to be sent')\n try {\n const archivistIn = await this.archivistInstance()\n const archivist = assertEx(archivistIn, () => 'Unable to resolve archivist')\n let currentHash: Hash | null = assertEx(this.config.startHash, () => 'Missing startHash')\n while (currentHash && result.length < (this.config.maxResults ?? 1000)) {\n console.log(`currentHash: ${currentHash}`)\n const bwPayload: BoundWitness | undefined = await this.archivistFindHash([archivist], currentHash)\n const bwWrapper: BoundWitnessWrapper | undefined = BoundWitnessWrapper.tryParse(bwPayload)\n if (bwWrapper) {\n result.push(bwWrapper.payload)\n currentHash = bwWrapper.prev(this.queryAddress)\n } else {\n //was not a bound witness - bail\n console.log(`Hash is not a BoundWitness [${currentHash}]`)\n currentHash = null\n }\n }\n } catch (ex) {\n console.log(ex)\n }\n return result\n }\n\n private async archivistFindHash(archivists: ArchivistInstance[], hash: Hash): Promise<BoundWitness | undefined> {\n console.log('archivistFindHash')\n let index = 0\n if (archivists[index]) {\n const result = (await archivists[index].get([hash])).
|
|
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, Schema } from '@xyo-network/payload-model'\n\n// This diviner returns the most recent boundwitness signed by the address that can be found\n// if multiple broken chains are found, all the heads are returned\nexport type MemoryAddressChainDivinerParams = DivinerParams<AnyConfigSchema<AddressChainDivinerConfig>>\n\nexport class MemoryAddressChainDiviner<\n TParams extends MemoryAddressChainDivinerParams = MemoryAddressChainDivinerParams,\n> extends AddressChainDiviner<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, AddressChainDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = AddressChainDivinerConfigSchema\n\n get queryAddress() {\n return assertEx(this.config.address, () => 'Missing address')\n }\n\n protected override async divineHandler(payloads?: Payload[]): Promise<Payload[]> {\n const result: Payload[] = []\n assertEx(!payloads?.length, () => 'MemoryAddressChainDiviner.divine does not allow payloads to be sent')\n try {\n const archivistIn = await this.archivistInstance()\n const archivist = assertEx(archivistIn, () => 'Unable to resolve archivist')\n let currentHash: Hash | null = assertEx(this.config.startHash, () => 'Missing startHash')\n while (currentHash && result.length < (this.config.maxResults ?? 1000)) {\n console.log(`currentHash: ${currentHash}`)\n const bwPayload: BoundWitness | undefined = await this.archivistFindHash([archivist], currentHash)\n const bwWrapper: BoundWitnessWrapper | undefined = BoundWitnessWrapper.tryParse(bwPayload)\n if (bwWrapper) {\n result.push(bwWrapper.payload)\n currentHash = bwWrapper.prev(this.queryAddress)\n } else {\n //was not a bound witness - bail\n console.log(`Hash is not a BoundWitness [${currentHash}]`)\n currentHash = null\n }\n }\n } catch (ex) {\n console.log(ex)\n }\n return result\n }\n\n private async archivistFindHash(archivists: ArchivistInstance[], hash: Hash): Promise<BoundWitness | undefined> {\n console.log('archivistFindHash')\n let index = 0\n if (archivists[index]) {\n const result = (await archivists[index].get([hash])).findLast(isBoundWitnessWithMeta)\n if (result) {\n return result\n }\n index++\n }\n }\n}\n"],"mappings":"yqBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,+BAAAE,IAAA,eAAAC,EAAAH,GCAA,IAAAI,EAAyB,0BAGzBC,EAAqD,2CACrDC,EAAoC,6CACpCC,EAAoC,uDACpCC,EAA2E,oDASpE,IAAMC,EAAN,MAAMA,UAEHC,qBAAAA,CAIR,IAAIC,cAAe,CACjB,SAAOC,YAAS,KAAKC,OAAOC,QAAS,IAAM,iBAAA,CAC7C,CAEA,MAAyBC,cAAcC,EAA0C,CAC/E,IAAMC,EAAoB,CAAA,KAC1BL,YAAS,EAACI,GAAAA,MAAAA,EAAUE,QAAQ,IAAM,qEAAA,EAClC,GAAI,CACF,IAAMC,EAAc,MAAM,KAAKC,kBAAiB,EAC1CC,KAAYT,YAASO,EAAa,IAAM,6BAAA,EAC1CG,KAA2BV,YAAS,KAAKC,OAAOU,UAAW,IAAM,mBAAA,EACrE,KAAOD,GAAeL,EAAOC,QAAU,KAAKL,OAAOW,YAAc,MAAO,CACtEC,QAAQC,IAAI,gBAAgBJ,CAAAA,EAAa,EACzC,IAAMK,EAAsC,MAAM,KAAKC,kBAAkB,CAACP,GAAYC,CAAAA,EAChFO,EAA6CC,sBAAoBC,SAASJ,CAAAA,EAC5EE,GACFZ,EAAOe,KAAKH,EAAUI,OAAO,EAC7BX,EAAcO,EAAUK,KAAK,KAAKvB,YAAY,IAG9Cc,QAAQC,IAAI,+BAA+BJ,CAAAA,GAAc,EACzDA,EAAc,KAElB,CACF,OAASa,EAAI,CACXV,QAAQC,IAAIS,CAAAA,CACd,CACA,OAAOlB,CACT,CAEA,MAAcW,kBAAkBQ,EAAiCC,EAA+C,CAC9GZ,QAAQC,IAAI,mBAAA,EACZ,IAAIY,EAAQ,EACZ,GAAIF,EAAWE,CAAAA,EAAQ,CACrB,IAAMrB,GAAU,MAAMmB,EAAWE,CAAAA,EAAOC,IAAI,CAACF,EAAK,GAAGG,SAASC,wBAAAA,EAC9D,GAAIxB,EACF,OAAOA,EAETqB,GACF,CACF,CACF,EA7CU5B,EAAAA,EAAAA,6BACRgC,EAHWjC,EAGckC,gBAA0B,IAAIC,EAAAC,IAAMF,iBAAeG,oCAC5EJ,EAJWjC,EAIcsC,sBAA8BD,mCAJlD,IAAMrC,EAANoC","names":["src_exports","__export","MemoryAddressChainDiviner","__toCommonJS","import_assert","import_boundwitness_model","import_boundwitness_wrapper","import_diviner_address_chain_abstract","import_diviner_address_chain_model","MemoryAddressChainDiviner","AddressChainDiviner","queryAddress","assertEx","config","address","divineHandler","payloads","result","length","archivistIn","archivistInstance","archivist","currentHash","startHash","maxResults","console","log","bwPayload","archivistFindHash","bwWrapper","BoundWitnessWrapper","tryParse","push","payload","prev","ex","archivists","hash","index","get","findLast","isBoundWitnessWithMeta","__publicField","configSchemas","__superGet","_MemoryAddressChainDiviner","AddressChainDivinerConfigSchema","defaultConfigSchema"]}
|
package/dist/node/index.js
CHANGED
|
@@ -1,69 +1,2 @@
|
|
|
1
|
-
var
|
|
2
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
3
|
-
var __reflectGet = Reflect.get;
|
|
4
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
|
-
var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
|
|
8
|
-
|
|
9
|
-
// src/MemoryDiviner.ts
|
|
10
|
-
import { assertEx } from "@xylabs/assert";
|
|
11
|
-
import { isBoundWitnessWithMeta } from "@xyo-network/boundwitness-model";
|
|
12
|
-
import { BoundWitnessWrapper } from "@xyo-network/boundwitness-wrapper";
|
|
13
|
-
import { AddressChainDiviner } from "@xyo-network/diviner-address-chain-abstract";
|
|
14
|
-
import { AddressChainDivinerConfigSchema } from "@xyo-network/diviner-address-chain-model";
|
|
15
|
-
var _MemoryAddressChainDiviner = class _MemoryAddressChainDiviner extends AddressChainDiviner {
|
|
16
|
-
get queryAddress() {
|
|
17
|
-
return assertEx(this.config.address, () => "Missing address");
|
|
18
|
-
}
|
|
19
|
-
async divineHandler(payloads) {
|
|
20
|
-
const result = [];
|
|
21
|
-
assertEx(!(payloads == null ? void 0 : payloads.length), () => "MemoryAddressChainDiviner.divine does not allow payloads to be sent");
|
|
22
|
-
try {
|
|
23
|
-
const archivistIn = await this.archivistInstance();
|
|
24
|
-
const archivist = assertEx(archivistIn, () => "Unable to resolve archivist");
|
|
25
|
-
let currentHash = assertEx(this.config.startHash, () => "Missing startHash");
|
|
26
|
-
while (currentHash && result.length < (this.config.maxResults ?? 1e3)) {
|
|
27
|
-
console.log(`currentHash: ${currentHash}`);
|
|
28
|
-
const bwPayload = await this.archivistFindHash([
|
|
29
|
-
archivist
|
|
30
|
-
], currentHash);
|
|
31
|
-
const bwWrapper = BoundWitnessWrapper.tryParse(bwPayload);
|
|
32
|
-
if (bwWrapper) {
|
|
33
|
-
result.push(bwWrapper.payload);
|
|
34
|
-
currentHash = bwWrapper.prev(this.queryAddress);
|
|
35
|
-
} else {
|
|
36
|
-
console.log(`Hash is not a BoundWitness [${currentHash}]`);
|
|
37
|
-
currentHash = null;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
} catch (ex) {
|
|
41
|
-
console.log(ex);
|
|
42
|
-
}
|
|
43
|
-
return result;
|
|
44
|
-
}
|
|
45
|
-
async archivistFindHash(archivists, hash) {
|
|
46
|
-
console.log("archivistFindHash");
|
|
47
|
-
let index = 0;
|
|
48
|
-
if (archivists[index]) {
|
|
49
|
-
const result = (await archivists[index].get([
|
|
50
|
-
hash
|
|
51
|
-
])).filter(isBoundWitnessWithMeta).pop();
|
|
52
|
-
if (result) {
|
|
53
|
-
return result;
|
|
54
|
-
}
|
|
55
|
-
index++;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
__name(_MemoryAddressChainDiviner, "MemoryAddressChainDiviner");
|
|
60
|
-
__publicField(_MemoryAddressChainDiviner, "configSchemas", [
|
|
61
|
-
...__superGet(_MemoryAddressChainDiviner, _MemoryAddressChainDiviner, "configSchemas"),
|
|
62
|
-
AddressChainDivinerConfigSchema
|
|
63
|
-
]);
|
|
64
|
-
__publicField(_MemoryAddressChainDiviner, "defaultConfigSchema", AddressChainDivinerConfigSchema);
|
|
65
|
-
var MemoryAddressChainDiviner = _MemoryAddressChainDiviner;
|
|
66
|
-
export {
|
|
67
|
-
MemoryAddressChainDiviner
|
|
68
|
-
};
|
|
1
|
+
var l=Object.defineProperty;var m=Object.getPrototypeOf;var H=Reflect.get;var v=(i,t,s)=>t in i?l(i,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[t]=s;var f=(i,t)=>l(i,"name",{value:t,configurable:!0});var h=(i,t,s)=>v(i,typeof t!="symbol"?t+"":t,s);var g=(i,t,s)=>H(m(i),s,t);import{assertEx as r}from"@xylabs/assert";import{isBoundWitnessWithMeta as w}from"@xyo-network/boundwitness-model";import{BoundWitnessWrapper as x}from"@xyo-network/boundwitness-wrapper";import{AddressChainDiviner as W}from"@xyo-network/diviner-address-chain-abstract";import{AddressChainDivinerConfigSchema as u}from"@xyo-network/diviner-address-chain-model";var n=class n extends W{get queryAddress(){return r(this.config.address,()=>"Missing address")}async divineHandler(t){let s=[];r(!(t!=null&&t.length),()=>"MemoryAddressChainDiviner.divine does not allow payloads to be sent");try{let e=await this.archivistInstance(),o=r(e,()=>"Unable to resolve archivist"),a=r(this.config.startHash,()=>"Missing startHash");for(;a&&s.length<(this.config.maxResults??1e3);){console.log(`currentHash: ${a}`);let p=await this.archivistFindHash([o],a),c=x.tryParse(p);c?(s.push(c.payload),a=c.prev(this.queryAddress)):(console.log(`Hash is not a BoundWitness [${a}]`),a=null)}}catch(e){console.log(e)}return s}async archivistFindHash(t,s){console.log("archivistFindHash");let e=0;if(t[e]){let o=(await t[e].get([s])).findLast(w);if(o)return o;e++}}};f(n,"MemoryAddressChainDiviner"),h(n,"configSchemas",[...g(n,n,"configSchemas"),u]),h(n,"defaultConfigSchema",u);var d=n;export{d as MemoryAddressChainDiviner};
|
|
69
2
|
//# sourceMappingURL=index.js.map
|
package/dist/node/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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, Schema } from '@xyo-network/payload-model'\n\n// This diviner returns the most recent boundwitness signed by the address that can be found\n// if multiple broken chains are found, all the heads are returned\nexport type MemoryAddressChainDivinerParams = DivinerParams<AnyConfigSchema<AddressChainDivinerConfig>>\n\nexport class MemoryAddressChainDiviner<\n TParams extends MemoryAddressChainDivinerParams = MemoryAddressChainDivinerParams,\n> extends AddressChainDiviner<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, AddressChainDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = AddressChainDivinerConfigSchema\n\n get queryAddress() {\n return assertEx(this.config.address, () => 'Missing address')\n }\n\n protected override async divineHandler(payloads?: Payload[]): Promise<Payload[]> {\n const result: Payload[] = []\n assertEx(!payloads?.length, () => 'MemoryAddressChainDiviner.divine does not allow payloads to be sent')\n try {\n const archivistIn = await this.archivistInstance()\n const archivist = assertEx(archivistIn, () => 'Unable to resolve archivist')\n let currentHash: Hash | null = assertEx(this.config.startHash, () => 'Missing startHash')\n while (currentHash && result.length < (this.config.maxResults ?? 1000)) {\n console.log(`currentHash: ${currentHash}`)\n const bwPayload: BoundWitness | undefined = await this.archivistFindHash([archivist], currentHash)\n const bwWrapper: BoundWitnessWrapper | undefined = BoundWitnessWrapper.tryParse(bwPayload)\n if (bwWrapper) {\n result.push(bwWrapper.payload)\n currentHash = bwWrapper.prev(this.queryAddress)\n } else {\n //was not a bound witness - bail\n console.log(`Hash is not a BoundWitness [${currentHash}]`)\n currentHash = null\n }\n }\n } catch (ex) {\n console.log(ex)\n }\n return result\n }\n\n private async archivistFindHash(archivists: ArchivistInstance[], hash: Hash): Promise<BoundWitness | undefined> {\n console.log('archivistFindHash')\n let index = 0\n if (archivists[index]) {\n const result = (await archivists[index].get([hash])).
|
|
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, Schema } from '@xyo-network/payload-model'\n\n// This diviner returns the most recent boundwitness signed by the address that can be found\n// if multiple broken chains are found, all the heads are returned\nexport type MemoryAddressChainDivinerParams = DivinerParams<AnyConfigSchema<AddressChainDivinerConfig>>\n\nexport class MemoryAddressChainDiviner<\n TParams extends MemoryAddressChainDivinerParams = MemoryAddressChainDivinerParams,\n> extends AddressChainDiviner<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, AddressChainDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = AddressChainDivinerConfigSchema\n\n get queryAddress() {\n return assertEx(this.config.address, () => 'Missing address')\n }\n\n protected override async divineHandler(payloads?: Payload[]): Promise<Payload[]> {\n const result: Payload[] = []\n assertEx(!payloads?.length, () => 'MemoryAddressChainDiviner.divine does not allow payloads to be sent')\n try {\n const archivistIn = await this.archivistInstance()\n const archivist = assertEx(archivistIn, () => 'Unable to resolve archivist')\n let currentHash: Hash | null = assertEx(this.config.startHash, () => 'Missing startHash')\n while (currentHash && result.length < (this.config.maxResults ?? 1000)) {\n console.log(`currentHash: ${currentHash}`)\n const bwPayload: BoundWitness | undefined = await this.archivistFindHash([archivist], currentHash)\n const bwWrapper: BoundWitnessWrapper | undefined = BoundWitnessWrapper.tryParse(bwPayload)\n if (bwWrapper) {\n result.push(bwWrapper.payload)\n currentHash = bwWrapper.prev(this.queryAddress)\n } else {\n //was not a bound witness - bail\n console.log(`Hash is not a BoundWitness [${currentHash}]`)\n currentHash = null\n }\n }\n } catch (ex) {\n console.log(ex)\n }\n return result\n }\n\n private async archivistFindHash(archivists: ArchivistInstance[], hash: Hash): Promise<BoundWitness | undefined> {\n console.log('archivistFindHash')\n let index = 0\n if (archivists[index]) {\n const result = (await archivists[index].get([hash])).findLast(isBoundWitnessWithMeta)\n if (result) {\n return result\n }\n index++\n }\n }\n}\n"],"mappings":"gSAAA,OAASA,YAAAA,MAAgB,iBAGzB,OAAuBC,0BAAAA,MAA8B,kCACrD,OAASC,uBAAAA,MAA2B,oCACpC,OAASC,uBAAAA,MAA2B,8CACpC,OAAoCC,mCAAAA,MAAuC,2CASpE,IAAMC,EAAN,MAAMA,UAEHC,CAAAA,CAIR,IAAIC,cAAe,CACjB,OAAOC,EAAS,KAAKC,OAAOC,QAAS,IAAM,iBAAA,CAC7C,CAEA,MAAyBC,cAAcC,EAA0C,CAC/E,IAAMC,EAAoB,CAAA,EAC1BL,EAAS,EAACI,GAAAA,MAAAA,EAAUE,QAAQ,IAAM,qEAAA,EAClC,GAAI,CACF,IAAMC,EAAc,MAAM,KAAKC,kBAAiB,EAC1CC,EAAYT,EAASO,EAAa,IAAM,6BAAA,EAC1CG,EAA2BV,EAAS,KAAKC,OAAOU,UAAW,IAAM,mBAAA,EACrE,KAAOD,GAAeL,EAAOC,QAAU,KAAKL,OAAOW,YAAc,MAAO,CACtEC,QAAQC,IAAI,gBAAgBJ,CAAAA,EAAa,EACzC,IAAMK,EAAsC,MAAM,KAAKC,kBAAkB,CAACP,GAAYC,CAAAA,EAChFO,EAA6CC,EAAoBC,SAASJ,CAAAA,EAC5EE,GACFZ,EAAOe,KAAKH,EAAUI,OAAO,EAC7BX,EAAcO,EAAUK,KAAK,KAAKvB,YAAY,IAG9Cc,QAAQC,IAAI,+BAA+BJ,CAAAA,GAAc,EACzDA,EAAc,KAElB,CACF,OAASa,EAAI,CACXV,QAAQC,IAAIS,CAAAA,CACd,CACA,OAAOlB,CACT,CAEA,MAAcW,kBAAkBQ,EAAiCC,EAA+C,CAC9GZ,QAAQC,IAAI,mBAAA,EACZ,IAAIY,EAAQ,EACZ,GAAIF,EAAWE,CAAAA,EAAQ,CACrB,IAAMrB,GAAU,MAAMmB,EAAWE,CAAAA,EAAOC,IAAI,CAACF,EAAK,GAAGG,SAASC,CAAAA,EAC9D,GAAIxB,EACF,OAAOA,EAETqB,GACF,CACF,CACF,EA7CU5B,EAAAA,EAAAA,6BACRgC,EAHWjC,EAGckC,gBAA0B,IAAIC,EAAAC,IAAMF,iBAAeG,IAC5EJ,EAJWjC,EAIcsC,sBAA8BD,GAJlD,IAAMrC,EAANoC","names":["assertEx","isBoundWitnessWithMeta","BoundWitnessWrapper","AddressChainDiviner","AddressChainDivinerConfigSchema","MemoryAddressChainDiviner","AddressChainDiviner","queryAddress","assertEx","config","address","divineHandler","payloads","result","length","archivistIn","archivistInstance","archivist","currentHash","startHash","maxResults","console","log","bwPayload","archivistFindHash","bwWrapper","BoundWitnessWrapper","tryParse","push","payload","prev","ex","archivists","hash","index","get","findLast","isBoundWitnessWithMeta","__publicField","configSchemas","__superGet","_MemoryAddressChainDiviner","AddressChainDivinerConfigSchema","defaultConfigSchema"]}
|
package/package.json
CHANGED
|
@@ -12,26 +12,26 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@xylabs/assert": "^3.5.1",
|
|
14
14
|
"@xylabs/hex": "^3.5.1",
|
|
15
|
-
"@xyo-network/archivist-model": "~2.
|
|
16
|
-
"@xyo-network/boundwitness-model": "~2.
|
|
17
|
-
"@xyo-network/boundwitness-wrapper": "~2.
|
|
18
|
-
"@xyo-network/diviner-address-chain-abstract": "~2.
|
|
19
|
-
"@xyo-network/diviner-address-chain-model": "~2.
|
|
20
|
-
"@xyo-network/diviner-model": "~2.
|
|
21
|
-
"@xyo-network/module-model": "~2.
|
|
22
|
-
"@xyo-network/payload-model": "~2.
|
|
15
|
+
"@xyo-network/archivist-model": "~2.107.0",
|
|
16
|
+
"@xyo-network/boundwitness-model": "~2.107.0",
|
|
17
|
+
"@xyo-network/boundwitness-wrapper": "~2.107.0",
|
|
18
|
+
"@xyo-network/diviner-address-chain-abstract": "~2.107.0",
|
|
19
|
+
"@xyo-network/diviner-address-chain-model": "~2.107.0",
|
|
20
|
+
"@xyo-network/diviner-model": "~2.107.0",
|
|
21
|
+
"@xyo-network/module-model": "~2.107.0",
|
|
22
|
+
"@xyo-network/payload-model": "~2.107.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@xylabs/ts-scripts-yarn3": "^3.11.
|
|
26
|
-
"@xylabs/tsconfig": "^3.11.
|
|
27
|
-
"@xyo-network/account": "~2.
|
|
28
|
-
"@xyo-network/archivist-memory": "~2.
|
|
29
|
-
"@xyo-network/archivist-wrapper": "~2.
|
|
30
|
-
"@xyo-network/node-memory": "~2.
|
|
31
|
-
"@xyo-network/node-model": "~2.
|
|
32
|
-
"@xyo-network/payload-builder": "~2.
|
|
33
|
-
"@xyo-network/payload-wrapper": "~2.
|
|
34
|
-
"typescript": "^5.
|
|
25
|
+
"@xylabs/ts-scripts-yarn3": "^3.11.8",
|
|
26
|
+
"@xylabs/tsconfig": "^3.11.8",
|
|
27
|
+
"@xyo-network/account": "~2.107.0",
|
|
28
|
+
"@xyo-network/archivist-memory": "~2.107.0",
|
|
29
|
+
"@xyo-network/archivist-wrapper": "~2.107.0",
|
|
30
|
+
"@xyo-network/node-memory": "~2.107.0",
|
|
31
|
+
"@xyo-network/node-model": "~2.107.0",
|
|
32
|
+
"@xyo-network/payload-builder": "~2.107.0",
|
|
33
|
+
"@xyo-network/payload-wrapper": "~2.107.0",
|
|
34
|
+
"typescript": "^5.5.2"
|
|
35
35
|
},
|
|
36
36
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
37
37
|
"types": "dist/node/index.d.ts",
|
|
@@ -72,6 +72,6 @@
|
|
|
72
72
|
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js.git"
|
|
73
73
|
},
|
|
74
74
|
"sideEffects": false,
|
|
75
|
-
"version": "2.
|
|
75
|
+
"version": "2.107.0",
|
|
76
76
|
"type": "module"
|
|
77
77
|
}
|
package/src/MemoryDiviner.ts
CHANGED
|
@@ -53,7 +53,7 @@ export class MemoryAddressChainDiviner<
|
|
|
53
53
|
console.log('archivistFindHash')
|
|
54
54
|
let index = 0
|
|
55
55
|
if (archivists[index]) {
|
|
56
|
-
const result = (await archivists[index].get([hash])).
|
|
56
|
+
const result = (await archivists[index].get([hash])).findLast(isBoundWitnessWithMeta)
|
|
57
57
|
if (result) {
|
|
58
58
|
return result
|
|
59
59
|
}
|