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
1b21831c
Commit
1b21831c
authored
Feb 08, 2023
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
api fixes
parent
8c349948
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
33 additions
and
44 deletions
+33
-44
contract.ts
types/api/contract.ts
+1
-1
ContractVerificationForm.pw.tsx
ui/contractVerification/ContractVerificationForm.pw.tsx
+4
-4
ContractVerificationForm.tsx
ui/contractVerification/ContractVerificationForm.tsx
+7
-10
ContractVerificationFieldMethod.tsx
...ctVerification/fields/ContractVerificationFieldMethod.tsx
+5
-5
types.ts
ui/contractVerification/types.ts
+5
-5
utils.ts
ui/contractVerification/utils.ts
+11
-19
No files found.
types/api/contract.ts
View file @
1b21831c
...
...
@@ -116,7 +116,7 @@ export type SmartContractQueryMethodRead = SmartContractQueryMethodReadSuccess |
// VERIFICATION
export
type
SmartContractVerificationMethod
=
'
flattened
_code
'
|
'
standard_input
'
|
'
sourcify
'
|
'
multi_part
'
|
'
vyper_code
'
|
'
vyper_multi_
part
'
;
export
type
SmartContractVerificationMethod
=
'
flattened
-code
'
|
'
standard-input
'
|
'
sourcify
'
|
'
multi-part
'
|
'
vyper-code
'
|
'
vyper-multi-
part
'
;
export
interface
SmartContractVerificationConfigRaw
{
solidity_compiler_versions
:
Array
<
string
>
;
...
...
ui/contractVerification/ContractVerificationForm.pw.tsx
View file @
1b21831c
...
...
@@ -29,11 +29,11 @@ const formConfig: SmartContractVerificationConfig = {
'
berlin
'
,
],
verification_options
:
[
'
flattened
_
code
'
,
'
standard
_
input
'
,
'
flattened
-
code
'
,
'
standard
-
input
'
,
'
sourcify
'
,
'
multi
_
part
'
,
'
vyper
_
code
'
,
'
multi
-
part
'
,
'
vyper
-
code
'
,
],
vyper_compiler_versions
:
[
'
v0.3.7+commit.6020b8bb
'
,
...
...
ui/contractVerification/ContractVerificationForm.tsx
View file @
1b21831c
...
...
@@ -21,15 +21,15 @@ import ContractVerificationSourcify from './methods/ContractVerificationSourcify
import
ContractVerificationStandardInput
from
'
./methods/ContractVerificationStandardInput
'
;
import
ContractVerificationVyperContract
from
'
./methods/ContractVerificationVyperContract
'
;
import
ContractVerificationVyperMultiPartFile
from
'
./methods/ContractVerificationVyperMultiPartFile
'
;
import
{
prepareRequestBody
,
METHOD_TO_ENDPOINT_MAP
,
formatSocketErrors
}
from
'
./utils
'
;
import
{
prepareRequestBody
,
formatSocketErrors
}
from
'
./utils
'
;
const
METHOD_COMPONENTS
=
{
flattened_code
:
<
ContractVerificationFlattenSourceCode
/>,
standard_input
:
<
ContractVerificationStandardInput
/>,
'
flattened-code
'
:
<
ContractVerificationFlattenSourceCode
/>
,
'
standard-input
'
:
<
ContractVerificationStandardInput
/>
,
sourcify
:
<
ContractVerificationSourcify
/>,
multi_part
:
<
ContractVerificationMultiPartFile
/>,
vyper_code
:
<
ContractVerificationVyperContract
/>,
vyper_multi_part
:
<
ContractVerificationVyperMultiPartFile
/>,
'
multi-part
'
:
<
ContractVerificationMultiPartFile
/>
,
'
vyper-code
'
:
<
ContractVerificationVyperContract
/>
,
'
vyper-multi-part
'
:
<
ContractVerificationVyperMultiPartFile
/>
,
};
interface
Props
{
...
...
@@ -53,14 +53,11 @@ const ContractVerificationForm = ({ method: methodFromQuery, config, hash }: Pro
const
router
=
useRouter
();
const
onFormSubmit
:
SubmitHandler
<
FormFields
>
=
React
.
useCallback
(
async
(
data
)
=>
{
// eslint-disable-next-line no-console
console
.
log
(
'
__>__
'
,
data
);
const
body
=
prepareRequestBody
(
data
);
try
{
await
apiFetch
(
'
contract_verification_via
'
,
{
pathParams
:
{
method
:
METHOD_TO_ENDPOINT_MAP
[
data
.
method
]
,
id
:
hash
},
pathParams
:
{
method
:
data
.
method
,
id
:
hash
},
fetchParams
:
{
method
:
'
POST
'
,
body
,
...
...
ui/contractVerification/fields/ContractVerificationFieldMethod.tsx
View file @
1b21831c
...
...
@@ -37,9 +37,9 @@ const ContractVerificationFieldMethod = ({ control, isDisabled, methods }: Props
const
renderItem
=
React
.
useCallback
((
method
:
SmartContractVerificationMethod
)
=>
{
switch
(
method
)
{
case
'
flattened
_
code
'
:
case
'
flattened
-
code
'
:
return
'
Via flattened source code
'
;
case
'
standard
_
input
'
:
case
'
standard
-
input
'
:
return
(
<>
<
span
>
Via standard
</
span
>
...
...
@@ -85,11 +85,11 @@ const ContractVerificationFieldMethod = ({ control, isDisabled, methods }: Props
</
Popover
>
</>
);
case
'
multi
_
part
'
:
case
'
multi
-
part
'
:
return
'
Via multi-part files
'
;
case
'
vyper
_
code
'
:
case
'
vyper
-
code
'
:
return
'
Vyper contract
'
;
case
'
vyper
_multi_
part
'
:
case
'
vyper
-multi-
part
'
:
return
'
Via multi-part Vyper files
'
;
default
:
...
...
ui/contractVerification/types.ts
View file @
1b21831c
...
...
@@ -5,7 +5,7 @@ export interface ContractLibrary {
address
:
string
;
}
export
interface
FormFieldsFlattenSourceCode
{
method
:
'
flattened
_
code
'
;
method
:
'
flattened
-
code
'
;
is_yul
:
boolean
;
name
:
string
;
compiler
:
Option
;
...
...
@@ -19,7 +19,7 @@ export interface FormFieldsFlattenSourceCode {
}
export
interface
FormFieldsStandardInput
{
method
:
'
standard
_
input
'
;
method
:
'
standard
-
input
'
;
name
:
string
;
compiler
:
Option
;
sources
:
Array
<
File
>
;
...
...
@@ -33,7 +33,7 @@ export interface FormFieldsSourcify {
}
export
interface
FormFieldsMultiPartFile
{
method
:
'
multi
_
part
'
;
method
:
'
multi
-
part
'
;
compiler
:
Option
;
evm_version
:
Option
;
is_optimization_enabled
:
boolean
;
...
...
@@ -43,7 +43,7 @@ export interface FormFieldsMultiPartFile {
}
export
interface
FormFieldsVyperContract
{
method
:
'
vyper
_
code
'
;
method
:
'
vyper
-
code
'
;
name
:
string
;
compiler
:
Option
;
code
:
string
;
...
...
@@ -51,7 +51,7 @@ export interface FormFieldsVyperContract {
}
export
interface
FormFieldsVyperMultiPartFile
{
method
:
'
vyper
_multi_
part
'
;
method
:
'
vyper
-multi-
part
'
;
compiler
:
Option
;
evm_version
:
Option
;
sources
:
Array
<
File
>
;
...
...
ui/contractVerification/utils.ts
View file @
1b21831c
...
...
@@ -6,23 +6,14 @@ import type { SmartContractVerificationMethod, SmartContractVerificationError }
import
type
{
Params
as
FetchParams
}
from
'
lib/hooks/useFetch
'
;
export
const
SUPPORTED_VERIFICATION_METHODS
:
Array
<
SmartContractVerificationMethod
>
=
[
'
flattened
_
code
'
,
'
standard
_
input
'
,
'
flattened
-
code
'
,
'
standard
-
input
'
,
'
sourcify
'
,
'
multi
_
part
'
,
'
vyper
_
code
'
,
'
vyper
_multi_
part
'
,
'
multi
-
part
'
,
'
vyper
-
code
'
,
'
vyper
-multi-
part
'
,
];
export
const
METHOD_TO_ENDPOINT_MAP
:
Record
<
SmartContractVerificationMethod
,
string
>
=
{
flattened_code
:
'
flattened-code
'
,
standard_input
:
'
standard-input
'
,
sourcify
:
'
sourcify
'
,
multi_part
:
'
multi-part
'
,
vyper_code
:
'
vyper-code
'
,
vyper_multi_part
:
'
vyper-multi-part
'
,
};
export
function
isValidVerificationMethod
(
method
?:
string
):
method
is
SmartContractVerificationMethod
{
return
method
&&
SUPPORTED_VERIFICATION_METHODS
.
includes
(
method
as
SmartContractVerificationMethod
)
?
true
:
false
;
}
...
...
@@ -44,11 +35,12 @@ export function sortVerificationMethods(methodA: SmartContractVerificationMethod
export
function
prepareRequestBody
(
data
:
FormFields
):
FetchParams
[
'
body
'
]
{
switch
(
data
.
method
)
{
case
'
flattened
_
code
'
:
{
case
'
flattened
-
code
'
:
{
return
{
compiler_version
:
data
.
compiler
?.
value
,
source_code
:
data
.
code
,
is_optimization_enabled
:
data
.
is_optimization_enabled
,
is_yul_contract
:
data
.
is_yul
,
optimization_runs
:
data
.
optimization_runs
,
contract_name
:
data
.
name
,
libraries
:
reduceLibrariesArray
(
data
.
libraries
),
...
...
@@ -58,7 +50,7 @@ export function prepareRequestBody(data: FormFields): FetchParams['body'] {
};
}
case
'
standard
_
input
'
:
{
case
'
standard
-
input
'
:
{
const
body
=
new
FormData
();
body
.
set
(
'
compiler_version
'
,
data
.
compiler
?.
value
);
body
.
set
(
'
contract_name
'
,
data
.
name
);
...
...
@@ -76,7 +68,7 @@ export function prepareRequestBody(data: FormFields): FetchParams['body'] {
return
body
;
}
case
'
multi
_
part
'
:
{
case
'
multi
-
part
'
:
{
const
body
=
new
FormData
();
body
.
set
(
'
compiler_version
'
,
data
.
compiler
?.
value
);
body
.
set
(
'
evm_version
'
,
data
.
evm_version
?.
value
);
...
...
@@ -90,7 +82,7 @@ export function prepareRequestBody(data: FormFields): FetchParams['body'] {
return
body
;
}
case
'
vyper
_
code
'
:
{
case
'
vyper
-
code
'
:
{
return
{
compiler_version
:
data
.
compiler
?.
value
,
source_code
:
data
.
code
,
...
...
@@ -99,7 +91,7 @@ export function prepareRequestBody(data: FormFields): FetchParams['body'] {
};
}
case
'
vyper
_multi_
part
'
:
{
case
'
vyper
-multi-
part
'
:
{
const
body
=
new
FormData
();
body
.
set
(
'
compiler_version
'
,
data
.
compiler
?.
value
);
body
.
set
(
'
evm_version
'
,
data
.
evm_version
?.
value
);
...
...
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