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
7ebc966a
Commit
7ebc966a
authored
Jun 30, 2023
by
Mark Tyneway
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bindings: canonicalize
parent
72d18485
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
47 additions
and
6 deletions
+47
-6
canonicalize.go
op-bindings/ast/canonicalize.go
+16
-1
erc20_more.go
op-bindings/bindings/erc20_more.go
+1
-1
preimageoracle_more.go
op-bindings/bindings/preimageoracle_more.go
+1
-1
weth9.go
op-bindings/bindings/weth9.go
+1
-1
weth9_more.go
op-bindings/bindings/weth9_more.go
+1
-1
main.go
op-bindings/gen/main.go
+27
-1
No files found.
op-bindings/ast/canonicalize.go
View file @
7ebc966a
package
ast
package
ast
import
(
import
(
"path/filepath"
"regexp"
"regexp"
"sort"
"sort"
"strconv"
"strconv"
"strings"
"strings"
"golang.org/x/exp/slices"
"github.com/ethereum-optimism/optimism/op-bindings/solc"
"github.com/ethereum-optimism/optimism/op-bindings/solc"
)
)
...
@@ -83,9 +86,21 @@ func CanonicalizeASTIDs(in *solc.StorageLayout) *solc.StorageLayout {
...
@@ -83,9 +86,21 @@ func CanonicalizeASTIDs(in *solc.StorageLayout) *solc.StorageLayout {
Types
:
make
(
map
[
string
]
solc
.
StorageLayoutType
),
Types
:
make
(
map
[
string
]
solc
.
StorageLayoutType
),
}
}
for
_
,
slot
:=
range
in
.
Storage
{
for
_
,
slot
:=
range
in
.
Storage
{
contract
:=
slot
.
Contract
// Normalize the name of the contract since absolute paths
// are used when there are 2 contracts imported with the same
// name
if
filepath
.
IsAbs
(
contract
)
{
elements
:=
strings
.
Split
(
contract
,
"/"
)
if
idx
:=
slices
.
Index
(
elements
,
"optimism"
);
idx
!=
-
1
{
contract
=
filepath
.
Join
(
elements
[
idx
+
1
:
]
...
)
}
}
outLayout
.
Storage
=
append
(
outLayout
.
Storage
,
solc
.
StorageLayoutEntry
{
outLayout
.
Storage
=
append
(
outLayout
.
Storage
,
solc
.
StorageLayoutEntry
{
AstId
:
astIDRemappings
[
slot
.
AstId
],
AstId
:
astIDRemappings
[
slot
.
AstId
],
Contract
:
slot
.
C
ontract
,
Contract
:
c
ontract
,
Label
:
slot
.
Label
,
Label
:
slot
.
Label
,
Offset
:
slot
.
Offset
,
Offset
:
slot
.
Offset
,
Slot
:
slot
.
Slot
,
Slot
:
slot
.
Slot
,
...
...
op-bindings/bindings/erc20_more.go
View file @
7ebc966a
...
@@ -9,7 +9,7 @@ import (
...
@@ -9,7 +9,7 @@ import (
"github.com/ethereum-optimism/optimism/op-bindings/solc"
"github.com/ethereum-optimism/optimism/op-bindings/solc"
)
)
const
ERC20StorageLayoutJSON
=
"{
\"
storage
\"
:[{
\"
astId
\"
:1000,
\"
contract
\"
:
\"
node_modules/
@openzeppelin/contracts/token/ERC20/ERC20.sol:ERC20
\"
,
\"
label
\"
:
\"
_balances
\"
,
\"
offset
\"
:0,
\"
slot
\"
:
\"
0
\"
,
\"
type
\"
:
\"
t_mapping(t_address,t_uint256)
\"
},{
\"
astId
\"
:1001,
\"
contract
\"
:
\"
node_modules/@openzeppelin/contracts/token/ERC20/ERC20.sol:ERC20
\"
,
\"
label
\"
:
\"
_allowances
\"
,
\"
offset
\"
:0,
\"
slot
\"
:
\"
1
\"
,
\"
type
\"
:
\"
t_mapping(t_address,t_mapping(t_address,t_uint256))
\"
},{
\"
astId
\"
:1002,
\"
contract
\"
:
\"
node_modules/@openzeppelin/contracts/token/ERC20/ERC20.sol:ERC20
\"
,
\"
label
\"
:
\"
_totalSupply
\"
,
\"
offset
\"
:0,
\"
slot
\"
:
\"
2
\"
,
\"
type
\"
:
\"
t_uint256
\"
},{
\"
astId
\"
:1003,
\"
contract
\"
:
\"
node_modules/@openzeppelin/contracts/token/ERC20/ERC20.sol:ERC20
\"
,
\"
label
\"
:
\"
_name
\"
,
\"
offset
\"
:0,
\"
slot
\"
:
\"
3
\"
,
\"
type
\"
:
\"
t_string_storage
\"
},{
\"
astId
\"
:1004,
\"
contract
\"
:
\"
node_modules/@openzeppelin/contracts/token/ERC20/ERC20.sol:ERC20
\"
,
\"
label
\"
:
\"
_symbol
\"
,
\"
offset
\"
:0,
\"
slot
\"
:
\"
4
\"
,
\"
type
\"
:
\"
t_string_storage
\"
}],
\"
types
\"
:{
\"
t_address
\"
:{
\"
encoding
\"
:
\"
inplace
\"
,
\"
label
\"
:
\"
address
\"
,
\"
numberOfBytes
\"
:
\"
20
\"
},
\"
t_mapping(t_address,t_mapping(t_address,t_uint256))
\"
:{
\"
encoding
\"
:
\"
mapping
\"
,
\"
label
\"
:
\"
mapping(address =
\u003e
mapping(address =
\u003e
uint256))
\"
,
\"
numberOfBytes
\"
:
\"
32
\"
,
\"
key
\"
:
\"
t_address
\"
,
\"
value
\"
:
\"
t_mapping(t_address,t_uint256)
\"
},
\"
t_mapping(t_address,t_uint256)
\"
:{
\"
encoding
\"
:
\"
mapping
\"
,
\"
label
\"
:
\"
mapping(address =
\u003e
uint256)
\"
,
\"
numberOfBytes
\"
:
\"
32
\"
,
\"
key
\"
:
\"
t_address
\"
,
\"
value
\"
:
\"
t_uint256
\"
},
\"
t_string_storage
\"
:{
\"
encoding
\"
:
\"
bytes
\"
,
\"
label
\"
:
\"
string
\"
,
\"
numberOfBytes
\"
:
\"
32
\"
},
\"
t_uint256
\"
:{
\"
encoding
\"
:
\"
inplace
\"
,
\"
label
\"
:
\"
uint256
\"
,
\"
numberOfBytes
\"
:
\"
32
\"
}}}"
const
ERC20StorageLayoutJSON
=
"{
\"
storage
\"
:[{
\"
astId
\"
:1000,
\"
contract
\"
:
\"
node_modules/
.pnpm/@openzeppelin+contracts@4.7.3/node_modules/@openzeppelin/contracts/token/ERC20/ERC20.sol:ERC20
\"
,
\"
label
\"
:
\"
_balances
\"
,
\"
offset
\"
:0,
\"
slot
\"
:
\"
0
\"
,
\"
type
\"
:
\"
t_mapping(t_address,t_uint256)
\"
},{
\"
astId
\"
:1001,
\"
contract
\"
:
\"
node_modules/.pnpm/@openzeppelin+contracts@4.7.3/node_modules/@openzeppelin/contracts/token/ERC20/ERC20.sol:ERC20
\"
,
\"
label
\"
:
\"
_allowances
\"
,
\"
offset
\"
:0,
\"
slot
\"
:
\"
1
\"
,
\"
type
\"
:
\"
t_mapping(t_address,t_mapping(t_address,t_uint256))
\"
},{
\"
astId
\"
:1002,
\"
contract
\"
:
\"
node_modules/.pnpm/@openzeppelin+contracts@4.7.3/node_modules/@openzeppelin/contracts/token/ERC20/ERC20.sol:ERC20
\"
,
\"
label
\"
:
\"
_totalSupply
\"
,
\"
offset
\"
:0,
\"
slot
\"
:
\"
2
\"
,
\"
type
\"
:
\"
t_uint256
\"
},{
\"
astId
\"
:1003,
\"
contract
\"
:
\"
node_modules/.pnpm/@openzeppelin+contracts@4.7.3/node_modules/@openzeppelin/contracts/token/ERC20/ERC20.sol:ERC20
\"
,
\"
label
\"
:
\"
_name
\"
,
\"
offset
\"
:0,
\"
slot
\"
:
\"
3
\"
,
\"
type
\"
:
\"
t_string_storage
\"
},{
\"
astId
\"
:1004,
\"
contract
\"
:
\"
node_modules/.pnpm/@openzeppelin+contracts@4.7.3/
node_modules/@openzeppelin/contracts/token/ERC20/ERC20.sol:ERC20
\"
,
\"
label
\"
:
\"
_symbol
\"
,
\"
offset
\"
:0,
\"
slot
\"
:
\"
4
\"
,
\"
type
\"
:
\"
t_string_storage
\"
}],
\"
types
\"
:{
\"
t_address
\"
:{
\"
encoding
\"
:
\"
inplace
\"
,
\"
label
\"
:
\"
address
\"
,
\"
numberOfBytes
\"
:
\"
20
\"
},
\"
t_mapping(t_address,t_mapping(t_address,t_uint256))
\"
:{
\"
encoding
\"
:
\"
mapping
\"
,
\"
label
\"
:
\"
mapping(address =
\u003e
mapping(address =
\u003e
uint256))
\"
,
\"
numberOfBytes
\"
:
\"
32
\"
,
\"
key
\"
:
\"
t_address
\"
,
\"
value
\"
:
\"
t_mapping(t_address,t_uint256)
\"
},
\"
t_mapping(t_address,t_uint256)
\"
:{
\"
encoding
\"
:
\"
mapping
\"
,
\"
label
\"
:
\"
mapping(address =
\u003e
uint256)
\"
,
\"
numberOfBytes
\"
:
\"
32
\"
,
\"
key
\"
:
\"
t_address
\"
,
\"
value
\"
:
\"
t_uint256
\"
},
\"
t_string_storage
\"
:{
\"
encoding
\"
:
\"
bytes
\"
,
\"
label
\"
:
\"
string
\"
,
\"
numberOfBytes
\"
:
\"
32
\"
},
\"
t_uint256
\"
:{
\"
encoding
\"
:
\"
inplace
\"
,
\"
label
\"
:
\"
uint256
\"
,
\"
numberOfBytes
\"
:
\"
32
\"
}}}"
var
ERC20StorageLayout
=
new
(
solc
.
StorageLayout
)
var
ERC20StorageLayout
=
new
(
solc
.
StorageLayout
)
...
...
op-bindings/bindings/preimageoracle_more.go
View file @
7ebc966a
This diff is collapsed.
Click to expand it.
op-bindings/bindings/weth9.go
View file @
7ebc966a
This diff is collapsed.
Click to expand it.
op-bindings/bindings/weth9_more.go
View file @
7ebc966a
...
@@ -13,7 +13,7 @@ const WETH9StorageLayoutJSON = "{\"storage\":[{\"astId\":1000,\"contract\":\"con
...
@@ -13,7 +13,7 @@ const WETH9StorageLayoutJSON = "{\"storage\":[{\"astId\":1000,\"contract\":\"con
var
WETH9StorageLayout
=
new
(
solc
.
StorageLayout
)
var
WETH9StorageLayout
=
new
(
solc
.
StorageLayout
)
var
WETH9DeployedBin
=
"0x6080604052600436106100bc5760003560e01c8063313ce56711610074578063a9059cbb1161004e578063a9059cbb146102cb578063d0e30db0146100bc578063dd62ed3e14610311576100bc565b8063313ce5671461024b57806370a082311461027657806395d89b41146102b6576100bc565b806318160ddd116100a557806318160ddd146101aa57806323b872dd146101d15780632e1a7d4d14610221576100bc565b806306fdde03146100c6578063095ea7b314610150575b6100c4610359565b005b3480156100d257600080fd5b506100db6103a8565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101155781810151838201526020016100fd565b50505050905090810190601f1680156101425780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561015c57600080fd5b506101966004803603604081101561017357600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610454565b604080519115158252519081900360200190f35b3480156101b657600080fd5b506101bf6104c7565b60408051918252519081900360200190f35b3480156101dd57600080fd5b50610196600480360360608110156101f457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135811691602081013590911690604001356104cb565b34801561022d57600080fd5b506100c46004803603602081101561024457600080fd5b503561066b565b34801561025757600080fd5b50610260610700565b6040805160ff9092168252519081900360200190f35b34801561028257600080fd5b506101bf6004803603602081101561029957600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610709565b3480156102c257600080fd5b506100db61071b565b3480156102d757600080fd5b50610196600480360360408110156102ee57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610793565b34801561031d57600080fd5b506101bf6004803603604081101561033457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160200135166107a7565b33600081815260036020908152604091829020805434908101909155825190815291517fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c9281900390910190a2565b6000805460408051602060026001851615610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190941693909304601f8101849004840282018401909252818152929183018282801561044c5780601f106104215761010080835404028352916020019161044c565b820191906000526020600020905b81548152906001019060200180831161042f57829003601f168201915b505050505081565b33600081815260046020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b4790565b73ffffffffffffffffffffffffffffffffffffffff83166000908152600360205260408120548211156104fd57600080fd5b73ffffffffffffffffffffffffffffffffffffffff84163314801590610573575073ffffffffffffffffffffffffffffffffffffffff841660009081526004602090815260408083203384529091529020547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14155b156105ed5773ffffffffffffffffffffffffffffffffffffffff841660009081526004602090815260408083203384529091529020548211156105b557600080fd5b73ffffffffffffffffffffffffffffffffffffffff841660009081526004602090815260408083203384529091529020805483900390555b73ffffffffffffffffffffffffffffffffffffffff808516600081815260036020908152604080832080548890039055938716808352918490208054870190558351868152935191937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929081900390910190a35060019392505050565b3360009081526003602052604090205481111561068757600080fd5b33600081815260036020526040808220805485900390555183156108fc0291849190818181858888f193505050501580156106c6573d6000803e3d6000fd5b5060408051828152905133917f7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65919081900360200190a250565b60025460ff1681565b60036020526000908152604090205481565b60018054604080516020600284861615610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190941693909304601f8101849004840282018401909252818152929183018282801561044c5780601f106104215761010080835404028352916020019161044c565b60006107a03384846104cb565b9392505050565b60046020908152600092835260408084209091529082529020548156fea265627a7a72315820
e496abb80c5983b030f680d0bd88f66bf44e261bc3be070d612dd72f9f1f5e9a
64736f6c63430005110032"
var
WETH9DeployedBin
=
"0x6080604052600436106100bc5760003560e01c8063313ce56711610074578063a9059cbb1161004e578063a9059cbb146102cb578063d0e30db0146100bc578063dd62ed3e14610311576100bc565b8063313ce5671461024b57806370a082311461027657806395d89b41146102b6576100bc565b806318160ddd116100a557806318160ddd146101aa57806323b872dd146101d15780632e1a7d4d14610221576100bc565b806306fdde03146100c6578063095ea7b314610150575b6100c4610359565b005b3480156100d257600080fd5b506100db6103a8565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101155781810151838201526020016100fd565b50505050905090810190601f1680156101425780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561015c57600080fd5b506101966004803603604081101561017357600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610454565b604080519115158252519081900360200190f35b3480156101b657600080fd5b506101bf6104c7565b60408051918252519081900360200190f35b3480156101dd57600080fd5b50610196600480360360608110156101f457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135811691602081013590911690604001356104cb565b34801561022d57600080fd5b506100c46004803603602081101561024457600080fd5b503561066b565b34801561025757600080fd5b50610260610700565b6040805160ff9092168252519081900360200190f35b34801561028257600080fd5b506101bf6004803603602081101561029957600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610709565b3480156102c257600080fd5b506100db61071b565b3480156102d757600080fd5b50610196600480360360408110156102ee57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610793565b34801561031d57600080fd5b506101bf6004803603604081101561033457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160200135166107a7565b33600081815260036020908152604091829020805434908101909155825190815291517fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c9281900390910190a2565b6000805460408051602060026001851615610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190941693909304601f8101849004840282018401909252818152929183018282801561044c5780601f106104215761010080835404028352916020019161044c565b820191906000526020600020905b81548152906001019060200180831161042f57829003601f168201915b505050505081565b33600081815260046020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b4790565b73ffffffffffffffffffffffffffffffffffffffff83166000908152600360205260408120548211156104fd57600080fd5b73ffffffffffffffffffffffffffffffffffffffff84163314801590610573575073ffffffffffffffffffffffffffffffffffffffff841660009081526004602090815260408083203384529091529020547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14155b156105ed5773ffffffffffffffffffffffffffffffffffffffff841660009081526004602090815260408083203384529091529020548211156105b557600080fd5b73ffffffffffffffffffffffffffffffffffffffff841660009081526004602090815260408083203384529091529020805483900390555b73ffffffffffffffffffffffffffffffffffffffff808516600081815260036020908152604080832080548890039055938716808352918490208054870190558351868152935191937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929081900390910190a35060019392505050565b3360009081526003602052604090205481111561068757600080fd5b33600081815260036020526040808220805485900390555183156108fc0291849190818181858888f193505050501580156106c6573d6000803e3d6000fd5b5060408051828152905133917f7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65919081900360200190a250565b60025460ff1681565b60036020526000908152604090205481565b60018054604080516020600284861615610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190941693909304601f8101849004840282018401909252818152929183018282801561044c5780601f106104215761010080835404028352916020019161044c565b60006107a03384846104cb565b9392505050565b60046020908152600092835260408084209091529082529020548156fea265627a7a72315820
9986313d57065c03e7af2eaca174ea0f3317796e58c6959c4d19de7e6a109fff
64736f6c63430005110032"
func
init
()
{
func
init
()
{
if
err
:=
json
.
Unmarshal
([]
byte
(
WETH9StorageLayoutJSON
),
WETH9StorageLayout
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
([]
byte
(
WETH9StorageLayoutJSON
),
WETH9StorageLayout
);
err
!=
nil
{
...
...
op-bindings/gen/main.go
View file @
7ebc966a
...
@@ -72,12 +72,38 @@ func main() {
...
@@ -72,12 +72,38 @@ func main() {
defer
os
.
RemoveAll
(
dir
)
defer
os
.
RemoveAll
(
dir
)
log
.
Printf
(
"created temp dir %s
\n
"
,
dir
)
log
.
Printf
(
"created temp dir %s
\n
"
,
dir
)
// If some contracts have the same name then the path to their
// artifact depends on their full import path. Scan over all artifacts
// and hold a mapping from the contract name to the contract path.
// Walk walks the directory deterministically, so the later instance
// of the contract with the same name will be used
artifactPaths
:=
make
(
map
[
string
]
string
)
if
err
:=
filepath
.
Walk
(
f
.
ForgeArtifacts
,
func
(
path
string
,
info
os
.
FileInfo
,
err
error
)
error
{
if
err
!=
nil
{
return
err
}
base
:=
filepath
.
Base
(
path
)
if
strings
.
HasSuffix
(
base
,
".json"
)
{
name
:=
base
[
:
len
(
base
)
-
5
]
if
_
,
ok
:=
artifactPaths
[
name
];
!
ok
{
artifactPaths
[
name
]
=
path
}
}
return
nil
});
err
!=
nil
{
log
.
Fatal
(
err
)
}
for
_
,
name
:=
range
contracts
{
for
_
,
name
:=
range
contracts
{
log
.
Printf
(
"generating code for %s
\n
"
,
name
)
log
.
Printf
(
"generating code for %s
\n
"
,
name
)
forgeArtifactData
,
err
:=
os
.
ReadFile
(
path
.
Join
(
f
.
ForgeArtifacts
,
name
+
".sol"
,
name
+
".json"
))
forgeArtifactData
,
err
:=
os
.
ReadFile
(
path
.
Join
(
f
.
ForgeArtifacts
,
name
+
".sol"
,
name
+
".json"
))
if
errors
.
Is
(
err
,
os
.
ErrNotExist
)
{
if
errors
.
Is
(
err
,
os
.
ErrNotExist
)
{
log
.
Fatalf
(
"cannot find forge-artifact of %q
\n
"
,
name
)
forgeArtifactData
,
err
=
os
.
ReadFile
(
artifactPaths
[
name
])
if
errors
.
Is
(
err
,
os
.
ErrNotExist
)
{
log
.
Fatalf
(
"cannot find forge-artifact of %q
\n
"
,
name
)
}
}
}
var
artifact
foundry
.
Artifact
var
artifact
foundry
.
Artifact
...
...
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