From 7d8603f9ee43907af15adda6a0263d3f4a0e3710 Mon Sep 17 00:00:00 2001 From: Marco Castignoli Date: Wed, 21 Jun 2023 17:59:50 +0200 Subject: [PATCH] #1071 prevent overriding already verified contract * fix missing check for address/chainId --- .../verification/verification.common.ts | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/server/controllers/verification/verification.common.ts b/src/server/controllers/verification/verification.common.ts index d95e333f9..9212ea82f 100644 --- a/src/server/controllers/verification/verification.common.ts +++ b/src/server/controllers/verification/verification.common.ts @@ -299,16 +299,19 @@ export const verifyContractsInSession = async ( for (const id in contractWrappers) { const contractWrapper = contractWrappers[id]; - const found = repositoryService.checkByChainAndAddress( - contractWrapper.address as string, - contractWrapper.chainId as string - ); + // Check if contract is already verified + if (Boolean(contractWrapper.address) && Boolean(contractWrapper.chainId)) { + const found = repositoryService.checkByChainAndAddress( + contractWrapper.address as string, + contractWrapper.chainId as string + ); - if (found.length) { - contractWrapper.status = found[0].status || "error"; - contractWrapper.statusMessage = found[0].message; - contractWrapper.storageTimestamp = found[0].storageTimestamp; - continue; + if (found.length) { + contractWrapper.status = found[0].status || "error"; + contractWrapper.statusMessage = found[0].message; + contractWrapper.storageTimestamp = found[0].storageTimestamp; + continue; + } } await checkAndFetchMissing(contractWrapper.contract);