Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions packages/utils/src/networks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,25 @@ export function getDeployedContract(supportedNetwork: SupportedNetwork) {
throw new Error(`Semaphore has not been deployed on '${supportedNetwork}' yet`)
}

const deployedContract = deployedContracts.find(({ network }) => network === supportedNetwork)
const networkDeployedContracts = deployedContracts.find(({ network }) => network === supportedNetwork)

return deployedContract!.contracts.find(({ name }) => name === "Semaphore") as {
if (!networkDeployedContracts) {
throw new Error(
`No deployed contracts found for network '${supportedNetwork}'. ` +
"Please ensure 'deployed-contracts.json' contains an entry for this network."
)
}

const semaphoreContract = networkDeployedContracts.contracts.find(({ name }) => name === "Semaphore")

if (!semaphoreContract) {
throw new Error(
`Contract 'Semaphore' not found in deployed contracts for network '${supportedNetwork}'. ` +
"Make sure deployments include 'Semaphore' for this network."
)
}

return semaphoreContract as {
name: string
address: string
startBlock: number
Expand Down