chore: add env var to download all snark artifacts

This commit is contained in:
cedoor
2022-11-18 16:13:25 +01:00
parent ba149545f2
commit 8f269ecafc
2 changed files with 12 additions and 6 deletions

View File

@@ -1,5 +1,6 @@
DEFAULT_NETWORK=hardhat
TREE_DEPTH=20
ALL_SNARK_ARTIFACTS=true
REPORT_GAS=false
BACKEND_PRIVATE_KEY=
INFURA_API_KEY=

View File

@@ -1,15 +1,20 @@
import download from "download"
import fs from "fs"
import dotenv from "dotenv"
dotenv.config()
async function main() {
const snarkArtifactsPath = "./snark-artifacts"
const url = `https://www.trusted-setup-pse.org/semaphore/${process.env.TREE_DEPTH || 20}`
if (!fs.existsSync(snarkArtifactsPath)) {
fs.mkdirSync(snarkArtifactsPath, { recursive: true })
}
if (process.env.ALL_SNARK_ARTIFACTS === "true") {
const url = `https://www.trusted-setup-pse.org/semaphore/semaphore.zip`
await download(url, snarkArtifactsPath, {
extract: true
})
} else {
const url = `https://www.trusted-setup-pse.org/semaphore/${process.env.TREE_DEPTH || 20}`
if (!fs.existsSync(`${snarkArtifactsPath}/semaphore.zkey`)) {
await download(`${url}/semaphore.wasm`, snarkArtifactsPath)
await download(`${url}/semaphore.zkey`, snarkArtifactsPath)
await download(`${url}/semaphore.json`, snarkArtifactsPath)