good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
4
4byte
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
4byte
Commits
8b19d10a
Commit
8b19d10a
authored
Jun 27, 2023
by
Garet Halliday
Browse files
Options
Downloads
Patches
Plain Diff
upload solidity
parent
321f7426
No related branches found
No related tags found
No related merge requests found
Pipeline
#22286
passed
Jun 27, 2023
Stage: build
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
common/server/impl.go
+34
-4
34 additions, 4 deletions
common/server/impl.go
common/sig/entry.go
+28
-0
28 additions, 0 deletions
common/sig/entry.go
with
62 additions
and
4 deletions
common/server/impl.go
+
34
−
4
View file @
8b19d10a
...
...
@@ -48,15 +48,36 @@ func (s *Impl) makeEventSignature(sig *sig.Entry) api.EventSignature {
}
func
(
s
*
Impl
)
APIV1ImportSolidityPost
(
ctx
context
.
Context
,
req
api
.
APIV1ImportSolidityPostReq
)
(
*
api
.
UploadResult
,
error
)
{
var
sourceCode
string
switch
r
:=
req
.
(
type
)
{
case
*
api
.
APIV1ImportSolidityPostApplicationJSON
:
_
=
r
.
SourceCode
sourceCode
=
r
.
SourceCode
case
*
api
.
APIV1ImportSolidityPostApplicationXWwwFormUrlencoded
:
_
=
r
.
SourceCode
sourceCode
=
r
.
SourceCode
case
*
api
.
ImportSolidityMultipart
:
_
=
r
.
SourceCode
sourceCode
=
r
.
SourceCode
}
panic
(
"not implemented"
)
// TODO: Implement
entries
:=
sig
.
FromSolidity
(
sourceCode
)
res
:=
&
api
.
UploadResult
{}
for
_
,
entry
:=
range
entries
{
res
.
NumProcessed
++
addedSig
,
err
:=
s
.
Store
.
Put
(
ctx
,
entry
)
if
err
!=
nil
{
return
nil
,
err
}
if
addedSig
==
nil
{
res
.
NumDuplicates
++
}
else
{
res
.
NumImported
++
}
}
return
res
,
nil
}
func
(
s
*
Impl
)
APIV1ImportAbiPost
(
ctx
context
.
Context
,
req
api
.
APIV1ImportAbiPostReq
)
(
*
api
.
UploadResult
,
error
)
{
...
...
@@ -115,6 +136,15 @@ func (s *Impl) APIV1ImportAbiPost(ctx context.Context, req api.APIV1ImportAbiPos
return
nil
,
err
}
}
if
err
=
handleSig
(
parsedAbi
.
Constructor
.
Sig
);
err
!=
nil
{
return
nil
,
err
}
if
err
=
handleSig
(
parsedAbi
.
Fallback
.
Sig
);
err
!=
nil
{
return
nil
,
err
}
if
err
=
handleSig
(
parsedAbi
.
Receive
.
Sig
);
err
!=
nil
{
return
nil
,
err
}
return
res
,
nil
}
...
...
This diff is collapsed.
Click to expand it.
common/sig/entry.go
+
28
−
0
View file @
8b19d10a
package
sig
import
(
"strings"
"time"
"gfx.cafe/open/4byte/common/util/hashpool"
...
...
@@ -33,6 +34,33 @@ func FromText(s string) *Entry {
return
entry
}
func
FromSolidity
(
src
string
)
[]
*
Entry
{
var
entries
[]
*
Entry
for
{
idx
:=
strings
.
Index
(
src
,
"function"
)
if
idx
==
-
1
{
break
}
// try to read signature
sig
,
ok
:=
Normalize
(
src
[
idx
:
])
src
=
src
[
idx
+
len
(
"function"
)
:
]
if
!
ok
{
continue
}
entry
:=
&
Entry
{
Signature
:
sig
,
CreatedAt
:
time
.
Now
(),
}
entry
.
init
()
entries
=
append
(
entries
,
entry
)
}
return
entries
}
func
(
e
*
Entry
)
init
()
{
e
.
calculateEventHash
()
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment