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
b604f4f8
Commit
b604f4f8
authored
Nov 24, 2023
by
Mark Tyneway
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-chain-ops: improve checks
parent
297dff38
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
41 deletions
+25
-41
immutables.go
op-chain-ops/immutables/immutables.go
+25
-41
No files found.
op-chain-ops/immutables/immutables.go
View file @
b604f4f8
package
immutables
import
(
"errors"
"fmt"
"math/big"
"reflect"
...
...
@@ -75,47 +74,32 @@ type PredeploysImmutableConfig struct {
var
Create2DeployerCodeHash
=
common
.
HexToHash
(
"0xb0550b5b431e30d38000efb7107aaa0ade03d48a7198a140edda9d27134468b2"
)
// Check will ensure that the required fields are set on the config.
// An error returned by `GetImmutableReferences` means that the solc compiler
// output for the contract has no immutables in it.
func
(
c
*
PredeploysImmutableConfig
)
Check
()
error
{
if
c
.
L2CrossDomainMessenger
.
OtherMessenger
==
(
common
.
Address
{})
{
return
errors
.
New
(
"L2CrossDomainMessenger otherMessenger not set"
)
}
if
c
.
L2StandardBridge
.
OtherBridge
==
(
common
.
Address
{})
{
return
errors
.
New
(
"L2StandardBridge otherBridge not set"
)
}
if
c
.
SequencerFeeVault
.
Recipient
==
(
common
.
Address
{})
{
return
errors
.
New
(
"SequencerFeeVault recipient not set"
)
}
if
c
.
SequencerFeeVault
.
MinWithdrawalAmount
==
nil
||
c
.
SequencerFeeVault
.
MinWithdrawalAmount
.
Cmp
(
big
.
NewInt
(
0
))
==
0
{
return
errors
.
New
(
"SequencerFeeVault minWithdrawalAmount not set"
)
}
if
c
.
OptimismMintableERC20Factory
.
Bridge
==
(
common
.
Address
{})
{
return
errors
.
New
(
"OptimismMintableERC20Factory bridge not set"
)
}
if
c
.
L2ERC721Bridge
.
Messenger
==
(
common
.
Address
{})
{
return
errors
.
New
(
"L2ERC721Bridge messenger not set"
)
}
if
c
.
L2ERC721Bridge
.
OtherBridge
==
(
common
.
Address
{})
{
return
errors
.
New
(
"L2ERC721Bridge otherBridge not set"
)
}
if
c
.
OptimismMintableERC721Factory
.
Bridge
==
(
common
.
Address
{})
{
return
errors
.
New
(
"OptimismMintableERC721Factory bridge not set"
)
}
if
c
.
OptimismMintableERC721Factory
.
RemoteChainId
==
nil
||
c
.
OptimismMintableERC721Factory
.
RemoteChainId
.
Cmp
(
big
.
NewInt
(
0
))
==
0
{
return
errors
.
New
(
"OptimismMintableERC721Factory remoteChainId not set"
)
}
if
c
.
BaseFeeVault
.
Recipient
==
(
common
.
Address
{})
{
return
errors
.
New
(
"BaseFeeVault recipient not set"
)
}
if
c
.
BaseFeeVault
.
MinWithdrawalAmount
==
nil
||
c
.
BaseFeeVault
.
MinWithdrawalAmount
.
Cmp
(
big
.
NewInt
(
0
))
==
0
{
return
errors
.
New
(
"BaseFeeVault minWithdrawalAmount not set"
)
}
if
c
.
L1FeeVault
.
Recipient
==
(
common
.
Address
{})
{
return
errors
.
New
(
"L1FeeVault recipient not set"
)
}
if
c
.
L1FeeVault
.
MinWithdrawalAmount
==
nil
||
c
.
L1FeeVault
.
MinWithdrawalAmount
.
Cmp
(
big
.
NewInt
(
0
))
==
0
{
return
errors
.
New
(
"L1FeeVault minWithdrawalAmount not set"
)
}
return
nil
return
c
.
ForEach
(
func
(
name
string
,
values
any
)
error
{
val
:=
reflect
.
ValueOf
(
values
)
if
val
.
NumField
()
==
0
{
return
nil
}
_
,
err
:=
bindings
.
GetImmutableReferences
(
name
)
exists
:=
err
==
nil
isZero
:=
val
.
IsZero
()
// There are immutables defined in the solc output and
// the config is not empty.
if
exists
&&
!
isZero
{
return
nil
}
// There are no immutables defined in the solc output and
// the config is empty
if
!
exists
&&
isZero
{
return
nil
}
return
fmt
.
Errorf
(
"invalid immutables config: field %s: %w"
,
name
,
err
)
})
}
// ForEach will iterate over each of the fields in the config and call the callback
...
...
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