@xyo-network/evm-abi-diviner 2.97.0 → 2.98.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 +74 -1
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.js +51 -1
- package/dist/browser/index.js.map +1 -1
- package/dist/neutral/index.cjs +74 -1
- package/dist/neutral/index.cjs.map +1 -1
- package/dist/neutral/index.js +51 -1
- package/dist/neutral/index.js.map +1 -1
- package/dist/node/index.cjs +81 -1
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.js +52 -1
- package/dist/node/index.js.map +1 -1
- package/package.json +12 -12
package/dist/browser/index.cjs
CHANGED
|
@@ -1,2 +1,75 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
EvmAbiImplementedDiviner: () => EvmAbiImplementedDiviner,
|
|
24
|
+
EvmAbiImplementedDivinerConfigSchema: () => EvmAbiImplementedDivinerConfigSchema,
|
|
25
|
+
EvmFunctionImplementedSchema: () => EvmFunctionImplementedSchema
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(src_exports);
|
|
28
|
+
|
|
29
|
+
// src/Diviner.ts
|
|
30
|
+
var import_assert = require("@xylabs/assert");
|
|
31
|
+
var import_diviner_abstract = require("@xyo-network/diviner-abstract");
|
|
32
|
+
var import_evm_contract_witness = require("@xyo-network/evm-contract-witness");
|
|
33
|
+
var import_payload_model = require("@xyo-network/payload-model");
|
|
34
|
+
var import_ethers = require("ethers");
|
|
35
|
+
|
|
36
|
+
// src/Payload.ts
|
|
37
|
+
var EvmFunctionImplementedSchema = "network.xyo.evm.function.implemented";
|
|
38
|
+
|
|
39
|
+
// src/Diviner.ts
|
|
40
|
+
var EvmAbiImplementedDivinerConfigSchema = "network.xyo.evm.abi.implemented.diviner.config";
|
|
41
|
+
var EvmAbiImplementedDiviner = class extends import_diviner_abstract.AbstractDiviner {
|
|
42
|
+
static configSchemas = [...super.configSchemas, EvmAbiImplementedDivinerConfigSchema];
|
|
43
|
+
static defaultConfigSchema = EvmAbiImplementedDivinerConfigSchema;
|
|
44
|
+
get abi() {
|
|
45
|
+
return (0, import_assert.assertEx)(this.config?.abi, () => "No ABI specified");
|
|
46
|
+
}
|
|
47
|
+
async divineHandler(inPayloads = []) {
|
|
48
|
+
await this.started("throw");
|
|
49
|
+
try {
|
|
50
|
+
const observations = await Promise.all(
|
|
51
|
+
inPayloads.filter((0, import_payload_model.isPayloadOfSchemaType)(import_evm_contract_witness.EvmContractSchema)).map(({ address, code }) => {
|
|
52
|
+
const contractInterface = new import_ethers.Interface(this.abi);
|
|
53
|
+
const byteCode = (0, import_assert.assertEx)(code, () => "Missing code");
|
|
54
|
+
const results = [];
|
|
55
|
+
contractInterface.forEachFunction(({ selector }) => {
|
|
56
|
+
const observation = {
|
|
57
|
+
address,
|
|
58
|
+
implemented: byteCode.includes(BigInt(selector).toString(16)),
|
|
59
|
+
schema: EvmFunctionImplementedSchema,
|
|
60
|
+
selector
|
|
61
|
+
};
|
|
62
|
+
results.push(observation);
|
|
63
|
+
});
|
|
64
|
+
return results;
|
|
65
|
+
})
|
|
66
|
+
);
|
|
67
|
+
return observations.flat();
|
|
68
|
+
} catch (ex) {
|
|
69
|
+
const error = ex;
|
|
70
|
+
console.log(`Error [${this.config.name}]: ${error.message}`);
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
2
75
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -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, Schema } 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 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')\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":"
|
|
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, Schema } 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 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')\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,2BAA8C;AAC9C,oBAA0B;;;ACDnB,IAAM,+BAA+B;;;ADKrC,IAAM,uCAAuC;AAO7C,IAAM,2BAAN,cAAwH,wCAI7H;AAAA,EACA,OAAyB,gBAA0B,CAAC,GAAG,MAAM,eAAe,oCAAoC;AAAA,EAChH,OAAyB,sBAA8B;AAAA,EAEvD,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
|
@@ -1,2 +1,52 @@
|
|
|
1
|
-
|
|
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
|
+
};
|
|
2
52
|
//# sourceMappingURL=index.js.map
|
|
@@ -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, Schema } 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 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')\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,
|
|
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, Schema } 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 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')\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,6BAAqC;AAC9C,SAAS,iBAAiB;;;ACDnB,IAAM,+BAA+B;;;ADKrC,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":[]}
|
package/dist/neutral/index.cjs
CHANGED
|
@@ -1,2 +1,75 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
EvmAbiImplementedDiviner: () => EvmAbiImplementedDiviner,
|
|
24
|
+
EvmAbiImplementedDivinerConfigSchema: () => EvmAbiImplementedDivinerConfigSchema,
|
|
25
|
+
EvmFunctionImplementedSchema: () => EvmFunctionImplementedSchema
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(src_exports);
|
|
28
|
+
|
|
29
|
+
// src/Diviner.ts
|
|
30
|
+
var import_assert = require("@xylabs/assert");
|
|
31
|
+
var import_diviner_abstract = require("@xyo-network/diviner-abstract");
|
|
32
|
+
var import_evm_contract_witness = require("@xyo-network/evm-contract-witness");
|
|
33
|
+
var import_payload_model = require("@xyo-network/payload-model");
|
|
34
|
+
var import_ethers = require("ethers");
|
|
35
|
+
|
|
36
|
+
// src/Payload.ts
|
|
37
|
+
var EvmFunctionImplementedSchema = "network.xyo.evm.function.implemented";
|
|
38
|
+
|
|
39
|
+
// src/Diviner.ts
|
|
40
|
+
var EvmAbiImplementedDivinerConfigSchema = "network.xyo.evm.abi.implemented.diviner.config";
|
|
41
|
+
var EvmAbiImplementedDiviner = class extends import_diviner_abstract.AbstractDiviner {
|
|
42
|
+
static configSchemas = [...super.configSchemas, EvmAbiImplementedDivinerConfigSchema];
|
|
43
|
+
static defaultConfigSchema = EvmAbiImplementedDivinerConfigSchema;
|
|
44
|
+
get abi() {
|
|
45
|
+
return (0, import_assert.assertEx)(this.config?.abi, () => "No ABI specified");
|
|
46
|
+
}
|
|
47
|
+
async divineHandler(inPayloads = []) {
|
|
48
|
+
await this.started("throw");
|
|
49
|
+
try {
|
|
50
|
+
const observations = await Promise.all(
|
|
51
|
+
inPayloads.filter((0, import_payload_model.isPayloadOfSchemaType)(import_evm_contract_witness.EvmContractSchema)).map(({ address, code }) => {
|
|
52
|
+
const contractInterface = new import_ethers.Interface(this.abi);
|
|
53
|
+
const byteCode = (0, import_assert.assertEx)(code, () => "Missing code");
|
|
54
|
+
const results = [];
|
|
55
|
+
contractInterface.forEachFunction(({ selector }) => {
|
|
56
|
+
const observation = {
|
|
57
|
+
address,
|
|
58
|
+
implemented: byteCode.includes(BigInt(selector).toString(16)),
|
|
59
|
+
schema: EvmFunctionImplementedSchema,
|
|
60
|
+
selector
|
|
61
|
+
};
|
|
62
|
+
results.push(observation);
|
|
63
|
+
});
|
|
64
|
+
return results;
|
|
65
|
+
})
|
|
66
|
+
);
|
|
67
|
+
return observations.flat();
|
|
68
|
+
} catch (ex) {
|
|
69
|
+
const error = ex;
|
|
70
|
+
console.log(`Error [${this.config.name}]: ${error.message}`);
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
2
75
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -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, Schema } 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 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')\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":"
|
|
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, Schema } 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 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')\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,2BAA8C;AAC9C,oBAA0B;;;ACDnB,IAAM,+BAA+B;;;ADKrC,IAAM,uCAAuC;AAO7C,IAAM,2BAAN,cAAwH,wCAI7H;AAAA,EACA,OAAyB,gBAA0B,CAAC,GAAG,MAAM,eAAe,oCAAoC;AAAA,EAChH,OAAyB,sBAA8B;AAAA,EAEvD,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/neutral/index.js
CHANGED
|
@@ -1,2 +1,52 @@
|
|
|
1
|
-
|
|
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
|
+
};
|
|
2
52
|
//# sourceMappingURL=index.js.map
|
|
@@ -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, Schema } 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 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')\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,
|
|
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, Schema } 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 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')\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,6BAAqC;AAC9C,SAAS,iBAAiB;;;ACDnB,IAAM,+BAA+B;;;ADKrC,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":[]}
|
package/dist/node/index.cjs
CHANGED
|
@@ -1,2 +1,82 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
EvmAbiImplementedDiviner: () => EvmAbiImplementedDiviner,
|
|
24
|
+
EvmAbiImplementedDivinerConfigSchema: () => EvmAbiImplementedDivinerConfigSchema,
|
|
25
|
+
EvmFunctionImplementedSchema: () => EvmFunctionImplementedSchema
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(src_exports);
|
|
28
|
+
|
|
29
|
+
// src/Diviner.ts
|
|
30
|
+
var import_assert = require("@xylabs/assert");
|
|
31
|
+
var import_diviner_abstract = require("@xyo-network/diviner-abstract");
|
|
32
|
+
var import_evm_contract_witness = require("@xyo-network/evm-contract-witness");
|
|
33
|
+
var import_payload_model = require("@xyo-network/payload-model");
|
|
34
|
+
var import_ethers = require("ethers");
|
|
35
|
+
|
|
36
|
+
// src/Payload.ts
|
|
37
|
+
var EvmFunctionImplementedSchema = "network.xyo.evm.function.implemented";
|
|
38
|
+
|
|
39
|
+
// src/Diviner.ts
|
|
40
|
+
var EvmAbiImplementedDivinerConfigSchema = "network.xyo.evm.abi.implemented.diviner.config";
|
|
41
|
+
var EvmAbiImplementedDiviner = class extends import_diviner_abstract.AbstractDiviner {
|
|
42
|
+
static configSchemas = [...super.configSchemas, EvmAbiImplementedDivinerConfigSchema];
|
|
43
|
+
static defaultConfigSchema = EvmAbiImplementedDivinerConfigSchema;
|
|
44
|
+
get abi() {
|
|
45
|
+
var _a;
|
|
46
|
+
return (0, import_assert.assertEx)((_a = this.config) == null ? void 0 : _a.abi, () => "No ABI specified");
|
|
47
|
+
}
|
|
48
|
+
async divineHandler(inPayloads = []) {
|
|
49
|
+
await this.started("throw");
|
|
50
|
+
try {
|
|
51
|
+
const observations = await Promise.all(
|
|
52
|
+
inPayloads.filter((0, import_payload_model.isPayloadOfSchemaType)(import_evm_contract_witness.EvmContractSchema)).map(({ address, code }) => {
|
|
53
|
+
const contractInterface = new import_ethers.Interface(this.abi);
|
|
54
|
+
const byteCode = (0, import_assert.assertEx)(code, () => "Missing code");
|
|
55
|
+
const results = [];
|
|
56
|
+
contractInterface.forEachFunction(({ selector }) => {
|
|
57
|
+
const observation = {
|
|
58
|
+
address,
|
|
59
|
+
implemented: byteCode.includes(BigInt(selector).toString(16)),
|
|
60
|
+
schema: EvmFunctionImplementedSchema,
|
|
61
|
+
selector
|
|
62
|
+
};
|
|
63
|
+
results.push(observation);
|
|
64
|
+
});
|
|
65
|
+
return results;
|
|
66
|
+
})
|
|
67
|
+
);
|
|
68
|
+
return observations.flat();
|
|
69
|
+
} catch (ex) {
|
|
70
|
+
const error = ex;
|
|
71
|
+
console.log(`Error [${this.config.name}]: ${error.message}`);
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
77
|
+
0 && (module.exports = {
|
|
78
|
+
EvmAbiImplementedDiviner,
|
|
79
|
+
EvmAbiImplementedDivinerConfigSchema,
|
|
80
|
+
EvmFunctionImplementedSchema
|
|
81
|
+
});
|
|
2
82
|
//# sourceMappingURL=index.cjs.map
|
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, Schema } 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 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')\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":"
|
|
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, Schema } 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 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')\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,2BAA8C;AAC9C,oBAA0B;;;ACDnB,IAAM,+BAA+B;;;ADKrC,IAAM,uCAAuC;AAO7C,IAAM,2BAAN,cAAwH,wCAI7H;AAAA,EACA,OAAyB,gBAA0B,CAAC,GAAG,MAAM,eAAe,oCAAoC;AAAA,EAChH,OAAyB,sBAA8B;AAAA,EAEvD,IAAI,MAAM;AAzBZ;AA0BI,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
|
@@ -1,2 +1,53 @@
|
|
|
1
|
-
|
|
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
|
+
var _a;
|
|
18
|
+
return assertEx((_a = this.config) == null ? void 0 : _a.abi, () => "No ABI specified");
|
|
19
|
+
}
|
|
20
|
+
async divineHandler(inPayloads = []) {
|
|
21
|
+
await this.started("throw");
|
|
22
|
+
try {
|
|
23
|
+
const observations = await Promise.all(
|
|
24
|
+
inPayloads.filter(isPayloadOfSchemaType(EvmContractSchema)).map(({ address, code }) => {
|
|
25
|
+
const contractInterface = new Interface(this.abi);
|
|
26
|
+
const byteCode = assertEx(code, () => "Missing code");
|
|
27
|
+
const results = [];
|
|
28
|
+
contractInterface.forEachFunction(({ selector }) => {
|
|
29
|
+
const observation = {
|
|
30
|
+
address,
|
|
31
|
+
implemented: byteCode.includes(BigInt(selector).toString(16)),
|
|
32
|
+
schema: EvmFunctionImplementedSchema,
|
|
33
|
+
selector
|
|
34
|
+
};
|
|
35
|
+
results.push(observation);
|
|
36
|
+
});
|
|
37
|
+
return results;
|
|
38
|
+
})
|
|
39
|
+
);
|
|
40
|
+
return observations.flat();
|
|
41
|
+
} catch (ex) {
|
|
42
|
+
const error = ex;
|
|
43
|
+
console.log(`Error [${this.config.name}]: ${error.message}`);
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
export {
|
|
49
|
+
EvmAbiImplementedDiviner,
|
|
50
|
+
EvmAbiImplementedDivinerConfigSchema,
|
|
51
|
+
EvmFunctionImplementedSchema
|
|
52
|
+
};
|
|
2
53
|
//# sourceMappingURL=index.js.map
|
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, Schema } 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 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')\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,
|
|
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, Schema } 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 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')\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,6BAAqC;AAC9C,SAAS,iBAAiB;;;ACDnB,IAAM,+BAA+B;;;ADKrC,IAAM,uCAAuC;AAO7C,IAAM,2BAAN,cAAwH,gBAI7H;AAAA,EACA,OAAyB,gBAA0B,CAAC,GAAG,MAAM,eAAe,oCAAoC;AAAA,EAChH,OAAyB,sBAA8B;AAAA,EAEvD,IAAI,MAAM;AAzBZ;AA0BI,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.5.
|
|
14
|
-
"@xyo-network/diviner-abstract": "^2.
|
|
15
|
-
"@xyo-network/diviner-model": "^2.
|
|
16
|
-
"@xyo-network/evm-contract-witness": "
|
|
17
|
-
"@xyo-network/module-model": "^2.
|
|
18
|
-
"@xyo-network/payload-model": "^2.
|
|
13
|
+
"@xylabs/assert": "^3.5.2",
|
|
14
|
+
"@xyo-network/diviner-abstract": "^2.108.0",
|
|
15
|
+
"@xyo-network/diviner-model": "^2.108.0",
|
|
16
|
+
"@xyo-network/evm-contract-witness": "^2.98.0",
|
|
17
|
+
"@xyo-network/module-model": "^2.108.0",
|
|
18
|
+
"@xyo-network/payload-model": "^2.108.0",
|
|
19
19
|
"ethers": "^6.13.1"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@xylabs/jest-helpers": "^3.5.
|
|
23
|
-
"@xylabs/ts-scripts-yarn3": "^3.11.
|
|
24
|
-
"@xylabs/tsconfig": "^3.11.
|
|
22
|
+
"@xylabs/jest-helpers": "^3.5.2",
|
|
23
|
+
"@xylabs/ts-scripts-yarn3": "^3.11.12",
|
|
24
|
+
"@xylabs/tsconfig": "^3.11.12",
|
|
25
25
|
"@xyo-network/open-zeppelin-typechain": "^3.0.5",
|
|
26
|
-
"@xyo-network/witness-evm-abstract": "^2.
|
|
26
|
+
"@xyo-network/witness-evm-abstract": "^2.108.0",
|
|
27
27
|
"jest": "^29.7.0",
|
|
28
|
-
"typescript": "^5.5.
|
|
28
|
+
"typescript": "^5.5.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.98.0",
|
|
70
70
|
"type": "module"
|
|
71
71
|
}
|