From 93cd86b37940c98bbd6fcc6ecc196bd218996b46 Mon Sep 17 00:00:00 2001 From: Jimmy Chu <898091+jimmychu0807@users.noreply.github.com> Date: Wed, 16 Oct 2024 22:01:31 +0800 Subject: [PATCH] refactor(contracts): update SemaphoreVerifierKeyPts library to be internal re #330 --- .../base/SemaphoreVerifierKeyPts.sol | 2 +- packages/contracts/scripts/utils.ts | 2 +- packages/contracts/tasks/deploy.ts | 29 +++---------------- 3 files changed, 6 insertions(+), 27 deletions(-) diff --git a/packages/contracts/contracts/base/SemaphoreVerifierKeyPts.sol b/packages/contracts/contracts/base/SemaphoreVerifierKeyPts.sol index 67e9bec5c..407b26f50 100644 --- a/packages/contracts/contracts/base/SemaphoreVerifierKeyPts.sol +++ b/packages/contracts/contracts/base/SemaphoreVerifierKeyPts.sol @@ -974,7 +974,7 @@ library SemaphoreVerifierKeyPts { hex"1ff343732becbc72450b2faedef7112b951edf2ee03bebe4b71365755e6d5518" hex"10e06fbbc2176bff93433750bcbfec05aea120f193a1e4c5bf5993e098916f96"; - function get_pts(uint256 merkleTreeDepth) public pure returns (uint256[SET_SIZE] memory pts) { + function get_pts(uint256 merkleTreeDepth) internal pure returns (uint256[SET_SIZE] memory pts) { bytes memory pt_bytes = VK_POINT_BYTES; uint256 byte_offset = 32 + (merkleTreeDepth - 1) * SET_SIZE * 32; diff --git a/packages/contracts/scripts/utils.ts b/packages/contracts/scripts/utils.ts index 11b4a00f4..9a6b0c19e 100644 --- a/packages/contracts/scripts/utils.ts +++ b/packages/contracts/scripts/utils.ts @@ -3,7 +3,7 @@ import { readFileSync, writeFileSync } from "fs" import { FactoryOptions } from "hardhat/types" export type NetworkDeployedContracts = { - name: "Semaphore" | "SemaphoreVerifier" | "PoseidonT3" | "SemaphoreVerifierKeyPts" + name: "Semaphore" | "SemaphoreVerifier" | "PoseidonT3" address: string startBlock: number }[] diff --git a/packages/contracts/tasks/deploy.ts b/packages/contracts/tasks/deploy.ts index f89c1e0b6..cb79edcd1 100644 --- a/packages/contracts/tasks/deploy.ts +++ b/packages/contracts/tasks/deploy.ts @@ -3,35 +3,18 @@ import { task, types } from "hardhat/config" import { deploy, saveDeployedContracts } from "../scripts/utils" task("deploy", "Deploy a Semaphore contract") - .addOptionalParam("verifierKeyPts", "Verifier key points library address", undefined, types.string) .addOptionalParam("verifier", "Verifier contract address", undefined, types.string) .addOptionalParam("poseidon", "Poseidon library address", undefined, types.string) .addOptionalParam("logs", "Print the logs", true, types.boolean) .setAction( async ( - { - logs, - verifierKeyPts: verifierKeyPtsAddress, - verifier: semaphoreVerifierAddress, - poseidon: poseidonT3Address - }, + { logs, verifier: semaphoreVerifierAddress, poseidon: poseidonT3Address }, { ethers, hardhatArguments } ): Promise => { const startBlock = await ethers.provider.getBlockNumber() - if (!verifierKeyPtsAddress) { - verifierKeyPtsAddress = await deploy(ethers, "SemaphoreVerifierKeyPts", hardhatArguments.network) - if (logs) { - console.info(`SemaphoreVerifierKeyPts library has been deployed to: ${verifierKeyPtsAddress}`) - } - } - if (!semaphoreVerifierAddress) { - semaphoreVerifierAddress = await deploy(ethers, "SemaphoreVerifier", hardhatArguments.network, [], { - libraries: { - SemaphoreVerifierKeyPts: verifierKeyPtsAddress - } - }) + semaphoreVerifierAddress = await deploy(ethers, "SemaphoreVerifier", hardhatArguments.network) if (logs) { console.info(`SemaphoreVerifier contract has been deployed to: ${semaphoreVerifierAddress}`) } @@ -39,6 +22,7 @@ task("deploy", "Deploy a Semaphore contract") if (!poseidonT3Address) { poseidonT3Address = await deploy(ethers, "PoseidonT3", hardhatArguments.network) + if (logs) { console.info(`PoseidonT3 library has been deployed to: ${poseidonT3Address}`) } @@ -55,17 +39,13 @@ task("deploy", "Deploy a Semaphore contract") } } ) + if (logs) { console.info(`Semaphore contract has been deployed to: ${semaphoreAddress}`) } saveDeployedContracts( [ - { - name: "SemaphoreVerifierKeyPts", - address: verifierKeyPtsAddress, - startBlock - }, { name: "SemaphoreVerifier", address: semaphoreVerifierAddress, @@ -88,7 +68,6 @@ task("deploy", "Deploy a Semaphore contract") return { semaphore: await ethers.getContractAt("Semaphore", semaphoreAddress), verifierAddress: semaphoreVerifierAddress, - verifierKeyPtsAddress, poseidonAddress: poseidonT3Address } }