show selected network

pull/5370/head
Aniket-Engg 2 years ago committed by Aniket
parent 0fbdb97bf2
commit 692bb62d89
  1. 4
      apps/etherscan/src/app/utils/verify.ts
  2. 21
      apps/etherscan/src/app/views/VerifyView.tsx

@ -119,14 +119,14 @@ export const verify = async (
resetAfter10Seconds(client, setResults) resetAfter10Seconds(client, setResults)
return returnValue return returnValue
} }
return { return {
message: 'unknown reason ' + result, message: 'unknown reason ' + result,
succeed: false succeed: false
} }
} catch (error: any) { } catch (error: any) {
console.error(error) console.error(error)
setResults("Something wrong happened, try again") setResults("Something wrong happened, try again")
return { return {
message: error.message, message: error.message,
succeed: false succeed: false
} }

@ -30,6 +30,7 @@ export const VerifyView: React.FC<Props> = ({
onVerifiedContract, onVerifiedContract,
}) => { }) => {
const [results, setResults] = useState("") const [results, setResults] = useState("")
const [networkName, setNetworkName] = useState("")
const verificationResult = useRef({}) const verificationResult = useRef({})
const onVerifyContract = async (values: FormValues) => { const onVerifyContract = async (values: FormValues) => {
@ -43,7 +44,6 @@ export const VerifyView: React.FC<Props> = ({
} }
const contractArguments = values.contractArguments.replace("0x", "") const contractArguments = values.contractArguments.replace("0x", "")
verificationResult.current = await verify( verificationResult.current = await verify(
apiKey, apiKey,
values.contractAddress, values.contractAddress,
@ -81,10 +81,21 @@ export const VerifyView: React.FC<Props> = ({
}} }}
onSubmit={(values) => onVerifyContract(values)} onSubmit={(values) => onVerifyContract(values)}
> >
{({ errors, touched, handleSubmit, isSubmitting }) => ( {({ errors, touched, handleSubmit, isSubmitting }) => {
<form onSubmit={handleSubmit}> if (client && client.call) client.call("network", "detectNetwork").then((network) => {
if (network && network['name']) setNetworkName(network['name'])
})
return (<form onSubmit={handleSubmit}>
<h6>Verify your smart contracts</h6> <h6>Verify your smart contracts</h6>
<div className="form-group"> <div className="form-group">
<label htmlFor="network">Selected Network</label>
<Field
className="form-control form-control-sm"
type="text"
name="network"
value={networkName}
/>
<label htmlFor="contractName">Contract Name</label> <label htmlFor="contractName">Contract Name</label>
<Field <Field
as="select" as="select"
@ -175,7 +186,9 @@ export const VerifyView: React.FC<Props> = ({
Generate Verification Scripts Generate Verification Scripts
</button> </button>
</form> </form>
)} )
}
}
</Formik> </Formik>
<div data-id="verify-result" <div data-id="verify-result"

Loading…
Cancel
Save