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
bc69a003
Commit
bc69a003
authored
Feb 02, 2023
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove nightly checkbox
parent
25bd3615
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
32 deletions
+16
-32
ContractVerificationFieldCompiler.tsx
...Verification/fields/ContractVerificationFieldCompiler.tsx
+16
-32
No files found.
ui/contractVerification/fields/ContractVerificationFieldCompiler.tsx
View file @
bc69a003
import
{
C
heckbox
,
C
ode
}
from
'
@chakra-ui/react
'
;
import
{
Code
}
from
'
@chakra-ui/react
'
;
import
{
useQueryClient
}
from
'
@tanstack/react-query
'
;
import
{
useQueryClient
}
from
'
@tanstack/react-query
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
ControllerRenderProps
}
from
'
react-hook-form
'
;
import
type
{
ControllerRenderProps
}
from
'
react-hook-form
'
;
...
@@ -20,30 +20,26 @@ interface Props {
...
@@ -20,30 +20,26 @@ interface Props {
}
}
const
ContractVerificationFieldCompiler
=
({
isVyper
}:
Props
)
=>
{
const
ContractVerificationFieldCompiler
=
({
isVyper
}:
Props
)
=>
{
const
[
isNightly
,
setIsNightly
]
=
React
.
useState
(
false
);
const
{
formState
,
control
}
=
useFormContext
<
FormFields
>
();
const
{
formState
,
control
,
getValues
,
resetField
}
=
useFormContext
<
FormFields
>
();
const
isMobile
=
useIsMobile
();
const
isMobile
=
useIsMobile
();
const
queryClient
=
useQueryClient
();
const
queryClient
=
useQueryClient
();
const
config
=
queryClient
.
getQueryData
<
SmartContractVerificationConfig
>
(
getResourceKey
(
'
contract_verification_config
'
));
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
(()
=>
(
const
options
=
React
.
useMemo
(()
=>
(
(
isVyper
?
config
?.
vyper_compiler_versions
:
config
?.
solidity_compiler_versions
)?.
map
((
option
)
=>
({
label
:
option
,
value
:
option
}))
||
[]
(
isVyper
?
config
?.
vyper_compiler_versions
:
config
?.
solidity_compiler_versions
)?.
map
((
option
)
=>
({
label
:
option
,
value
:
option
}))
||
[]
),
[
config
?.
solidity_compiler_versions
,
config
?.
vyper_compiler_versions
,
isVyper
]);
),
[
config
?.
solidity_compiler_versions
,
config
?.
vyper_compiler_versions
,
isVyper
]);
const
loadOptions
=
React
.
useCallback
(
async
(
inputValue
:
string
)
=>
{
const
loadOptions
=
React
.
useCallback
(
async
(
inputValue
:
string
)
=>
{
return
options
return
options
.
filter
(({
label
})
=>
!
inputValue
||
label
.
toLowerCase
().
includes
(
inputValue
.
toLowerCase
()))
.
filter
(({
label
})
=>
{
.
filter
(({
label
})
=>
isNightly
?
true
:
!
label
.
includes
(
'
nightly
'
))
if
(
!
inputValue
)
{
return
!
label
.
toLowerCase
().
includes
(
'
nightly
'
);
}
return
label
.
toLowerCase
().
includes
(
inputValue
.
toLowerCase
());
})
.
slice
(
0
,
OPTIONS_LIMIT
);
.
slice
(
0
,
OPTIONS_LIMIT
);
},
[
isNightly
,
options
]);
},
[
options
]);
const
renderControl
=
React
.
useCallback
(({
field
}:
{
field
:
ControllerRenderProps
<
FormFields
,
'
compiler
'
>
})
=>
{
const
renderControl
=
React
.
useCallback
(({
field
}:
{
field
:
ControllerRenderProps
<
FormFields
,
'
compiler
'
>
})
=>
{
const
error
=
'
compiler
'
in
formState
.
errors
?
formState
.
errors
.
compiler
:
undefined
;
const
error
=
'
compiler
'
in
formState
.
errors
?
formState
.
errors
.
compiler
:
undefined
;
...
@@ -65,24 +61,12 @@ const ContractVerificationFieldCompiler = ({ isVyper }: Props) => {
...
@@ -65,24 +61,12 @@ const ContractVerificationFieldCompiler = ({ isVyper }: Props) => {
return
(
return
(
<
ContractVerificationFormRow
>
<
ContractVerificationFormRow
>
<>
<
Controller
<
Controller
name=
"compiler"
name=
"compiler"
control=
{
control
}
control=
{
control
}
render=
{
renderControl
}
render=
{
renderControl
}
rules=
{
{
required
:
true
}
}
rules=
{
{
required
:
true
}
}
/>
/>
{
!
isVyper
&&
(
<
Checkbox
size=
"lg"
mt=
{
3
}
onChange=
{
handleCheckboxChange
}
isDisabled=
{
formState
.
isSubmitting
}
>
Include nightly builds
</
Checkbox
>
)
}
</>
{
isVyper
?
null
:
(
{
isVyper
?
null
:
(
<>
<>
<
span
>
The compiler version is specified in
</
span
>
<
span
>
The compiler version is specified in
</
span
>
...
...
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