mirror of
https://github.com/semaphore-protocol/semaphore.git
synced 2026-04-28 03:00:41 -04:00
revert(contracts): re-add script to verify contracts
This commit is contained in:
@@ -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",
|
||||
|
||||
44
packages/contracts/scripts/verify-contracts.ts
Normal file
44
packages/contracts/scripts/verify-contracts.ts
Normal 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)
|
||||
})
|
||||
Reference in New Issue
Block a user