Skip to content

Commit e0a1774

Browse files
KyrylRArvolear
andauthoredNov 8, 2024··
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 <[email protected]> --------- Co-authored-by: Artem Chystiakov <[email protected]>
1 parent a68981e commit e0a1774

File tree

6 files changed

+15
-10
lines changed

6 files changed

+15
-10
lines changed
 

Diff for: ‎CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## [v0.4.2]
4+
5+
* Fixed redundant protocol type generation in the `hardhat.config.ts`.
6+
37
## [v0.3.1-v0.4.1]
48

59
* Added an ability to provide protocol type in the ZKType config structure (#17)

Diff for: ‎package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: ‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@solarity/zktype",
3-
"version": "0.4.1",
3+
"version": "0.4.2",
44
"description": "Unleash TypeScript bindings for Circom circuits",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

Diff for: ‎src/core/ZkitTSGenerator.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
GeneratedCircuitWrapperResult,
1717
CircuitSet,
1818
ProtocolType,
19+
ArtifactWithPath,
1920
} from "../types";
2021

2122
import { normalizeName } from "../utils";
@@ -37,7 +38,6 @@ export default class ZkitTSGenerator extends BaseTSGenerator {
3738
circuitClasses.push({
3839
name: this._getCircuitName(artifacts[0].circuitArtifact),
3940
object: this._getCircuitName(artifacts[0].circuitArtifact),
40-
protocol: artifacts[0].protocol,
4141
});
4242

4343
continue;
@@ -59,11 +59,13 @@ export default class ZkitTSGenerator extends BaseTSGenerator {
5959
continue;
6060
}
6161

62+
const isProtocolTypeTheSame = this._isProtocolTypeTheSame(artifacts);
63+
6264
for (const artifact of artifacts) {
6365
circuitClasses.push({
6466
name: this._getFullCircuitName(artifact.circuitArtifact),
6567
object: this._getObjectPath(artifact.pathToGeneratedFile),
66-
protocol: artifact.protocol,
68+
protocol: isProtocolTypeTheSame ? undefined : artifact.protocol,
6769
});
6870
}
6971
}
@@ -244,4 +246,8 @@ export default class ZkitTSGenerator extends BaseTSGenerator {
244246

245247
return new Set(circuitArtifact.baseCircuitInfo.protocol);
246248
}
249+
250+
private _isProtocolTypeTheSame(artifactWithPaths: ArtifactWithPath[]) {
251+
return artifactWithPaths.every((circuit) => circuit.protocol === artifactWithPaths[0].protocol);
252+
}
247253
}

Diff for: ‎src/types/common.ts

-4
This file was deleted.

Diff for: ‎src/types/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
export * from "./config";
2-
export * from "./common";
32
export * from "./typesGenerator";
43
export * from "./circuitArtifact";

0 commit comments

Comments
 (0)
Please sign in to comment.