import { List, Box, createListCollection, } from '@chakra-ui/react'; import React from 'react'; import type { FormFields } from '../types'; import type { SmartContractVerificationMethod, SmartContractVerificationConfig } from 'types/client/contract'; import { Heading } from 'toolkit/chakra/heading'; import { Link } from 'toolkit/chakra/link'; import type { SelectOption } from 'toolkit/chakra/select'; import { FormFieldSelect } from 'toolkit/components/forms/fields/FormFieldSelect'; import { Hint } from 'toolkit/components/Hint/Hint'; import { nbsp } from 'toolkit/utils/htmlEntities'; import { METHOD_LABELS } from '../utils'; interface Props { methods: SmartContractVerificationConfig['verification_options']; } const ContractVerificationFieldMethod = ({ methods }: Props) => { const collection = React.useMemo(() => createListCollection({ items: methods.map((method) => ({ value: method, label: METHOD_LABELS[method], })), }), [ methods ]); const renderPopoverListItem = React.useCallback((method: SmartContractVerificationMethod) => { switch (method) { case 'flattened-code': return Verification through a single file.; case 'multi-part': return Verification of multi-part Solidity files.; case 'sourcify': return Verification through Sourcify.; case 'standard-input': return ( Verification using Standard input JSON file. ); case 'vyper-code': return Verification of Vyper contract.; case 'vyper-multi-part': return Verification of multi-part Vyper files.; case 'vyper-standard-input': return ( Verification of Vyper contract using Standard input JSON file. ); case 'solidity-hardhat': return Verification through Hardhat plugin.; case 'solidity-foundry': return Verification through Foundry.; case 'stylus-github-repository': return Verification of Stylus contract via GitHub repository.; } }, []); const tooltipContent = ( Currently, Blockscout supports { methods.length } methods: { methods.map(renderPopoverListItem) } ); return ( <> Currently, Blockscout supports { methods.length }{ nbsp }contract verification methods name="method" placeholder="Verification method (compiler type)" collection={ collection } required readOnly={ collection.items.length === 1 } /> ); }; export default React.memo(ContractVerificationFieldMethod);