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
0ea5e054
Commit
0ea5e054
authored
May 31, 2023
by
Mark Tyneway
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-wheel: typesafe flag parsing
parent
ad4a4ff2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
4 deletions
+14
-4
cheat.go
op-wheel/cheat/cheat.go
+3
-2
commands.go
op-wheel/commands.go
+11
-2
No files found.
op-wheel/cheat/cheat.go
View file @
0ea5e054
...
@@ -14,6 +14,7 @@ import (
...
@@ -14,6 +14,7 @@ import (
"github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/consensus/beacon"
"github.com/ethereum/go-ethereum/consensus/beacon"
"github.com/ethereum/go-ethereum/consensus/ethash"
"github.com/ethereum/go-ethereum/consensus/ethash"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core"
...
@@ -379,9 +380,9 @@ func SetBalance(addr common.Address, amount *big.Int) HeadFn {
...
@@ -379,9 +380,9 @@ func SetBalance(addr common.Address, amount *big.Int) HeadFn {
}
}
}
}
func
SetCode
(
addr
common
.
Address
,
code
string
)
HeadFn
{
func
SetCode
(
addr
common
.
Address
,
code
hexutil
.
Bytes
)
HeadFn
{
return
func
(
headState
*
state
.
StateDB
)
error
{
return
func
(
headState
*
state
.
StateDB
)
error
{
headState
.
SetCode
(
addr
,
co
mmon
.
FromHex
(
code
)
)
headState
.
SetCode
(
addr
,
co
de
)
return
nil
return
nil
}
}
}
}
...
...
op-wheel/commands.go
View file @
0ea5e054
...
@@ -12,6 +12,7 @@ import (
...
@@ -12,6 +12,7 @@ import (
"time"
"time"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum/go-ethereum/rpc"
...
@@ -179,6 +180,10 @@ func addrFlag(name string, usage string) cli.GenericFlag {
...
@@ -179,6 +180,10 @@ func addrFlag(name string, usage string) cli.GenericFlag {
return
textFlag
[
*
common
.
Address
](
name
,
usage
,
new
(
common
.
Address
))
return
textFlag
[
*
common
.
Address
](
name
,
usage
,
new
(
common
.
Address
))
}
}
func
bytesFlag
(
name
string
,
usage
string
)
cli
.
GenericFlag
{
return
textFlag
[
*
hexutil
.
Bytes
](
name
,
usage
,
new
(
hexutil
.
Bytes
))
}
func
hashFlag
(
name
string
,
usage
string
)
cli
.
GenericFlag
{
func
hashFlag
(
name
string
,
usage
string
)
cli
.
GenericFlag
{
return
textFlag
[
*
common
.
Hash
](
name
,
usage
,
new
(
common
.
Hash
))
return
textFlag
[
*
common
.
Hash
](
name
,
usage
,
new
(
common
.
Hash
))
}
}
...
@@ -191,6 +196,10 @@ func addrFlagValue(name string, ctx *cli.Context) common.Address {
...
@@ -191,6 +196,10 @@ func addrFlagValue(name string, ctx *cli.Context) common.Address {
return
*
ctx
.
Generic
(
name
)
.
(
*
TextFlag
[
*
common
.
Address
])
.
Value
return
*
ctx
.
Generic
(
name
)
.
(
*
TextFlag
[
*
common
.
Address
])
.
Value
}
}
func
bytesFlagValue
(
name
string
,
ctx
*
cli
.
Context
)
hexutil
.
Bytes
{
return
*
ctx
.
Generic
(
name
)
.
(
*
TextFlag
[
*
hexutil
.
Bytes
])
.
Value
}
func
hashFlagValue
(
name
string
,
ctx
*
cli
.
Context
)
common
.
Hash
{
func
hashFlagValue
(
name
string
,
ctx
*
cli
.
Context
)
common
.
Hash
{
return
*
ctx
.
Generic
(
name
)
.
(
*
TextFlag
[
*
common
.
Hash
])
.
Value
return
*
ctx
.
Generic
(
name
)
.
(
*
TextFlag
[
*
common
.
Hash
])
.
Value
}
}
...
@@ -276,10 +285,10 @@ var (
...
@@ -276,10 +285,10 @@ var (
Flags
:
[]
cli
.
Flag
{
Flags
:
[]
cli
.
Flag
{
DataDirFlag
,
DataDirFlag
,
addrFlag
(
"address"
,
"Address to change code of"
),
addrFlag
(
"address"
,
"Address to change code of"
),
cli
.
StringFlag
{
Name
:
"code"
,
Usage
:
"New code of the account"
}
,
bytesFlag
(
"code"
,
"New code of the account"
)
,
},
},
Action
:
CheatAction
(
false
,
func
(
ctx
*
cli
.
Context
,
ch
*
cheat
.
Cheater
)
error
{
Action
:
CheatAction
(
false
,
func
(
ctx
*
cli
.
Context
,
ch
*
cheat
.
Cheater
)
error
{
return
ch
.
RunAndClose
(
cheat
.
SetCode
(
addrFlagValue
(
"address"
,
ctx
),
ctx
.
String
(
"code"
)))
return
ch
.
RunAndClose
(
cheat
.
SetCode
(
addrFlagValue
(
"address"
,
ctx
),
bytesFlagValue
(
"code"
,
ctx
)))
}),
}),
}
}
CheatSetNonceCmd
=
cli
.
Command
{
CheatSetNonceCmd
=
cli
.
Command
{
...
...
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