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
995b42ee
Commit
995b42ee
authored
Jan 20, 2023
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
methods sections + yul and name fields
parent
95cee729
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
242 additions
and
15 deletions
+242
-15
ContractVerificationForm.tsx
ui/contractVerification/ContractVerificationForm.tsx
+29
-13
ContractVerificationMethod.tsx
ui/contractVerification/ContractVerificationMethod.tsx
+20
-0
ContractVerificationFieldIsYul.tsx
...actVerification/fields/ContractVerificationFieldIsYul.tsx
+33
-0
ContractVerificationFieldMethod.tsx
...ctVerification/fields/ContractVerificationFieldMethod.tsx
+2
-2
ContractVerificationFieldName.tsx
...ractVerification/fields/ContractVerificationFieldName.tsx
+47
-0
ContractVerificationFlattenSourceCode.tsx
...ication/methods/ContractVerificationFlattenSourceCode.tsx
+23
-0
ContractVerificationMultiPartFile.tsx
...erification/methods/ContractVerificationMultiPartFile.tsx
+21
-0
ContractVerificationSourcify.tsx
...ractVerification/methods/ContractVerificationSourcify.tsx
+21
-0
ContractVerificationStandardInput.tsx
...erification/methods/ContractVerificationStandardInput.tsx
+21
-0
ContractVerificationVyperContract.tsx
...erification/methods/ContractVerificationVyperContract.tsx
+21
-0
types.ts
ui/contractVerification/types.ts
+4
-0
No files found.
ui/contractVerification/ContractVerificationForm.tsx
View file @
995b42ee
...
@@ -5,20 +5,33 @@ import { useForm } from 'react-hook-form';
...
@@ -5,20 +5,33 @@ import { useForm } from 'react-hook-form';
import
type
{
FormFields
}
from
'
./types
'
;
import
type
{
FormFields
}
from
'
./types
'
;
import
ContractVerificationFieldMethod
from
'
./ContractVerificationFieldMethod
'
;
import
ContractVerificationFieldMethod
from
'
./fields/ContractVerificationFieldMethod
'
;
import
ContractVerificationFlattenSourceCode
from
'
./methods/ContractVerificationFlattenSourceCode
'
;
import
ContractVerificationMultiPartFile
from
'
./methods/ContractVerificationMultiPartFile
'
;
import
ContractVerificationSourcify
from
'
./methods/ContractVerificationSourcify
'
;
import
ContractVerificationStandardInput
from
'
./methods/ContractVerificationStandardInput
'
;
import
ContractVerificationVyperContract
from
'
./methods/ContractVerificationVyperContract
'
;
const
ContractVerificationForm
=
()
=>
{
const
ContractVerificationForm
=
()
=>
{
const
{
control
,
handleSubmit
}
=
useForm
<
FormFields
>
({
const
{
control
,
handleSubmit
,
watch
}
=
useForm
<
FormFields
>
();
defaultValues
:
{
method
:
'
flatten_source_code
'
,
},
});
const
onFormSubmit
:
SubmitHandler
<
FormFields
>
=
React
.
useCallback
((
data
)
=>
{
const
onFormSubmit
:
SubmitHandler
<
FormFields
>
=
React
.
useCallback
((
data
)
=>
{
// eslint-disable-next-line no-console
// eslint-disable-next-line no-console
console
.
log
(
'
__>__
'
,
data
);
console
.
log
(
'
__>__
'
,
data
);
},
[]);
},
[]);
const
methods
=
React
.
useMemo
(()
=>
({
flatten_source_code
:
<
ContractVerificationFlattenSourceCode
control=
{
control
}
/>,
standard_input
:
<
ContractVerificationStandardInput
control=
{
control
}
/>,
sourcify
:
<
ContractVerificationSourcify
control=
{
control
}
/>,
multi_part_file
:
<
ContractVerificationMultiPartFile
control=
{
control
}
/>,
vyper_contract
:
<
ContractVerificationVyperContract
control=
{
control
}
/>,
}),
[
control
]);
const
method
=
watch
(
'
method
'
);
const
content
=
methods
[
method
]
||
null
;
return
(
return
(
<
chakra
.
form
<
chakra
.
form
noValidate
noValidate
...
@@ -26,14 +39,17 @@ const ContractVerificationForm = () => {
...
@@ -26,14 +39,17 @@ const ContractVerificationForm = () => {
mt=
{
12
}
mt=
{
12
}
>
>
<
ContractVerificationFieldMethod
control=
{
control
}
/>
<
ContractVerificationFieldMethod
control=
{
control
}
/>
<
Button
{
content
}
variant=
"solid"
{
Boolean
(
method
)
&&
(
size=
"lg"
<
Button
type=
"submit"
variant=
"solid"
mt=
{
12
}
size=
"lg"
>
type=
"submit"
mt=
{
12
}
>
Verify
&
publish
Verify
&
publish
</
Button
>
</
Button
>
)
}
</
chakra
.
form
>
</
chakra
.
form
>
);
);
};
};
...
...
ui/contractVerification/ContractVerificationMethod.tsx
0 → 100644
View file @
995b42ee
import
{
Grid
,
Text
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
interface
Props
{
title
:
string
;
children
:
React
.
ReactNode
;
}
const
ContractVerificationMethod
=
({
title
,
children
}:
Props
)
=>
{
return
(
<
section
>
<
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)
'
}
}
>
{
children
}
</
Grid
>
</
section
>
);
};
export
default
React
.
memo
(
ContractVerificationMethod
);
ui/contractVerification/fields/ContractVerificationFieldIsYul.tsx
0 → 100644
View file @
995b42ee
import
{
GridItem
}
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
'
;
import
CheckboxInput
from
'
ui/shared/CheckboxInput
'
;
interface
Props
{
control
:
Control
<
FormFields
>
;
}
const
ContractVerificationFieldIsYul
=
({
control
}:
Props
)
=>
{
const
renderControl
=
React
.
useCallback
(({
field
}:
{
field
:
ControllerRenderProps
<
FormFields
,
'
is_yul
'
>
})
=>
(
<
CheckboxInput
<
FormFields
,
'
is_yul
'
>
text="Is Yul contract" field=
{
field
}
/
>
), []);
return (
<>
<
GridItem
>
<
Controller
name=
"is_yul"
control=
{
control
}
render=
{
renderControl
}
/>
</
GridItem
>
<
GridItem
/>
</>
);
};
export default React.memo(ContractVerificationFieldIsYul);
ui/contractVerification/ContractVerificationFieldMethod.tsx
→
ui/contractVerification/
fields/
ContractVerificationFieldMethod.tsx
View file @
995b42ee
...
@@ -19,7 +19,7 @@ import React from 'react';
...
@@ -19,7 +19,7 @@ import React from 'react';
import
type
{
ControllerRenderProps
,
Control
}
from
'
react-hook-form
'
;
import
type
{
ControllerRenderProps
,
Control
}
from
'
react-hook-form
'
;
import
{
Controller
}
from
'
react-hook-form
'
;
import
{
Controller
}
from
'
react-hook-form
'
;
import
type
{
FormFields
,
VerificationMethod
}
from
'
./types
'
;
import
type
{
FormFields
,
VerificationMethod
}
from
'
.
.
/types
'
;
import
infoIcon
from
'
icons/info.svg
'
;
import
infoIcon
from
'
icons/info.svg
'
;
...
@@ -110,7 +110,7 @@ const ContractVerificationFieldMethod = ({ control, isDisabled }: Props) => {
...
@@ -110,7 +110,7 @@ const ContractVerificationFieldMethod = ({ control, isDisabled }: Props) => {
return
(
return
(
<
section
>
<
section
>
<
Text
variant=
"secondary"
fontSize=
"sm"
mb=
{
5
}
>
New solidity/yul smart contract verification
</
Text
>
<
Text
variant=
"secondary"
fontSize=
"sm"
mb=
{
5
}
>
Smart-contract verification method
</
Text
>
<
Controller
<
Controller
name=
"method"
name=
"method"
control=
{
control
}
control=
{
control
}
...
...
ui/contractVerification/fields/ContractVerificationFieldName.tsx
0 → 100644
View file @
995b42ee
import
{
chakra
,
Code
,
FormControl
,
GridItem
,
Input
}
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
'
;
import
InputPlaceholder
from
'
ui/shared/InputPlaceholder
'
;
interface
Props
{
control
:
Control
<
FormFields
>
;
}
const
ContractVerificationFieldName
=
({
control
}:
Props
)
=>
{
const
renderControl
=
React
.
useCallback
(({
field
}:
{
field
:
ControllerRenderProps
<
FormFields
,
'
name
'
>
})
=>
{
return
(
<
FormControl
variant=
"floating"
id=
{
field
.
name
}
isRequired
size=
"lg"
>
<
Input
{
...
field
}
required
maxLength=
{
255
}
/>
<
InputPlaceholder
text=
"Contract name"
/>
</
FormControl
>
);
},
[]);
return
(
<>
<
GridItem
>
<
Controller
name=
"name"
control=
{
control
}
render=
{
renderControl
}
rules=
{
{
required
:
true
}
}
/>
</
GridItem
>
<
GridItem
fontSize=
"sm"
>
<
span
>
Must match the name specified in the code. For example, in
</
span
>
<
Code
>
{
`contract MyContract {..}`
}
</
Code
>
<
span
>
.
<
chakra
.
span
fontWeight=
{
600
}
>
MyContract
</
chakra
.
span
>
is the contract name.
</
span
>
</
GridItem
>
</>
);
};
export
default
React
.
memo
(
ContractVerificationFieldName
);
ui/contractVerification/methods/ContractVerificationFlattenSourceCode.tsx
0 → 100644
View file @
995b42ee
import
React
from
'
react
'
;
import
type
{
Control
}
from
'
react-hook-form
'
;
import
type
{
FormFields
}
from
'
../types
'
;
import
ContractVerificationMethod
from
'
../ContractVerificationMethod
'
;
import
ContractVerificationFieldIsYul
from
'
../fields/ContractVerificationFieldIsYul
'
;
import
ContractVerificationFieldName
from
'
../fields/ContractVerificationFieldName
'
;
interface
Props
{
control
:
Control
<
FormFields
>
;
}
const
ContractVerificationFlattenSourceCode
=
({
control
}:
Props
)
=>
{
return
(
<
ContractVerificationMethod
title=
"New Solidity/Yul Smart Contract Verification"
>
<
ContractVerificationFieldIsYul
control=
{
control
}
/>
<
ContractVerificationFieldName
control=
{
control
}
/>
</
ContractVerificationMethod
>
);
};
export
default
React
.
memo
(
ContractVerificationFlattenSourceCode
);
ui/contractVerification/methods/ContractVerificationMultiPartFile.tsx
0 → 100644
View file @
995b42ee
import
React
from
'
react
'
;
import
type
{
Control
}
from
'
react-hook-form
'
;
import
type
{
FormFields
}
from
'
../types
'
;
import
ContractVerificationMethod
from
'
../ContractVerificationMethod
'
;
interface
Props
{
control
:
Control
<
FormFields
>
;
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const
ContractVerificationMultiPartFile
=
({
control
}:
Props
)
=>
{
return
(
<
ContractVerificationMethod
title=
"New Solidity/Yul Smart Contract Verification"
>
ContractVerificationMultiPartFile
</
ContractVerificationMethod
>
);
};
export
default
React
.
memo
(
ContractVerificationMultiPartFile
);
ui/contractVerification/methods/ContractVerificationSourcify.tsx
0 → 100644
View file @
995b42ee
import
React
from
'
react
'
;
import
type
{
Control
}
from
'
react-hook-form
'
;
import
type
{
FormFields
}
from
'
../types
'
;
import
ContractVerificationMethod
from
'
../ContractVerificationMethod
'
;
interface
Props
{
control
:
Control
<
FormFields
>
;
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const
ContractVerificationSourcify
=
({
control
}:
Props
)
=>
{
return
(
<
ContractVerificationMethod
title=
"New Smart Contract Verification"
>
ContractVerificationSourcify
</
ContractVerificationMethod
>
);
};
export
default
React
.
memo
(
ContractVerificationSourcify
);
ui/contractVerification/methods/ContractVerificationStandardInput.tsx
0 → 100644
View file @
995b42ee
import
React
from
'
react
'
;
import
type
{
Control
}
from
'
react-hook-form
'
;
import
type
{
FormFields
}
from
'
../types
'
;
import
ContractVerificationMethod
from
'
../ContractVerificationMethod
'
;
interface
Props
{
control
:
Control
<
FormFields
>
;
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const
ContractVerificationStandardInput
=
({
control
}:
Props
)
=>
{
return
(
<
ContractVerificationMethod
title=
"New Smart Contract Verification"
>
ContractVerificationStandardInput
</
ContractVerificationMethod
>
);
};
export
default
React
.
memo
(
ContractVerificationStandardInput
);
ui/contractVerification/methods/ContractVerificationVyperContract.tsx
0 → 100644
View file @
995b42ee
import
React
from
'
react
'
;
import
type
{
Control
}
from
'
react-hook-form
'
;
import
type
{
FormFields
}
from
'
../types
'
;
import
ContractVerificationMethod
from
'
../ContractVerificationMethod
'
;
interface
Props
{
control
:
Control
<
FormFields
>
;
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const
ContractVerificationVyperContract
=
({
control
}:
Props
)
=>
{
return
(
<
ContractVerificationMethod
title=
"New Vyper Smart Contract Verification"
>
ContractVerificationVyperContract
</
ContractVerificationMethod
>
);
};
export
default
React
.
memo
(
ContractVerificationVyperContract
);
ui/contractVerification/types.ts
View file @
995b42ee
...
@@ -2,10 +2,13 @@ export type VerificationMethod = 'flatten_source_code' | 'standard_input' | 'sou
...
@@ -2,10 +2,13 @@ export type VerificationMethod = 'flatten_source_code' | 'standard_input' | 'sou
export
interface
FormFieldsFlattenSourceCode
{
export
interface
FormFieldsFlattenSourceCode
{
method
:
'
flatten_source_code
'
;
method
:
'
flatten_source_code
'
;
is_yul
:
boolean
;
name
:
string
;
}
}
export
interface
FormFieldsStandardInput
{
export
interface
FormFieldsStandardInput
{
method
:
'
standard_input
'
;
method
:
'
standard_input
'
;
name
:
string
;
}
}
export
interface
FormFieldsSourcify
{
export
interface
FormFieldsSourcify
{
...
@@ -18,6 +21,7 @@ export interface FormFieldsMultiPartFile {
...
@@ -18,6 +21,7 @@ export interface FormFieldsMultiPartFile {
export
interface
FormFieldsVyperContract
{
export
interface
FormFieldsVyperContract
{
method
:
'
vyper_contract
'
;
method
:
'
vyper_contract
'
;
name
:
string
;
}
}
export
type
FormFields
=
FormFieldsFlattenSourceCode
|
FormFieldsStandardInput
|
FormFieldsSourcify
|
export
type
FormFields
=
FormFieldsFlattenSourceCode
|
FormFieldsStandardInput
|
FormFieldsSourcify
|
...
...
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