parent
1f0a5c46d0
commit
2a42111e42
@ -0,0 +1,33 @@ |
|||||||
|
import React, { useEffect, useState, useContext } from 'react' |
||||||
|
import { ethers } from 'ethers/' |
||||||
|
|
||||||
|
interface ContractAddressInputProps { |
||||||
|
label: string |
||||||
|
id: string |
||||||
|
setContractAddress: (address: string) => void |
||||||
|
contractAddress: string |
||||||
|
} |
||||||
|
|
||||||
|
// Chooses one contract from the compilation output.
|
||||||
|
export const ContractAddressInput: React.FC<ContractAddressInputProps> = ({ label, id, setContractAddress, contractAddress }) => { |
||||||
|
const [contractAddressError, setContractAddressError] = useState('') |
||||||
|
|
||||||
|
const handleAddressChange = (event: React.ChangeEvent<HTMLInputElement>) => { |
||||||
|
const isValidAddress = ethers.utils.isAddress(event.target.value) |
||||||
|
setContractAddress(event.target.value) |
||||||
|
if (!isValidAddress) { |
||||||
|
setContractAddressError('Invalid contract address') |
||||||
|
console.error('Invalid contract address') |
||||||
|
return |
||||||
|
} |
||||||
|
setContractAddressError('') |
||||||
|
} |
||||||
|
|
||||||
|
return ( |
||||||
|
<div className="form-group"> |
||||||
|
<label htmlFor={id}>{label}</label> |
||||||
|
<div>{contractAddressError && <div className="text-danger">{contractAddressError}</div>}</div> |
||||||
|
<input type="text" className="form-control" id={id} placeholder="0x2738d13E81e..." value={contractAddress} onChange={handleAddressChange} /> |
||||||
|
</div> |
||||||
|
) |
||||||
|
} |
@ -1,3 +1,4 @@ |
|||||||
export { NavMenu } from './NavMenu' |
export { NavMenu } from './NavMenu' |
||||||
export { ContractDropdown } from './ContractDropdown' |
export { ContractDropdown } from './ContractDropdown' |
||||||
export { SearchableDropdown } from './SearchableDropdown' |
export { SearchableChainDropdown } from './SearchableChainDropdown' |
||||||
|
export { ContractAddressInput } from './ContractAddressInput' |
||||||
|
@ -0,0 +1,22 @@ |
|||||||
|
import { useState } from 'react' |
||||||
|
import { SearchableChainDropdown, ContractAddressInput } from '../components' |
||||||
|
import { Chain } from '../types/VerificationTypes' |
||||||
|
|
||||||
|
export const LookupView = () => { |
||||||
|
const [selectedChain, setSelectedChain] = useState<Chain | undefined>() |
||||||
|
const [contractAddress, setContractAddress] = useState('') |
||||||
|
|
||||||
|
const handleLookup = () => {} |
||||||
|
|
||||||
|
return ( |
||||||
|
<form onSubmit={handleLookup}> |
||||||
|
<SearchableChainDropdown label="Chain" id="network-dropdown" setSelectedChain={setSelectedChain} selectedChain={selectedChain} /> |
||||||
|
|
||||||
|
<ContractAddressInput label="Contract Address" id="contract-address" setContractAddress={setContractAddress} contractAddress={contractAddress} /> |
||||||
|
|
||||||
|
<button type="submit" className="btn btn-primary"> |
||||||
|
Lookup |
||||||
|
</button> |
||||||
|
</form> |
||||||
|
) |
||||||
|
} |
Loading…
Reference in new issue