-
Notifications
You must be signed in to change notification settings - Fork 235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(data): refactor parameter validation using @zk-kit/utils #938
refactor(data): refactor parameter validation using @zk-kit/utils #938
Conversation
Co-authored-by: Vivian Plasencia <[email protected]>
…/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 <[email protected]> * docs(proof): add links to other repos in proof README * chore: bump `yarn.lock` * docs(proof): add punctuation --------- Co-authored-by: Cedoor <[email protected]>
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
Signed-off-by: hanghuge <[email protected]>
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 <[email protected]> --------- Co-authored-by: Vivian Plasencia <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @FaezehShakouri! Great work! Thank you very much! I just left some comments.
packages/data/src/ethers.ts
Outdated
@@ -17,8 +17,8 @@ import { | |||
Provider | |||
} from "ethers/providers" | |||
import { SemaphoreABI } from "@semaphore-protocol/utils/constants" | |||
import { errorHandlers } from "@zk-kit/utils" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
|
||
const { members = false, validatedProofs = false } = options | ||
|
||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just created a PR to support requireBoolean
, see privacy-scaling-explorations/zk-kit#373.
When the new version of the package is ready, this section can be updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
|
||
const { members = false, validatedProofs = false } = options | ||
|
||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -1,6 +1,6 @@ | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
checkParameter
function with theerrorHandlers
utility from the@zk-kit/utils
package for parameter validation across multiple files. This change improves code consistency and leverages existing utility functions for better error handling.checkParameter
to validate parameters.errorHandlers.requireString
anderrorHandlers.requireObject
for parameter validation, which provides a more standardized approach to error handling.Note: Currently, there is no
requireBoolean
function available in@zk-kit/utils
, so we are usingrequireDefined
for 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 format
andyarn lint
without getting any errors