Skip to content
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(utils): remove @zk-kit/utils/snark-artifacts #288

Merged
merged 3 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const projects: any = fs
rootDir: `packages/${name}`,
displayName: name,
moduleNameMapper: {
"@zk-kit/artifacts": ["<rootDir>/../../node_modules/@zk-kit/artifacts/dist/index.node.cjs"],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as @zk-kit/artifacts is out of the monorepo packages, we must not override the corresponding entry it in the moduleNameMapper object. Is there a better way?

"@zk-kit/(.*)/(.*)": ["<rootDir>/../$1/src/$2.ts", "<rootDir>/../$1/src/$2/$2.node.ts"],
"@zk-kit/(.*)": "<rootDir>/../$1/src/index.ts"
}
Expand Down
1 change: 1 addition & 0 deletions packages/poseidon-proof/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"rollup-plugin-cleanup": "^3.2.1"
},
"dependencies": {
"@zk-kit/artifacts": "^1.3.1",
"@zk-kit/utils": "1.0.0-beta.4",
"ethers": "^6.12.0",
"snarkjs": "^0.7.3"
Expand Down
3 changes: 1 addition & 2 deletions packages/poseidon-proof/src/generate.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { BigNumber } from "@ethersproject/bignumber"
import type { SnarkArtifacts } from "@zk-kit/utils"
import { maybeGetSnarkArtifacts, Project, type SnarkArtifacts } from "@zk-kit/artifacts"
import { packGroth16Proof } from "@zk-kit/utils/proof-packing"
import maybeGetSnarkArtifacts, { Project } from "@zk-kit/utils/snark-artifacts"
import { BigNumberish } from "ethers"
import { NumericString, groth16 } from "snarkjs"
import hash from "./hash"
Expand Down
16 changes: 2 additions & 14 deletions packages/utils/rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,7 @@ export default [
external: Object.keys(pkg.dependencies),
plugins: [
alias({
entries: [
{ find: "./crypto/crypto.node", replacement: "./crypto/crypto.browser" },
{
find: "./snark-artifacts/snark-artifacts.node",
replacement: "./snark-artifacts/snark-artifacts.browser"
}
]
entries: [{ find: "./crypto/crypto.node", replacement: "./crypto/crypto.browser" }]
}),
typescript({
tsconfig: "./build.tsconfig.json"
Expand All @@ -77,13 +71,7 @@ export default [
external: [],
plugins: [
alias({
entries: [
{ find: "./crypto/crypto.node", replacement: "./crypto/crypto.browser" },
{
find: "./snark-artifacts/snark-artifacts.node",
replacement: "./snark-artifacts/snark-artifacts.browser"
}
]
entries: [{ find: "./crypto/crypto.node", replacement: "./crypto/crypto.browser" }]
}),
typescript({
tsconfig: "./build.tsconfig.json"
Expand Down
3 changes: 1 addition & 2 deletions packages/utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import * as errorHandlers from "./error-handlers"
import F1Field from "./f1-field"
import * as packing from "./proof-packing"
import * as scalar from "./scalar"
import maybeGetSnarkArtifacts from "./snark-artifacts/snark-artifacts.node"
import * as typeChecks from "./type-checks"

export * from "./conversions"
export * from "./error-handlers"
export * from "./proof-packing"
export * from "./type-checks"
export * from "./types"
export { F1Field, conversions, crypto, errorHandlers, maybeGetSnarkArtifacts, packing, scalar, typeChecks }
export { F1Field, conversions, crypto, errorHandlers, packing, scalar, typeChecks }
9 changes: 0 additions & 9 deletions packages/utils/src/snark-artifacts/projects.ts

This file was deleted.

28 changes: 0 additions & 28 deletions packages/utils/src/snark-artifacts/snark-artifacts.browser.ts

This file was deleted.

73 changes: 0 additions & 73 deletions packages/utils/src/snark-artifacts/snark-artifacts.node.ts

This file was deleted.

24 changes: 0 additions & 24 deletions packages/utils/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,3 @@ export type PackedGroth16Proof = [
NumericString,
NumericString
]

/**
* @prop SnarkArtifacts.wasm
* @prop SnarkArtifacts.zkey
* @interface
*/
export type SnarkArtifacts = Record<"wasm" | "zkey", string>

type Digit = `${number}`
type PreRelease = "alpha" | "beta"

/**
* Semantic version.
* @example
* 1.0.0-beta
* 2.0.0
* @example
* "latest"
*/
export type Version =
| `${Digit}.${Digit}.${Digit}`
| `${Digit}.${Digit}.${Digit}-${PreRelease}`
| `${Digit}.${Digit}.${Digit}-${PreRelease}.${Digit}`
| "latest"
94 changes: 0 additions & 94 deletions packages/utils/tests/snark-artifacts.test.ts

This file was deleted.

8 changes: 8 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3437,6 +3437,13 @@ __metadata:
languageName: node
linkType: hard

"@zk-kit/artifacts@npm:^1.3.1":
version: 1.3.1
resolution: "@zk-kit/artifacts@npm:1.3.1"
checksum: 10/8be21e3967c05b0b8ed250db84c0d37c86bcbc389b0792b55b27313c5b8fdae03e8fd5fdcafd8dfcbabee253f7d90669c485b168790eaf96e60e38261698a4d4
languageName: node
linkType: hard

"@zk-kit/baby-jubjub@npm:1.0.0, @zk-kit/baby-jubjub@workspace:packages/baby-jubjub":
version: 0.0.0-use.local
resolution: "@zk-kit/baby-jubjub@workspace:packages/baby-jubjub"
Expand Down Expand Up @@ -3590,6 +3597,7 @@ __metadata:
"@types/download": "npm:^8.0.5"
"@types/snarkjs": "npm:^0"
"@types/tmp": "npm:^0.2.6"
"@zk-kit/artifacts": "npm:^1.3.1"
"@zk-kit/utils": "npm:1.0.0-beta.4"
ethers: "npm:^6.12.0"
poseidon-lite: "npm:^0.2.0"
Expand Down
Loading