-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from iosis-tech/better_NPM
Better npm
- Loading branch information
Showing
8 changed files
with
857 additions
and
30 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,40 @@ | ||
pkg/ | ||
# Node modules | ||
node_modules/ | ||
|
||
# Output directories | ||
pkg/ | ||
dist/ | ||
|
||
# Generated files from scripts | ||
generated_imports.ts | ||
generated_verifier_map.ts | ||
|
||
# Logs | ||
*.log | ||
|
||
# TypeScript compiled output | ||
*.js | ||
*.js.map | ||
|
||
# IDE settings | ||
.vscode/ | ||
.idea/ | ||
*.sublime-project | ||
*.sublime-workspace | ||
|
||
# Environment variables | ||
.env | ||
.env.local | ||
.env.*.local | ||
|
||
# NPM/Yarn specific files | ||
package-lock.json | ||
yarn.lock | ||
|
||
# Operating System files | ||
.DS_Store | ||
Thumbs.db | ||
|
||
# Other files to ignore | ||
*.tgz | ||
*.zip |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#!/bin/bash | ||
|
||
# Define arrays for the different layouts, hashers, and stones | ||
LAYOUTS=("dex" "recursive" "recursive_with_poseidon" "small" "starknet" "starknet_with_keccak" "dynamic") | ||
HASHERS=("keccak_160_lsb" "keccak_248_lsb" "blake2s_160_lsb" "blake2s_248_lsb") | ||
STONES=("stone5" "stone6") | ||
|
||
# Function to build WASM packages | ||
build_wasm_packages() { | ||
for layout in "${LAYOUTS[@]}"; do | ||
for hasher in "${HASHERS[@]}"; do | ||
for stone in "${STONES[@]}"; do | ||
# Define output directory and features | ||
output_dir="src/pkg/swiftness_${layout}_${hasher}_${stone}" | ||
features="${layout},${hasher},${stone}" | ||
|
||
# Print message | ||
echo "Building WASM package with layout=$layout, hasher=$hasher, stone=$stone" | ||
|
||
# Run wasm-pack build with the specified features and output directory | ||
wasm-pack build --out-dir "$output_dir" --target web --features "$features" --no-default-features | ||
done | ||
done | ||
done | ||
} | ||
|
||
# Function to generate import statements | ||
generate_imports() { | ||
local output_file="generated_imports.ts" | ||
> "$output_file" # Clear the file if it exists | ||
|
||
for layout in "${LAYOUTS[@]}"; do | ||
for hasher in "${HASHERS[@]}"; do | ||
for stone in "${STONES[@]}"; do | ||
# Construct package and function names | ||
pkg_name="swiftness_${layout}_${hasher}_${stone}" | ||
parse_fn="parse_proof_${pkg_name}" | ||
verify_fn="verify_proof_${pkg_name}" | ||
|
||
# Generate import statement and append to output file | ||
echo "import init_${pkg_name}, {" >> "$output_file" | ||
echo " parse_proof as ${parse_fn}," >> "$output_file" | ||
echo " verify_proof as ${verify_fn}," >> "$output_file" | ||
echo "} from \"./pkg/${pkg_name}\";" >> "$output_file" | ||
echo "" >> "$output_file" | ||
done | ||
done | ||
done | ||
|
||
echo "Import statements have been generated and saved to $output_file." | ||
} | ||
|
||
# Function to generate the VerifierMap | ||
generate_verifier_map() { | ||
local output_file="generated_verifier_map.ts" | ||
> "$output_file" # Clear the file if it exists | ||
|
||
# Write the initial part of the VerifierMap object | ||
echo "const verifier_map: VerifierMap = {" >> "$output_file" | ||
|
||
for layout in "${LAYOUTS[@]}"; do | ||
for hasher in "${HASHERS[@]}"; do | ||
for stone in "${STONES[@]}"; do | ||
# Construct the unique identifiers | ||
map_key="\${Layout.${layout^^}}_\${Commitment.${hasher^^}}_\${Stone.${stone^^}}" | ||
pkg_name="swiftness_${layout}_${hasher}_${stone}" | ||
parse_fn="parse_proof_${pkg_name}" | ||
verify_fn="verify_proof_${pkg_name}" | ||
|
||
# Generate TypeScript entry for each combination | ||
echo " [\`${map_key}\`]: [" >> "$output_file" | ||
echo " init_${pkg_name}," >> "$output_file" | ||
echo " ${parse_fn}," >> "$output_file" | ||
echo " ${verify_fn}," >> "$output_file" | ||
echo " ]," >> "$output_file" | ||
done | ||
done | ||
done | ||
|
||
# Close the VerifierMap object | ||
echo "};" >> "$output_file" | ||
echo "Verifier map has been generated and saved to $output_file." | ||
} | ||
|
||
# Main execution | ||
build_wasm_packages | ||
# generate_imports | ||
# generate_verifier_map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"name": "swiftness", | ||
"type": "module", | ||
"description": "Swiftness CairoVM Verifier", | ||
"version": "0.1.2", | ||
"license": "SEE LICENSE IN LICENSE", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/iosis-tech/swiftness" | ||
}, | ||
"files": [ | ||
"dist/*", | ||
"swiftness.ts" | ||
], | ||
"main": "dist/swiftness.js", | ||
"types": "dist/swiftness.d.ts", | ||
"sideEffects": [ | ||
"./snippets/*" | ||
], | ||
"devDependencies": { | ||
"typescript": "^4.x.x" | ||
}, | ||
"scripts": { | ||
"build": "tsc && cp -r src/pkg dist", | ||
"prepublishOnly": "npm run build" | ||
} | ||
} |
Oops, something went wrong.