From b3714639b72dfd28d0a0648d9f62ad4db54123e7 Mon Sep 17 00:00:00 2001 From: Manuel Wedler Date: Tue, 30 Jul 2024 12:38:15 +0200 Subject: [PATCH] Add proxy verification call to VerifyView --- .../src/app/views/VerifyView.tsx | 44 ++++++++++++++++--- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/apps/contract-verification/src/app/views/VerifyView.tsx b/apps/contract-verification/src/app/views/VerifyView.tsx index 196cd2d797..7a53ce6b13 100644 --- a/apps/contract-verification/src/app/views/VerifyView.tsx +++ b/apps/contract-verification/src/app/views/VerifyView.tsx @@ -2,7 +2,7 @@ import { useContext, useEffect, useState } from 'react' import { AppContext } from '../AppContext' import { SearchableChainDropdown, ContractDropdown, ContractAddressInput } from '../components' -import type { VerifierIdentifier, Chain, SubmittedContract, VerificationReceipt, VerifierInfo } from '../types' +import type { VerifierIdentifier, Chain, SubmittedContract, VerificationReceipt, VerifierInfo, VerificationResponse } from '../types' import { VERIFIERS } from '../types' import { mergeChainSettingsWithDefaults, validConfiguration } from '../utils' import { useNavigate } from 'react-router-dom' @@ -80,18 +80,48 @@ export const VerifyView = () => { if (abiEncodedConstructorArgs) { newSubmittedContract.abiEncodedConstructorArgs = abiEncodedConstructorArgs } + + const proxyReceipts: VerificationReceipt[] = [] + if (hasProxy) { + for (const [verifierId, enabled] of Object.entries(enabledVerifiers)) { + if (!enabled) { + continue + } + + const verifierSettings = chainSettings.verifiers[verifierId] + const verifier = getVerifier(verifierId as VerifierIdentifier, { ...verifierSettings }) + if (!verifier.verifyProxy) { + continue + } + + const verifierInfo: VerifierInfo = { + apiUrl: verifierSettings.apiUrl, + name: verifierId as VerifierIdentifier, + } + proxyReceipts.push({ verifierInfo, status: 'pending', contractId, isProxyReceipt: true }) + } + + newSubmittedContract.proxyAddress = proxyAddress + newSubmittedContract.proxyReceipts = proxyReceipts + } + setSubmittedContracts((prev) => ({ ...prev, [newSubmittedContract.id]: newSubmittedContract })) // Take user to receipt view navigate('/receipts') - // Verify for each verifier. forEach does not wait for await and each promise will execute in parallel - receipts.forEach(async (receipt) => { + const verify = async (receipt: VerificationReceipt) => { const { verifierInfo } = receipt const verifierSettings = chainSettings.verifiers[verifierInfo.name] const verifier = getVerifier(verifierInfo.name, { ...verifierSettings }) try { - const { status, message, receiptId } = await verifier.verify(newSubmittedContract, compilerAbstract) + let response: VerificationResponse + if (receipt.isProxyReceipt) { + response = await verifier.verifyProxy(newSubmittedContract) + } else { + response = await verifier.verify(newSubmittedContract, compilerAbstract) + } + const { status, message, receiptId } = response receipt.status = status receipt.message = message if (receiptId) { @@ -105,7 +135,11 @@ export const VerifyView = () => { // Update the UI setSubmittedContracts((prev) => ({ ...prev, [newSubmittedContract.id]: newSubmittedContract })) - }) + } + + // Verify for each verifier. forEach does not wait for await and each promise will execute in parallel + receipts.forEach(verify) + proxyReceipts.forEach(verify) } return (