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