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
9657e427
Unverified
Commit
9657e427
authored
Sep 13, 2024
by
tom goriunov
Committed by
GitHub
Sep 13, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass the file path when verifying a multi-part contract (#2208)
Fixes #2207
parent
344fbaef
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
9 deletions
+17
-9
ContractVerificationFieldSources.tsx
...tVerification/fields/ContractVerificationFieldSources.tsx
+4
-3
ContractVerificationMultiPartFile.tsx
...erification/methods/ContractVerificationMultiPartFile.tsx
+1
-0
ContractVerificationVyperMultiPartFile.tsx
...cation/methods/ContractVerificationVyperMultiPartFile.tsx
+1
-0
DragAndDropArea.tsx
ui/shared/forms/DragAndDropArea.tsx
+4
-3
files.ts
ui/shared/forms/utils/files.ts
+7
-3
No files found.
ui/contractVerification/fields/ContractVerificationFieldSources.tsx
View file @
9657e427
...
@@ -18,13 +18,14 @@ type FileTypes = '.sol' | '.yul' | '.json' | '.vy'
...
@@ -18,13 +18,14 @@ type FileTypes = '.sol' | '.yul' | '.json' | '.vy'
interface
Props
{
interface
Props
{
name
?:
'
sources
'
|
'
interfaces
'
;
name
?:
'
sources
'
|
'
interfaces
'
;
fileTypes
:
Array
<
FileTypes
>
;
fileTypes
:
Array
<
FileTypes
>
;
fullFilePath
?:
boolean
;
multiple
?:
boolean
;
multiple
?:
boolean
;
required
?:
boolean
;
required
?:
boolean
;
title
:
string
;
title
:
string
;
hint
:
string
|
React
.
ReactNode
;
hint
:
string
|
React
.
ReactNode
;
}
}
const
ContractVerificationFieldSources
=
({
fileTypes
,
multiple
,
required
,
title
,
hint
,
name
=
'
sources
'
}:
Props
)
=>
{
const
ContractVerificationFieldSources
=
({
fileTypes
,
multiple
,
required
,
title
,
hint
,
name
=
'
sources
'
,
fullFilePath
}:
Props
)
=>
{
const
{
setValue
,
getValues
,
control
,
formState
,
clearErrors
}
=
useFormContext
<
FormFields
>
();
const
{
setValue
,
getValues
,
control
,
formState
,
clearErrors
}
=
useFormContext
<
FormFields
>
();
const
error
=
(()
=>
{
const
error
=
(()
=>
{
...
@@ -114,7 +115,7 @@ const ContractVerificationFieldSources = ({ fileTypes, multiple, required, title
...
@@ -114,7 +115,7 @@ const ContractVerificationFieldSources = ({ fileTypes, multiple, required, title
rowGap=
{
2
}
rowGap=
{
2
}
w=
"100%"
w=
"100%"
>
>
<
DragAndDropArea
onDrop=
{
onChange
}
p=
{
{
base
:
3
,
lg
:
6
}
}
isDisabled=
{
formState
.
isSubmitting
}
>
<
DragAndDropArea
onDrop=
{
onChange
}
fullFilePath=
{
fullFilePath
}
p=
{
{
base
:
3
,
lg
:
6
}
}
isDisabled=
{
formState
.
isSubmitting
}
>
{
hasValue
?
renderFiles
(
field
.
value
)
:
renderUploadButton
()
}
{
hasValue
?
renderFiles
(
field
.
value
)
:
renderUploadButton
()
}
</
DragAndDropArea
>
</
DragAndDropArea
>
</
Flex
>
</
Flex
>
...
@@ -123,7 +124,7 @@ const ContractVerificationFieldSources = ({ fileTypes, multiple, required, title
...
@@ -123,7 +124,7 @@ const ContractVerificationFieldSources = ({ fileTypes, multiple, required, title
{
errorElement
}
{
errorElement
}
</>
</>
);
);
},
[
fileTypes
,
multiple
,
commonError
,
formState
.
isSubmitting
,
renderFiles
,
renderUploadButton
]);
},
[
fileTypes
,
multiple
,
commonError
,
formState
.
isSubmitting
,
renderFiles
,
renderUploadButton
,
fullFilePath
]);
const
validateFileType
=
React
.
useCallback
(
async
(
value
:
FieldPathValue
<
FormFields
,
typeof
name
>
):
Promise
<
ValidateResult
>
=>
{
const
validateFileType
=
React
.
useCallback
(
async
(
value
:
FieldPathValue
<
FormFields
,
typeof
name
>
):
Promise
<
ValidateResult
>
=>
{
if
(
Array
.
isArray
(
value
))
{
if
(
Array
.
isArray
(
value
))
{
...
...
ui/contractVerification/methods/ContractVerificationMultiPartFile.tsx
View file @
9657e427
...
@@ -18,6 +18,7 @@ const ContractVerificationMultiPartFile = () => {
...
@@ -18,6 +18,7 @@ const ContractVerificationMultiPartFile = () => {
<
ContractVerificationFieldSources
<
ContractVerificationFieldSources
fileTypes=
{
FILE_TYPES
}
fileTypes=
{
FILE_TYPES
}
multiple
multiple
fullFilePath
required
required
title=
"Sources *.sol or *.yul files"
title=
"Sources *.sol or *.yul files"
hint=
"Upload all Solidity or Yul contract source files."
hint=
"Upload all Solidity or Yul contract source files."
...
...
ui/contractVerification/methods/ContractVerificationVyperMultiPartFile.tsx
View file @
9657e427
...
@@ -37,6 +37,7 @@ const ContractVerificationVyperMultiPartFile = () => {
...
@@ -37,6 +37,7 @@ const ContractVerificationVyperMultiPartFile = () => {
name=
"interfaces"
name=
"interfaces"
fileTypes=
{
INTERFACE_TYPES
}
fileTypes=
{
INTERFACE_TYPES
}
multiple
multiple
fullFilePath
title=
"Interfaces (.vy or .json)"
title=
"Interfaces (.vy or .json)"
hint=
{
interfacesHint
}
hint=
{
interfacesHint
}
/>
/>
...
...
ui/shared/forms/DragAndDropArea.tsx
View file @
9657e427
...
@@ -9,9 +9,10 @@ interface Props {
...
@@ -9,9 +9,10 @@ interface Props {
onDrop
:
(
files
:
Array
<
File
>
)
=>
void
;
onDrop
:
(
files
:
Array
<
File
>
)
=>
void
;
className
?:
string
;
className
?:
string
;
isDisabled
?:
boolean
;
isDisabled
?:
boolean
;
fullFilePath
?:
boolean
;
}
}
const
DragAndDropArea
=
({
onDrop
,
children
,
className
,
isDisabled
}:
Props
)
=>
{
const
DragAndDropArea
=
({
onDrop
,
children
,
className
,
isDisabled
,
fullFilePath
}:
Props
)
=>
{
const
[
isDragOver
,
setIsDragOver
]
=
React
.
useState
(
false
);
const
[
isDragOver
,
setIsDragOver
]
=
React
.
useState
(
false
);
const
handleDrop
=
React
.
useCallback
(
async
(
event
:
DragEvent
<
HTMLDivElement
>
)
=>
{
const
handleDrop
=
React
.
useCallback
(
async
(
event
:
DragEvent
<
HTMLDivElement
>
)
=>
{
...
@@ -22,11 +23,11 @@ const DragAndDropArea = ({ onDrop, children, className, isDisabled }: Props) =>
...
@@ -22,11 +23,11 @@ const DragAndDropArea = ({ onDrop, children, className, isDisabled }: Props) =>
}
}
const
fileEntries
=
await
getAllFileEntries
(
event
.
dataTransfer
.
items
);
const
fileEntries
=
await
getAllFileEntries
(
event
.
dataTransfer
.
items
);
const
files
=
await
Promise
.
all
(
fileEntries
.
map
(
convertFileEntryToFile
));
const
files
=
await
Promise
.
all
(
fileEntries
.
map
(
(
fileEntry
)
=>
convertFileEntryToFile
(
fileEntry
,
fullFilePath
)
));
onDrop
(
files
);
onDrop
(
files
);
setIsDragOver
(
false
);
setIsDragOver
(
false
);
},
[
isDisabled
,
onDrop
]);
},
[
isDisabled
,
onDrop
,
fullFilePath
]);
const
handleDragOver
=
React
.
useCallback
((
event
:
DragEvent
<
HTMLDivElement
>
)
=>
{
const
handleDragOver
=
React
.
useCallback
((
event
:
DragEvent
<
HTMLDivElement
>
)
=>
{
event
.
preventDefault
();
event
.
preventDefault
();
...
...
ui/shared/forms/utils/files.ts
View file @
9657e427
import
stripLeadingSlash
from
'
lib/stripLeadingSlash
'
;
// Function to get all files in drop directory
// Function to get all files in drop directory
export
async
function
getAllFileEntries
(
dataTransferItemList
:
DataTransferItemList
):
Promise
<
Array
<
FileSystemFileEntry
>>
{
export
async
function
getAllFileEntries
(
dataTransferItemList
:
DataTransferItemList
):
Promise
<
Array
<
FileSystemFileEntry
>>
{
const
fileEntries
:
Array
<
FileSystemFileEntry
>
=
[];
const
fileEntries
:
Array
<
FileSystemFileEntry
>
=
[];
...
@@ -54,11 +56,13 @@ async function readEntriesPromise(directoryReader: DirectoryReader): Promise<Arr
...
@@ -54,11 +56,13 @@ async function readEntriesPromise(directoryReader: DirectoryReader): Promise<Arr
}
catch
(
err
)
{}
}
catch
(
err
)
{}
}
}
export
function
convertFileEntryToFile
(
entry
:
FileSystemFileEntry
):
Promise
<
File
>
{
export
function
convertFileEntryToFile
(
entry
:
FileSystemFileEntry
,
fullFilePath
?:
boolean
):
Promise
<
File
>
{
return
new
Promise
((
resolve
)
=>
{
return
new
Promise
((
resolve
)
=>
{
entry
.
file
(
async
(
file
:
File
)
=>
{
entry
.
file
(
async
(
file
:
File
)
=>
{
// const newFile = new File([ file ], entry.fullPath, { lastModified: file.lastModified, type: file.type });
const
newFile
=
fullFilePath
?
resolve
(
file
);
new
File
([
file
],
stripLeadingSlash
(
entry
.
fullPath
),
{
lastModified
:
file
.
lastModified
,
type
:
file
.
type
})
:
file
;
resolve
(
newFile
);
});
});
});
});
}
}
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