Commit 8c601d38 authored by tom's avatar tom

evm version and compiler

parent 995b42ee
...@@ -2,6 +2,7 @@ import { checkboxAnatomy as parts } from '@chakra-ui/anatomy'; ...@@ -2,6 +2,7 @@ import { checkboxAnatomy as parts } from '@chakra-ui/anatomy';
import { import {
createMultiStyleConfigHelpers, createMultiStyleConfigHelpers,
defineStyle, defineStyle,
cssVar,
} from '@chakra-ui/styled-system'; } from '@chakra-ui/styled-system';
import { mode } from '@chakra-ui/theme-tools'; import { mode } from '@chakra-ui/theme-tools';
import { runIfFn } from '@chakra-ui/utils'; import { runIfFn } from '@chakra-ui/utils';
...@@ -9,6 +10,8 @@ import { runIfFn } from '@chakra-ui/utils'; ...@@ -9,6 +10,8 @@ import { runIfFn } from '@chakra-ui/utils';
const { definePartsStyle, defineMultiStyleConfig } = const { definePartsStyle, defineMultiStyleConfig } =
createMultiStyleConfigHelpers(parts.keys); createMultiStyleConfigHelpers(parts.keys);
const $size = cssVar('checkbox-size');
const baseStyleControl = defineStyle((props) => { const baseStyleControl = defineStyle((props) => {
const { colorScheme: c } = props; const { colorScheme: c } = props;
...@@ -28,6 +31,24 @@ const baseStyleControl = defineStyle((props) => { ...@@ -28,6 +31,24 @@ const baseStyleControl = defineStyle((props) => {
}; };
}); });
const sizes = {
sm: definePartsStyle({
control: { [$size.variable]: 'sizes.3' },
label: { fontSize: 'sm' },
icon: { fontSize: '3xs' },
}),
md: definePartsStyle({
control: { [$size.variable]: 'sizes.4' },
label: { fontSize: 'md' },
icon: { fontSize: '2xs' },
}),
lg: definePartsStyle({
control: { [$size.variable]: 'sizes.5' },
label: { fontSize: 'md' },
icon: { fontSize: '2xs' },
}),
};
const baseStyleLabel = defineStyle({ const baseStyleLabel = defineStyle({
_disabled: { opacity: 0.2 }, _disabled: { opacity: 0.2 },
}); });
...@@ -39,6 +60,7 @@ const baseStyle = definePartsStyle((props) => ({ ...@@ -39,6 +60,7 @@ const baseStyle = definePartsStyle((props) => ({
const Checkbox = defineMultiStyleConfig({ const Checkbox = defineMultiStyleConfig({
baseStyle, baseStyle,
sizes,
}); });
export default Checkbox; export default Checkbox;
...@@ -21,8 +21,24 @@ const baseStyle = definePartsStyle({ ...@@ -21,8 +21,24 @@ const baseStyle = definePartsStyle({
container: baseStyleContainer, container: baseStyleContainer,
}); });
const sizes = {
md: definePartsStyle({
control: { w: '4', h: '4' },
label: { fontSize: 'md' },
}),
lg: definePartsStyle({
control: { w: '5', h: '5' },
label: { fontSize: 'md' },
}),
sm: definePartsStyle({
control: { width: '3', height: '3' },
label: { fontSize: 'sm' },
}),
};
const Radio = defineMultiStyleConfig({ const Radio = defineMultiStyleConfig({
baseStyle, baseStyle,
sizes,
}); });
export default Radio; export default Radio;
import { selectAnatomy as parts } from '@chakra-ui/anatomy';
import {
createMultiStyleConfigHelpers,
defineStyle,
} from '@chakra-ui/styled-system';
import Input from './Input';
const { defineMultiStyleConfig } =
createMultiStyleConfigHelpers(parts.keys);
const iconSpacing = defineStyle({
paddingInlineEnd: '8',
});
const sizes = {
lg: {
...Input.sizes?.lg,
field: {
...Input.sizes?.lg.field,
...iconSpacing,
},
},
md: {
...Input.sizes?.md,
field: {
...Input.sizes?.md.field,
...iconSpacing,
},
},
sm: {
...Input.sizes?.sm,
field: {
...Input.sizes?.sm.field,
...iconSpacing,
},
},
};
const Select = defineMultiStyleConfig({
sizes,
defaultProps: {
size: 'sm',
},
});
export default Select;
...@@ -11,6 +11,7 @@ import Link from './Link'; ...@@ -11,6 +11,7 @@ import Link from './Link';
import Modal from './Modal'; import Modal from './Modal';
import Popover from './Popover'; import Popover from './Popover';
import Radio from './Radio'; import Radio from './Radio';
import Select from './Select';
import Skeleton from './Skeleton'; import Skeleton from './Skeleton';
import Spinner from './Spinner'; import Spinner from './Spinner';
import Switch from './Switch'; import Switch from './Switch';
...@@ -35,6 +36,7 @@ const components = { ...@@ -35,6 +36,7 @@ const components = {
Modal, Modal,
Popover, Popover,
Radio, Radio,
Select,
Skeleton, Skeleton,
Spinner, Spinner,
Switch, Switch,
......
import { GridItem, Link, Select } from '@chakra-ui/react';
import React from 'react';
import type { ControllerRenderProps, Control } from 'react-hook-form';
import { Controller } from 'react-hook-form';
import type { FormFields } from '../types';
const VERSIONS = [
'default',
'london',
'berlin',
];
interface Props {
control: Control<FormFields>;
}
const ContractVerificationEvmVersion = ({ control }: Props) => {
const renderControl = React.useCallback(({ field }: {field: ControllerRenderProps<FormFields, 'evm_version'>}) => {
return (
<Select
{ ...field }
size={{ base: 'md', lg: 'lg' }}
placeholder="EVM Version"
>
{ VERSIONS.map((option) => <option key={ option } value={ option }>{ option }</option>) }
</Select>
);
}, [ ]);
return (
<>
<GridItem>
<Controller
name="evm_version"
control={ control }
render={ renderControl }
rules={{ required: true }}
/>
</GridItem>
<GridItem fontSize="sm">
<span>The EVM version the contract is written for. If the bytecode does not match the version, we try to verify using the latest EVM version. </span>
<Link href="https://forum.poa.network/t/smart-contract-verification-evm-version-details/2318" target="_blank">EVM version details</Link>
</GridItem>
</>
);
};
export default React.memo(ContractVerificationEvmVersion);
import { Code, GridItem, Select, Checkbox } from '@chakra-ui/react';
import React from 'react';
import type { ControllerRenderProps, Control } from 'react-hook-form';
import { Controller } from 'react-hook-form';
import type { FormFields } from '../types';
const COMPILERS = [
'v0.8.17+commit.8df45f5f',
'v0.8.16+commit.07a7930e',
'v0.8.15+commit.e14f2714',
];
const COMPILERS_NIGHTLY = [
'v0.8.18-nightly.2022.11.23+commit.eb2f874e',
'v0.8.17-nightly.2022.8.24+commit.22a0c46e',
'v0.8.16-nightly.2022.7.6+commit.b6f11b33',
];
interface Props {
control: Control<FormFields>;
}
const ContractVerificationFieldCompiler = ({ control }: Props) => {
const [ isNightly, setIsNightly ] = React.useState(false);
const handleCheckboxChange = React.useCallback(() => {
setIsNightly(prev => !prev);
}, []);
const renderControl = React.useCallback(({ field }: {field: ControllerRenderProps<FormFields, 'compiler'>}) => {
return (
<Select
{ ...field }
size={{ base: 'md', lg: 'lg' }}
placeholder="Compiler"
>
{ [ ...COMPILERS, ...(isNightly ? COMPILERS_NIGHTLY : []) ].map((option) => <option key={ option } value={ option }>{ option }</option>) }
</Select>
);
}, [ isNightly ]);
return (
<>
<GridItem>
<Controller
name="compiler"
control={ control }
render={ renderControl }
rules={{ required: true }}
/>
<Checkbox
size="lg"
mt={ 3 }
onChange={ handleCheckboxChange }
>
Include nightly builds
</Checkbox>
</GridItem>
<GridItem fontSize="sm">
<span>The compiler version is specified in </span>
<Code>pragma solidity X.X.X</Code>
<span>. Use the compiler version rather than the nightly build. If using the Solidity compiler, run </span>
<Code>solc —version</Code>
<span> to check.</span>
</GridItem>
</>
);
};
export default React.memo(ContractVerificationFieldCompiler);
...@@ -101,7 +101,7 @@ const ContractVerificationFieldMethod = ({ control, isDisabled }: Props) => { ...@@ -101,7 +101,7 @@ const ContractVerificationFieldMethod = ({ control, isDisabled }: Props) => {
<RadioGroup defaultValue="add" colorScheme="blue" isDisabled={ isDisabled } { ...field }> <RadioGroup defaultValue="add" colorScheme="blue" isDisabled={ isDisabled } { ...field }>
<Stack spacing={ 4 }> <Stack spacing={ 4 }>
{ VERIFICATION_METHODS.map((method) => { { VERIFICATION_METHODS.map((method) => {
return <Radio key={ method } value={ method }>{ renderItem(method) }</Radio>; return <Radio key={ method } value={ method } size="lg">{ renderItem(method) }</Radio>;
}) } }) }
</Stack> </Stack>
</RadioGroup> </RadioGroup>
......
...@@ -14,7 +14,7 @@ interface Props { ...@@ -14,7 +14,7 @@ interface Props {
const ContractVerificationFieldName = ({ control }: Props) => { const ContractVerificationFieldName = ({ control }: Props) => {
const renderControl = React.useCallback(({ field }: {field: ControllerRenderProps<FormFields, 'name'>}) => { const renderControl = React.useCallback(({ field }: {field: ControllerRenderProps<FormFields, 'name'>}) => {
return ( return (
<FormControl variant="floating" id={ field.name } isRequired size="lg"> <FormControl variant="floating" id={ field.name } isRequired size={{ base: 'md', lg: 'lg' }}>
<Input <Input
{ ...field } { ...field }
required required
......
...@@ -4,6 +4,8 @@ import type { Control } from 'react-hook-form'; ...@@ -4,6 +4,8 @@ import type { Control } from 'react-hook-form';
import type { FormFields } from '../types'; import type { FormFields } from '../types';
import ContractVerificationMethod from '../ContractVerificationMethod'; import ContractVerificationMethod from '../ContractVerificationMethod';
import ContractVerificationEvmVersion from '../fields/ContractVerificationEvmVersion';
import ContractVerificationFieldCompiler from '../fields/ContractVerificationFieldCompiler';
import ContractVerificationFieldIsYul from '../fields/ContractVerificationFieldIsYul'; import ContractVerificationFieldIsYul from '../fields/ContractVerificationFieldIsYul';
import ContractVerificationFieldName from '../fields/ContractVerificationFieldName'; import ContractVerificationFieldName from '../fields/ContractVerificationFieldName';
...@@ -16,6 +18,8 @@ const ContractVerificationFlattenSourceCode = ({ control }: Props) => { ...@@ -16,6 +18,8 @@ const ContractVerificationFlattenSourceCode = ({ control }: Props) => {
<ContractVerificationMethod title="New Solidity/Yul Smart Contract Verification"> <ContractVerificationMethod title="New Solidity/Yul Smart Contract Verification">
<ContractVerificationFieldIsYul control={ control }/> <ContractVerificationFieldIsYul control={ control }/>
<ContractVerificationFieldName control={ control }/> <ContractVerificationFieldName control={ control }/>
<ContractVerificationFieldCompiler control={ control }/>
<ContractVerificationEvmVersion control={ control }/>
</ContractVerificationMethod> </ContractVerificationMethod>
); );
}; };
......
...@@ -4,6 +4,8 @@ export interface FormFieldsFlattenSourceCode { ...@@ -4,6 +4,8 @@ export interface FormFieldsFlattenSourceCode {
method: 'flatten_source_code'; method: 'flatten_source_code';
is_yul: boolean; is_yul: boolean;
name: string; name: string;
compiler: string;
evm_version: string;
} }
export interface FormFieldsStandardInput { export interface FormFieldsStandardInput {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment