@xyo-network/diviner-address-chain 6.0.4 → 6.1.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/README.md +3 -1
- package/dist/neutral/MemoryAddressChainDiviner.d.ts +2 -2
- package/dist/neutral/MemoryAddressChainDiviner.d.ts.map +1 -1
- package/dist/neutral/Query.d.ts.map +1 -1
- package/dist/neutral/Schema.d.ts +1 -1
- package/dist/neutral/Schema.d.ts.map +1 -1
- package/dist/neutral/index.mjs.map +2 -2
- package/dist/neutral/memory.mjs.map +2 -2
- package/dist/neutral/model.mjs.map +2 -2
- package/package.json +20 -21
package/README.md
CHANGED
|
@@ -38,10 +38,12 @@ bun add {{name}}
|
|
|
38
38
|
|
|
39
39
|
See the [LICENSE](LICENSE) file for license rights and limitations (LGPL-3.0-only).
|
|
40
40
|
|
|
41
|
+
## Credits
|
|
41
42
|
|
|
43
|
+
[Made with 🔥 and ❄️ by XYO Foundation](https://xyo.network)
|
|
42
44
|
|
|
43
|
-
[logo]: https://cdn.xy.company/img/brand/XYO_full_colored.png
|
|
44
45
|
[npm-badge]: https://img.shields.io/npm/v/@xyo-network/diviner-address-chain.svg
|
|
45
46
|
[npm-link]: https://www.npmjs.com/package/@xyo-network/diviner-address-chain
|
|
46
47
|
[license-badge]: https://img.shields.io/npm/l/@xyo-network/diviner-address-chain.svg
|
|
47
48
|
[license-link]: https://github.com/xylabs/sdk-js/blob/main/LICENSE
|
|
49
|
+
[logo]: https://cdn.xy.company/img/brand/XYO_full_colored.png
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DivinerParams } from '@xyo-network/diviner-model';
|
|
2
2
|
import type { AnyConfigSchema } from '@xyo-network/module-model';
|
|
3
|
-
import type { Payload, Schema } from '@xyo-network/sdk-protocol-js';
|
|
3
|
+
import type { Payload, Schema, XyoQuantAddress } from '@xyo-network/sdk-protocol-js';
|
|
4
4
|
import { AddressChainDiviner } from './AddressChainDiviner.ts';
|
|
5
5
|
import type { AddressChainDivinerConfig } from './Config.ts';
|
|
6
6
|
export type MemoryAddressChainDivinerParams = DivinerParams<AnyConfigSchema<AddressChainDivinerConfig>>;
|
|
@@ -11,7 +11,7 @@ export declare class MemoryAddressChainDiviner<TParams extends MemoryAddressChai
|
|
|
11
11
|
readonly __hex: true;
|
|
12
12
|
} & {
|
|
13
13
|
readonly __address: true;
|
|
14
|
-
}) |
|
|
14
|
+
}) | XyoQuantAddress;
|
|
15
15
|
protected divineHandler(payloads?: Payload[]): Promise<Payload[]>;
|
|
16
16
|
private archivistFindHash;
|
|
17
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemoryAddressChainDiviner.d.ts","sourceRoot":"","sources":["../../src/MemoryAddressChainDiviner.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,KAAK,EACI,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"MemoryAddressChainDiviner.d.ts","sourceRoot":"","sources":["../../src/MemoryAddressChainDiviner.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,KAAK,EACI,OAAO,EAAE,MAAM,EAC7B,eAAe,EAChB,MAAM,8BAA8B,CAAA;AAGrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAK5D,MAAM,MAAM,+BAA+B,GAAG,aAAa,CAAC,eAAe,CAAC,yBAAyB,CAAC,CAAC,CAAA;AAEvG,qBAAa,yBAAyB,CACpC,OAAO,SAAS,+BAA+B,GAAG,+BAA+B,CACjF,SAAQ,mBAAmB,CAAC,OAAO,CAAC;IACpC,gBAAyB,aAAa,EAAE,MAAM,EAAE,CAA4D;IAC5G,gBAAyB,mBAAmB,EAAE,MAAM,CAAkC;IAEtF,IAAI,YAAY,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG;QACvC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAA;KACrB,GAAG;QACF,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAA;KACzB,CAAC,GAAG,eAAe,CAEnB;cAEwB,aAAa,CAAC,QAAQ,GAAE,OAAO,EAAO,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;YAwBtE,iBAAiB;CAMhC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Query.d.ts","sourceRoot":"","sources":["../../src/Query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAA;AAG5E,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAErD,MAAM,MAAM,wBAAwB,GAAG,KAAK,CAAC;IAAE,MAAM,EAAE,uBAAuB,CAAA;CAAE,GAAG,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC,CAAA;AACrH,eAAO,MAAM,0BAA0B,
|
|
1
|
+
{"version":3,"file":"Query.d.ts","sourceRoot":"","sources":["../../src/Query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAA;AAG5E,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAErD,MAAM,MAAM,wBAAwB,GAAG,KAAK,CAAC;IAAE,MAAM,EAAE,uBAAuB,CAAA;CAAE,GAAG,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC,CAAA;AACrH,eAAO,MAAM,0BAA0B,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,KAAK,CAAC,IAAI,wBAAmG,CAAA"}
|
package/dist/neutral/Schema.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Schema.d.ts","sourceRoot":"","sources":["../../src/Schema.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB
|
|
1
|
+
{"version":3,"file":"Schema.d.ts","sourceRoot":"","sources":["../../src/Schema.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB,EAAE,mCAAmC,GAAG;IACrE,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAA;CAC8B,CAAA;AACvD,MAAM,MAAM,kBAAkB,GAAG,OAAO,kBAAkB,CAAA;AAE1D,eAAO,MAAM,+BAA+B,EAAE,MAAM,GAAG;IACrD,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAA;CACyB,CAAA;AAClD,MAAM,MAAM,+BAA+B,GAAG,OAAO,+BAA+B,CAAA;AAEpF,eAAO,MAAM,uBAAuB,EAAE,MAAM,GAAG;IAC7C,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAA;CACwB,CAAA;AACjD,MAAM,MAAM,uBAAuB,GAAG,OAAO,uBAAuB,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/AddressChainDiviner.ts", "../../src/MemoryAddressChainDiviner.ts", "../../src/Schema.ts", "../../src/Payload.ts", "../../src/Query.ts"],
|
|
4
|
-
"sourcesContent": ["import { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport type { DivinerInstance, DivinerModuleEventData } from '@xyo-network/diviner-model'\nimport type { Payload } from '@xyo-network/sdk-protocol-js'\n\nimport type { AddressChainDivinerParams } from './Params.ts'\n\nexport abstract class AddressChainDiviner<\n TParams extends AddressChainDivinerParams = AddressChainDivinerParams,\n TIn extends Payload = Payload,\n TOut extends Payload = Payload,\n TEventData extends DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut> = DivinerModuleEventData<\n DivinerInstance<TParams, TIn, TOut>,\n TIn,\n TOut\n >,\n> extends AbstractDiviner<TParams, TIn, TOut, TEventData> {}\n", "import type { Hash } from '@xylabs/sdk-js'\nimport { assertEx } from '@xylabs/sdk-js'\nimport type { ArchivistInstance } from '@xyo-network/archivist-model'\nimport type { DivinerParams } from '@xyo-network/diviner-model'\nimport type { AnyConfigSchema } from '@xyo-network/module-model'\nimport type {\n BoundWitness, Payload, Schema,\n} from '@xyo-network/sdk-protocol-js'\nimport { BoundWitnessSchema, isStorageMeta } from '@xyo-network/sdk-protocol-js'\n\nimport { AddressChainDiviner } from './AddressChainDiviner.ts'\nimport type { AddressChainDivinerConfig } from './Config.ts'\nimport { AddressChainDivinerConfigSchema } from './Schema.ts'\n\n// This diviner returns the most recent boundwitness signed by the address that can be found\n// if multiple broken chains are found, all the heads are returned\nexport type MemoryAddressChainDivinerParams = DivinerParams<AnyConfigSchema<AddressChainDivinerConfig>>\n\nexport class MemoryAddressChainDiviner<\n TParams extends MemoryAddressChainDivinerParams = MemoryAddressChainDivinerParams,\n> extends AddressChainDiviner<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, AddressChainDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = AddressChainDivinerConfigSchema\n\n get queryAddress() {\n return assertEx(this.config.address, () => 'Missing address')\n }\n\n protected override async divineHandler(payloads: Payload[] = []): Promise<Payload[]> {\n const result: Payload[] = []\n assertEx(payloads.length === 0, () => 'MemoryAddressChainDiviner.divine does not allow payloads to be sent')\n try {\n const archivistIn = await this.archivistInstance()\n const archivist = assertEx(archivistIn, () => 'Unable to resolve archivist')\n let currentHash: Hash | null = assertEx(this.config.startHash, () => 'Missing startHash')\n while (currentHash && result.length < (this.config.maxResults ?? 1000)) {\n const bw = await this.archivistFindHash([archivist], currentHash)\n if (bw) {\n result.push(bw)\n const addressIndex = bw.addresses.indexOf(this.queryAddress)\n currentHash = addressIndex === -1 ? null : bw.previous_hashes[addressIndex] ?? null\n } else {\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 const archivist = archivists[0]\n if (archivist) {\n return (await archivist.get([hash])).findLast(x => x.schema === BoundWitnessSchema && isStorageMeta(x)) as BoundWitness | undefined\n }\n }\n}\n", "import { asSchema } from '@xyo-network/sdk-protocol-js'\n\nexport const AddressChainSchema = asSchema('network.xyo.diviner.address.chain', true)\nexport type AddressChainSchema = typeof AddressChainSchema\n\nexport const AddressChainDivinerConfigSchema = asSchema(`${AddressChainSchema}.config`, true)\nexport type AddressChainDivinerConfigSchema = typeof AddressChainDivinerConfigSchema\n\nexport const AddressChainQuerySchema = asSchema(`${AddressChainSchema}.query`, true)\nexport type AddressChainQuerySchema = typeof AddressChainQuerySchema\n", "import type { Payload } from '@xyo-network/sdk-protocol-js'\n\nimport { AddressChainSchema } from './Schema.ts'\n\nexport type AddressChainPayload = Payload<{ schema: AddressChainSchema }>\nexport const isAddressChainPayload = (x?: Payload | null): x is AddressChainPayload => x?.schema === AddressChainSchema\n", "import type { PayloadFindFilter, Query } from '@xyo-network/sdk-protocol-js'\nimport { isPayloadOfSchemaType } from '@xyo-network/sdk-protocol-js'\n\nimport { AddressChainQuerySchema } from './Schema.ts'\n\nexport type AddressChainQueryPayload = Query<{ schema: AddressChainQuerySchema } & Omit<PayloadFindFilter, 'schema'>>\nexport const isAddressChainQueryPayload = isPayloadOfSchemaType<AddressChainQueryPayload>(AddressChainQuerySchema)\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,uBAAuB;AAMzB,IAAe,sBAAf,cASG,gBAAgD;AAAC;;;ACd3D,SAAS,gBAAgB;
|
|
4
|
+
"sourcesContent": ["import { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport type { DivinerInstance, DivinerModuleEventData } from '@xyo-network/diviner-model'\nimport type { Payload } from '@xyo-network/sdk-protocol-js'\n\nimport type { AddressChainDivinerParams } from './Params.ts'\n\nexport abstract class AddressChainDiviner<\n TParams extends AddressChainDivinerParams = AddressChainDivinerParams,\n TIn extends Payload = Payload,\n TOut extends Payload = Payload,\n TEventData extends DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut> = DivinerModuleEventData<\n DivinerInstance<TParams, TIn, TOut>,\n TIn,\n TOut\n >,\n> extends AbstractDiviner<TParams, TIn, TOut, TEventData> {}\n", "import type { Hash } from '@xylabs/sdk-js'\nimport { assertEx } from '@xylabs/sdk-js'\nimport type { ArchivistInstance } from '@xyo-network/archivist-model'\nimport type { DivinerParams } from '@xyo-network/diviner-model'\nimport type { AnyConfigSchema } from '@xyo-network/module-model'\nimport type {\n BoundWitness, Payload, Schema,\n XyoQuantAddress,\n} from '@xyo-network/sdk-protocol-js'\nimport { BoundWitnessSchema, isStorageMeta } from '@xyo-network/sdk-protocol-js'\n\nimport { AddressChainDiviner } from './AddressChainDiviner.ts'\nimport type { AddressChainDivinerConfig } from './Config.ts'\nimport { AddressChainDivinerConfigSchema } from './Schema.ts'\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(): (Lowercase<string> & {\n readonly __hex: true\n } & {\n readonly __address: true\n }) | XyoQuantAddress {\n return assertEx(this.config.address, () => 'Missing address')\n }\n\n protected override async divineHandler(payloads: Payload[] = []): Promise<Payload[]> {\n const result: Payload[] = []\n assertEx(payloads.length === 0, () => 'MemoryAddressChainDiviner.divine does not allow payloads to be sent')\n try {\n const archivistIn = await this.archivistInstance()\n const archivist = assertEx(archivistIn, () => 'Unable to resolve archivist')\n let currentHash: Hash | null = assertEx(this.config.startHash, () => 'Missing startHash')\n while (currentHash && result.length < (this.config.maxResults ?? 1000)) {\n const bw = await this.archivistFindHash([archivist], currentHash)\n if (bw) {\n result.push(bw)\n const addressIndex = bw.addresses.indexOf(this.queryAddress)\n currentHash = addressIndex === -1 ? null : bw.previous_hashes[addressIndex] ?? null\n } else {\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 const archivist = archivists[0]\n if (archivist) {\n return (await archivist.get([hash])).findLast(x => x.schema === BoundWitnessSchema && isStorageMeta(x)) as BoundWitness | undefined\n }\n }\n}\n", "import { asSchema } from '@xyo-network/sdk-protocol-js'\n\nexport const AddressChainSchema: 'network.xyo.diviner.address.chain' & {\n readonly __schema: true\n} = asSchema('network.xyo.diviner.address.chain', true)\nexport type AddressChainSchema = typeof AddressChainSchema\n\nexport const AddressChainDivinerConfigSchema: string & {\n readonly __schema: true\n} = asSchema(`${AddressChainSchema}.config`, true)\nexport type AddressChainDivinerConfigSchema = typeof AddressChainDivinerConfigSchema\n\nexport const AddressChainQuerySchema: string & {\n readonly __schema: true\n} = asSchema(`${AddressChainSchema}.query`, true)\nexport type AddressChainQuerySchema = typeof AddressChainQuerySchema\n", "import type { Payload } from '@xyo-network/sdk-protocol-js'\n\nimport { AddressChainSchema } from './Schema.ts'\n\nexport type AddressChainPayload = Payload<{ schema: AddressChainSchema }>\nexport const isAddressChainPayload = (x?: Payload | null): x is AddressChainPayload => x?.schema === AddressChainSchema\n", "import type { PayloadFindFilter, Query } from '@xyo-network/sdk-protocol-js'\nimport { isPayloadOfSchemaType } from '@xyo-network/sdk-protocol-js'\n\nimport { AddressChainQuerySchema } from './Schema.ts'\n\nexport type AddressChainQueryPayload = Query<{ schema: AddressChainQuerySchema } & Omit<PayloadFindFilter, 'schema'>>\nexport const isAddressChainQueryPayload: (x?: unknown) => x is AddressChainQueryPayload = isPayloadOfSchemaType<AddressChainQueryPayload>(AddressChainQuerySchema)\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,uBAAuB;AAMzB,IAAe,sBAAf,cASG,gBAAgD;AAAC;;;ACd3D,SAAS,gBAAgB;AAQzB,SAAS,oBAAoB,qBAAqB;;;ACTlD,SAAS,gBAAgB;AAElB,IAAM,qBAET,SAAS,qCAAqC,IAAI;AAG/C,IAAM,kCAET,SAAS,GAAG,kBAAkB,WAAW,IAAI;AAG1C,IAAM,0BAET,SAAS,GAAG,kBAAkB,UAAU,IAAI;;;ADKzC,IAAM,4BAAN,cAEG,oBAA6B;AAAA,EACrC,OAAyB,gBAA0B,CAAC,GAAG,MAAM,eAAe,+BAA+B;AAAA,EAC3G,OAAyB,sBAA8B;AAAA,EAEvD,IAAI,eAIiB;AACnB,WAAO,SAAS,KAAK,OAAO,SAAS,MAAM,iBAAiB;AAAA,EAC9D;AAAA,EAEA,MAAyB,cAAc,WAAsB,CAAC,GAAuB;AACnF,UAAM,SAAoB,CAAC;AAC3B,aAAS,SAAS,WAAW,GAAG,MAAM,qEAAqE;AAC3G,QAAI;AACF,YAAM,cAAc,MAAM,KAAK,kBAAkB;AACjD,YAAM,YAAY,SAAS,aAAa,MAAM,6BAA6B;AAC3E,UAAI,cAA2B,SAAS,KAAK,OAAO,WAAW,MAAM,mBAAmB;AACxF,aAAO,eAAe,OAAO,UAAU,KAAK,OAAO,cAAc,MAAO;AACtE,cAAM,KAAK,MAAM,KAAK,kBAAkB,CAAC,SAAS,GAAG,WAAW;AAChE,YAAI,IAAI;AACN,iBAAO,KAAK,EAAE;AACd,gBAAM,eAAe,GAAG,UAAU,QAAQ,KAAK,YAAY;AAC3D,wBAAc,iBAAiB,KAAK,OAAO,GAAG,gBAAgB,YAAY,KAAK;AAAA,QACjF,OAAO;AACL,kBAAQ,IAAI,+BAA+B,WAAW,GAAG;AACzD,wBAAc;AAAA,QAChB;AAAA,MACF;AAAA,IACF,SAAS,IAAI;AACX,cAAQ,IAAI,EAAE;AAAA,IAChB;AACA,WAAO;AAAA,EACT;AAAA,EAEA,MAAc,kBAAkB,YAAiC,MAA+C;AAC9G,UAAM,YAAY,WAAW,CAAC;AAC9B,QAAI,WAAW;AACb,cAAQ,MAAM,UAAU,IAAI,CAAC,IAAI,CAAC,GAAG,SAAS,OAAK,EAAE,WAAW,sBAAsB,cAAc,CAAC,CAAC;AAAA,IACxG;AAAA,EACF;AACF;;;AE1DO,IAAM,wBAAwB,CAAC,MAAiD,GAAG,WAAW;;;ACJrG,SAAS,6BAA6B;AAK/B,IAAM,6BAA6E,sBAAgD,uBAAuB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/MemoryAddressChainDiviner.ts", "../../src/AddressChainDiviner.ts", "../../src/Schema.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Hash } from '@xylabs/sdk-js'\nimport { assertEx } from '@xylabs/sdk-js'\nimport type { ArchivistInstance } from '@xyo-network/archivist-model'\nimport type { DivinerParams } from '@xyo-network/diviner-model'\nimport type { AnyConfigSchema } from '@xyo-network/module-model'\nimport type {\n BoundWitness, Payload, Schema,\n} from '@xyo-network/sdk-protocol-js'\nimport { BoundWitnessSchema, isStorageMeta } from '@xyo-network/sdk-protocol-js'\n\nimport { AddressChainDiviner } from './AddressChainDiviner.ts'\nimport type { AddressChainDivinerConfig } from './Config.ts'\nimport { AddressChainDivinerConfigSchema } from './Schema.ts'\n\n// This diviner returns the most recent boundwitness signed by the address that can be found\n// if multiple broken chains are found, all the heads are returned\nexport type MemoryAddressChainDivinerParams = DivinerParams<AnyConfigSchema<AddressChainDivinerConfig>>\n\nexport class MemoryAddressChainDiviner<\n TParams extends MemoryAddressChainDivinerParams = MemoryAddressChainDivinerParams,\n> extends AddressChainDiviner<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, AddressChainDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = AddressChainDivinerConfigSchema\n\n get queryAddress() {\n return assertEx(this.config.address, () => 'Missing address')\n }\n\n protected override async divineHandler(payloads: Payload[] = []): Promise<Payload[]> {\n const result: Payload[] = []\n assertEx(payloads.length === 0, () => 'MemoryAddressChainDiviner.divine does not allow payloads to be sent')\n try {\n const archivistIn = await this.archivistInstance()\n const archivist = assertEx(archivistIn, () => 'Unable to resolve archivist')\n let currentHash: Hash | null = assertEx(this.config.startHash, () => 'Missing startHash')\n while (currentHash && result.length < (this.config.maxResults ?? 1000)) {\n const bw = await this.archivistFindHash([archivist], currentHash)\n if (bw) {\n result.push(bw)\n const addressIndex = bw.addresses.indexOf(this.queryAddress)\n currentHash = addressIndex === -1 ? null : bw.previous_hashes[addressIndex] ?? null\n } else {\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 const archivist = archivists[0]\n if (archivist) {\n return (await archivist.get([hash])).findLast(x => x.schema === BoundWitnessSchema && isStorageMeta(x)) as BoundWitness | undefined\n }\n }\n}\n", "import { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport type { DivinerInstance, DivinerModuleEventData } from '@xyo-network/diviner-model'\nimport type { Payload } from '@xyo-network/sdk-protocol-js'\n\nimport type { AddressChainDivinerParams } from './Params.ts'\n\nexport abstract class AddressChainDiviner<\n TParams extends AddressChainDivinerParams = AddressChainDivinerParams,\n TIn extends Payload = Payload,\n TOut extends Payload = Payload,\n TEventData extends DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut> = DivinerModuleEventData<\n DivinerInstance<TParams, TIn, TOut>,\n TIn,\n TOut\n >,\n> extends AbstractDiviner<TParams, TIn, TOut, TEventData> {}\n", "import { asSchema } from '@xyo-network/sdk-protocol-js'\n\nexport const AddressChainSchema = asSchema('network.xyo.diviner.address.chain', true)\nexport type AddressChainSchema = typeof AddressChainSchema\n\nexport const AddressChainDivinerConfigSchema = asSchema(`${AddressChainSchema}.config`, true)\nexport type AddressChainDivinerConfigSchema = typeof AddressChainDivinerConfigSchema\n\nexport const AddressChainQuerySchema = asSchema(`${AddressChainSchema}.query`, true)\nexport type AddressChainQuerySchema = typeof AddressChainQuerySchema\n"],
|
|
5
|
-
"mappings": ";AACA,SAAS,gBAAgB;
|
|
4
|
+
"sourcesContent": ["import type { Hash } from '@xylabs/sdk-js'\nimport { assertEx } from '@xylabs/sdk-js'\nimport type { ArchivistInstance } from '@xyo-network/archivist-model'\nimport type { DivinerParams } from '@xyo-network/diviner-model'\nimport type { AnyConfigSchema } from '@xyo-network/module-model'\nimport type {\n BoundWitness, Payload, Schema,\n XyoQuantAddress,\n} from '@xyo-network/sdk-protocol-js'\nimport { BoundWitnessSchema, isStorageMeta } from '@xyo-network/sdk-protocol-js'\n\nimport { AddressChainDiviner } from './AddressChainDiviner.ts'\nimport type { AddressChainDivinerConfig } from './Config.ts'\nimport { AddressChainDivinerConfigSchema } from './Schema.ts'\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(): (Lowercase<string> & {\n readonly __hex: true\n } & {\n readonly __address: true\n }) | XyoQuantAddress {\n return assertEx(this.config.address, () => 'Missing address')\n }\n\n protected override async divineHandler(payloads: Payload[] = []): Promise<Payload[]> {\n const result: Payload[] = []\n assertEx(payloads.length === 0, () => 'MemoryAddressChainDiviner.divine does not allow payloads to be sent')\n try {\n const archivistIn = await this.archivistInstance()\n const archivist = assertEx(archivistIn, () => 'Unable to resolve archivist')\n let currentHash: Hash | null = assertEx(this.config.startHash, () => 'Missing startHash')\n while (currentHash && result.length < (this.config.maxResults ?? 1000)) {\n const bw = await this.archivistFindHash([archivist], currentHash)\n if (bw) {\n result.push(bw)\n const addressIndex = bw.addresses.indexOf(this.queryAddress)\n currentHash = addressIndex === -1 ? null : bw.previous_hashes[addressIndex] ?? null\n } else {\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 const archivist = archivists[0]\n if (archivist) {\n return (await archivist.get([hash])).findLast(x => x.schema === BoundWitnessSchema && isStorageMeta(x)) as BoundWitness | undefined\n }\n }\n}\n", "import { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport type { DivinerInstance, DivinerModuleEventData } from '@xyo-network/diviner-model'\nimport type { Payload } from '@xyo-network/sdk-protocol-js'\n\nimport type { AddressChainDivinerParams } from './Params.ts'\n\nexport abstract class AddressChainDiviner<\n TParams extends AddressChainDivinerParams = AddressChainDivinerParams,\n TIn extends Payload = Payload,\n TOut extends Payload = Payload,\n TEventData extends DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut> = DivinerModuleEventData<\n DivinerInstance<TParams, TIn, TOut>,\n TIn,\n TOut\n >,\n> extends AbstractDiviner<TParams, TIn, TOut, TEventData> {}\n", "import { asSchema } from '@xyo-network/sdk-protocol-js'\n\nexport const AddressChainSchema: 'network.xyo.diviner.address.chain' & {\n readonly __schema: true\n} = asSchema('network.xyo.diviner.address.chain', true)\nexport type AddressChainSchema = typeof AddressChainSchema\n\nexport const AddressChainDivinerConfigSchema: string & {\n readonly __schema: true\n} = asSchema(`${AddressChainSchema}.config`, true)\nexport type AddressChainDivinerConfigSchema = typeof AddressChainDivinerConfigSchema\n\nexport const AddressChainQuerySchema: string & {\n readonly __schema: true\n} = asSchema(`${AddressChainSchema}.query`, true)\nexport type AddressChainQuerySchema = typeof AddressChainQuerySchema\n"],
|
|
5
|
+
"mappings": ";AACA,SAAS,gBAAgB;AAQzB,SAAS,oBAAoB,qBAAqB;;;ACTlD,SAAS,uBAAuB;AAMzB,IAAe,sBAAf,cASG,gBAAgD;AAAC;;;ACf3D,SAAS,gBAAgB;AAElB,IAAM,qBAET,SAAS,qCAAqC,IAAI;AAG/C,IAAM,kCAET,SAAS,GAAG,kBAAkB,WAAW,IAAI;AAG1C,IAAM,0BAET,SAAS,GAAG,kBAAkB,UAAU,IAAI;;;AFKzC,IAAM,4BAAN,cAEG,oBAA6B;AAAA,EACrC,OAAyB,gBAA0B,CAAC,GAAG,MAAM,eAAe,+BAA+B;AAAA,EAC3G,OAAyB,sBAA8B;AAAA,EAEvD,IAAI,eAIiB;AACnB,WAAO,SAAS,KAAK,OAAO,SAAS,MAAM,iBAAiB;AAAA,EAC9D;AAAA,EAEA,MAAyB,cAAc,WAAsB,CAAC,GAAuB;AACnF,UAAM,SAAoB,CAAC;AAC3B,aAAS,SAAS,WAAW,GAAG,MAAM,qEAAqE;AAC3G,QAAI;AACF,YAAM,cAAc,MAAM,KAAK,kBAAkB;AACjD,YAAM,YAAY,SAAS,aAAa,MAAM,6BAA6B;AAC3E,UAAI,cAA2B,SAAS,KAAK,OAAO,WAAW,MAAM,mBAAmB;AACxF,aAAO,eAAe,OAAO,UAAU,KAAK,OAAO,cAAc,MAAO;AACtE,cAAM,KAAK,MAAM,KAAK,kBAAkB,CAAC,SAAS,GAAG,WAAW;AAChE,YAAI,IAAI;AACN,iBAAO,KAAK,EAAE;AACd,gBAAM,eAAe,GAAG,UAAU,QAAQ,KAAK,YAAY;AAC3D,wBAAc,iBAAiB,KAAK,OAAO,GAAG,gBAAgB,YAAY,KAAK;AAAA,QACjF,OAAO;AACL,kBAAQ,IAAI,+BAA+B,WAAW,GAAG;AACzD,wBAAc;AAAA,QAChB;AAAA,MACF;AAAA,IACF,SAAS,IAAI;AACX,cAAQ,IAAI,EAAE;AAAA,IAChB;AACA,WAAO;AAAA,EACT;AAAA,EAEA,MAAc,kBAAkB,YAAiC,MAA+C;AAC9G,UAAM,YAAY,WAAW,CAAC;AAC9B,QAAI,WAAW;AACb,cAAQ,MAAM,UAAU,IAAI,CAAC,IAAI,CAAC,GAAG,SAAS,OAAK,EAAE,WAAW,sBAAsB,cAAc,CAAC,CAAC;AAAA,IACxG;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Schema.ts", "../../src/Payload.ts", "../../src/Query.ts"],
|
|
4
|
-
"sourcesContent": ["import { asSchema } from '@xyo-network/sdk-protocol-js'\n\nexport const AddressChainSchema = asSchema('network.xyo.diviner.address.chain', true)\nexport type AddressChainSchema = typeof AddressChainSchema\n\nexport const AddressChainDivinerConfigSchema = asSchema(`${AddressChainSchema}.config`, true)\nexport type AddressChainDivinerConfigSchema = typeof AddressChainDivinerConfigSchema\n\nexport const AddressChainQuerySchema = asSchema(`${AddressChainSchema}.query`, true)\nexport type AddressChainQuerySchema = typeof AddressChainQuerySchema\n", "import type { Payload } from '@xyo-network/sdk-protocol-js'\n\nimport { AddressChainSchema } from './Schema.ts'\n\nexport type AddressChainPayload = Payload<{ schema: AddressChainSchema }>\nexport const isAddressChainPayload = (x?: Payload | null): x is AddressChainPayload => x?.schema === AddressChainSchema\n", "import type { PayloadFindFilter, Query } from '@xyo-network/sdk-protocol-js'\nimport { isPayloadOfSchemaType } from '@xyo-network/sdk-protocol-js'\n\nimport { AddressChainQuerySchema } from './Schema.ts'\n\nexport type AddressChainQueryPayload = Query<{ schema: AddressChainQuerySchema } & Omit<PayloadFindFilter, 'schema'>>\nexport const isAddressChainQueryPayload = isPayloadOfSchemaType<AddressChainQueryPayload>(AddressChainQuerySchema)\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,gBAAgB;AAElB,IAAM,
|
|
4
|
+
"sourcesContent": ["import { asSchema } from '@xyo-network/sdk-protocol-js'\n\nexport const AddressChainSchema: 'network.xyo.diviner.address.chain' & {\n readonly __schema: true\n} = asSchema('network.xyo.diviner.address.chain', true)\nexport type AddressChainSchema = typeof AddressChainSchema\n\nexport const AddressChainDivinerConfigSchema: string & {\n readonly __schema: true\n} = asSchema(`${AddressChainSchema}.config`, true)\nexport type AddressChainDivinerConfigSchema = typeof AddressChainDivinerConfigSchema\n\nexport const AddressChainQuerySchema: string & {\n readonly __schema: true\n} = asSchema(`${AddressChainSchema}.query`, true)\nexport type AddressChainQuerySchema = typeof AddressChainQuerySchema\n", "import type { Payload } from '@xyo-network/sdk-protocol-js'\n\nimport { AddressChainSchema } from './Schema.ts'\n\nexport type AddressChainPayload = Payload<{ schema: AddressChainSchema }>\nexport const isAddressChainPayload = (x?: Payload | null): x is AddressChainPayload => x?.schema === AddressChainSchema\n", "import type { PayloadFindFilter, Query } from '@xyo-network/sdk-protocol-js'\nimport { isPayloadOfSchemaType } from '@xyo-network/sdk-protocol-js'\n\nimport { AddressChainQuerySchema } from './Schema.ts'\n\nexport type AddressChainQueryPayload = Query<{ schema: AddressChainQuerySchema } & Omit<PayloadFindFilter, 'schema'>>\nexport const isAddressChainQueryPayload: (x?: unknown) => x is AddressChainQueryPayload = isPayloadOfSchemaType<AddressChainQueryPayload>(AddressChainQuerySchema)\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,gBAAgB;AAElB,IAAM,qBAET,SAAS,qCAAqC,IAAI;AAG/C,IAAM,kCAET,SAAS,GAAG,kBAAkB,WAAW,IAAI;AAG1C,IAAM,0BAET,SAAS,GAAG,kBAAkB,UAAU,IAAI;;;ACTzC,IAAM,wBAAwB,CAAC,MAAiD,GAAG,WAAW;;;ACJrG,SAAS,6BAA6B;AAK/B,IAAM,6BAA6E,sBAAgD,uBAAuB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/diviner-address-chain",
|
|
3
|
-
"version": "6.0
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"README.md"
|
|
47
47
|
],
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@xyo-network/diviner-abstract": "~6.0
|
|
50
|
-
"@xyo-network/
|
|
51
|
-
"@xyo-network/
|
|
49
|
+
"@xyo-network/diviner-abstract": "~6.1.0",
|
|
50
|
+
"@xyo-network/diviner-model": "~6.1.0",
|
|
51
|
+
"@xyo-network/module-model": "~6.1.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@bitauth/libauth": "~3.0.0",
|
|
@@ -58,17 +58,15 @@
|
|
|
58
58
|
"@opentelemetry/sdk-trace-base": "^2.7.1",
|
|
59
59
|
"@scure/base": "~2.2.0",
|
|
60
60
|
"@scure/bip39": "~2.2.0",
|
|
61
|
-
"@xylabs/geo": "^6.0
|
|
62
|
-
"@xylabs/sdk-js": "^6.0
|
|
63
|
-
"@xylabs/threads": "^6.0
|
|
64
|
-
"@xylabs/toolchain": "
|
|
65
|
-
"@xylabs/tsconfig": "
|
|
66
|
-
"@xylabs/vitest-extended": "
|
|
67
|
-
"@xyo-network/sdk-protocol-js": "
|
|
61
|
+
"@xylabs/geo": "^6.1.0",
|
|
62
|
+
"@xylabs/sdk-js": "^6.1.0",
|
|
63
|
+
"@xylabs/threads": "^6.1.0",
|
|
64
|
+
"@xylabs/toolchain": "^8.1.20",
|
|
65
|
+
"@xylabs/tsconfig": "^8.1.20",
|
|
66
|
+
"@xylabs/vitest-extended": "^6.1.0",
|
|
67
|
+
"@xyo-network/sdk-protocol-js": "^6.1.0",
|
|
68
68
|
"ajv": "^8.20.0",
|
|
69
69
|
"async-mutex": "^0.5.0",
|
|
70
|
-
"bn.js": "^5.2.3",
|
|
71
|
-
"buffer": "^6.0.3",
|
|
72
70
|
"debug": "~4.4.3",
|
|
73
71
|
"eslint": "^10.4.1",
|
|
74
72
|
"ethers": "^6.16.0",
|
|
@@ -81,11 +79,11 @@
|
|
|
81
79
|
"vitest": "~4.1.8",
|
|
82
80
|
"webextension-polyfill": "^0.12.0",
|
|
83
81
|
"zod": "^4.4.3",
|
|
84
|
-
"@xyo-network/archivist-memory": "~6.0
|
|
85
|
-
"@xyo-network/archivist-model": "~6.0
|
|
86
|
-
"@xyo-network/archivist-wrapper": "~6.0
|
|
87
|
-
"@xyo-network/node-
|
|
88
|
-
"@xyo-network/node-
|
|
82
|
+
"@xyo-network/archivist-memory": "~6.1.0",
|
|
83
|
+
"@xyo-network/archivist-model": "~6.1.0",
|
|
84
|
+
"@xyo-network/archivist-wrapper": "~6.1.0",
|
|
85
|
+
"@xyo-network/node-memory": "~6.1.0",
|
|
86
|
+
"@xyo-network/node-model": "~6.1.0"
|
|
89
87
|
},
|
|
90
88
|
"peerDependencies": {
|
|
91
89
|
"@bitauth/libauth": "~3.0",
|
|
@@ -98,11 +96,9 @@
|
|
|
98
96
|
"@xylabs/geo": "^6.0",
|
|
99
97
|
"@xylabs/sdk-js": "^6.0",
|
|
100
98
|
"@xylabs/threads": "^6.0",
|
|
101
|
-
"@xyo-network/sdk-protocol-js": "
|
|
99
|
+
"@xyo-network/sdk-protocol-js": "^6.1",
|
|
102
100
|
"ajv": "^8.20",
|
|
103
101
|
"async-mutex": "^0.5",
|
|
104
|
-
"bn.js": "^5.2",
|
|
105
|
-
"buffer": "^6.0",
|
|
106
102
|
"debug": "~4.4",
|
|
107
103
|
"ethers": "^6.16",
|
|
108
104
|
"hash-wasm": "~4.12",
|
|
@@ -112,6 +108,9 @@
|
|
|
112
108
|
"webextension-polyfill": "^0.12",
|
|
113
109
|
"zod": "^4.4"
|
|
114
110
|
},
|
|
111
|
+
"engines": {
|
|
112
|
+
"node": "^24"
|
|
113
|
+
},
|
|
115
114
|
"publishConfig": {
|
|
116
115
|
"access": "public"
|
|
117
116
|
}
|