@xyo-network/evm-abi-diviner 5.2.4 → 5.3.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/evm-abi-diviner",
3
- "version": "5.2.4",
3
+ "version": "5.3.2",
4
4
  "description": "Typescript/Javascript Plugins for XYO Platform",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -35,25 +35,29 @@
35
35
  "!**/*.spec.*",
36
36
  "!**/*.test.*"
37
37
  ],
38
- "dependencies": {
39
- "@xylabs/assert": "~5.0.49",
40
- "@xyo-network/diviner-abstract": "~5.2.14",
41
- "@xyo-network/diviner-model": "~5.2.14",
42
- "@xyo-network/evm-contract-witness": "~5.2.4",
43
- "@xyo-network/module-model": "~5.2.14",
44
- "@xyo-network/payload-model": "~5.2.14",
45
- "ethers": "^6.16.0"
46
- },
47
38
  "devDependencies": {
48
- "@xylabs/ts-scripts-yarn3": "~7.2.8",
49
- "@xylabs/tsconfig": "~7.2.8",
50
- "@xylabs/vitest-extended": "~5.0.49",
51
- "@xyo-network/open-zeppelin-typechain": "~4.0.11",
52
- "@xyo-network/witness-evm-abstract": "~5.2.14",
39
+ "@xylabs/sdk-js": "^5.0.90",
40
+ "@xylabs/ts-scripts-yarn3": "~7.5.10",
41
+ "@xylabs/tsconfig": "~7.5.10",
42
+ "@xylabs/vitest-extended": "~5.0.90",
43
+ "@xyo-network/diviner-abstract": "~5.3.5",
44
+ "@xyo-network/diviner-model": "~5.3.5",
45
+ "@xyo-network/evm-contract-witness": "5.3.2",
46
+ "@xyo-network/module-model": "~5.3.5",
47
+ "@xyo-network/open-zeppelin-typechain": "~4.1.1",
48
+ "@xyo-network/payload-model": "~5.3.5",
49
+ "@xyo-network/witness-evm-abstract": "~5.3.5",
50
+ "ethers": "^6.16.0",
53
51
  "typescript": "~5.9.3",
54
- "vitest": "~4.0.15"
52
+ "vitest": "~4.1.2",
53
+ "zod": "^4.3.6"
54
+ },
55
+ "peerDependencies": {
56
+ "@xylabs/sdk-js": "^5",
57
+ "ethers": "^6",
58
+ "zod": "^4"
55
59
  },
56
60
  "publishConfig": {
57
61
  "access": "public"
58
62
  }
59
- }
63
+ }
package/src/Diviner.ts CHANGED
@@ -1,17 +1,17 @@
1
- import { assertEx } from '@xylabs/assert'
1
+ import { assertEx } from '@xylabs/sdk-js'
2
2
  import { AbstractDiviner } from '@xyo-network/diviner-abstract'
3
3
  import type { DivinerConfig, DivinerParams } from '@xyo-network/diviner-model'
4
4
  import type { EvmContract } from '@xyo-network/evm-contract-witness'
5
5
  import { EvmContractSchema } from '@xyo-network/evm-contract-witness'
6
6
  import type { AnyConfigSchema } from '@xyo-network/module-model'
7
7
  import type { Schema } from '@xyo-network/payload-model'
8
- import { isPayloadOfSchemaType } from '@xyo-network/payload-model'
8
+ import { asSchema, isPayloadOfSchemaType } from '@xyo-network/payload-model'
9
9
  import { Interface } from 'ethers'
10
10
 
11
11
  import type { EvmFunctionImplemented, InterfaceAbi } from './Payload.ts'
12
12
  import { EvmFunctionImplementedSchema } from './Payload.ts'
13
13
 
14
- export const EvmAbiImplementedDivinerConfigSchema = 'network.xyo.evm.abi.implemented.diviner.config'
14
+ export const EvmAbiImplementedDivinerConfigSchema = asSchema('network.xyo.evm.abi.implemented.diviner.config', true)
15
15
  export type EvmAbiImplementedDivinerConfigSchema = typeof EvmAbiImplementedDivinerConfigSchema
16
16
 
17
17
  export type EvmAbiImplementedDivinerConfig = DivinerConfig<{ abi?: InterfaceAbi; schema: EvmAbiImplementedDivinerConfigSchema }>
