common method

pull/3879/head
Aniket-Engg 1 year ago committed by Aniket
parent 4721fc233a
commit ffd54b4b14
  1. 17
      apps/etherscan/src/app/views/VerifyView.tsx

@ -52,8 +52,11 @@ export const VerifyView: React.FC<Props> = ({
}, [client])
useEffect(() => {
if (contracts.includes(selectedContract)) {
client.call("compilerArtefacts" as any, "getArtefactsByContractName", selectedContract).then((result) => {
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)
@ -64,7 +67,6 @@ export const VerifyView: React.FC<Props> = ({
}
})
}
}, [contracts])
const onVerifyContract = async (values: FormValues) => {
const compilationResult = (await client.call(
@ -156,14 +158,7 @@ export const VerifyView: React.FC<Props> = ({
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)
}}
>
<option disabled={true} value="">

Loading…
Cancel
Save