chore: create semaphore monorepo

Former-commit-id: a38dd20276
This commit is contained in:
cedoor
2022-09-16 16:50:21 +02:00
parent ecca5a4ee9
commit 8cf04ddb98
128 changed files with 4290 additions and 18022 deletions

View File

@@ -1,61 +0,0 @@
import fs from "fs"
import { run, hardhatArguments } from "hardhat"
async function main() {
const deployedContracts: { name: string; address: string }[] = []
// Deploy verifiers.
for (let treeDepth = 16; treeDepth <= 32; treeDepth++) {
const { address } = await run("deploy:verifier", { depth: treeDepth })
deployedContracts.push({
name: `Verifier${treeDepth}`,
address
})
if (
hardhatArguments.network &&
hardhatArguments.network !== "hardhat" &&
hardhatArguments.network !== "localhost"
) {
// Verify verifier.
await run("verify:verify", { address })
}
}
// Deploy Semaphore.
const { address } = await run("deploy:semaphore", {
verifiers: deployedContracts.map((c) => ({ merkleTreeDepth: c.name.substring(8), contractAddress: c.address }))
})
if (
hardhatArguments.network &&
hardhatArguments.network !== "hardhat" &&
hardhatArguments.network !== "localhost"
) {
// Verify Semaphore.
await run("verify:verify", {
address,
constructorArguments: [
deployedContracts.map((c) => ({ merkleTreeDepth: c.name.substring(8), contractAddress: c.address }))
]
})
deployedContracts.push({
name: `Semaphore`,
address
})
fs.writeFileSync(
`./deployed-contracts/${hardhatArguments.network}.json`,
JSON.stringify(deployedContracts, null, 4)
)
}
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error)
process.exit(1)
})

View File

@@ -1,24 +0,0 @@
import download from "download"
import fs from "fs"
import { config } from "../package.json"
async function main() {
const snarkArtifactsPath = config.paths.build["snark-artifacts"]
const url = `https://www.trusted-setup-pse.org/semaphore/${process.env.TREE_DEPTH}`
if (!fs.existsSync(snarkArtifactsPath)) {
fs.mkdirSync(snarkArtifactsPath, { recursive: true })
}
if (!fs.existsSync(`${snarkArtifactsPath}/semaphore.zkey`)) {
await download(`${url}/semaphore.wasm`, snarkArtifactsPath)
await download(`${url}/semaphore.zkey`, snarkArtifactsPath)
}
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error)
process.exit(1)
})