@xyo-network/evm-abi-diviner 5.3.1 → 5.3.3

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,5 +1,5 @@
1
1
  // src/Diviner.ts
2
- import { assertEx } from "@xylabs/assert";
2
+ import { assertEx } from "@xylabs/sdk-js";
3
3
  import { AbstractDiviner } from "@xyo-network/diviner-abstract";
4
4
  import { EvmContractSchema } from "@xyo-network/evm-contract-witness";
5
5
  import { asSchema as asSchema2, isPayloadOfSchemaType } from "@xyo-network/payload-model";
@@ -1 +1 @@
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 { asSchema, 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 = asSchema('network.xyo.evm.abi.implemented.diviner.config', true)\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 { asSchema, 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 = asSchema('network.xyo.evm.function.implemented', true)\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,YAAAA,WAAU,6BAA6B;AAChD,SAAS,iBAAiB;;;ACR1B,SAAS,gBAA8B;AAKhC,IAAM,+BAA+B,SAAS,wCAAwC,IAAI;;;ADQ1F,IAAM,uCAAuCC,UAAS,kDAAkD,IAAI;AAO5G,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":["asSchema","asSchema"]}
1
+ {"version":3,"sources":["../../src/Diviner.ts","../../src/Payload.ts"],"sourcesContent":["import { assertEx } from '@xylabs/sdk-js'\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 { asSchema, 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 = asSchema('network.xyo.evm.abi.implemented.diviner.config', true)\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 { asSchema, 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 = asSchema('network.xyo.evm.function.implemented', true)\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,YAAAA,WAAU,6BAA6B;AAChD,SAAS,iBAAiB;;;ACR1B,SAAS,gBAA8B;AAKhC,IAAM,+BAA+B,SAAS,wCAAwC,IAAI;;;ADQ1F,IAAM,uCAAuCC,UAAS,kDAAkD,IAAI;AAO5G,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":["asSchema","asSchema"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/evm-abi-diviner",
3
- "version": "5.3.1",
3
+ "version": "5.3.3",
4
4
  "description": "Typescript/Javascript Plugins for XYO Platform",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -30,28 +30,36 @@
30
30
  "types": "dist/neutral/index.d.ts",
31
31
  "files": [
32
32
  "dist",
33
- "src",
34
- "!**/*.bench.*",
35
- "!**/*.spec.*",
36
- "!**/*.test.*"
33
+ "README.md"
37
34
  ],
38
35
  "dependencies": {
39
- "@xylabs/assert": "~5.0.64",
40
- "@xyo-network/diviner-abstract": "~5.3.2",
41
- "@xyo-network/diviner-model": "~5.3.2",
42
- "@xyo-network/evm-contract-witness": "5.3.1",
43
- "@xyo-network/module-model": "~5.3.2",
44
- "@xyo-network/payload-model": "~5.3.2",
45
- "ethers": "^6.16.0"
36
+ "@xyo-network/evm-contract-witness": "workspace:^"
46
37
  },
47
38
  "devDependencies": {
48
- "@xylabs/ts-scripts-yarn3": "~7.3.2",
49
- "@xylabs/tsconfig": "~7.3.2",
50
- "@xylabs/vitest-extended": "~5.0.64",
39
+ "@xylabs/sdk-js": "^5.0.90",
40
+ "@xylabs/ts-scripts-common": "~7.5.10",
41
+ "@xylabs/ts-scripts-yarn3": "~7.5.10",
42
+ "@xylabs/tsconfig": "~7.5.10",
43
+ "@xylabs/vitest-extended": "~5.0.90",
44
+ "@xyo-network/diviner-abstract": "~5.3.5",
45
+ "@xyo-network/diviner-model": "~5.3.5",
46
+ "@xyo-network/module-model": "~5.3.5",
51
47
  "@xyo-network/open-zeppelin-typechain": "~4.1.1",
52
- "@xyo-network/witness-evm-abstract": "~5.3.2",
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.18"
52
+ "vitest": "~4.1.2",
53
+ "zod": "^4.3.6"
54
+ },
55
+ "peerDependencies": {
56
+ "@xylabs/sdk-js": "^5",
57
+ "@xyo-network/diviner-abstract": "^5",
58
+ "@xyo-network/diviner-model": "^5",
59
+ "@xyo-network/module-model": "^5",
60
+ "@xyo-network/payload-model": "^5",
61
+ "ethers": "^6",
62
+ "zod": "^4"
55
63
  },
56
64
  "publishConfig": {
57
65
  "access": "public"
package/src/Diviner.ts DELETED
@@ -1,63 +0,0 @@
1
- import { assertEx } from '@xylabs/assert'
2
- import { AbstractDiviner } from '@xyo-network/diviner-abstract'
3
- import type { DivinerConfig, DivinerParams } from '@xyo-network/diviner-model'
4
- import type { EvmContract } from '@xyo-network/evm-contract-witness'
5
- import { EvmContractSchema } from '@xyo-network/evm-contract-witness'
6
- import type { AnyConfigSchema } from '@xyo-network/module-model'
7
- import type { Schema } from '@xyo-network/payload-model'
8
- import { asSchema, isPayloadOfSchemaType } from '@xyo-network/payload-model'
9
- import { Interface } from 'ethers'
10
-
11
- import type { EvmFunctionImplemented, InterfaceAbi } from './Payload.ts'
12
- import { EvmFunctionImplementedSchema } from './Payload.ts'
13
-
14
- export const EvmAbiImplementedDivinerConfigSchema = asSchema('network.xyo.evm.abi.implemented.diviner.config', true)
15
- export type EvmAbiImplementedDivinerConfigSchema = typeof EvmAbiImplementedDivinerConfigSchema
16
-
17
- export type EvmAbiImplementedDivinerConfig = DivinerConfig<{ abi?: InterfaceAbi; schema: EvmAbiImplementedDivinerConfigSchema }>
18
-
19
- export type EvmAbiImplementedDivinerParams = DivinerParams<AnyConfigSchema<EvmAbiImplementedDivinerConfig>>
20
-
21
- export class EvmAbiImplementedDiviner<TParams extends EvmAbiImplementedDivinerParams = EvmAbiImplementedDivinerParams> extends AbstractDiviner<
22
- TParams,
23
- EvmContract,
24
- EvmFunctionImplemented
25
- > {
26
- static override readonly configSchemas: Schema[] = [...super.configSchemas, EvmAbiImplementedDivinerConfigSchema]
27
- static override readonly defaultConfigSchema: Schema = EvmAbiImplementedDivinerConfigSchema
28
-
29
- get abi() {
30
- return assertEx(this.config?.abi, () => 'No ABI specified') as InterfaceAbi
31
- }
32
-
33
- protected override async divineHandler(inPayloads: EvmContract[] = []): Promise<EvmFunctionImplemented[]> {
34
- await this.started('throw')
35
- try {
36
- const observations = await Promise.all(
37
- inPayloads.filter(isPayloadOfSchemaType<EvmContract>(EvmContractSchema)).map(({ address, code }) => {
38
- const contractInterface = new Interface(this.abi)
39
- const byteCode = assertEx(code, () => 'Missing code')
40
-
41
- const results: EvmFunctionImplemented[] = []
42
-
43
- contractInterface.forEachFunction(({ selector }) => {
44
- const observation: EvmFunctionImplemented = {
45
- address,
46
- implemented: byteCode.includes(BigInt(selector).toString(16)),
47
- schema: EvmFunctionImplementedSchema,
48
- selector,
49
- }
50
- results.push(observation)
51
- })
52
-
53
- return results
54
- }),
55
- )
56
- return observations.flat()
57
- } catch (ex) {
58
- const error = ex as Error
59
- console.log(`Error [${this.config.name}]: ${error.message}`)
60
- throw error
61
- }
62
- }
63
- }
package/src/Payload.ts DELETED
@@ -1,16 +0,0 @@
1
- import { asSchema, type Payload } from '@xyo-network/payload-model'
2
- import type { Fragment, JsonFragment } from 'ethers'
3
-
4
- export type InterfaceAbi = string | ReadonlyArray<Fragment | JsonFragment | string>
5
-
6
- export const EvmFunctionImplementedSchema = asSchema('network.xyo.evm.function.implemented', true)
7
- export type EvmFunctionImplementedSchema = typeof EvmFunctionImplementedSchema
8
-
9
- export type EvmFunctionImplemented = Payload<
10
- {
11
- address: string
12
- implemented: boolean
13
- selector: string
14
- },
15
- EvmFunctionImplementedSchema
16
- >
package/src/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from './Diviner.ts'
2
- export * from './Payload.ts'