From e0a1774370388b6bf1703d8f056d67d3b8fe7491 Mon Sep 17 00:00:00 2001 From: Kyrylo Riabov Date: Fri, 8 Nov 2024 19:52:59 +0200 Subject: [PATCH] Fix redundant protocol type generation in the hardhat.config.ts (#18) * Fixed redundant protocol type generation in the hardhat.config.ts * Update src/core/ZkitTSGenerator.ts LGTM Co-authored-by: Artem Chystiakov <47551140+Arvolear@users.noreply.github.com> --------- Co-authored-by: Artem Chystiakov <47551140+Arvolear@users.noreply.github.com> --- CHANGELOG.md | 4 ++++ package-lock.json | 4 ++-- package.json | 2 +- src/core/ZkitTSGenerator.ts | 10 ++++++++-- src/types/common.ts | 4 ---- src/types/index.ts | 1 - 6 files changed, 15 insertions(+), 10 deletions(-) delete mode 100644 src/types/common.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 3192271..83cfbce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## [v0.4.2] + +* Fixed redundant protocol type generation in the `hardhat.config.ts`. + ## [v0.3.1-v0.4.1] * Added an ability to provide protocol type in the ZKType config structure (#17) diff --git a/package-lock.json b/package-lock.json index 992ca90..532c0d5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@solarity/zktype", - "version": "0.4.1", + "version": "0.4.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@solarity/zktype", - "version": "0.4.1", + "version": "0.4.2", "license": "MIT", "dependencies": { "ejs": "3.1.10", diff --git a/package.json b/package.json index 3c57158..024c89f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@solarity/zktype", - "version": "0.4.1", + "version": "0.4.2", "description": "Unleash TypeScript bindings for Circom circuits", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/core/ZkitTSGenerator.ts b/src/core/ZkitTSGenerator.ts index 3a548d9..6908f0f 100644 --- a/src/core/ZkitTSGenerator.ts +++ b/src/core/ZkitTSGenerator.ts @@ -16,6 +16,7 @@ import { GeneratedCircuitWrapperResult, CircuitSet, ProtocolType, + ArtifactWithPath, } from "../types"; import { normalizeName } from "../utils"; @@ -37,7 +38,6 @@ export default class ZkitTSGenerator extends BaseTSGenerator { circuitClasses.push({ name: this._getCircuitName(artifacts[0].circuitArtifact), object: this._getCircuitName(artifacts[0].circuitArtifact), - protocol: artifacts[0].protocol, }); continue; @@ -59,11 +59,13 @@ export default class ZkitTSGenerator extends BaseTSGenerator { continue; } + const isProtocolTypeTheSame = this._isProtocolTypeTheSame(artifacts); + for (const artifact of artifacts) { circuitClasses.push({ name: this._getFullCircuitName(artifact.circuitArtifact), object: this._getObjectPath(artifact.pathToGeneratedFile), - protocol: artifact.protocol, + protocol: isProtocolTypeTheSame ? undefined : artifact.protocol, }); } } @@ -244,4 +246,8 @@ export default class ZkitTSGenerator extends BaseTSGenerator { return new Set(circuitArtifact.baseCircuitInfo.protocol); } + + private _isProtocolTypeTheSame(artifactWithPaths: ArtifactWithPath[]) { + return artifactWithPaths.every((circuit) => circuit.protocol === artifactWithPaths[0].protocol); + } } diff --git a/src/types/common.ts b/src/types/common.ts deleted file mode 100644 index 9c53d79..0000000 --- a/src/types/common.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface Result { - data: T; - error: { message: string } | null; -} diff --git a/src/types/index.ts b/src/types/index.ts index 27183ed..9dd717c 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -1,4 +1,3 @@ export * from "./config"; -export * from "./common"; export * from "./typesGenerator"; export * from "./circuitArtifact";