package/src/Payload.ts CHANGED
@@ -1,9 +1,9 @@
1
- import type { Payload } from '@xyo-network/payload-model'
1
+ import { asSchema, type Payload } from '@xyo-network/payload-model'
2
2
  import type { Fragment, JsonFragment } from 'ethers'
3
3
 
4
4
  export type InterfaceAbi = string | ReadonlyArray<Fragment | JsonFragment | string>
5
5
 
6
- export const EvmFunctionImplementedSchema = 'network.xyo.evm.function.implemented'
6
+ export const EvmFunctionImplementedSchema = asSchema('network.xyo.evm.function.implemented', true)
7
7
  export type EvmFunctionImplementedSchema = typeof EvmFunctionImplementedSchema
8
8
 
9
9
  export type EvmFunctionImplemented = Payload<
@@ -1,20 +0,0 @@
1
- import { AbstractDiviner } from '@xyo-network/diviner-abstract';
2
- import type { DivinerConfig, DivinerParams } from '@xyo-network/diviner-model';
3
- import type { EvmContract } from '@xyo-network/evm-contract-witness';
4
- import type { AnyConfigSchema } from '@xyo-network/module-model';
5
- import type { Schema } from '@xyo-network/payload-model';
6
- import type { EvmFunctionImplemented, InterfaceAbi } from './Payload.ts';
7
- export declare const EvmAbiImplementedDivinerConfigSchema = "network.xyo.evm.abi.implemented.diviner.config";
8
- export type EvmAbiImplementedDivinerConfigSchema = typeof EvmAbiImplementedDivinerConfigSchema;
9
- export type EvmAbiImplementedDivinerConfig = DivinerConfig<{
10
- abi?: InterfaceAbi;
11
- schema: EvmAbiImplementedDivinerConfigSchema;
12
- }>;
13
- export type EvmAbiImplementedDivinerParams = DivinerParams<AnyConfigSchema<EvmAbiImplementedDivinerConfig>>;
14
- export declare class EvmAbiImplementedDiviner<TParams extends EvmAbiImplementedDivinerParams = EvmAbiImplementedDivinerParams> extends AbstractDiviner<TParams, EvmContract, EvmFunctionImplemented> {
15
- static readonly configSchemas: Schema[];
16
- static readonly defaultConfigSchema: Schema;
17
- get abi(): InterfaceAbi;
18
- protected divineHandler(inPayloads?: EvmContract[]): Promise<EvmFunctionImplemented[]>;
19
- }
20
- //# sourceMappingURL=Diviner.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Diviner.d.ts","sourceRoot":"","sources":["../../src/Diviner.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC9E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAA;AAEpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAIxD,OAAO,KAAK,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAGxE,eAAO,MAAM,oCAAoC,mDAAmD,CAAA;AACpG,MAAM,MAAM,oCAAoC,GAAG,OAAO,oCAAoC,CAAA;AAE9F,MAAM,MAAM,8BAA8B,GAAG,aAAa,CAAC;IAAE,GAAG,CAAC,EAAE,YAAY,CAAC;IAAC,MAAM,EAAE,oCAAoC,CAAA;CAAE,CAAC,CAAA;AAEhI,MAAM,MAAM,8BAA8B,GAAG,aAAa,CAAC,eAAe,CAAC,8BAA8B,CAAC,CAAC,CAAA;AAE3G,qBAAa,wBAAwB,CAAC,OAAO,SAAS,8BAA8B,GAAG,8BAA8B,CAAE,SAAQ,eAAe,CAC5I,OAAO,EACP,WAAW,EACX,sBAAsB,CACvB;IACC,gBAAyB,aAAa,EAAE,MAAM,EAAE,CAAiE;IACjH,gBAAyB,mBAAmB,EAAE,MAAM,CAAuC;IAE3F,IAAI,GAAG,IAC0D,YAAY,CAC5E;cAEwB,aAAa,CAAC,UAAU,GAAE,WAAW,EAAO,GAAG,OAAO,CAAC,sBAAsB,EAAE,CAAC;CA8B1G"}
@@ -1,11 +0,0 @@
1
- import type { Payload } from '@xyo-network/payload-model';
2
- import type { Fragment, JsonFragment } from 'ethers';
3
- export type InterfaceAbi = string | ReadonlyArray<Fragment | JsonFragment | string>;
4
- export declare const EvmFunctionImplementedSchema = "network.xyo.evm.function.implemented";
5
- export type EvmFunctionImplementedSchema = typeof EvmFunctionImplementedSchema;
6
- export type EvmFunctionImplemented = Payload<{
7
- address: string;
8
- implemented: boolean;
9
- selector: string;
10
- }, EvmFunctionImplementedSchema>;
11
- //# sourceMappingURL=Payload.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Payload.d.ts","sourceRoot":"","sources":["../../src/Payload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAEpD,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,aAAa,CAAC,QAAQ,GAAG,YAAY,GAAG,MAAM,CAAC,CAAA;AAEnF,eAAO,MAAM,4BAA4B,yCAAyC,CAAA;AAClF,MAAM,MAAM,4BAA4B,GAAG,OAAO,4BAA4B,CAAA;AAE9E,MAAM,MAAM,sBAAsB,GAAG,OAAO,CAC1C;IACE,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,OAAO,CAAA;IACpB,QAAQ,EAAE,MAAM,CAAA;CACjB,EACD,4BAA4B,CAC7B,CAAA"}
@@ -1,3 +0,0 @@
1
- export * from './Diviner.ts';
2
- export * from './Payload.ts';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA"}
@@ -1,52 +0,0 @@
1
- // src/Diviner.ts
2
- import { assertEx } from "@xylabs/assert";
3
- import { AbstractDiviner } from "@xyo-network/diviner-abstract";
4
- import { EvmContractSchema } from "@xyo-network/evm-contract-witness";
5
- import { isPayloadOfSchemaType } from "@xyo-network/payload-model";
6
- import { Interface } from "ethers";
7
-
8
- // src/Payload.ts
9
- var EvmFunctionImplementedSchema = "network.xyo.evm.function.implemented";
10
-
11
- // src/Diviner.ts
12
- var EvmAbiImplementedDivinerConfigSchema = "network.xyo.evm.abi.implemented.diviner.config";
13
- var EvmAbiImplementedDiviner = class extends AbstractDiviner {
14
- static configSchemas = [...super.configSchemas, EvmAbiImplementedDivinerConfigSchema];
15
- static defaultConfigSchema = EvmAbiImplementedDivinerConfigSchema;
16
- get abi() {
17
- return assertEx(this.config?.abi, () => "No ABI specified");
18
- }
19
- async divineHandler(inPayloads = []) {
20
- await this.started("throw");
21
- try {
22
- const observations = await Promise.all(
23
- inPayloads.filter(isPayloadOfSchemaType(EvmContractSchema)).map(({ address, code }) => {
24
- const contractInterface = new Interface(this.abi);
25
- const byteCode = assertEx(code, () => "Missing code");
26
- const results = [];
27
- contractInterface.forEachFunction(({ selector }) => {
28
- const observation = {
29
- address,
30
- implemented: byteCode.includes(BigInt(selector).toString(16)),
31
- schema: EvmFunctionImplementedSchema,
32
- selector
33
- };
34
- results.push(observation);
35
- });
36
- return results;
37
- })
38
- );
39
- return observations.flat();
40
- } catch (ex) {
41
- const error = ex;
42
- console.log(`Error [${this.config.name}]: ${error.message}`);
43
- throw error;
44
- }
45
- }
46
- };
47
- export {
48
- EvmAbiImplementedDiviner,
49
- EvmAbiImplementedDivinerConfigSchema,
50
- EvmFunctionImplementedSchema
51
- };
52
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/Diviner.ts","../../src/Payload.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport type { DivinerConfig, DivinerParams } from '@xyo-network/diviner-model'\nimport type { EvmContract } from '@xyo-network/evm-contract-witness'\nimport { EvmContractSchema } from '@xyo-network/evm-contract-witness'\nimport type { AnyConfigSchema } from '@xyo-network/module-model'\nimport type { Schema } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\nimport { Interface } from 'ethers'\n\nimport type { EvmFunctionImplemented, InterfaceAbi } from './Payload.ts'\nimport { EvmFunctionImplementedSchema } from './Payload.ts'\n\nexport const EvmAbiImplementedDivinerConfigSchema = 'network.xyo.evm.abi.implemented.diviner.config'\nexport type EvmAbiImplementedDivinerConfigSchema = typeof EvmAbiImplementedDivinerConfigSchema\n\nexport type EvmAbiImplementedDivinerConfig = DivinerConfig<{ abi?: InterfaceAbi; schema: EvmAbiImplementedDivinerConfigSchema }>\n\nexport type EvmAbiImplementedDivinerParams = DivinerParams<AnyConfigSchema<EvmAbiImplementedDivinerConfig>>\n\nexport class EvmAbiImplementedDiviner<TParams extends EvmAbiImplementedDivinerParams = EvmAbiImplementedDivinerParams> extends AbstractDiviner<\n TParams,\n EvmContract,\n EvmFunctionImplemented\n> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, EvmAbiImplementedDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = EvmAbiImplementedDivinerConfigSchema\n\n get abi() {\n return assertEx(this.config?.abi, () => 'No ABI specified') as InterfaceAbi\n }\n\n protected override async divineHandler(inPayloads: EvmContract[] = []): Promise<EvmFunctionImplemented[]> {\n await this.started('throw')\n try {\n const observations = await Promise.all(\n inPayloads.filter(isPayloadOfSchemaType<EvmContract>(EvmContractSchema)).map(({ address, code }) => {\n const contractInterface = new Interface(this.abi)\n const byteCode = assertEx(code, () => 'Missing code')\n\n const results: EvmFunctionImplemented[] = []\n\n contractInterface.forEachFunction(({ selector }) => {\n const observation: EvmFunctionImplemented = {\n address,\n implemented: byteCode.includes(BigInt(selector).toString(16)),\n schema: EvmFunctionImplementedSchema,\n selector,\n }\n results.push(observation)\n })\n\n return results\n }),\n )\n return observations.flat()\n } catch (ex) {\n const error = ex as Error\n console.log(`Error [${this.config.name}]: ${error.message}`)\n throw error\n }\n }\n}\n","import type { Payload } from '@xyo-network/payload-model'\nimport type { Fragment, JsonFragment } from 'ethers'\n\nexport type InterfaceAbi = string | ReadonlyArray<Fragment | JsonFragment | string>\n\nexport const EvmFunctionImplementedSchema = 'network.xyo.evm.function.implemented'\nexport type EvmFunctionImplementedSchema = typeof EvmFunctionImplementedSchema\n\nexport type EvmFunctionImplemented = Payload<\n {\n address: string\n implemented: boolean\n selector: string\n },\n EvmFunctionImplementedSchema\n>\n"],"mappings":";AAAA,SAAS,gBAAgB;AACzB,SAAS,uBAAuB;AAGhC,SAAS,yBAAyB;AAGlC,SAAS,6BAA6B;AACtC,SAAS,iBAAiB;;;ACHnB,IAAM,+BAA+B;;;ADQrC,IAAM,uCAAuC;AAO7C,IAAM,2BAAN,cAAwH,gBAI7H;AAAA,EACA,OAAyB,gBAA0B,CAAC,GAAG,MAAM,eAAe,oCAAoC;AAAA,EAChH,OAAyB,sBAA8B;AAAA,EAEvD,IAAI,MAAM;AACR,WAAO,SAAS,KAAK,QAAQ,KAAK,MAAM,kBAAkB;AAAA,EAC5D;AAAA,EAEA,MAAyB,cAAc,aAA4B,CAAC,GAAsC;AACxG,UAAM,KAAK,QAAQ,OAAO;AAC1B,QAAI;AACF,YAAM,eAAe,MAAM,QAAQ;AAAA,QACjC,WAAW,OAAO,sBAAmC,iBAAiB,CAAC,EAAE,IAAI,CAAC,EAAE,SAAS,KAAK,MAAM;AAClG,gBAAM,oBAAoB,IAAI,UAAU,KAAK,GAAG;AAChD,gBAAM,WAAW,SAAS,MAAM,MAAM,cAAc;AAEpD,gBAAM,UAAoC,CAAC;AAE3C,4BAAkB,gBAAgB,CAAC,EAAE,SAAS,MAAM;AAClD,kBAAM,cAAsC;AAAA,cAC1C;AAAA,cACA,aAAa,SAAS,SAAS,OAAO,QAAQ,EAAE,SAAS,EAAE,CAAC;AAAA,cAC5D,QAAQ;AAAA,cACR;AAAA,YACF;AACA,oBAAQ,KAAK,WAAW;AAAA,UAC1B,CAAC;AAED,iBAAO;AAAA,QACT,CAAC;AAAA,MACH;AACA,aAAO,aAAa,KAAK;AAAA,IAC3B,SAAS,IAAI;AACX,YAAM,QAAQ;AACd,cAAQ,IAAI,UAAU,KAAK,OAAO,IAAI,MAAM,MAAM,OAAO,EAAE;AAC3D,YAAM;AAAA,IACR;AAAA,EACF;AACF;","names":[]}