Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
e128c78f
Commit
e128c78f
authored
Feb 14, 2023
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
compiler and optimization fields change
parent
ca46b77f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
69 additions
and
49 deletions
+69
-49
ContractVerificationMethod.tsx
ui/contractVerification/ContractVerificationMethod.tsx
+2
-2
ContractVerificationFieldCompiler.tsx
...Verification/fields/ContractVerificationFieldCompiler.tsx
+35
-19
ContractVerificationFieldOptimization.tsx
...fication/fields/ContractVerificationFieldOptimization.tsx
+31
-27
ContractVerificationFlattenSourceCode.tsx
...ication/methods/ContractVerificationFlattenSourceCode.tsx
+1
-1
No files found.
ui/contractVerification/ContractVerificationMethod.tsx
View file @
e128c78f
...
...
@@ -15,8 +15,8 @@ const ContractVerificationMethod = ({ title, children }: Props) => {
return
(
<
section
ref=
{
ref
}
>
<
Text
variant=
"secondary"
mt=
{
12
}
mb=
{
5
}
fontSize=
"sm"
>
{
title
}
</
Text
>
<
Grid
columnGap=
"30px"
rowGap=
{
{
base
:
2
,
lg
:
4
}
}
templateColumns=
{
{
base
:
'
1fr
'
,
lg
:
'
minmax(auto
, 680px) minmax(0, 340px)
'
}
}
>
<
Text
fontWeight=
{
500
}
fontSize=
"lg"
fontFamily=
"heading"
mt=
{
12
}
mb=
{
5
}
>
{
title
}
</
Text
>
<
Grid
columnGap=
"30px"
rowGap=
{
{
base
:
2
,
lg
:
5
}
}
templateColumns=
{
{
base
:
'
1fr
'
,
lg
:
'
minmax(0
, 680px) minmax(0, 340px)
'
}
}
>
{
children
}
</
Grid
>
</
section
>
...
...
ui/contractVerification/fields/ContractVerificationFieldCompiler.tsx
View file @
e128c78f
import
{
Code
}
from
'
@chakra-ui/react
'
;
import
{
chakra
,
Checkbox
,
Code
}
from
'
@chakra-ui/react
'
;
import
{
useQueryClient
}
from
'
@tanstack/react-query
'
;
import
React
from
'
react
'
;
import
type
{
ControllerRenderProps
}
from
'
react-hook-form
'
;
...
...
@@ -20,26 +20,30 @@ interface Props {
}
const
ContractVerificationFieldCompiler
=
({
isVyper
}:
Props
)
=>
{
const
{
formState
,
control
}
=
useFormContext
<
FormFields
>
();
const
[
isNightly
,
setIsNightly
]
=
React
.
useState
(
false
);
const
{
formState
,
control
,
getValues
,
resetField
}
=
useFormContext
<
FormFields
>
();
const
isMobile
=
useIsMobile
();
const
queryClient
=
useQueryClient
();
const
config
=
queryClient
.
getQueryData
<
SmartContractVerificationConfig
>
(
getResourceKey
(
'
contract_verification_config
'
));
const
handleCheckboxChange
=
React
.
useCallback
(()
=>
{
if
(
isNightly
)
{
const
field
=
getValues
(
'
compiler
'
);
field
?.
value
.
includes
(
'
nightly
'
)
&&
resetField
(
'
compiler
'
,
{
defaultValue
:
null
});
}
setIsNightly
(
prev
=>
!
prev
);
},
[
getValues
,
isNightly
,
resetField
]);
const
options
=
React
.
useMemo
(()
=>
(
(
isVyper
?
config
?.
vyper_compiler_versions
:
config
?.
solidity_compiler_versions
)?.
map
((
option
)
=>
({
label
:
option
,
value
:
option
}))
||
[]
),
[
config
?.
solidity_compiler_versions
,
config
?.
vyper_compiler_versions
,
isVyper
]);
const
loadOptions
=
React
.
useCallback
(
async
(
inputValue
:
string
)
=>
{
return
options
.
filter
(({
label
})
=>
{
if
(
!
inputValue
)
{
return
!
label
.
toLowerCase
().
includes
(
'
nightly
'
);
}
return
label
.
toLowerCase
().
includes
(
inputValue
.
toLowerCase
());
})
.
filter
(({
label
})
=>
!
inputValue
||
label
.
toLowerCase
().
includes
(
inputValue
.
toLowerCase
()))
.
filter
(({
label
})
=>
isNightly
?
true
:
!
label
.
includes
(
'
nightly
'
))
.
slice
(
0
,
OPTIONS_LIMIT
);
},
[
options
]);
},
[
isNightly
,
options
]);
const
renderControl
=
React
.
useCallback
(({
field
}:
{
field
:
ControllerRenderProps
<
FormFields
,
'
compiler
'
>
})
=>
{
const
error
=
'
compiler
'
in
formState
.
errors
?
formState
.
errors
.
compiler
:
undefined
;
...
...
@@ -61,20 +65,32 @@ const ContractVerificationFieldCompiler = ({ isVyper }: Props) => {
return
(
<
ContractVerificationFormRow
>
<>
{
!
isVyper
&&
(
<
Checkbox
size=
"lg"
mb=
{
2
}
onChange=
{
handleCheckboxChange
}
isDisabled=
{
formState
.
isSubmitting
}
>
Include nightly builds
</
Checkbox
>
)
}
<
Controller
name=
"compiler"
control=
{
control
}
render=
{
renderControl
}
rules=
{
{
required
:
true
}
}
/>
</>
{
isVyper
?
null
:
(
<>
<
span
>
The compiler version is specified in
</
span
>
<
chakra
.
div
mt=
{
{
base
:
0
,
lg
:
8
}
}
>
<
span
>
The compiler version is specified in
</
span
>
<
Code
color=
"text_secondary"
>
pragma solidity X.X.X
</
Code
>
<
span
>
. Use the compiler version rather than the nightly build. If using the Solidity compiler, run
</
span
>
<
Code
color=
"text_secondary"
>
solc —version
</
Code
>
<
span
>
to check.
</
span
>
</>
</
chakra
.
div
>
)
}
</
ContractVerificationFormRow
>
);
...
...
ui/contractVerification/fields/ContractVerificationFieldOptimization.tsx
View file @
e128c78f
import
{
F
ormControl
,
Input
}
from
'
@chakra-ui/react
'
;
import
{
F
lex
,
Input
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
type
{
ControllerRenderProps
}
from
'
react-hook-form
'
;
import
{
Controller
,
useFormContext
}
from
'
react-hook-form
'
;
...
...
@@ -6,7 +6,6 @@ import { Controller, useFormContext } from 'react-hook-form';
import
type
{
FormFields
}
from
'
../types
'
;
import
CheckboxInput
from
'
ui/shared/CheckboxInput
'
;
import
InputPlaceholder
from
'
ui/shared/InputPlaceholder
'
;
import
ContractVerificationFormRow
from
'
../ContractVerificationFormRow
'
;
...
...
@@ -14,46 +13,51 @@ const ContractVerificationFieldOptimization = () => {
const
[
isEnabled
,
setIsEnabled
]
=
React
.
useState
(
true
);
const
{
formState
,
control
}
=
useFormContext
<
FormFields
>
();
const
error
=
'
optimization_runs
'
in
formState
.
errors
?
formState
.
errors
.
optimization_runs
:
undefined
;
const
handleCheckboxChange
=
React
.
useCallback
(()
=>
{
setIsEnabled
(
prev
=>
!
prev
);
},
[]);
const
renderCheckboxControl
=
React
.
useCallback
(({
field
}:
{
field
:
ControllerRenderProps
<
FormFields
,
'
is_optimization_enabled
'
>
})
=>
(
<
Flex
flexShrink=
{
0
}
>
<
CheckboxInput
<
FormFields
,
'
is_optimization_enabled
'
>
text="Optimization enabled"
field=
{
field
}
onChange=
{
handleCheckboxChange
}
isDisabled=
{
formState
.
isSubmitting
}
/
>
</
Flex
>
), [ formState.isSubmitting, handleCheckboxChange ]);
const renderInputControl = React.useCallback((
{
field
}
:
{
field
:
ControllerRenderProps
<
FormFields
,
'
optimization_runs
'
>
}
) =
>
{
return
(
<
FormControl
variant=
"floating"
id=
{
field
.
name
}
size=
{
{
base
:
'
md
'
,
lg
:
'
lg
'
}
}
isRequired
>
<
Input
{
...
field
}
required
isDisabled=
{
formState
.
isSubmitting
}
autoComplete=
"off"
type=
"number"
placeholder=
"Optimization runs"
size=
"xs"
minW=
"100px"
maxW=
"200px"
flexShrink=
{
1
}
isInvalid=
{
Boolean
(
error
)
}
/>
<
InputPlaceholder
text=
"Optimization runs"
/>
</
FormControl
>
);
}
, [ formState.isSubmitting ]);
}
, [
error,
formState.isSubmitting ]);
return (
<>
<
ContractVerificationFormRow
>
<
Flex
columnGap=
{
5
}
h=
{
{
base
:
'
auto
'
,
lg
:
'
32px
'
}
}
>
<
Controller
name=
"is_optimization_enabled"
control=
{
control
}
render=
{
renderCheckboxControl
}
defaultValue=
{
true
}
/>
</
ContractVerificationFormRow
>
{
isEnabled
&&
(
<
ContractVerificationFormRow
>
<
Controller
name=
"optimization_runs"
control=
{
control
}
...
...
@@ -61,9 +65,9 @@ const ContractVerificationFieldOptimization = () => {
rules=
{
{
required
:
true
}
}
defaultValue=
"200"
/>
</
ContractVerificationFormRow
>
)
}
</>
</
Flex
>
</
ContractVerificationFormRow
>
);
};
...
...
ui/contractVerification/methods/ContractVerificationFlattenSourceCode.tsx
View file @
e128c78f
...
...
@@ -13,8 +13,8 @@ import ContractVerificationFieldOptimization from '../fields/ContractVerificatio
const
ContractVerificationFlattenSourceCode
=
()
=>
{
return
(
<
ContractVerificationMethod
title=
"New Solidity/Yul Smart Contract Verification"
>
<
ContractVerificationFieldIsYul
/>
<
ContractVerificationFieldName
/>
<
ContractVerificationFieldIsYul
/>
<
ContractVerificationFieldCompiler
/>
<
ContractVerificationFieldEvmVersion
/>
<
ContractVerificationFieldOptimization
/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment