import { task } from "hardhat/config"; import { HardhatRuntimeEnvironment } from "hardhat/types"; import { ZKSMPSVerifier, ZKSMPSVerifier__factory } from "../types"; import { getDeployer, logHre, confirm } from "./utils"; export type DeploySingleSourceVerifierArgs = { // prefix for the contract name deploymentNamePrefix?: string; // Enable logging log?: boolean; // Manually confirm deployment manualConfirm?: boolean; // public key of the sismo soc sismoSocPubKeyX: string; sismoSocPubKeyY: string; }; export type DeployedSingleSourceVerifier = { zkSmpsVerifier: ZKSMPSVerifier; }; const CONTRACT_NAME = "ZKSMPSVerifier"; async function deploiementAction( { deploymentNamePrefix, log, manualConfirm, }: DeploySingleSourceVerifierArgs, hre: HardhatRuntimeEnvironment ): Promise { if (log) await logHre(hre); const deployer = await getDeployer(hre); if (manualConfirm) { console.log(`######## Arguments ${CONTRACT_NAME} Contract ########`); console.log({ from: deployer.address, }); await confirm(); } const deploymentName = deploymentNamePrefix ? `${deploymentNamePrefix}_${CONTRACT_NAME}` : CONTRACT_NAME; const deployed = await hre.deployments.deploy(deploymentName, { contract: CONTRACT_NAME, from: deployer.address, args: [], skipIfAlreadyDeployed: false }); if (log) { console.log(`######## Successfully Deployed ${CONTRACT_NAME} Contract ########`); console.log("Deployer: ", deployer.address); console.log("Address: ", deployed.address); console.log("\n"); } const zkSmpsVerifier = ZKSMPSVerifier__factory.connect(deployed.address, deployer); return { zkSmpsVerifier }; } task("deploy-zk-smps-verifier") .addOptionalParam("deploymentNamePrefix", "Prefix of the deployment name") .addFlag("log", "Log deployment steps") .addFlag("manualConfirm", "Manually confirm the deployment") .setAction(deploiementAction);