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
d795e14d
Commit
d795e14d
authored
Feb 16, 2023
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sourcify new flow
parent
006dc415
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
81 additions
and
2 deletions
+81
-2
ContractVerificationForm.tsx
ui/contractVerification/ContractVerificationForm.tsx
+1
-1
ContractVerificationFieldContractIndex.tsx
...ication/fields/ContractVerificationFieldContractIndex.tsx
+75
-0
ContractVerificationSourcify.tsx
...ractVerification/methods/ContractVerificationSourcify.tsx
+2
-0
types.ts
ui/contractVerification/types.ts
+1
-0
utils.ts
ui/contractVerification/utils.ts
+1
-0
FieldError.tsx
ui/shared/forms/FieldError.tsx
+1
-1
No files found.
ui/contractVerification/ContractVerificationForm.tsx
View file @
d795e14d
...
...
@@ -55,7 +55,7 @@ const ContractVerificationForm = ({ method: methodFromQuery, config, hash }: Pro
try
{
await
apiFetch
(
'
contract_verification_via
'
,
{
pathParams
:
{
method
:
data
.
method
.
value
,
id
:
hash
},
pathParams
:
{
method
:
data
.
method
.
value
,
id
:
hash
.
toLowerCase
()
},
fetchParams
:
{
method
:
'
POST
'
,
body
,
...
...
ui/contractVerification/fields/ContractVerificationFieldContractIndex.tsx
0 → 100644
View file @
d795e14d
import
{
useUpdateEffect
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
type
{
ControllerRenderProps
}
from
'
react-hook-form
'
;
import
{
useFormContext
,
Controller
}
from
'
react-hook-form
'
;
import
type
{
FormFields
}
from
'
../types
'
;
import
type
{
Option
}
from
'
ui/shared/FancySelect/types
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
FancySelect
from
'
ui/shared/FancySelect/FancySelect
'
;
import
ContractVerificationFormRow
from
'
../ContractVerificationFormRow
'
;
const
SOURCIFY_ERROR_REGEXP
=
/
(?<
=
\b
contracts
\s\([^
()
]
*
)\w
+/gi
;
const
ContractVerificationFieldContractIndex
=
()
=>
{
const
[
options
,
setOptions
]
=
React
.
useState
<
Array
<
Option
>>
([]);
const
{
formState
,
control
,
watch
}
=
useFormContext
<
FormFields
>
();
const
isMobile
=
useIsMobile
();
const
sources
=
watch
(
'
sources
'
);
const
sourcesError
=
'
sources
'
in
formState
.
errors
?
formState
.
errors
.
sources
?.
message
:
undefined
;
useUpdateEffect
(()
=>
{
if
(
!
sourcesError
)
{
return
;
}
const
parsedMethods
=
sourcesError
.
match
(
SOURCIFY_ERROR_REGEXP
);
if
(
!
Array
.
isArray
(
parsedMethods
)
||
parsedMethods
.
length
===
0
)
{
return
;
}
const
newOptions
=
parsedMethods
.
map
((
option
,
index
)
=>
({
label
:
option
,
value
:
String
(
index
+
1
)
}));
setOptions
(
newOptions
);
},
[
sourcesError
]);
useUpdateEffect
(()
=>
{
setOptions
([]);
},
[
sources
]);
const
renderControl
=
React
.
useCallback
(({
field
}:
{
field
:
ControllerRenderProps
<
FormFields
,
'
contract_index
'
>
})
=>
{
const
error
=
'
contract_index
'
in
formState
.
errors
?
formState
.
errors
.
contract_index
:
undefined
;
return
(
<
FancySelect
{
...
field
}
options=
{
options
}
size=
{
isMobile
?
'
md
'
:
'
lg
'
}
placeholder=
"Contract name"
isDisabled=
{
formState
.
isSubmitting
}
error=
{
error
}
isRequired
isAsync=
{
false
}
/>
);
},
[
formState
.
errors
,
formState
.
isSubmitting
,
isMobile
,
options
]);
if
(
options
.
length
===
0
)
{
return
null
;
}
return
(
<
ContractVerificationFormRow
>
<
Controller
name=
"contract_index"
control=
{
control
}
render=
{
renderControl
}
rules=
{
{
required
:
true
}
}
/>
</
ContractVerificationFormRow
>
);
};
export
default
React
.
memo
(
ContractVerificationFieldContractIndex
);
ui/contractVerification/methods/ContractVerificationSourcify.tsx
View file @
d795e14d
import
React
from
'
react
'
;
import
ContractVerificationMethod
from
'
../ContractVerificationMethod
'
;
import
ContractVerificationFieldContractIndex
from
'
../fields/ContractVerificationFieldContractIndex
'
;
import
ContractVerificationFieldSources
from
'
../fields/ContractVerificationFieldSources
'
;
const
FILE_TYPES
=
[
'
.json
'
as
const
,
'
.sol
'
as
const
];
...
...
@@ -14,6 +15,7 @@ const ContractVerificationSourcify = () => {
title=
"Sources and Metadata JSON"
hint=
"Upload all Solidity contract source files and JSON metadata file(s) created during contract compilation."
/>
<
ContractVerificationFieldContractIndex
/>
</
ContractVerificationMethod
>
);
};
...
...
ui/contractVerification/types.ts
View file @
d795e14d
...
...
@@ -37,6 +37,7 @@ export interface FormFieldsStandardInput {
export
interface
FormFieldsSourcify
{
method
:
MethodOption
;
sources
:
Array
<
File
>
;
contract_index
?:
Option
;
}
export
interface
FormFieldsMultiPartFile
{
...
...
ui/contractVerification/utils.ts
View file @
d795e14d
...
...
@@ -154,6 +154,7 @@ export function prepareRequestBody(data: FormFields): FetchParams['body'] {
const
_data
=
data
as
FormFieldsSourcify
;
const
body
=
new
FormData
();
addFilesToFormData
(
body
,
_data
.
sources
);
_data
.
contract_index
&&
body
.
set
(
'
chosen_contract_index
'
,
_data
.
contract_index
.
value
);
return
body
;
}
...
...
ui/shared/forms/FieldError.tsx
View file @
d795e14d
...
...
@@ -7,7 +7,7 @@ interface Props {
}
const
FieldError
=
({
message
,
className
}:
Props
)
=>
{
return
<
Box
className=
{
className
}
color=
"error"
fontSize=
"sm"
mt=
{
2
}
wordBreak=
"break-
all
"
>
{
message
}
</
Box
>;
return
<
Box
className=
{
className
}
color=
"error"
fontSize=
"sm"
mt=
{
2
}
wordBreak=
"break-
word
"
>
{
message
}
</
Box
>;
};
export
default
chakra
(
FieldError
);
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