update constructor arguments section

pull/3879/head
Aniket-Engg 1 year ago committed by Aniket
parent b997c89359
commit 165b789e0d
  1. 21
      apps/etherscan/src/app/views/VerifyView.tsx

@ -33,6 +33,7 @@ export const VerifyView: React.FC<Props> = ({
}) => { }) => {
const [results, setResults] = useState("") const [results, setResults] = useState("")
const [networkName, setNetworkName] = useState("Loading...") const [networkName, setNetworkName] = useState("Loading...")
const [selectedContract, setSelectedContract] = useState("")
const [showConstructorArgs, setShowConstructorArgs] = useState(false) const [showConstructorArgs, setShowConstructorArgs] = useState(false)
const [isProxyContract, setIsProxyContract] = useState(false) const [isProxyContract, setIsProxyContract] = useState(false)
const [constructorInputs, setConstructorInputs] = useState([]) const [constructorInputs, setConstructorInputs] = useState([])
@ -50,6 +51,25 @@ export const VerifyView: React.FC<Props> = ({
} }
}, [client]) }, [client])
useEffect(() => {
console.log('contracts are updated--->', contracts)
console.log('contracts are updated-selectedContract-->', selectedContract)
if (contracts.includes(selectedContract)) {
console.log('contracts are updated-ShowConstructorArgs-->', showConstructorArgs)
client.call("compilerArtefacts" as any, "getArtefactsByContractName", selectedContract).then((artefact) => {
console.log('artefact----->', artefact)
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)
}
})
}
}, [contracts])
const onVerifyContract = async (values: FormValues) => { const onVerifyContract = async (values: FormValues) => {
const compilationResult = (await client.call( const compilationResult = (await client.call(
"solidity", "solidity",
@ -139,6 +159,7 @@ export const VerifyView: React.FC<Props> = ({
name="contractName" name="contractName"
onChange={async (e) => { onChange={async (e) => {
handleChange(e) handleChange(e)
setSelectedContract(e.target.value)
const {artefact} = await client.call("compilerArtefacts" as any, "getArtefactsByContractName", 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) { 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) setConstructorInputs(artefact.abi[0].inputs)

Loading…
Cancel
Save