Skip to content

Commit

Permalink
update (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
zjg555543 authored Aug 9, 2024
1 parent 4b7dcf8 commit 6018d38
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions ethtxmanager/ethtxmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,27 +65,34 @@ type l1Tx struct {
}

// New creates new eth tx manager
func New(cfg Config) (*Client, error) {
func New(cfg Config, from common.Address) (*Client, error) {
etherman, err := etherman.NewClient(cfg.Etherman)
if err != nil {
return nil, err
}

auth, err := etherman.LoadAuthFromKeyStore(cfg.PrivateKeys[0].Path, cfg.PrivateKeys[0].Password)
if err != nil {
return nil, err
}
// For X Layer custodial signature
if !cfg.CustodialAssets.Enable {
auth, err := etherman.LoadAuthFromKeyStore(cfg.PrivateKeys[0].Path, cfg.PrivateKeys[0].Password)
if err != nil {
return nil, err
}

err = etherman.AddOrReplaceAuth(*auth)
if err != nil {
return nil, err
err = etherman.AddOrReplaceAuth(*auth)
if err != nil {
return nil, err
}

if auth.From != from {
return nil, fmt.Errorf(fmt.Sprintf("private key does not match the from address, %v,%v", auth.From, from))
}
}

client := Client{
cfg: cfg,
etherman: etherman,
storage: NewMemStorage(cfg.PersistenceFilename),
from: auth.From,
from: from,
}

log.Init(cfg.Log)
Expand Down

0 comments on commit 6018d38

Please sign in to comment.