From e7bbc321c2ab33bb7c9e68f15643e2261a60ab4f Mon Sep 17 00:00:00 2001 From: kumaryash90 Date: Mon, 21 Oct 2024 22:09:39 +0000 Subject: [PATCH] Fix auto verification of contracts (#5099) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Problem solved Short description of the bug fixed or feature added --- ## PR-Codex overview This PR introduces the export of the `verifyContract` function from `ContractSourcesPage.tsx` and integrates it into the `CustomContractForm` component to send a verification request after deploying a contract. ### Detailed summary - Changed `verifyContract` from a local function to an exported function in `ContractSourcesPage.tsx`. - Imported `verifyContract` into `custom-contract.tsx`. - Added a call to `verifyContract` in the `CustomContractForm` after contract deployment. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` --- .../[contractAddress]/sources/ContractSourcesPage.tsx | 2 +- .../contract-deploy-form/custom-contract.tsx | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/sources/ContractSourcesPage.tsx b/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/sources/ContractSourcesPage.tsx index 99fb0761c63..0134c9729b0 100644 --- a/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/sources/ContractSourcesPage.tsx +++ b/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/sources/ContractSourcesPage.tsx @@ -34,7 +34,7 @@ interface VerificationResult { error?: string; } -async function verifyContract(contract: ThirdwebContract) { +export async function verifyContract(contract: ThirdwebContract) { try { const response = await fetch( "https://contract.thirdweb.com/verify/contract", diff --git a/apps/dashboard/src/components/contract-components/contract-deploy-form/custom-contract.tsx b/apps/dashboard/src/components/contract-components/contract-deploy-form/custom-contract.tsx index 1f8237dd256..e5eb538ddf7 100644 --- a/apps/dashboard/src/components/contract-components/contract-deploy-form/custom-contract.tsx +++ b/apps/dashboard/src/components/contract-components/contract-deploy-form/custom-contract.tsx @@ -18,6 +18,7 @@ import { FormControl, } from "@chakra-ui/react"; import { useMutation, useQuery } from "@tanstack/react-query"; +import { verifyContract } from "app/(dashboard)/(chain)/[chain_id]/[contractAddress]/sources/ContractSourcesPage"; import { NetworkSelectorButton } from "components/selects/NetworkSelectorButton"; import { SolidityInput } from "contract-ui/components/solidity-inputs"; import { useTrack } from "hooks/analytics/useTrack"; @@ -537,6 +538,13 @@ export const CustomContractForm: React.FC = ({ // do the actual deployment const contractAddr = await deployMutation.mutateAsync(formData); + // send verification request - no need to await + verifyContract({ + address: contractAddr, + chain: walletChain, + client: thirdwebClient, + }); + trackEvent({ category: "custom-contract", action: "deploy",