@xyo-network/evm-abi-diviner 2.89.2 → 2.90.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 +2 -2
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.js +2 -2
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +2 -2
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.js +2 -2
- package/dist/node/index.js.map +1 -1
- package/package.json +10 -10
- package/src/Diviner.ts +2 -2
package/dist/browser/index.cjs
CHANGED
|
@@ -41,7 +41,7 @@ var EvmAbiImplementedDivinerConfigSchema = "network.xyo.evm.abi.implemented.divi
|
|
|
41
41
|
var EvmAbiImplementedDiviner = class extends import_diviner_abstract.AbstractDiviner {
|
|
42
42
|
static configSchemas = [EvmAbiImplementedDivinerConfigSchema];
|
|
43
43
|
get abi() {
|
|
44
|
-
return (0, import_assert.assertEx)(this.config?.abi, "No ABI specified");
|
|
44
|
+
return (0, import_assert.assertEx)(this.config?.abi, () => "No ABI specified");
|
|
45
45
|
}
|
|
46
46
|
async divineHandler(inPayloads = []) {
|
|
47
47
|
await this.started("throw");
|
|
@@ -49,7 +49,7 @@ var EvmAbiImplementedDiviner = class extends import_diviner_abstract.AbstractDiv
|
|
|
49
49
|
const observations = await Promise.all(
|
|
50
50
|
inPayloads.filter((0, import_payload_model.isPayloadOfSchemaType)(import_evm_contract_witness.EvmContractSchema)).map(({ address, code }) => {
|
|
51
51
|
const contractInterface = new import_ethers.Interface(this.abi);
|
|
52
|
-
const byteCode = (0, import_assert.assertEx)(code, "Missing code");
|
|
52
|
+
const byteCode = (0, import_assert.assertEx)(code, () => "Missing code");
|
|
53
53
|
const results = [];
|
|
54
54
|
contractInterface.forEachFunction(({ selector }) => {
|
|
55
55
|
const observation = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/Diviner.ts","../../src/Payload.ts"],"sourcesContent":["export * from './Diviner'\nexport * from './Payload'\n","import { assertEx } from '@xylabs/assert'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport { DivinerConfig, DivinerParams } from '@xyo-network/diviner-model'\nimport { EvmContract, EvmContractSchema } from '@xyo-network/evm-contract-witness'\nimport { AnyConfigSchema } from '@xyo-network/module-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\nimport { Interface } from 'ethers'\n\nimport { EvmFunctionImplemented, EvmFunctionImplementedSchema, InterfaceAbi } from './Payload'\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 configSchemas = [EvmAbiImplementedDivinerConfigSchema]\n\n get abi() {\n return assertEx(this.config?.abi, 'No ABI specified')\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 { Payload } from '@xyo-network/payload-model'\nimport { JsonFragment } from 'ethers'\n\nexport type InterfaceAbi = ReadonlyArray<JsonFragment>\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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAAyB;AACzB,8BAAgC;AAEhC,kCAA+C;AAE/C,2BAAsC;AACtC,oBAA0B;;;ACDnB,IAAM,+BAA+B;;;ADKrC,IAAM,uCAAuC;AAO7C,IAAM,2BAAN,cAAwH,wCAI7H;AAAA,EACA,OAAgB,gBAAgB,CAAC,oCAAoC;AAAA,EAErE,IAAI,MAAM;AACR,eAAO,wBAAS,KAAK,QAAQ,KAAK,kBAAkB;AAAA,
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/Diviner.ts","../../src/Payload.ts"],"sourcesContent":["export * from './Diviner'\nexport * from './Payload'\n","import { assertEx } from '@xylabs/assert'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport { DivinerConfig, DivinerParams } from '@xyo-network/diviner-model'\nimport { EvmContract, EvmContractSchema } from '@xyo-network/evm-contract-witness'\nimport { AnyConfigSchema } from '@xyo-network/module-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\nimport { Interface } from 'ethers'\n\nimport { EvmFunctionImplemented, EvmFunctionImplementedSchema, InterfaceAbi } from './Payload'\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 configSchemas = [EvmAbiImplementedDivinerConfigSchema]\n\n get abi() {\n return assertEx(this.config?.abi, () => 'No ABI specified')\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 { Payload } from '@xyo-network/payload-model'\nimport { JsonFragment } from 'ethers'\n\nexport type InterfaceAbi = ReadonlyArray<JsonFragment>\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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAAyB;AACzB,8BAAgC;AAEhC,kCAA+C;AAE/C,2BAAsC;AACtC,oBAA0B;;;ACDnB,IAAM,+BAA+B;;;ADKrC,IAAM,uCAAuC;AAO7C,IAAM,2BAAN,cAAwH,wCAI7H;AAAA,EACA,OAAgB,gBAAgB,CAAC,oCAAoC;AAAA,EAErE,IAAI,MAAM;AACR,eAAO,wBAAS,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,WAAO,4CAAmC,6CAAiB,CAAC,EAAE,IAAI,CAAC,EAAE,SAAS,KAAK,MAAM;AAClG,gBAAM,oBAAoB,IAAI,wBAAU,KAAK,GAAG;AAChD,gBAAM,eAAW,wBAAS,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":[]}
|
package/dist/browser/index.js
CHANGED
|
@@ -13,7 +13,7 @@ var EvmAbiImplementedDivinerConfigSchema = "network.xyo.evm.abi.implemented.divi
|
|
|
13
13
|
var EvmAbiImplementedDiviner = class extends AbstractDiviner {
|
|
14
14
|
static configSchemas = [EvmAbiImplementedDivinerConfigSchema];
|
|
15
15
|
get abi() {
|
|
16
|
-
return assertEx(this.config?.abi, "No ABI specified");
|
|
16
|
+
return assertEx(this.config?.abi, () => "No ABI specified");
|
|
17
17
|
}
|
|
18
18
|
async divineHandler(inPayloads = []) {
|
|
19
19
|
await this.started("throw");
|
|
@@ -21,7 +21,7 @@ var EvmAbiImplementedDiviner = class extends AbstractDiviner {
|
|
|
21
21
|
const observations = await Promise.all(
|
|
22
22
|
inPayloads.filter(isPayloadOfSchemaType(EvmContractSchema)).map(({ address, code }) => {
|
|
23
23
|
const contractInterface = new Interface(this.abi);
|
|
24
|
-
const byteCode = assertEx(code, "Missing code");
|
|
24
|
+
const byteCode = assertEx(code, () => "Missing code");
|
|
25
25
|
const results = [];
|
|
26
26
|
contractInterface.forEachFunction(({ selector }) => {
|
|
27
27
|
const observation = {
|
|
@@ -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 { DivinerConfig, DivinerParams } from '@xyo-network/diviner-model'\nimport { EvmContract, EvmContractSchema } from '@xyo-network/evm-contract-witness'\nimport { AnyConfigSchema } from '@xyo-network/module-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\nimport { Interface } from 'ethers'\n\nimport { EvmFunctionImplemented, EvmFunctionImplementedSchema, InterfaceAbi } from './Payload'\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 configSchemas = [EvmAbiImplementedDivinerConfigSchema]\n\n get abi() {\n return assertEx(this.config?.abi, 'No ABI specified')\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 { Payload } from '@xyo-network/payload-model'\nimport { JsonFragment } from 'ethers'\n\nexport type InterfaceAbi = ReadonlyArray<JsonFragment>\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;AAEhC,SAAsB,yBAAyB;AAE/C,SAAS,6BAA6B;AACtC,SAAS,iBAAiB;;;ACDnB,IAAM,+BAA+B;;;ADKrC,IAAM,uCAAuC;AAO7C,IAAM,2BAAN,cAAwH,gBAI7H;AAAA,EACA,OAAgB,gBAAgB,CAAC,oCAAoC;AAAA,EAErE,IAAI,MAAM;AACR,WAAO,SAAS,KAAK,QAAQ,KAAK,kBAAkB;AAAA,
|
|
1
|
+
{"version":3,"sources":["../../src/Diviner.ts","../../src/Payload.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport { DivinerConfig, DivinerParams } from '@xyo-network/diviner-model'\nimport { EvmContract, EvmContractSchema } from '@xyo-network/evm-contract-witness'\nimport { AnyConfigSchema } from '@xyo-network/module-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\nimport { Interface } from 'ethers'\n\nimport { EvmFunctionImplemented, EvmFunctionImplementedSchema, InterfaceAbi } from './Payload'\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 configSchemas = [EvmAbiImplementedDivinerConfigSchema]\n\n get abi() {\n return assertEx(this.config?.abi, () => 'No ABI specified')\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 { Payload } from '@xyo-network/payload-model'\nimport { JsonFragment } from 'ethers'\n\nexport type InterfaceAbi = ReadonlyArray<JsonFragment>\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;AAEhC,SAAsB,yBAAyB;AAE/C,SAAS,6BAA6B;AACtC,SAAS,iBAAiB;;;ACDnB,IAAM,+BAA+B;;;ADKrC,IAAM,uCAAuC;AAO7C,IAAM,2BAAN,cAAwH,gBAI7H;AAAA,EACA,OAAgB,gBAAgB,CAAC,oCAAoC;AAAA,EAErE,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":[]}
|
package/dist/node/index.cjs
CHANGED
|
@@ -42,7 +42,7 @@ var EvmAbiImplementedDiviner = class extends import_diviner_abstract.AbstractDiv
|
|
|
42
42
|
static configSchemas = [EvmAbiImplementedDivinerConfigSchema];
|
|
43
43
|
get abi() {
|
|
44
44
|
var _a;
|
|
45
|
-
return (0, import_assert.assertEx)((_a = this.config) == null ? void 0 : _a.abi, "No ABI specified");
|
|
45
|
+
return (0, import_assert.assertEx)((_a = this.config) == null ? void 0 : _a.abi, () => "No ABI specified");
|
|
46
46
|
}
|
|
47
47
|
async divineHandler(inPayloads = []) {
|
|
48
48
|
await this.started("throw");
|
|
@@ -50,7 +50,7 @@ var EvmAbiImplementedDiviner = class extends import_diviner_abstract.AbstractDiv
|
|
|
50
50
|
const observations = await Promise.all(
|
|
51
51
|
inPayloads.filter((0, import_payload_model.isPayloadOfSchemaType)(import_evm_contract_witness.EvmContractSchema)).map(({ address, code }) => {
|
|
52
52
|
const contractInterface = new import_ethers.Interface(this.abi);
|
|
53
|
-
const byteCode = (0, import_assert.assertEx)(code, "Missing code");
|
|
53
|
+
const byteCode = (0, import_assert.assertEx)(code, () => "Missing code");
|
|
54
54
|
const results = [];
|
|
55
55
|
contractInterface.forEachFunction(({ selector }) => {
|
|
56
56
|
const observation = {
|
package/dist/node/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/Diviner.ts","../../src/Payload.ts"],"sourcesContent":["export * from './Diviner'\nexport * from './Payload'\n","import { assertEx } from '@xylabs/assert'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport { DivinerConfig, DivinerParams } from '@xyo-network/diviner-model'\nimport { EvmContract, EvmContractSchema } from '@xyo-network/evm-contract-witness'\nimport { AnyConfigSchema } from '@xyo-network/module-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\nimport { Interface } from 'ethers'\n\nimport { EvmFunctionImplemented, EvmFunctionImplementedSchema, InterfaceAbi } from './Payload'\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 configSchemas = [EvmAbiImplementedDivinerConfigSchema]\n\n get abi() {\n return assertEx(this.config?.abi, 'No ABI specified')\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 { Payload } from '@xyo-network/payload-model'\nimport { JsonFragment } from 'ethers'\n\nexport type InterfaceAbi = ReadonlyArray<JsonFragment>\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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAAyB;AACzB,8BAAgC;AAEhC,kCAA+C;AAE/C,2BAAsC;AACtC,oBAA0B;;;ACDnB,IAAM,+BAA+B;;;ADKrC,IAAM,uCAAuC;AAO7C,IAAM,2BAAN,cAAwH,wCAI7H;AAAA,EACA,OAAgB,gBAAgB,CAAC,oCAAoC;AAAA,EAErE,IAAI,MAAM;AAxBZ;AAyBI,eAAO,yBAAS,UAAK,WAAL,mBAAa,KAAK,kBAAkB;AAAA,
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/Diviner.ts","../../src/Payload.ts"],"sourcesContent":["export * from './Diviner'\nexport * from './Payload'\n","import { assertEx } from '@xylabs/assert'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport { DivinerConfig, DivinerParams } from '@xyo-network/diviner-model'\nimport { EvmContract, EvmContractSchema } from '@xyo-network/evm-contract-witness'\nimport { AnyConfigSchema } from '@xyo-network/module-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\nimport { Interface } from 'ethers'\n\nimport { EvmFunctionImplemented, EvmFunctionImplementedSchema, InterfaceAbi } from './Payload'\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 configSchemas = [EvmAbiImplementedDivinerConfigSchema]\n\n get abi() {\n return assertEx(this.config?.abi, () => 'No ABI specified')\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 { Payload } from '@xyo-network/payload-model'\nimport { JsonFragment } from 'ethers'\n\nexport type InterfaceAbi = ReadonlyArray<JsonFragment>\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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAAyB;AACzB,8BAAgC;AAEhC,kCAA+C;AAE/C,2BAAsC;AACtC,oBAA0B;;;ACDnB,IAAM,+BAA+B;;;ADKrC,IAAM,uCAAuC;AAO7C,IAAM,2BAAN,cAAwH,wCAI7H;AAAA,EACA,OAAgB,gBAAgB,CAAC,oCAAoC;AAAA,EAErE,IAAI,MAAM;AAxBZ;AAyBI,eAAO,yBAAS,UAAK,WAAL,mBAAa,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,WAAO,4CAAmC,6CAAiB,CAAC,EAAE,IAAI,CAAC,EAAE,SAAS,KAAK,MAAM;AAClG,gBAAM,oBAAoB,IAAI,wBAAU,KAAK,GAAG;AAChD,gBAAM,eAAW,wBAAS,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":[]}
|
package/dist/node/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var EvmAbiImplementedDiviner = class extends AbstractDiviner {
|
|
|
14
14
|
static configSchemas = [EvmAbiImplementedDivinerConfigSchema];
|
|
15
15
|
get abi() {
|
|
16
16
|
var _a;
|
|
17
|
-
return assertEx((_a = this.config) == null ? void 0 : _a.abi, "No ABI specified");
|
|
17
|
+
return assertEx((_a = this.config) == null ? void 0 : _a.abi, () => "No ABI specified");
|
|
18
18
|
}
|
|
19
19
|
async divineHandler(inPayloads = []) {
|
|
20
20
|
await this.started("throw");
|
|
@@ -22,7 +22,7 @@ var EvmAbiImplementedDiviner = class extends AbstractDiviner {
|
|
|
22
22
|
const observations = await Promise.all(
|
|
23
23
|
inPayloads.filter(isPayloadOfSchemaType(EvmContractSchema)).map(({ address, code }) => {
|
|
24
24
|
const contractInterface = new Interface(this.abi);
|
|
25
|
-
const byteCode = assertEx(code, "Missing code");
|
|
25
|
+
const byteCode = assertEx(code, () => "Missing code");
|
|
26
26
|
const results = [];
|
|
27
27
|
contractInterface.forEachFunction(({ selector }) => {
|
|
28
28
|
const observation = {
|
package/dist/node/index.js.map
CHANGED
|
@@ -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 { DivinerConfig, DivinerParams } from '@xyo-network/diviner-model'\nimport { EvmContract, EvmContractSchema } from '@xyo-network/evm-contract-witness'\nimport { AnyConfigSchema } from '@xyo-network/module-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\nimport { Interface } from 'ethers'\n\nimport { EvmFunctionImplemented, EvmFunctionImplementedSchema, InterfaceAbi } from './Payload'\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 configSchemas = [EvmAbiImplementedDivinerConfigSchema]\n\n get abi() {\n return assertEx(this.config?.abi, 'No ABI specified')\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 { Payload } from '@xyo-network/payload-model'\nimport { JsonFragment } from 'ethers'\n\nexport type InterfaceAbi = ReadonlyArray<JsonFragment>\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;AAEhC,SAAsB,yBAAyB;AAE/C,SAAS,6BAA6B;AACtC,SAAS,iBAAiB;;;ACDnB,IAAM,+BAA+B;;;ADKrC,IAAM,uCAAuC;AAO7C,IAAM,2BAAN,cAAwH,gBAI7H;AAAA,EACA,OAAgB,gBAAgB,CAAC,oCAAoC;AAAA,EAErE,IAAI,MAAM;AAxBZ;AAyBI,WAAO,UAAS,UAAK,WAAL,mBAAa,KAAK,kBAAkB;AAAA,
|
|
1
|
+
{"version":3,"sources":["../../src/Diviner.ts","../../src/Payload.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport { DivinerConfig, DivinerParams } from '@xyo-network/diviner-model'\nimport { EvmContract, EvmContractSchema } from '@xyo-network/evm-contract-witness'\nimport { AnyConfigSchema } from '@xyo-network/module-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\nimport { Interface } from 'ethers'\n\nimport { EvmFunctionImplemented, EvmFunctionImplementedSchema, InterfaceAbi } from './Payload'\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 configSchemas = [EvmAbiImplementedDivinerConfigSchema]\n\n get abi() {\n return assertEx(this.config?.abi, () => 'No ABI specified')\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 { Payload } from '@xyo-network/payload-model'\nimport { JsonFragment } from 'ethers'\n\nexport type InterfaceAbi = ReadonlyArray<JsonFragment>\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;AAEhC,SAAsB,yBAAyB;AAE/C,SAAS,6BAA6B;AACtC,SAAS,iBAAiB;;;ACDnB,IAAM,+BAA+B;;;ADKrC,IAAM,uCAAuC;AAO7C,IAAM,2BAAN,cAAwH,gBAI7H;AAAA,EACA,OAAgB,gBAAgB,CAAC,oCAAoC;AAAA,EAErE,IAAI,MAAM;AAxBZ;AAyBI,WAAO,UAAS,UAAK,WAAL,mBAAa,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":[]}
|
package/package.json
CHANGED
|
@@ -10,22 +10,22 @@
|
|
|
10
10
|
"url": "https://github.com/XYOracleNetwork/plugins/issues"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@xylabs/assert": "^3.0.
|
|
14
|
-
"@xyo-network/diviner-abstract": "^2.
|
|
15
|
-
"@xyo-network/diviner-model": "^2.
|
|
16
|
-
"@xyo-network/evm-contract-witness": "~2.
|
|
17
|
-
"@xyo-network/module-model": "^2.
|
|
18
|
-
"@xyo-network/payload-model": "^2.
|
|
13
|
+
"@xylabs/assert": "^3.0.24",
|
|
14
|
+
"@xyo-network/diviner-abstract": "^2.93.0",
|
|
15
|
+
"@xyo-network/diviner-model": "^2.93.0",
|
|
16
|
+
"@xyo-network/evm-contract-witness": "~2.90.0",
|
|
17
|
+
"@xyo-network/module-model": "^2.93.0",
|
|
18
|
+
"@xyo-network/payload-model": "^2.93.0",
|
|
19
19
|
"ethers": "^6.11.1"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@xylabs/jest-helpers": "^3.0.
|
|
22
|
+
"@xylabs/jest-helpers": "^3.0.24",
|
|
23
23
|
"@xylabs/ts-scripts-yarn3": "^3.5.2",
|
|
24
24
|
"@xylabs/tsconfig": "^3.5.2",
|
|
25
25
|
"@xyo-network/open-zeppelin-typechain": "^3.0.5",
|
|
26
|
-
"@xyo-network/witness-evm-abstract": "^2.
|
|
26
|
+
"@xyo-network/witness-evm-abstract": "^2.93.0",
|
|
27
27
|
"jest": "^29.7.0",
|
|
28
|
-
"typescript": "^5.4.
|
|
28
|
+
"typescript": "^5.4.3"
|
|
29
29
|
},
|
|
30
30
|
"description": "Typescript/Javascript Plugins for XYO Platform",
|
|
31
31
|
"types": "dist/node/index.d.ts",
|
|
@@ -66,6 +66,6 @@
|
|
|
66
66
|
"url": "https://github.com/XYOracleNetwork/plugins.git"
|
|
67
67
|
},
|
|
68
68
|
"sideEffects": false,
|
|
69
|
-
"version": "2.
|
|
69
|
+
"version": "2.90.0",
|
|
70
70
|
"type": "module"
|
|
71
71
|
}
|
package/src/Diviner.ts
CHANGED
|
@@ -23,7 +23,7 @@ export class EvmAbiImplementedDiviner<TParams extends EvmAbiImplementedDivinerPa
|
|
|
23
23
|
static override configSchemas = [EvmAbiImplementedDivinerConfigSchema]
|
|
24
24
|
|
|
25
25
|
get abi() {
|
|
26
|
-
return assertEx(this.config?.abi, 'No ABI specified')
|
|
26
|
+
return assertEx(this.config?.abi, () => 'No ABI specified')
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
protected override async divineHandler(inPayloads: EvmContract[] = []): Promise<EvmFunctionImplemented[]> {
|
|
@@ -32,7 +32,7 @@ export class EvmAbiImplementedDiviner<TParams extends EvmAbiImplementedDivinerPa
|
|
|
32
32
|
const observations = await Promise.all(
|
|
33
33
|
inPayloads.filter(isPayloadOfSchemaType<EvmContract>(EvmContractSchema)).map(({ address, code }) => {
|
|
34
34
|
const contractInterface = new Interface(this.abi)
|
|
35
|
-
const byteCode = assertEx(code, 'Missing code')
|
|
35
|
+
const byteCode = assertEx(code, () => 'Missing code')
|
|
36
36
|
|
|
37
37
|
const results: EvmFunctionImplemented[] = []
|
|
38
38
|
|