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
38307d90
Unverified
Commit
38307d90
authored
Jun 19, 2023
by
protolambda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-bindings: make sourcemap optional
parent
26f490d7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
12 deletions
+22
-12
Makefile
op-bindings/Makefile
+1
-0
main.go
op-bindings/gen/main.go
+21
-12
No files found.
op-bindings/Makefile
View file @
38307d90
...
...
@@ -149,6 +149,7 @@ more:
-forge-artifacts
../packages/contracts-bedrock/forge-artifacts
\
-out
./bindings
\
-contracts
SystemConfig,OptimismMintableERC20Factory,L2StandardBridge,L1BlockNumber,LegacyMessagePasser,DeployerWhitelist,Proxy,OptimismPortal,L2ToL1MessagePasser,L2CrossDomainMessenger,SequencerFeeVault,L1Block,LegacyERC20ETH,WETH9,GovernanceToken,L1CrossDomainMessenger,L2ERC721Bridge,OptimismMintableERC721Factory,ProxyAdmin,MIPS,Oracle
\
-source-maps
MIPS,Oracle
\
-package
bindings
mkdir
:
...
...
op-bindings/gen/main.go
View file @
38307d90
...
...
@@ -19,6 +19,7 @@ type flags struct {
ArtifactsDir
string
ForgeArtifacts
string
Contracts
string
SourceMaps
string
OutDir
string
Package
string
}
...
...
@@ -43,11 +44,17 @@ func main() {
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
.
Contracts
,
"contracts"
,
""
,
"Comma-separated list of contracts to generate code for"
)
flag
.
StringVar
(
&
f
.
SourceMaps
,
"source-maps"
,
""
,
"Comma-separated list of contracts to generate source-maps for"
)
flag
.
StringVar
(
&
f
.
Package
,
"package"
,
"artifacts"
,
"Go package name"
)
flag
.
Parse
()
artifacts
:=
strings
.
Split
(
f
.
ArtifactsDir
,
","
)
contracts
:=
strings
.
Split
(
f
.
Contracts
,
","
)
sourceMaps
:=
strings
.
Split
(
f
.
SourceMaps
,
","
)
sourceMapsSet
:=
make
(
map
[
string
]
struct
{})
for
_
,
k
:=
range
sourceMaps
{
sourceMapsSet
[
k
]
=
struct
{}{}
}
if
len
(
artifacts
)
==
0
{
log
.
Fatalf
(
"must define a list of artifacts"
)
...
...
@@ -82,18 +89,20 @@ func main() {
}
serStr
:=
strings
.
Replace
(
string
(
ser
),
"
\"
"
,
"
\\\"
"
,
-
1
)
// directory has .sol extension
forgeArtifactData
,
err
:=
os
.
ReadFile
(
path
.
Join
(
f
.
ForgeArtifacts
,
name
+
".sol"
,
name
+
".json"
))
if
errors
.
Is
(
err
,
os
.
ErrNotExist
)
{
log
.
Printf
(
"cannot find forge-artifact with source-map data of %q
\n
"
,
name
)
}
deployedSourceMap
:=
""
if
err
==
nil
{
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
_
,
ok
:=
sourceMapsSet
[
name
];
ok
{
// directory has .sol extension
forgeArtifactData
,
err
:=
os
.
ReadFile
(
path
.
Join
(
f
.
ForgeArtifacts
,
name
+
".sol"
,
name
+
".json"
))
if
errors
.
Is
(
err
,
os
.
ErrNotExist
)
{
log
.
Printf
(
"cannot find forge-artifact with source-map data of %q
\n
"
,
name
)
}
if
err
==
nil
{
var
artifact
forgeArtifact
if
err
:=
json
.
Unmarshal
(
forgeArtifactData
,
&
artifact
);
err
!=
nil
{
log
.
Fatalf
(
"failed to parse forge artifact of %q: %v
\n
"
,
name
,
err
)
}
deployedSourceMap
=
artifact
.
DeployedBytecode
.
SourceMap
}
deployedSourceMap
=
artifact
.
DeployedBytecode
.
SourceMap
}
d
:=
data
{
...
...
@@ -138,9 +147,9 @@ const {{.Name}}StorageLayoutJSON = "{{.StorageLayout}}"
var {{.Name}}StorageLayout = new(solc.StorageLayout)
var {{.Name}}DeployedBin = "{{.DeployedBin}}"
{{if .DeployedSourceMap}}
var {{.Name}}DeployedSourceMap = "{{.DeployedSourceMap}}"
{{end}}
func init() {
if err := json.Unmarshal([]byte({{.Name}}StorageLayoutJSON), {{.Name}}StorageLayout); err != nil {
panic(err)
...
...
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