-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improve constructor args, add optimizer config
- Loading branch information
Showing
10 changed files
with
209 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/lib/pages/evm-contract-verify/components/OptimizerConfiguration.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { Checkbox, Heading, HStack, Stack, Text } from "@chakra-ui/react"; | ||
import { Control, useController, useWatch } from "react-hook-form"; | ||
import { EvmContractVerifyForm } from "../types"; | ||
import { ControllerInput } from "lib/components/forms"; | ||
|
||
interface OptimizerConfigurationProps { | ||
control: Control<EvmContractVerifyForm>; | ||
} | ||
|
||
export const OptimizerConfiguration = ({ | ||
control, | ||
}: OptimizerConfigurationProps) => { | ||
const { field } = useController({ | ||
control, | ||
name: "verifyForm.form.optimizerConfig", | ||
}); | ||
|
||
const enabled = useWatch({ | ||
control, | ||
name: "verifyForm.form.optimizerConfig.enabled", | ||
}); | ||
|
||
return ( | ||
<Stack spacing={6}> | ||
<Stack spacing={1}> | ||
<Heading as="h6" variant="h6"> | ||
Optimization Configuration | ||
</Heading> | ||
<Text variant="body2" color="text.dark"> | ||
Provide optimization settings for the contract | ||
</Text> | ||
</Stack> | ||
<HStack spacing={4} pl={3}> | ||
<Checkbox | ||
isChecked={enabled} | ||
onChange={(e) => | ||
field.onChange({ ...field.value, enabled: e.target.checked }) | ||
} | ||
> | ||
<Text>Optimization Enabled</Text> | ||
</Checkbox> | ||
<HStack spacing={2}> | ||
<Text color="text.disabled">Optimization Run:</Text> | ||
<ControllerInput | ||
width={125} | ||
type="number" | ||
name="verifyForm.form.optimizerConfig.runs" | ||
isDisabled={!enabled} | ||
control={control} | ||
size="sm" | ||
/> | ||
</HStack> | ||
</HStack> | ||
</Stack> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { EvmProgrammingLanguage, VerificationOptions } from "../types"; | ||
|
||
export const getVerifyFormInitialValue = ( | ||
language: EvmProgrammingLanguage, | ||
verificationOption: VerificationOptions | ||
) => { | ||
const constructorArgs = { | ||
enabled: false, | ||
value: "", | ||
}; | ||
|
||
const optimizerConfig = { | ||
enabled: false, | ||
runs: 200, | ||
}; | ||
|
||
if (language === EvmProgrammingLanguage.Solidity) { | ||
switch (verificationOption) { | ||
case VerificationOptions.UploadFiles: | ||
return { | ||
option: verificationOption, | ||
constructorArgs, | ||
optimizerConfig, | ||
evmVersion: undefined, | ||
}; | ||
case VerificationOptions.ContractCode: | ||
return { | ||
option: verificationOption, | ||
constructorArgs, | ||
optimizerConfig, | ||
}; | ||
case VerificationOptions.JsonInput: | ||
return { | ||
option: verificationOption, | ||
constructorArgs, | ||
}; | ||
default: | ||
throw new Error("Invalid verification option for Solidity"); | ||
} | ||
} else if (language === EvmProgrammingLanguage.Vyper) { | ||
switch (verificationOption) { | ||
case VerificationOptions.UploadFile: | ||
return { | ||
option: verificationOption, | ||
constructorArgs, | ||
}; | ||
case VerificationOptions.ContractCode: | ||
return { | ||
option: verificationOption, | ||
constructorArgs, | ||
}; | ||
case VerificationOptions.JsonInput: | ||
return { | ||
option: verificationOption, | ||
constructorArgs, | ||
}; | ||
default: | ||
throw new Error("Invalid verification option for Vyper"); | ||
} | ||
} | ||
|
||
throw new Error("Invalid language (getVerifyFormInitialValue)"); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters