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
e52f2ea9
Commit
e52f2ea9
authored
Jan 20, 2023
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimisations, code and constructor args fields
parent
8c601d38
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
165 additions
and
1 deletion
+165
-1
ContractVerificationFieldCode.tsx
...ractVerification/fields/ContractVerificationFieldCode.tsx
+48
-0
ContractVerificationFieldIsConstArgs.tsx
...ification/fields/ContractVerificationFieldIsConstArgs.tsx
+33
-0
ContractVerificationFieldOptimization.tsx
...fication/fields/ContractVerificationFieldOptimization.tsx
+65
-0
ContractVerificationFlattenSourceCode.tsx
...ication/methods/ContractVerificationFlattenSourceCode.tsx
+6
-0
types.ts
ui/contractVerification/types.ts
+4
-0
CheckboxInput.tsx
ui/shared/CheckboxInput.tsx
+9
-1
No files found.
ui/contractVerification/fields/ContractVerificationFieldCode.tsx
0 → 100644
View file @
e52f2ea9
import
{
FormControl
,
GridItem
,
Link
,
Textarea
}
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
ContractVerificationFieldCode
=
({
control
}:
Props
)
=>
{
const
renderControl
=
React
.
useCallback
(({
field
}:
{
field
:
ControllerRenderProps
<
FormFields
,
'
code
'
>
})
=>
{
return
(
<
FormControl
variant=
"floating"
id=
{
field
.
name
}
isRequired
size=
{
{
base
:
'
md
'
,
lg
:
'
lg
'
}
}
>
<
Textarea
{
...
field
}
required
maxLength=
{
255
}
/>
<
InputPlaceholder
text=
"Contract code"
/>
</
FormControl
>
);
},
[]);
return
(
<>
<
GridItem
>
<
Controller
name=
"code"
control=
{
control
}
render=
{
renderControl
}
rules=
{
{
required
:
true
}
}
/>
</
GridItem
>
<
GridItem
fontSize=
"sm"
>
<
span
>
We recommend using flattened code. This is necessary if your code utilizes a library or inherits dependencies. Use the
</
span
>
<
Link
href=
"https://github.com/poanetwork/solidity-flattener"
target=
"_blank"
>
POA solidity flattener
</
Link
>
<
span
>
or the
</
span
>
<
Link
href=
"https://www.npmjs.com/package/truffle-flattener"
target=
"_blank"
>
Truffle flattener
</
Link
>
</
GridItem
>
</>
);
};
export
default
React
.
memo
(
ContractVerificationFieldCode
);
ui/contractVerification/fields/ContractVerificationFieldIsConstArgs.tsx
0 → 100644
View file @
e52f2ea9
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
ContractVerificationFieldIsConstArgs
=
({
control
}:
Props
)
=>
{
const
renderControl
=
React
.
useCallback
(({
field
}:
{
field
:
ControllerRenderProps
<
FormFields
,
'
constructor_args
'
>
})
=>
(
<
CheckboxInput
<
FormFields
,
'
constructor_args
'
>
text="Try to fetch constructor arguments automatically" field=
{
field
}
/
>
), []);
return (
<>
<
GridItem
>
<
Controller
name=
"constructor_args"
control=
{
control
}
render=
{
renderControl
}
/>
</
GridItem
>
<
GridItem
/>
</>
);
};
export default React.memo(ContractVerificationFieldIsConstArgs);
ui/contractVerification/fields/ContractVerificationFieldOptimization.tsx
0 → 100644
View file @
e52f2ea9
import
{
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
CheckboxInput
from
'
ui/shared/CheckboxInput
'
;
import
InputPlaceholder
from
'
ui/shared/InputPlaceholder
'
;
interface
Props
{
control
:
Control
<
FormFields
>
;
}
const
ContractVerificationFieldOptimization
=
({
control
}:
Props
)
=>
{
const
[
isEnabled
,
setIsEnabled
]
=
React
.
useState
(
false
);
const
handleCheckboxChange
=
React
.
useCallback
(()
=>
{
setIsEnabled
(
prev
=>
!
prev
);
},
[]);
const
renderCheckboxControl
=
React
.
useCallback
(({
field
}:
{
field
:
ControllerRenderProps
<
FormFields
,
'
is_optimization_enabled
'
>
})
=>
(
<
CheckboxInput
<
FormFields
,
'
is_optimization_enabled
'
>
text="Optimization enabled" field=
{
field
}
onChange=
{
handleCheckboxChange
}
/
>
), [ handleCheckboxChange ]);
const renderInputControl = React.useCallback((
{
field
}
:
{
field
:
ControllerRenderProps
<
FormFields
,
'
optimization_runs
'
>
}
) =
>
{
return
(
<
FormControl
variant=
"floating"
id=
{
field
.
name
}
size=
{
{
base
:
'
md
'
,
lg
:
'
lg
'
}
}
>
<
Input
{
...
field
}
required
maxLength=
{
255
}
/>
<
InputPlaceholder
text=
"Optimization runs"
/>
</
FormControl
>
);
}
, []);
return (
<>
<
GridItem
>
<
Controller
name=
"is_optimization_enabled"
control=
{
control
}
render=
{
renderCheckboxControl
}
/>
</
GridItem
>
<
GridItem
/>
{
isEnabled
&&
(
<>
<
GridItem
>
<
Controller
name=
"optimization_runs"
control=
{
control
}
render=
{
renderInputControl
}
/>
</
GridItem
>
<
GridItem
/>
</>
)
}
</>
);
};
export default React.memo(ContractVerificationFieldOptimization);
ui/contractVerification/methods/ContractVerificationFlattenSourceCode.tsx
View file @
e52f2ea9
...
...
@@ -5,9 +5,12 @@ import type { FormFields } from '../types';
import
ContractVerificationMethod
from
'
../ContractVerificationMethod
'
;
import
ContractVerificationEvmVersion
from
'
../fields/ContractVerificationEvmVersion
'
;
import
ContractVerificationFieldCode
from
'
../fields/ContractVerificationFieldCode
'
;
import
ContractVerificationFieldCompiler
from
'
../fields/ContractVerificationFieldCompiler
'
;
import
ContractVerificationFieldIsConstArgs
from
'
../fields/ContractVerificationFieldIsConstArgs
'
;
import
ContractVerificationFieldIsYul
from
'
../fields/ContractVerificationFieldIsYul
'
;
import
ContractVerificationFieldName
from
'
../fields/ContractVerificationFieldName
'
;
import
ContractVerificationFieldOptimization
from
'
../fields/ContractVerificationFieldOptimization
'
;
interface
Props
{
control
:
Control
<
FormFields
>
;
...
...
@@ -20,6 +23,9 @@ const ContractVerificationFlattenSourceCode = ({ control }: Props) => {
<
ContractVerificationFieldName
control=
{
control
}
/>
<
ContractVerificationFieldCompiler
control=
{
control
}
/>
<
ContractVerificationEvmVersion
control=
{
control
}
/>
<
ContractVerificationFieldOptimization
control=
{
control
}
/>
<
ContractVerificationFieldCode
control=
{
control
}
/>
<
ContractVerificationFieldIsConstArgs
control=
{
control
}
/>
</
ContractVerificationMethod
>
);
};
...
...
ui/contractVerification/types.ts
View file @
e52f2ea9
...
...
@@ -6,6 +6,10 @@ export interface FormFieldsFlattenSourceCode {
name
:
string
;
compiler
:
string
;
evm_version
:
string
;
is_optimization_enabled
:
boolean
;
optimization_runs
:
string
;
code
:
string
;
constructor_args
:
boolean
;
}
export
interface
FormFieldsStandardInput
{
...
...
ui/shared/CheckboxInput.tsx
View file @
e52f2ea9
...
...
@@ -7,17 +7,25 @@ import type { ControllerRenderProps, FieldValues, Path } from 'react-hook-form';
type
Props
<
TInputs
extends
FieldValues
,
TInputName
extends
Path
<
TInputs
>>
=
{
field
:
ControllerRenderProps
<
TInputs
,
TInputName
>
;
text
:
string
;
onChange
?:
()
=>
void
;
}
export
default
function
CheckboxInput
<
Inputs
extends
FieldValues
,
Name
extends
Path
<
Inputs
>>
(
{
field
,
text
,
onChange
,
}:
Props
<
Inputs
,
Name
>
)
{
const
handleChange
:
typeof
field
.
onChange
=
React
.
useCallback
((...
args
)
=>
{
field
.
onChange
(...
args
);
onChange
?.();
},
[
field
,
onChange
]);
return
(
<
Checkbox
isChecked=
{
field
.
value
}
onChange=
{
field
.
on
Change
}
onChange=
{
handle
Change
}
ref=
{
field
.
ref
}
colorScheme=
"blue"
size=
"lg"
...
...
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