refactor(data): refactor parameter validation using @zk-kit/utils#938
refactor(data): refactor parameter validation using @zk-kit/utils#938FaezehShakouri wants to merge 185 commits intosemaphore-protocol:mainfrom
Conversation
Co-authored-by: Vivian Plasencia <v.pcalana@gmail.com>
…/convert-hex-pk Convert hexadecimal private key before signing messages
Turn on solidity optimizer re semaphore-protocol#740
perf(contracts): turn on solidity optimizer
fix: incorrect alias check brought from snarkjs. (possible security vulnerability)
…s/update-code Update Solidity code to create groups in documentation website
…/baby-jubjub Add check to make sure Baby Jubjub secret scalar is < l
Don't version control `asdf` and `direnv` configuration files
…/install-circom-deps ci: fix circom deps installation steps
…/docs docs: fix `typedoc` compilation warnings
…ignore chore: update `.gitignore`
…emaphore-protocol#747) * chore(proof): bump `@zk-kit/utils` dep * refactor(proof): use `maybeGetSemaphoreSnarkArtifacts` from `@zk-kit/utils` Delete logic related to fetching snark artifacts (wasm and zkey files) that was moved to `@zk-kit/utils` * revert(proof): add back `requireObject(snarkArtifacts)` check * chore(proof): update rollup.browser.config.ts * docs(proof): update README * chore(proof): remove unused import in rollup.browser.config.ts * Update packages/proof/package.json Co-authored-by: Cedoor <me@cedoor.dev> * docs(proof): add links to other repos in proof README * chore: bump `yarn.lock` * docs(proof): add punctuation --------- Co-authored-by: Cedoor <me@cedoor.dev>
chore: remove heyauthn package The heyauthn package was moved to the semaphore-protocol extensions repo. re semaphore-protocol#752
* chore(docs): format `mdx` files with `remark` `prettier` doesn't not have proper support for MDX v3. Docusaurus recommends using `remark` instead. https://docusaurus.io/docs/markdown-features/react re semaphore-protocol#503 * chore(docs): add remark lint plugins * chore: bump yarn.lock * chore: add `quiet` option to remark
docs(website): update roadmap on the website
…tocol#945) * docs: make year update dynamically on website and docs * docs(docs): make year update dynamically
* broken redirect CONTRIBUTING.md * typo README.md
fix: circuit logic url
) * chore(subgraph): update matchstick-as dependency * chore(subgraph): update dependency versions * ci: update pull request workflow to install libssl1.1 before testing the subgraph * ci: update pull requests workflow * ci: update ubuntu version * ci: update ubuntu version in tests * ci: update ubuntu version
* Add new article * Update apps/website/src/data/articles.json remove referral link Co-authored-by: Vivian Plasencia <v.pcalana@gmail.com> --------- Co-authored-by: Vivian Plasencia <v.pcalana@gmail.com>
vplasencia
left a comment
There was a problem hiding this comment.
Hey @FaezehShakouri! Great work! Thank you very much! I just left some comments.
packages/data/src/ethers.ts
Outdated
| Provider | ||
| } from "ethers/providers" | ||
| import { SemaphoreABI } from "@semaphore-protocol/utils/constants" | ||
| import { errorHandlers } from "@zk-kit/utils" |
There was a problem hiding this comment.
| import { errorHandlers } from "@zk-kit/utils" | |
| import { requireString } from "@zk-kit/utils/error-handlers" |
The module can be imported directly. This way it's no longer necessary to use errorHandlers.requireString and requireString can be used directly.
packages/data/src/subgraph.ts
Outdated
|
|
||
| checkParameter(members, "members", "boolean") | ||
| checkParameter(validatedProofs, "validatedProofs", "boolean") | ||
| // NOTE: There is no function to check if a parameter is a boolean, so currently we are just checking if it is defined or not |
There was a problem hiding this comment.
I just created a PR to support requireBoolean , see zk-kit/zk-kit#373.
When the new version of the package is ready, this section can be updated.
There was a problem hiding this comment.
Hey! There is a new version of the @zk-kit/utils package that supports requireBoolean . Feel free to update the version in the project and use the new function.
The packages using the @zk-kit/utils library are: group, identity, proof.
The @zk-kit/utils library should also be added as a dependency to the data package.
|
Hey @FaezehShakouri! Next time, please make sure to ask for the issue first, get it assigned, and then start working on it. Thank you for this PR. Could you write something in the issue so that we can assign it to you? |
packages/data/src/subgraph.ts
Outdated
|
|
||
| checkParameter(members, "members", "boolean") | ||
| checkParameter(validatedProofs, "validatedProofs", "boolean") | ||
| // NOTE: There is no function to check if a parameter is a boolean, so currently we are just checking if it is defined or not |
There was a problem hiding this comment.
Hey! There is a new version of the @zk-kit/utils package that supports requireBoolean . Feel free to update the version in the project and use the new function.
The packages using the @zk-kit/utils library are: group, identity, proof.
The @zk-kit/utils library should also be added as a dependency to the data package.
packages/data/src/subgraph.ts
Outdated
| import { defaultNetwork, SupportedNetwork } from "@semaphore-protocol/utils/networks" | ||
| import { AxiosRequestConfig } from "axios" | ||
| import checkParameter from "./checkParameter" | ||
| import { errorHandlers } from "@zk-kit/utils" |
There was a problem hiding this comment.
| import { errorHandlers } from "@zk-kit/utils" | |
| import { requireString, requireObject, requireBoolean } from "@zk-kit/utils/error-handlers" |
Similar to the ethers.ts file, you can use the error-handlers module directly.
0b0b4fb to
0e5cf7c
Compare
8fb970c to
2ba7e82
Compare
refactor(data): refactor parameter validation using @zk-kit/utils
🚨 Report Summary
For more details view the full report in OpenZeppelin Code Inspector |
|
I'm closing this PR because I accidentally rewrote the commit messages. I will open another PR. Sorry for the inconvenience. |
Description
This pull request replaces the custom
checkParameterfunction with theerrorHandlersutility from the@zk-kit/utilspackage for parameter validation across multiple files. This change improves code consistency and leverages existing utility functions for better error handling.checkParameterto validate parameters.errorHandlers.requireStringanderrorHandlers.requireObjectfor parameter validation, which provides a more standardized approach to error handling.Note: Currently, there is no
requireBooleanfunction available in@zk-kit/utils, so we are usingrequireDefinedfor parameter validation in the meantime.Related Issue(s)
Closes #773
Other information
No visual changes are introduced by this PR, as it primarily focuses on refactoring the parameter validation logic.
Checklist
yarn formatandyarn lintwithout getting any errors