revert(contracts): re-add script to verify contracts

This commit is contained in:
cedoor
2024-01-19 12:45:00 +00:00
parent 887c51f629
commit 07ecafec1d
2 changed files with 45 additions and 0 deletions

View File

@@ -5,6 +5,7 @@
"start": "hardhat node",
"compile": "hardhat compile",
"deploy": "hardhat deploy",
"verify": "hardhat run scripts/verify-contracts.ts",
"test": "hardhat test",
"test:report-gas": "REPORT_GAS=true hardhat test",
"test:coverage": "hardhat coverage",

View File

@@ -0,0 +1,44 @@
import { hardhatArguments, run } from "hardhat"
import { readFileSync } from "fs"
type DeployedContracts = {
Poseidon: string
Semaphore: string
Verifier: string
}
export function getDeployedContracts(network: string | undefined): DeployedContracts | null {
try {
return JSON.parse(readFileSync(`./deployed-contracts/${network}.json`, "utf8"))
} catch (error) {
return null
}
}
async function verify(address: string, constructorArguments?: any[]): Promise<void> {
try {
await run("verify:verify", {
address,
constructorArguments
})
} catch (error) {
console.error(error)
}
}
async function main() {
const deployedContracts = getDeployedContracts(hardhatArguments.network)
if (deployedContracts) {
await verify(deployedContracts.Verifier)
await verify(deployedContracts.Poseidon)
await verify(deployedContracts.Semaphore, [deployedContracts.Verifier])
}
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error)
process.exit(1)
})