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
ca47d79c
Commit
ca47d79c
authored
Jan 20, 2023
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
contract libraries
parent
e52f2ea9
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
202 additions
and
8 deletions
+202
-8
ContractVerificationFieldConstArgs.tsx
...erification/fields/ContractVerificationFieldConstArgs.tsx
+2
-2
ContractVerificationFieldEvmVersion.tsx
...rification/fields/ContractVerificationFieldEvmVersion.tsx
+2
-2
ContractVerificationFieldLibraries.tsx
...erification/fields/ContractVerificationFieldLibraries.tsx
+64
-0
ContractVerificationFieldLibraryItem.tsx
...ification/fields/ContractVerificationFieldLibraryItem.tsx
+123
-0
ContractVerificationFlattenSourceCode.tsx
...ication/methods/ContractVerificationFlattenSourceCode.tsx
+6
-4
types.ts
ui/contractVerification/types.ts
+5
-0
No files found.
ui/contractVerification/fields/ContractVerificationField
Is
ConstArgs.tsx
→
ui/contractVerification/fields/ContractVerificationFieldConstArgs.tsx
View file @
ca47d79c
...
@@ -11,7 +11,7 @@ interface Props {
...
@@ -11,7 +11,7 @@ interface Props {
control
:
Control
<
FormFields
>
;
control
:
Control
<
FormFields
>
;
}
}
const
ContractVerificationField
Is
ConstArgs
=
({
control
}:
Props
)
=>
{
const
ContractVerificationFieldConstArgs
=
({
control
}:
Props
)
=>
{
const
renderControl
=
React
.
useCallback
(({
field
}:
{
field
:
ControllerRenderProps
<
FormFields
,
'
constructor_args
'
>
})
=>
(
const
renderControl
=
React
.
useCallback
(({
field
}:
{
field
:
ControllerRenderProps
<
FormFields
,
'
constructor_args
'
>
})
=>
(
<
CheckboxInput
<
FormFields
,
'
constructor_args
'
>
text="Try to fetch constructor arguments automatically" field=
{
field
}
/
>
<
CheckboxInput
<
FormFields
,
'
constructor_args
'
>
text="Try to fetch constructor arguments automatically" field=
{
field
}
/
>
), []);
), []);
...
@@ -30,4 +30,4 @@ const ContractVerificationFieldIsConstArgs = ({ control }: Props) => {
...
@@ -30,4 +30,4 @@ const ContractVerificationFieldIsConstArgs = ({ control }: Props) => {
);
);
};
};
export default React.memo(ContractVerificationField
Is
ConstArgs);
export default React.memo(ContractVerificationFieldConstArgs);
ui/contractVerification/fields/ContractVerificationEvmVersion.tsx
→
ui/contractVerification/fields/ContractVerification
Field
EvmVersion.tsx
View file @
ca47d79c
...
@@ -15,7 +15,7 @@ interface Props {
...
@@ -15,7 +15,7 @@ interface Props {
control
:
Control
<
FormFields
>
;
control
:
Control
<
FormFields
>
;
}
}
const
ContractVerificationEvmVersion
=
({
control
}:
Props
)
=>
{
const
ContractVerification
Field
EvmVersion
=
({
control
}:
Props
)
=>
{
const
renderControl
=
React
.
useCallback
(({
field
}:
{
field
:
ControllerRenderProps
<
FormFields
,
'
evm_version
'
>
})
=>
{
const
renderControl
=
React
.
useCallback
(({
field
}:
{
field
:
ControllerRenderProps
<
FormFields
,
'
evm_version
'
>
})
=>
{
return
(
return
(
<
Select
<
Select
...
@@ -46,4 +46,4 @@ const ContractVerificationEvmVersion = ({ control }: Props) => {
...
@@ -46,4 +46,4 @@ const ContractVerificationEvmVersion = ({ control }: Props) => {
);
);
};
};
export
default
React
.
memo
(
ContractVerificationEvmVersion
);
export
default
React
.
memo
(
ContractVerification
Field
EvmVersion
);
ui/contractVerification/fields/ContractVerificationFieldLibraries.tsx
0 → 100644
View file @
ca47d79c
import
{
Checkbox
,
GridItem
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
type
{
Control
}
from
'
react-hook-form
'
;
import
{
useFieldArray
}
from
'
react-hook-form
'
;
import
type
{
FormFields
}
from
'
../types
'
;
import
ContractVerificationFieldLibraryItem
from
'
./ContractVerificationFieldLibraryItem
'
;
interface
Props
{
control
:
Control
<
FormFields
>
;
}
const
ContractVerificationFieldLibraries
=
({
control
}:
Props
)
=>
{
const
[
isEnabled
,
setIsEnabled
]
=
React
.
useState
(
false
);
const
{
fields
,
append
,
remove
,
insert
}
=
useFieldArray
({
name
:
'
libraries
'
,
control
,
});
const
handleCheckboxChange
=
React
.
useCallback
(()
=>
{
if
(
!
isEnabled
)
{
append
({
name
:
''
,
address
:
''
});
}
else
{
remove
();
}
setIsEnabled
(
prev
=>
!
prev
);
},
[
append
,
isEnabled
,
remove
]);
const
handleAddFieldClick
=
React
.
useCallback
((
index
:
number
)
=>
{
insert
(
index
+
1
,
{
name
:
''
,
address
:
''
});
},
[
insert
]);
const
handleRemoveFieldClick
=
React
.
useCallback
((
index
:
number
)
=>
{
remove
(
index
);
},
[
remove
]);
return
(
<>
<
GridItem
mt=
{
12
}
>
<
Checkbox
size=
"lg"
onChange=
{
handleCheckboxChange
}
>
Add contract libraries
</
Checkbox
>
</
GridItem
>
<
GridItem
/>
{
fields
.
map
((
field
,
index
)
=>
(
<
ContractVerificationFieldLibraryItem
key=
{
field
.
id
}
index=
{
index
}
control=
{
control
}
fieldsLength=
{
fields
.
length
}
onAddFieldClick=
{
handleAddFieldClick
}
onRemoveFieldClick=
{
handleRemoveFieldClick
}
/>
))
}
</>
);
};
export
default
React
.
memo
(
ContractVerificationFieldLibraries
);
ui/contractVerification/fields/ContractVerificationFieldLibraryItem.tsx
0 → 100644
View file @
ca47d79c
import
{
Flex
,
FormControl
,
GridItem
,
Icon
,
IconButton
,
Input
,
Text
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
type
{
Control
,
ControllerRenderProps
}
from
'
react-hook-form
'
;
import
{
Controller
}
from
'
react-hook-form
'
;
import
type
{
FormFields
}
from
'
../types
'
;
import
minusIcon
from
'
icons/minus.svg
'
;
import
plusIcon
from
'
icons/plus.svg
'
;
import
{
ADDRESS_REGEXP
}
from
'
lib/validations/address
'
;
import
InputPlaceholder
from
'
ui/shared/InputPlaceholder
'
;
const
LIMIT
=
10
;
interface
Props
{
control
:
Control
<
FormFields
>
;
index
:
number
;
fieldsLength
:
number
;
onAddFieldClick
:
(
index
:
number
)
=>
void
;
onRemoveFieldClick
:
(
index
:
number
)
=>
void
;
}
const
ContractVerificationFieldLibraryItem
=
({
control
,
index
,
fieldsLength
,
onAddFieldClick
,
onRemoveFieldClick
}:
Props
)
=>
{
const
ref
=
React
.
useRef
<
HTMLDivElement
>
(
null
);
const
renderNameControl
=
React
.
useCallback
(({
field
}:
{
field
:
ControllerRenderProps
<
FormFields
,
`libraries.
${
number
}
.name`
>
})
=>
{
return
(
<
FormControl
variant=
"floating"
id=
{
field
.
name
}
isRequired
size=
{
{
base
:
'
md
'
,
lg
:
'
lg
'
}
}
>
<
Input
{
...
field
}
required
maxLength=
{
255
}
/>
<
InputPlaceholder
text=
"Library name (.sol file)"
/>
</
FormControl
>
);
},
[]);
const
renderAddressControl
=
React
.
useCallback
(({
field
}:
{
field
:
ControllerRenderProps
<
FormFields
,
`libraries.
${
number
}
.address`
>
})
=>
{
return
(
<
FormControl
variant=
"floating"
id=
{
field
.
name
}
isRequired
size=
{
{
base
:
'
md
'
,
lg
:
'
lg
'
}
}
>
<
Input
{
...
field
}
required
/>
<
InputPlaceholder
text=
"Library address (0x...)"
/>
</
FormControl
>
);
},
[]);
const
handleAddButtonClick
=
React
.
useCallback
(()
=>
{
onAddFieldClick
(
index
);
},
[
index
,
onAddFieldClick
]);
const
handleRemoveButtonClick
=
React
.
useCallback
(()
=>
{
onRemoveFieldClick
(
index
);
},
[
index
,
onRemoveFieldClick
]);
React
.
useEffect
(()
=>
{
ref
.
current
?.
scrollIntoView
({
behavior
:
'
smooth
'
});
},
[]);
return
(
<>
<
GridItem
mt=
{
index
!==
0
?
12
:
0
}
ref=
{
ref
}
>
<
Flex
alignItems=
"center"
justifyContent=
"space-between"
>
<
Text
variant=
"secondary"
fontSize=
"sm"
>
Contract library
{
index
+
1
}
</
Text
>
<
Flex
columnGap=
{
5
}
>
{
fieldsLength
>
1
&&
(
<
IconButton
aria
-
label=
"delete"
variant=
"outline"
w=
"30px"
h=
"30px"
onClick=
{
handleRemoveButtonClick
}
icon=
{
<
Icon
as=
{
minusIcon
}
w=
"20px"
h=
"20px"
/>
}
/>
)
}
{
fieldsLength
<
LIMIT
&&
(
<
IconButton
aria
-
label=
"add"
variant=
"outline"
w=
"30px"
h=
"30px"
onClick=
{
handleAddButtonClick
}
icon=
{
<
Icon
as=
{
plusIcon
}
w=
"20px"
h=
"20px"
/>
}
/>
)
}
</
Flex
>
</
Flex
>
</
GridItem
>
<
GridItem
/>
<
GridItem
>
<
Controller
name=
{
`libraries.${ index }.name`
}
control=
{
control
}
render=
{
renderNameControl
}
rules=
{
{
required
:
true
}
}
/>
</
GridItem
>
{
index
===
0
?
(
<
GridItem
fontSize=
"sm"
>
A library name called in the .sol file. Multiple libraries (up to 10) may be added for each contract.
</
GridItem
>
)
:
<
GridItem
/>
}
<
GridItem
>
<
Controller
name=
{
`libraries.${ index }.address`
}
control=
{
control
}
render=
{
renderAddressControl
}
rules=
{
{
required
:
true
,
pattern
:
ADDRESS_REGEXP
}
}
/>
</
GridItem
>
{
index
===
0
?
(
<
GridItem
fontSize=
"sm"
>
The 0x library address. This can be found in the generated json file or Truffle output (if using truffle).
</
GridItem
>
)
:
<
GridItem
/>
}
</>
);
};
export
default
React
.
memo
(
ContractVerificationFieldLibraryItem
);
ui/contractVerification/methods/ContractVerificationFlattenSourceCode.tsx
View file @
ca47d79c
...
@@ -4,11 +4,12 @@ import type { Control } from 'react-hook-form';
...
@@ -4,11 +4,12 @@ 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
ContractVerificationFieldCode
from
'
../fields/ContractVerificationFieldCode
'
;
import
ContractVerificationFieldCode
from
'
../fields/ContractVerificationFieldCode
'
;
import
ContractVerificationFieldCompiler
from
'
../fields/ContractVerificationFieldCompiler
'
;
import
ContractVerificationFieldCompiler
from
'
../fields/ContractVerificationFieldCompiler
'
;
import
ContractVerificationFieldIsConstArgs
from
'
../fields/ContractVerificationFieldIsConstArgs
'
;
import
ContractVerificationFieldConstArgs
from
'
../fields/ContractVerificationFieldConstArgs
'
;
import
ContractVerificationFieldEvmVersion
from
'
../fields/ContractVerificationFieldEvmVersion
'
;
import
ContractVerificationFieldIsYul
from
'
../fields/ContractVerificationFieldIsYul
'
;
import
ContractVerificationFieldIsYul
from
'
../fields/ContractVerificationFieldIsYul
'
;
import
ContractVerificationFieldLibraries
from
'
../fields/ContractVerificationFieldLibraries
'
;
import
ContractVerificationFieldName
from
'
../fields/ContractVerificationFieldName
'
;
import
ContractVerificationFieldName
from
'
../fields/ContractVerificationFieldName
'
;
import
ContractVerificationFieldOptimization
from
'
../fields/ContractVerificationFieldOptimization
'
;
import
ContractVerificationFieldOptimization
from
'
../fields/ContractVerificationFieldOptimization
'
;
...
@@ -22,10 +23,11 @@ const ContractVerificationFlattenSourceCode = ({ control }: Props) => {
...
@@ -22,10 +23,11 @@ const ContractVerificationFlattenSourceCode = ({ control }: Props) => {
<
ContractVerificationFieldIsYul
control=
{
control
}
/>
<
ContractVerificationFieldIsYul
control=
{
control
}
/>
<
ContractVerificationFieldName
control=
{
control
}
/>
<
ContractVerificationFieldName
control=
{
control
}
/>
<
ContractVerificationFieldCompiler
control=
{
control
}
/>
<
ContractVerificationFieldCompiler
control=
{
control
}
/>
<
ContractVerificationEvmVersion
control=
{
control
}
/>
<
ContractVerification
Field
EvmVersion
control=
{
control
}
/>
<
ContractVerificationFieldOptimization
control=
{
control
}
/>
<
ContractVerificationFieldOptimization
control=
{
control
}
/>
<
ContractVerificationFieldCode
control=
{
control
}
/>
<
ContractVerificationFieldCode
control=
{
control
}
/>
<
ContractVerificationFieldIsConstArgs
control=
{
control
}
/>
<
ContractVerificationFieldConstArgs
control=
{
control
}
/>
<
ContractVerificationFieldLibraries
control=
{
control
}
/>
</
ContractVerificationMethod
>
</
ContractVerificationMethod
>
);
);
};
};
...
...
ui/contractVerification/types.ts
View file @
ca47d79c
export
type
VerificationMethod
=
'
flatten_source_code
'
|
'
standard_input
'
|
'
sourcify
'
|
'
multi_part_file
'
|
'
vyper_contract
'
export
type
VerificationMethod
=
'
flatten_source_code
'
|
'
standard_input
'
|
'
sourcify
'
|
'
multi_part_file
'
|
'
vyper_contract
'
export
interface
ContractLibrary
{
name
:
string
;
address
:
string
;
}
export
interface
FormFieldsFlattenSourceCode
{
export
interface
FormFieldsFlattenSourceCode
{
method
:
'
flatten_source_code
'
;
method
:
'
flatten_source_code
'
;
is_yul
:
boolean
;
is_yul
:
boolean
;
...
@@ -10,6 +14,7 @@ export interface FormFieldsFlattenSourceCode {
...
@@ -10,6 +14,7 @@ export interface FormFieldsFlattenSourceCode {
optimization_runs
:
string
;
optimization_runs
:
string
;
code
:
string
;
code
:
string
;
constructor_args
:
boolean
;
constructor_args
:
boolean
;
libraries
:
Array
<
ContractLibrary
>
;
}
}
export
interface
FormFieldsStandardInput
{
export
interface
FormFieldsStandardInput
{
...
...
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