Skip to content

Commit

Permalink
Fixed redundant protocol type generation in the hardhat.config.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
KyrylR committed Nov 8, 2024
1 parent a68981e commit 6018891
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
9 changes: 7 additions & 2 deletions src/core/ZkitTSGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
GeneratedCircuitWrapperResult,
CircuitSet,
ProtocolType,
ArtifactWithPath,
} from "../types";

import { normalizeName } from "../utils";
Expand All @@ -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;
Expand All @@ -59,11 +59,12 @@ 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,
});
}
}
Expand Down Expand Up @@ -244,4 +245,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);
}
}
4 changes: 0 additions & 4 deletions src/types/common.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from "./config";
export * from "./common";
export * from "./typesGenerator";
export * from "./circuitArtifact";

0 comments on commit 6018891

Please sign in to comment.