Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
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
exchain
nebula
Commits
d59ac98d
Commit
d59ac98d
authored
Jun 26, 2023
by
Mark Tyneway
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-bindings: fix gen script
parent
38e48aa3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
14 deletions
+20
-14
main.go
op-bindings/gen/main.go
+20
-14
No files found.
op-bindings/gen/main.go
View file @
d59ac98d
...
@@ -12,7 +12,8 @@ import (
...
@@ -12,7 +12,8 @@ import (
"text/template"
"text/template"
"github.com/ethereum-optimism/optimism/op-bindings/ast"
"github.com/ethereum-optimism/optimism/op-bindings/ast"
"github.com/ethereum-optimism/optimism/op-bindings/hardhat"
"github.com/ethereum-optimism/optimism/op-bindings/solc"
"github.com/ethereum/go-ethereum/common/hexutil"
)
)
type
flags
struct
{
type
flags
struct
{
...
@@ -33,14 +34,16 @@ type data struct {
...
@@ -33,14 +34,16 @@ type data struct {
}
}
type
forgeArtifact
struct
{
type
forgeArtifact
struct
{
StorageLayout
*
solc
.
StorageLayout
`json:"storageLayout"`
DeployedBytecode
struct
{
DeployedBytecode
struct
{
SourceMap
string
`json:"sourceMap"`
SourceMap
string
`json:"sourceMap"`
Object
hexutil
.
Bytes
`json:"object"`
}
`json:"deployedBytecode"`
}
`json:"deployedBytecode"`
}
}
func
main
()
{
func
main
()
{
var
f
flags
var
f
flags
flag
.
StringVar
(
&
f
.
ArtifactsDir
,
"artifacts"
,
""
,
"Comma-separated list of directories
containing artifacts and
build info"
)
flag
.
StringVar
(
&
f
.
ArtifactsDir
,
"artifacts"
,
""
,
"Comma-separated list of directories build info"
)
flag
.
StringVar
(
&
f
.
ForgeArtifacts
,
"forge-artifacts"
,
""
,
"Forge artifacts directory, to load sourcemaps from, if available"
)
flag
.
StringVar
(
&
f
.
ForgeArtifacts
,
"forge-artifacts"
,
""
,
"Forge artifacts directory, to load sourcemaps from, if available"
)
flag
.
StringVar
(
&
f
.
OutDir
,
"out"
,
""
,
"Output directory to put code in"
)
flag
.
StringVar
(
&
f
.
OutDir
,
"out"
,
""
,
"Output directory to put code in"
)
flag
.
StringVar
(
&
f
.
Contracts
,
"contracts"
,
""
,
"Comma-separated list of contracts to generate code for"
)
flag
.
StringVar
(
&
f
.
Contracts
,
"contracts"
,
""
,
"Comma-separated list of contracts to generate code for"
)
...
@@ -64,25 +67,28 @@ func main() {
...
@@ -64,25 +67,28 @@ func main() {
log
.
Fatalf
(
"must define a list of contracts"
)
log
.
Fatalf
(
"must define a list of contracts"
)
}
}
hh
,
err
:=
hardhat
.
New
(
"dummy"
,
artifacts
,
nil
)
if
err
!=
nil
{
log
.
Fatalln
(
"error reading artifacts:"
,
err
)
}
t
:=
template
.
Must
(
template
.
New
(
"artifact"
)
.
Parse
(
tmpl
))
t
:=
template
.
Must
(
template
.
New
(
"artifact"
)
.
Parse
(
tmpl
))
for
_
,
name
:=
range
contracts
{
for
_
,
name
:=
range
contracts
{
art
,
err
:=
hh
.
GetArtifact
(
name
)
forgeArtifactData
,
err
:=
os
.
ReadFile
(
path
.
Join
(
f
.
ForgeArtifacts
,
name
+
".sol"
,
name
+
".json"
)
)
if
err
!=
nil
{
if
err
ors
.
Is
(
err
,
os
.
ErrNotExist
)
{
log
.
Fatalf
(
"error reading artifact %s: %v
\n
"
,
name
,
err
)
log
.
Printf
(
"cannot find forge-artifact with source-map data of %q
\n
"
,
name
)
}
}
storage
,
err
:=
hh
.
GetStorageLayout
(
name
)
var
artifact
forgeArtifact
if
err
:=
json
.
Unmarshal
(
forgeArtifactData
,
&
artifact
);
err
!=
nil
{
log
.
Fatalf
(
"failed to parse forge artifact of %q: %v
\n
"
,
name
,
err
)
}
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Fatalf
(
"error reading storage layout %s: %v
\n
"
,
name
,
err
)
log
.
Fatalf
(
"error reading storage layout %s: %v
\n
"
,
name
,
err
)
}
}
canonicalStorage
:=
ast
.
CanonicalizeASTIDs
(
storage
)
storage
:=
artifact
.
StorageLayout
if
storage
==
nil
{
log
.
Fatalf
(
"no storage layout for %s
\n
"
,
name
)
}
canonicalStorage
:=
ast
.
CanonicalizeASTIDs
(
storage
)
ser
,
err
:=
json
.
Marshal
(
canonicalStorage
)
ser
,
err
:=
json
.
Marshal
(
canonicalStorage
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Fatalf
(
"error marshaling storage: %v
\n
"
,
err
)
log
.
Fatalf
(
"error marshaling storage: %v
\n
"
,
err
)
...
@@ -108,7 +114,7 @@ func main() {
...
@@ -108,7 +114,7 @@ func main() {
d
:=
data
{
d
:=
data
{
Name
:
name
,
Name
:
name
,
StorageLayout
:
serStr
,
StorageLayout
:
serStr
,
DeployedBin
:
art
.
DeployedBytecode
.
String
(),
DeployedBin
:
art
ifact
.
DeployedBytecode
.
Object
.
String
(),
Package
:
f
.
Package
,
Package
:
f
.
Package
,
DeployedSourceMap
:
deployedSourceMap
,
DeployedSourceMap
:
deployedSourceMap
,
}
}
...
...
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