@xyo-network/diviner-payload-stats-memory 5.2.5 → 5.2.6

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.
@@ -1,7 +1,7 @@
1
1
  import type { Address } from '@xylabs/hex';
2
2
  import { PayloadStatsDiviner } from '@xyo-network/diviner-payload-stats-abstract';
3
3
  import type { PayloadStatsDivinerParams } from '@xyo-network/diviner-payload-stats-model';
4
- import type { Payload, Schema } from '@xyo-network/payload-model';
4
+ import { type Payload, type Schema } from '@xyo-network/payload-model';
5
5
  export declare class MemoryPayloadStatsDiviner<TParams extends PayloadStatsDivinerParams = PayloadStatsDivinerParams> extends PayloadStatsDiviner<TParams> {
6
6
  static readonly configSchemas: Schema[];
7
7
  static readonly defaultConfigSchema: Schema;
@@ -1 +1 @@
1
- {"version":3,"file":"MemoryPayloadStatsDiviner.d.ts","sourceRoot":"","sources":["../../src/MemoryPayloadStatsDiviner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAA;AACjF,OAAO,KAAK,EACV,yBAAyB,EAG1B,MAAM,0CAA0C,CAAA;AAOjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAEjE,qBAAa,yBAAyB,CAAC,OAAO,SAAS,yBAAyB,GAAG,yBAAyB,CAAE,SAAQ,mBAAmB,CAAC,OAAO,CAAC;IAChJ,gBAAyB,aAAa,EAAE,MAAM,EAAE,CAA4D;IAC5G,gBAAyB,mBAAmB,EAAE,MAAM,CAAkC;cAEtE,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;cAShD,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;cAM5B,aAAa,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CAcjF"}
1
+ {"version":3,"file":"MemoryPayloadStatsDiviner.d.ts","sourceRoot":"","sources":["../../src/MemoryPayloadStatsDiviner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAA;AACjF,OAAO,KAAK,EACV,yBAAyB,EAG1B,MAAM,0CAA0C,CAAA;AAOjD,OAAO,EACU,KAAK,OAAO,EAAE,KAAK,MAAM,EACzC,MAAM,4BAA4B,CAAA;AAEnC,qBAAa,yBAAyB,CAAC,OAAO,SAAS,yBAAyB,GAAG,yBAAyB,CAAE,SAAQ,mBAAmB,CAAC,OAAO,CAAC;IAChJ,gBAAyB,aAAa,EAAE,MAAM,EAAE,CAA4D;IAC5G,gBAAyB,mBAAmB,EAAE,MAAM,CAAkC;cAEtE,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;cAShD,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;cAM5B,aAAa,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CAcjF"}
@@ -1,6 +1,6 @@
1
1
  // src/MemoryPayloadStatsDiviner.ts
2
2
  import { assertEx } from "@xylabs/assert";
3
- import { isBoundWitnessWithStorageMeta } from "@xyo-network/boundwitness-model";
3
+ import { isBoundWitness } from "@xyo-network/boundwitness-model";
4
4
  import { PayloadStatsDiviner } from "@xyo-network/diviner-payload-stats-abstract";
5
5
  import {
6
6
  isPayloadStatsQueryPayload,
@@ -8,12 +8,15 @@ import {
8
8
  PayloadStatsDivinerSchema
9
9
  } from "@xyo-network/diviner-payload-stats-model";
10
10
  import { PayloadBuilder } from "@xyo-network/payload-builder";
11
+ import {
12
+ isStorageMeta
13
+ } from "@xyo-network/payload-model";
11
14
  var MemoryPayloadStatsDiviner = class extends PayloadStatsDiviner {
12
15
  static configSchemas = [...super.configSchemas, PayloadStatsDivinerConfigSchema];
13
16
  static defaultConfigSchema = PayloadStatsDivinerConfigSchema;
14
17
  async divineAddress(address) {
15
18
  const archivist = assertEx(await this.archivistInstance(), () => "Unable to resolve archivist");
16
- return (await archivist.next({ limit: 2e4 })).filter(isBoundWitnessWithStorageMeta).filter((bw) => bw.addresses.includes(address)).map((bw) => bw.payload_hashes.length).reduce((total, count) => total + count, 0);
19
+ return (await archivist.next({ limit: 2e4 })).filter((x) => isBoundWitness(x) && isStorageMeta(x)).filter((bw) => bw.addresses.includes(address)).map((bw) => bw.payload_hashes.length).reduce((total, count) => total + count, 0);
17
20
  }
18
21
  async divineAllAddresses() {
19
22
  const archivist = assertEx(await this.archivistInstance(), () => "Unable to resolve archivist");
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/MemoryPayloadStatsDiviner.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport type { Address } from '@xylabs/hex'\nimport { isBoundWitnessWithStorageMeta } from '@xyo-network/boundwitness-model'\nimport { PayloadStatsDiviner } from '@xyo-network/diviner-payload-stats-abstract'\nimport type {\n PayloadStatsDivinerParams,\n PayloadStatsPayload,\n PayloadStatsQueryPayload,\n} from '@xyo-network/diviner-payload-stats-model'\nimport {\n isPayloadStatsQueryPayload,\n PayloadStatsDivinerConfigSchema,\n PayloadStatsDivinerSchema,\n} from '@xyo-network/diviner-payload-stats-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\n\nexport class MemoryPayloadStatsDiviner<TParams extends PayloadStatsDivinerParams = PayloadStatsDivinerParams> extends PayloadStatsDiviner<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, PayloadStatsDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = PayloadStatsDivinerConfigSchema\n\n protected async divineAddress(address: Address): Promise<number> {\n const archivist = assertEx(await this.archivistInstance(), () => 'Unable to resolve archivist')\n return (await archivist.next({ limit: 20_000 }))\n .filter(isBoundWitnessWithStorageMeta)\n .filter(bw => bw.addresses.includes(address))\n .map(bw => bw.payload_hashes.length)\n .reduce((total, count) => total + count, 0)\n }\n\n protected async divineAllAddresses(): Promise<number> {\n const archivist = assertEx(await this.archivistInstance(), () => 'Unable to resolve archivist')\n const all = await archivist.next({ limit: 20_000 })\n return all.length\n }\n\n protected override async divineHandler(payloads?: Payload[]): Promise<Payload[]> {\n const query = payloads?.find<PayloadStatsQueryPayload>(isPayloadStatsQueryPayload)\n if (!query) return []\n const addresses\n = query?.address\n ? Array.isArray(query?.address)\n ? query.address\n : [query.address]\n : undefined\n const counts = addresses ? await Promise.all(addresses.map(address => this.divineAddress(address))) : [await this.divineAllAddresses()]\n return await Promise.all(\n counts.map(count => new PayloadBuilder<PayloadStatsPayload>({ schema: PayloadStatsDivinerSchema }).fields({ count }).build()),\n )\n }\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AAEzB,SAAS,qCAAqC;AAC9C,SAAS,2BAA2B;AAMpC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,sBAAsB;AAGxB,IAAM,4BAAN,cAA+G,oBAA6B;AAAA,EACjJ,OAAyB,gBAA0B,CAAC,GAAG,MAAM,eAAe,+BAA+B;AAAA,EAC3G,OAAyB,sBAA8B;AAAA,EAEvD,MAAgB,cAAc,SAAmC;AAC/D,UAAM,YAAY,SAAS,MAAM,KAAK,kBAAkB,GAAG,MAAM,6BAA6B;AAC9F,YAAQ,MAAM,UAAU,KAAK,EAAE,OAAO,IAAO,CAAC,GAC3C,OAAO,6BAA6B,EACpC,OAAO,QAAM,GAAG,UAAU,SAAS,OAAO,CAAC,EAC3C,IAAI,QAAM,GAAG,eAAe,MAAM,EAClC,OAAO,CAAC,OAAO,UAAU,QAAQ,OAAO,CAAC;AAAA,EAC9C;AAAA,EAEA,MAAgB,qBAAsC;AACpD,UAAM,YAAY,SAAS,MAAM,KAAK,kBAAkB,GAAG,MAAM,6BAA6B;AAC9F,UAAM,MAAM,MAAM,UAAU,KAAK,EAAE,OAAO,IAAO,CAAC;AAClD,WAAO,IAAI;AAAA,EACb;AAAA,EAEA,MAAyB,cAAc,UAA0C;AAC/E,UAAM,QAAQ,UAAU,KAA+B,0BAA0B;AACjF,QAAI,CAAC,MAAO,QAAO,CAAC;AACpB,UAAM,YACF,OAAO,UACL,MAAM,QAAQ,OAAO,OAAO,IAC1B,MAAM,UACN,CAAC,MAAM,OAAO,IAChB;AACN,UAAM,SAAS,YAAY,MAAM,QAAQ,IAAI,UAAU,IAAI,aAAW,KAAK,cAAc,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,KAAK,mBAAmB,CAAC;AACtI,WAAO,MAAM,QAAQ;AAAA,MACnB,OAAO,IAAI,WAAS,IAAI,eAAoC,EAAE,QAAQ,0BAA0B,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC;AAAA,IAC9H;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/MemoryPayloadStatsDiviner.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport type { Address } from '@xylabs/hex'\nimport { isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { PayloadStatsDiviner } from '@xyo-network/diviner-payload-stats-abstract'\nimport type {\n PayloadStatsDivinerParams,\n PayloadStatsPayload,\n PayloadStatsQueryPayload,\n} from '@xyo-network/diviner-payload-stats-model'\nimport {\n isPayloadStatsQueryPayload,\n PayloadStatsDivinerConfigSchema,\n PayloadStatsDivinerSchema,\n} from '@xyo-network/diviner-payload-stats-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport {\n isStorageMeta, type Payload, type Schema,\n} from '@xyo-network/payload-model'\n\nexport class MemoryPayloadStatsDiviner<TParams extends PayloadStatsDivinerParams = PayloadStatsDivinerParams> extends PayloadStatsDiviner<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, PayloadStatsDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = PayloadStatsDivinerConfigSchema\n\n protected async divineAddress(address: Address): Promise<number> {\n const archivist = assertEx(await this.archivistInstance(), () => 'Unable to resolve archivist')\n return (await archivist.next({ limit: 20_000 }))\n .filter(x => isBoundWitness(x) && isStorageMeta(x))\n .filter(bw => bw.addresses.includes(address))\n .map(bw => bw.payload_hashes.length)\n .reduce((total, count) => total + count, 0)\n }\n\n protected async divineAllAddresses(): Promise<number> {\n const archivist = assertEx(await this.archivistInstance(), () => 'Unable to resolve archivist')\n const all = await archivist.next({ limit: 20_000 })\n return all.length\n }\n\n protected override async divineHandler(payloads?: Payload[]): Promise<Payload[]> {\n const query = payloads?.find<PayloadStatsQueryPayload>(isPayloadStatsQueryPayload)\n if (!query) return []\n const addresses\n = query?.address\n ? Array.isArray(query?.address)\n ? query.address\n : [query.address]\n : undefined\n const counts = addresses ? await Promise.all(addresses.map(address => this.divineAddress(address))) : [await this.divineAllAddresses()]\n return await Promise.all(\n counts.map(count => new PayloadBuilder<PayloadStatsPayload>({ schema: PayloadStatsDivinerSchema }).fields({ count }).build()),\n )\n }\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AAEzB,SAAS,sBAAsB;AAC/B,SAAS,2BAA2B;AAMpC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,sBAAsB;AAC/B;AAAA,EACE;AAAA,OACK;AAEA,IAAM,4BAAN,cAA+G,oBAA6B;AAAA,EACjJ,OAAyB,gBAA0B,CAAC,GAAG,MAAM,eAAe,+BAA+B;AAAA,EAC3G,OAAyB,sBAA8B;AAAA,EAEvD,MAAgB,cAAc,SAAmC;AAC/D,UAAM,YAAY,SAAS,MAAM,KAAK,kBAAkB,GAAG,MAAM,6BAA6B;AAC9F,YAAQ,MAAM,UAAU,KAAK,EAAE,OAAO,IAAO,CAAC,GAC3C,OAAO,OAAK,eAAe,CAAC,KAAK,cAAc,CAAC,CAAC,EACjD,OAAO,QAAM,GAAG,UAAU,SAAS,OAAO,CAAC,EAC3C,IAAI,QAAM,GAAG,eAAe,MAAM,EAClC,OAAO,CAAC,OAAO,UAAU,QAAQ,OAAO,CAAC;AAAA,EAC9C;AAAA,EAEA,MAAgB,qBAAsC;AACpD,UAAM,YAAY,SAAS,MAAM,KAAK,kBAAkB,GAAG,MAAM,6BAA6B;AAC9F,UAAM,MAAM,MAAM,UAAU,KAAK,EAAE,OAAO,IAAO,CAAC;AAClD,WAAO,IAAI;AAAA,EACb;AAAA,EAEA,MAAyB,cAAc,UAA0C;AAC/E,UAAM,QAAQ,UAAU,KAA+B,0BAA0B;AACjF,QAAI,CAAC,MAAO,QAAO,CAAC;AACpB,UAAM,YACF,OAAO,UACL,MAAM,QAAQ,OAAO,OAAO,IAC1B,MAAM,UACN,CAAC,MAAM,OAAO,IAChB;AACN,UAAM,SAAS,YAAY,MAAM,QAAQ,IAAI,UAAU,IAAI,aAAW,KAAK,cAAc,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,KAAK,mBAAmB,CAAC;AACtI,WAAO,MAAM,QAAQ;AAAA,MACnB,OAAO,IAAI,WAAS,IAAI,eAAoC,EAAE,QAAQ,0BAA0B,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC;AAAA,IAC9H;AAAA,EACF;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/diviner-payload-stats-memory",
3
- "version": "5.2.5",
3
+ "version": "5.2.6",
4
4
  "description": "Primary SDK for using XYO Protocol 2.0",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -36,13 +36,13 @@
36
36
  "!**/*.test.*"
37
37
  ],
38
38
  "dependencies": {
39
- "@xylabs/assert": "~5.0.39",
40
- "@xylabs/hex": "~5.0.39",
41
- "@xyo-network/boundwitness-model": "~5.2.5",
42
- "@xyo-network/diviner-payload-stats-abstract": "~5.2.5",
43
- "@xyo-network/diviner-payload-stats-model": "~5.2.5",
44
- "@xyo-network/payload-builder": "~5.2.5",
45
- "@xyo-network/payload-model": "~5.2.5"
39
+ "@xylabs/assert": "~5.0.41",
40
+ "@xylabs/hex": "~5.0.41",
41
+ "@xyo-network/boundwitness-model": "~5.2.6",
42
+ "@xyo-network/diviner-payload-stats-abstract": "~5.2.6",
43
+ "@xyo-network/diviner-payload-stats-model": "~5.2.6",
44
+ "@xyo-network/payload-builder": "~5.2.6",
45
+ "@xyo-network/payload-model": "~5.2.6"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@xylabs/ts-scripts-yarn3": "~7.2.8",
@@ -1,6 +1,6 @@
1
1
  import { assertEx } from '@xylabs/assert'
2
2
  import type { Address } from '@xylabs/hex'
3
- import { isBoundWitnessWithStorageMeta } from '@xyo-network/boundwitness-model'
3
+ import { isBoundWitness } from '@xyo-network/boundwitness-model'
4
4
  import { PayloadStatsDiviner } from '@xyo-network/diviner-payload-stats-abstract'
5
5
  import type {
6
6
  PayloadStatsDivinerParams,
@@ -13,7 +13,9 @@ import {
13
13
  PayloadStatsDivinerSchema,
14
14
  } from '@xyo-network/diviner-payload-stats-model'
15
15
  import { PayloadBuilder } from '@xyo-network/payload-builder'
16
- import type { Payload, Schema } from '@xyo-network/payload-model'
16
+ import {
17
+ isStorageMeta, type Payload, type Schema,
18
+ } from '@xyo-network/payload-model'
17
19
 
18
20
  export class MemoryPayloadStatsDiviner<TParams extends PayloadStatsDivinerParams = PayloadStatsDivinerParams> extends PayloadStatsDiviner<TParams> {
19
21
  static override readonly configSchemas: Schema[] = [...super.configSchemas, PayloadStatsDivinerConfigSchema]
@@ -22,7 +24,7 @@ export class MemoryPayloadStatsDiviner<TParams extends PayloadStatsDivinerParams
22
24
  protected async divineAddress(address: Address): Promise<number> {
23
25
  const archivist = assertEx(await this.archivistInstance(), () => 'Unable to resolve archivist')
24
26
  return (await archivist.next({ limit: 20_000 }))
25
- .filter(isBoundWitnessWithStorageMeta)
27
+ .filter(x => isBoundWitness(x) && isStorageMeta(x))
26
28
  .filter(bw => bw.addresses.includes(address))
27
29
  .map(bw => bw.payload_hashes.length)
28
30
  .reduce((total, count) => total + count, 0)