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
bb56249f
Unverified
Commit
bb56249f
authored
Sep 25, 2023
by
Sabnock01
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: move SignerCLIConfig into op-service
parent
a7ff5a81
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
31 deletions
+31
-31
signature.go
op-service/crypto/signature.go
+3
-2
cli.go
op-service/tls/cli.go
+23
-0
client.go
op-signer/client/client.go
+1
-1
config.go
op-signer/client/config.go
+4
-28
No files found.
op-service/crypto/signature.go
View file @
bb56249f
...
...
@@ -18,6 +18,7 @@ import (
hdwallet
"github.com/ethereum-optimism/go-ethereum-hdwallet"
opsigner
"github.com/ethereum-optimism/optimism/op-signer/client"
optls
"github.com/ethereum-optimism/optimism/op-service/tls"
)
func
PrivateKeySignerFn
(
key
*
ecdsa
.
PrivateKey
,
chainID
*
big
.
Int
)
bind
.
SignerFn
{
...
...
@@ -43,9 +44,9 @@ type SignerFn func(context.Context, common.Address, *types.Transaction) (*types.
type
SignerFactory
func
(
chainID
*
big
.
Int
)
SignerFn
// SignerFactoryFromConfig considers three ways that signers are created & then creates single factory from those config options.
// It can either take a remote signer (via op
signer.
CLIConfig) or it can be provided either a mnemonic + derivation path or a private key.
// It can either take a remote signer (via op
tls.Signer
CLIConfig) or it can be provided either a mnemonic + derivation path or a private key.
// It prefers the remote signer, then the mnemonic or private key (only one of which can be provided).
func
SignerFactoryFromConfig
(
l
log
.
Logger
,
privateKey
,
mnemonic
,
hdPath
string
,
signerConfig
op
signer
.
CLIConfig
)
(
SignerFactory
,
common
.
Address
,
error
)
{
func
SignerFactoryFromConfig
(
l
log
.
Logger
,
privateKey
,
mnemonic
,
hdPath
string
,
signerConfig
op
tls
.
Signer
CLIConfig
)
(
SignerFactory
,
common
.
Address
,
error
)
{
var
signer
SignerFactory
var
fromAddress
common
.
Address
if
signerConfig
.
Enabled
()
{
...
...
op-service/tls/cli.go
View file @
bb56249f
...
...
@@ -108,3 +108,26 @@ func ReadCLIConfigWithPrefix(ctx *cli.Context, flagPrefix string) CLIConfig {
TLSKey
:
ctx
.
String
(
prefixFunc
(
TLSKeyFlagName
)),
}
}
type
SignerCLIConfig
struct
{
Endpoint
string
Address
string
TLSConfig
CLIConfig
}
func
(
c
SignerCLIConfig
)
Check
()
error
{
if
err
:=
c
.
TLSConfig
.
Check
();
err
!=
nil
{
return
err
}
if
!
((
c
.
Endpoint
==
""
&&
c
.
Address
==
""
)
||
(
c
.
Endpoint
!=
""
&&
c
.
Address
!=
""
))
{
return
errors
.
New
(
"signer endpoint and address must both be set or not set"
)
}
return
nil
}
func
(
c
SignerCLIConfig
)
Enabled
()
bool
{
if
c
.
Endpoint
!=
""
&&
c
.
Address
!=
""
{
return
true
}
return
false
}
op-signer/client/client.go
View file @
bb56249f
...
...
@@ -78,7 +78,7 @@ func NewSignerClient(logger log.Logger, endpoint string, tlsConfig optls.CLIConf
return
signer
,
nil
}
func
NewSignerClientFromConfig
(
logger
log
.
Logger
,
config
CLIConfig
)
(
*
SignerClient
,
error
)
{
func
NewSignerClientFromConfig
(
logger
log
.
Logger
,
config
optls
.
Signer
CLIConfig
)
(
*
SignerClient
,
error
)
{
return
NewSignerClient
(
logger
,
config
.
Endpoint
,
config
.
TLSConfig
)
}
...
...
op-signer/client/config.go
View file @
bb56249f
package
client
import
(
"errors"
"github.com/urfave/cli/v2"
opservice
"github.com/ethereum-optimism/optimism/op-service"
...
...
@@ -32,37 +30,15 @@ func CLIFlags(envPrefix string) []cli.Flag {
return
flags
}
type
CLIConfig
struct
{
Endpoint
string
Address
string
TLSConfig
optls
.
CLIConfig
}
func
NewCLIConfig
()
CLIConfig
{
return
CLIConfig
{
func
NewCLIConfig
()
optls
.
SignerCLIConfig
{
return
optls
.
SignerCLIConfig
{
TLSConfig
:
optls
.
NewCLIConfig
(),
}
}
func
(
c
CLIConfig
)
Check
()
error
{
if
err
:=
c
.
TLSConfig
.
Check
();
err
!=
nil
{
return
err
}
if
!
((
c
.
Endpoint
==
""
&&
c
.
Address
==
""
)
||
(
c
.
Endpoint
!=
""
&&
c
.
Address
!=
""
))
{
return
errors
.
New
(
"signer endpoint and address must both be set or not set"
)
}
return
nil
}
func
(
c
CLIConfig
)
Enabled
()
bool
{
if
c
.
Endpoint
!=
""
&&
c
.
Address
!=
""
{
return
true
}
return
false
}
func
ReadCLIConfig
(
ctx
*
cli
.
Context
)
CLIConfig
{
cfg
:=
CLIConfig
{
func
ReadCLIConfig
(
ctx
*
cli
.
Context
)
optls
.
Signer
CLIConfig
{
cfg
:=
optls
.
Signer
CLIConfig
{
Endpoint
:
ctx
.
String
(
EndpointFlagName
),
Address
:
ctx
.
String
(
AddressFlagName
),
TLSConfig
:
optls
.
ReadCLIConfigWithPrefix
(
ctx
,
"signer"
),
...
...
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