diff --git a/apps/etherscan/src/app/views/VerifyView.tsx b/apps/etherscan/src/app/views/VerifyView.tsx index 5e4323e940..35f5fce803 100644 --- a/apps/etherscan/src/app/views/VerifyView.tsx +++ b/apps/etherscan/src/app/views/VerifyView.tsx @@ -52,20 +52,22 @@ export const VerifyView: React.FC = ({ }, [client]) useEffect(() => { - if (contracts.includes(selectedContract)) { - client.call("compilerArtefacts" as any, "getArtefactsByContractName", selectedContract).then((result) => { - const { artefact } = result - if (artefact && artefact.abi && artefact.abi[0] && artefact.abi[0].type && artefact.abi[0].type === 'constructor' && artefact.abi[0].inputs.length > 0) { - setConstructorInputs(artefact.abi[0].inputs) - setShowConstructorArgs(true) - } else { - setConstructorInputs([]) - setShowConstructorArgs(false) - } - }) - } + if (contracts.includes(selectedContract)) updateConsFields(selectedContract) }, [contracts]) + const updateConsFields = (contractName) => { + client.call("compilerArtefacts" as any, "getArtefactsByContractName", contractName).then((result) => { + const { artefact } = result + if (artefact && artefact.abi && artefact.abi[0] && artefact.abi[0].type && artefact.abi[0].type === 'constructor' && artefact.abi[0].inputs.length > 0) { + setConstructorInputs(artefact.abi[0].inputs) + setShowConstructorArgs(true) + } else { + setConstructorInputs([]) + setShowConstructorArgs(false) + } + }) + } + const onVerifyContract = async (values: FormValues) => { const compilationResult = (await client.call( "solidity", @@ -156,14 +158,7 @@ export const VerifyView: React.FC = ({ onChange={async (e) => { handleChange(e) setSelectedContract(e.target.value) - const {artefact} = await client.call("compilerArtefacts" as any, "getArtefactsByContractName", e.target.value) - if (artefact && artefact.abi && artefact.abi[0] && artefact.abi[0].type && artefact.abi[0].type === 'constructor' && artefact.abi[0].inputs.length > 0) { - setConstructorInputs(artefact.abi[0].inputs) - setShowConstructorArgs(true) - } else { - setConstructorInputs([]) - setShowConstructorArgs(false) - } + updateConsFields(e.target.value) }} >