diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index aea6453..0000000 --- a/.eslintignore +++ /dev/null @@ -1,8 +0,0 @@ -build -node_modules -ptau -circuits -inputs -dist -.vscode -.github diff --git a/.eslintrc.json b/.eslintrc.json index 7dc6e74..a26cdb3 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -23,6 +23,7 @@ } ] }, + "ignorePatterns": ["build", "node_modules", "ptau", "circuits", "inputs", "dist", ".vscode", ".github"], "overrides": [ { "files": ["**/*.ts", "**/*.tsx"], diff --git a/.npmignore b/.npmignore deleted file mode 100644 index a66bec2..0000000 --- a/.npmignore +++ /dev/null @@ -1,5 +0,0 @@ -* -!dist -!LICENSE -!package.json -!README.md diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index b589d41..0000000 --- a/.prettierignore +++ /dev/null @@ -1,4 +0,0 @@ -build -node_modules -dist -ptau diff --git a/.prettierrc.js b/.prettierrc.js deleted file mode 100644 index 6e6775a..0000000 --- a/.prettierrc.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = { - bracketSpacing: false, - singleQuote: true, - trailingComma: 'es5', - arrowParens: 'avoid', - printWidth: 120, -}; diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index e7e4501..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,52 +0,0 @@ -# Changelog - -## [0.0.19] - 2023-XX-XX - -- Fixes [#33](https://github.com/erhant/circomkit/issues/33), now `instantiate` respect the custom `dirCircuits` configuration. The function is moved within the Circomkit class, instead of being at its own file under `utils/instantiate.ts`. -- Fixes [#31](https://github.com/erhant/circomkit/issues/31). -- Slight refactor on the CLI switch-case condition. -- Update typescript to `^5.3.2` (note that TS doesnt use semver). -- Removed `gts` and downloaded `eslint` & `prettier` manually. -- `circomkit.instantiate` now respects existing `dir` and `version` in circuit config. -- Added NPM publish workflow. - -## [0.0.18] - 2023-08-30 - -- Removed linting & styling from tests, GTS broke something regarding prettier perhaps? Lints pass locally but not at the workflow. -- Changed `init` logic to be a git clone instead. - -## [0.0.17] - 2023-08-30 - -- Merged `build` and `test` workflows. -- Added optional Circuit Config parameter to `compile` method, allowing one to compile without having the circuit config at `circuits.json`. -- Added tests for the opitonal argument. -- Added optional input data arguments to `prove` and `witness`, allowing one to provide data without having it at `inputs` folder. -- Tidy up the changelog. -- Updated `gts` for development - -## [0.0.16] - 2023-07-17 - -- Quickfix: `compile` failed when there is no `build` folder. - -## [0.0.15] - 2023-07-17 - -- `compile` now calls Circom subprocess instead of using WASM tester. This provides better control over cmdline args, e.g. we can call `--inspect` and `--O2` and such. [#20](https://github.com/erhant/circomkit/issues/20) -- Added `inspect` option to config, defaulting to `true`. -- Added `--O2` and `--O2round` optimization levels by allowing `optimization` to be any number. If optimization is greater than 2, it corresponds to `--O2round` with the max round number as optimization level. - -## [0.0.14] - 2023-07-15 - -- Teardown script to terminate SnarkJS which makes tests hang indefinitely otherwise. -- `readWitness` added to `WitnessTester`. -- `readWitnessSignals` added to `WitnessTester`. -- `compute` function parameter typing fixed, it now allows any symbol. -- Default optimization level is now changed to 1 from 0. -- Fixed missing `WitnessTester` import in outputs of `npx circomkit init`. - -## [0.0.13] - 2023-07-15 - -- Wrongfully published. - -## [0.0.12] - 2023-07-01 - -- Released to public via Twitter post: . diff --git a/package.json b/package.json index 64679ec..c9caa53 100644 --- a/package.json +++ b/package.json @@ -8,10 +8,9 @@ "node": ">=12.0.0" }, "files": [ - "dist", + "dist/", "LICENSE", - "README.md", - "package.json" + "README.md" ], "bin": "dist/bin/index.js", "main": "dist/index.js", @@ -27,20 +26,20 @@ "scripts": { "build": "npx tsc -p tsconfig.build.json", "prebuild": "rimraf dist/", - "prepublish": "yarn build", "cli": "yarn build && node ./dist/bin", "test": "npx mocha", "pretest": "rimraf build/", "check": "npx tsc --noEmit", "style": "yarn format && yarn lint", - "lint": "npx eslint '**/*.ts'", - "format": "npx prettier --check ./**/*.ts" + "lint": "npx eslint '**/*.ts' && echo 'All good!'", + "format": "npx prettier --check ./src/**/*.ts ./tests/**/*.ts" }, "devDependencies": { "@types/chai": "^4.3.4", "@types/mocha": "^10.0.1", "@types/mocha-each": "^2.0.0", "@types/node": "^18.11.18", + "@types/snarkjs": "^0.7.7", "@typescript-eslint/eslint-plugin": "^6.13.1", "@typescript-eslint/parser": "^6.13.1", "eslint": "^8.54.0", @@ -60,6 +59,13 @@ "loglevel": "^1.8.1", "snarkjs": "^0.7.0" }, + "prettier": { + "bracketSpacing": false, + "singleQuote": true, + "trailingComma": "es5", + "arrowParens": "avoid", + "printWidth": 120 + }, "keywords": [ "circom", "zero knowledge", diff --git a/src/bin/index.ts b/src/bin/index.ts index 5d73411..0cc8e78 100644 --- a/src/bin/index.ts +++ b/src/bin/index.ts @@ -20,7 +20,7 @@ async function cli(): Promise { const titleLog = (title: string) => circomkit.log(`===| ${title} |===`, 'title'); // execute command - const command = process.argv[2] as keyof Circomkit | 'init' | 'config'; + const command = process.argv[2] as keyof Circomkit | 'init' | 'config' | 'help'; switch (command) { case 'compile': { titleLog('Compiling the circuit'); @@ -59,7 +59,7 @@ async function cli(): Promise { titleLog('Circuit information'); const info = await circomkit.info(process.argv[3]); circomkit.log(`Prime Field: ${info.primeName}`); - circomkit.log(`Number of of Wires: ${info.variables}`); + circomkit.log(`Number of Wires: ${info.variables}`); circomkit.log(`Number of Constraints: ${info.constraints}`); circomkit.log(`Number of Private Inputs: ${info.privateInputs}`); circomkit.log(`Number of Public Inputs: ${info.publicInputs}`); @@ -153,8 +153,13 @@ async function cli(): Promise { break; } + case 'help': + // help should return with a normal exit code, no need to pass-through to `default` case + console.log(usageString); + break; + default: - // command satisfies never; // CLI cases are not that well-typed yet + // command satisfies never; // TODO: CLI cases are not that well-typed yet console.log(usageString); return 1; } diff --git a/tsconfig.base.json b/tsconfig.base.json deleted file mode 100644 index 8e17568..0000000 --- a/tsconfig.base.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - // Google's TS Config - "compilerOptions": { - "allowUnreachableCode": false, - "allowUnusedLabels": false, - "declaration": true, - "forceConsistentCasingInFileNames": true, - "lib": ["ES2020"], - "module": "commonjs", - "noEmitOnError": true, - "noFallthroughCasesInSwitch": true, - "noImplicitReturns": true, - "noImplicitOverride": true, - "esModuleInterop": true, - "pretty": true, - "sourceMap": true, - "strict": true, - "target": "ES2020" - }, - "exclude": ["node_modules"] -} diff --git a/tsconfig.build.json b/tsconfig.build.json index f75eff0..81f6b95 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -1,5 +1,5 @@ { - "extends": "./tsconfig.base.json", + "extends": "./tsconfig.json", "compilerOptions": { "rootDir": "src", "outDir": "dist", diff --git a/tsconfig.json b/tsconfig.json index 0167ad8..7ad0502 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,22 @@ { - "extends": "./tsconfig.base.json", + // Google's TS Config + "compilerOptions": { + "allowUnreachableCode": false, + "allowUnusedLabels": false, + "declaration": true, + "forceConsistentCasingInFileNames": true, + "lib": ["ES2020"], + "module": "commonjs", + "noEmitOnError": true, + "noFallthroughCasesInSwitch": true, + "noImplicitReturns": true, + "noImplicitOverride": true, + "esModuleInterop": true, + "pretty": true, + "sourceMap": true, + "strict": true, + "target": "ES2020" + }, "include": ["src/types/**/*.*", "src/**/*.*", "tests/**/*.ts"], "exclude": ["node_modules", "build", "dist", "ptau"] } diff --git a/yarn.lock b/yarn.lock index 4da8ad1..da78752 100644 --- a/yarn.lock +++ b/yarn.lock @@ -198,6 +198,11 @@ resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.5.6.tgz#c65b2bfce1bec346582c07724e3f8c1017a20339" integrity sha512-dn1l8LaMea/IjDoHNd9J52uBbInB796CDffS6VdIxvqYCPSG0V0DzHp76GpaWnlhg88uYyPbXCDIowa86ybd5A== +"@types/snarkjs@^0.7.7": + version "0.7.7" + resolved "https://registry.yarnpkg.com/@types/snarkjs/-/snarkjs-0.7.7.tgz#2613bd56466497d4e4df0000c59f06b8bc2cfcea" + integrity sha512-t/fYLdqUDM7W/XP+CKh4kvo9SS2ejtqHJz/2LQf/UsrrCsDYRjQ85DQFdvIJ6FvJjUvtEEPpTSCPk9gDDjcBWQ== + "@typescript-eslint/eslint-plugin@^6.13.1": version "6.13.1" resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.13.1.tgz#f98bd887bf95551203c917e734d113bf8d527a0c"