Skip to content

Commit

Permalink
fix: overwrite sender address and init ethman (#12)
Browse files Browse the repository at this point in the history
* modify sender address and init ehtman when call custodial assets interface

* fix lint

---------

Co-authored-by: Vui-Chee <vuicheesiew@gmail.com>
  • Loading branch information
giskook and Vui-Chee authored Dec 4, 2024
1 parent ce66a07 commit beb7f7f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
19 changes: 14 additions & 5 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,18 +247,27 @@ func createSequenceSender(
ApiKey: cfg.SequenceSender.EthTxManager.Etherman.Etherscan.ApiKey,
Url: cfg.SequenceSender.EthTxManager.Etherman.Etherscan.Url,
},
HTTPHeaders: cfg.SequenceSender.EthTxManager.Etherman.HTTPHeaders,
ZkEVMAddr: cfg.SequenceSender.EthTxManager.Etherman.ZkEVMAddr, // X Layer
RollupManagerAddr: cfg.SequenceSender.EthTxManager.Etherman.RollupManagerAddr, // X Layer
HTTPHeaders: cfg.SequenceSender.EthTxManager.Etherman.HTTPHeaders,
},
}, cfg.NetworkConfig.L1Config, cfg.Common)
if err != nil {
logger.Fatalf("Failed to create etherman. Err: %w, ", err)
}

auth, _, err := ethman.LoadAuthFromKeyStore(cfg.SequenceSender.PrivateKey.Path, cfg.SequenceSender.PrivateKey.Password)
if err != nil {
logger.Fatal(err)
// X Layer
if cfg.SequenceSender.EthTxManager.CustodialAssets.Enable {
cfg.SequenceSender.SenderAddress = cfg.SequenceSender.EthTxManager.CustodialAssets.SequencerAddr
} else {
auth, _, err := ethman.LoadAuthFromKeyStore(
cfg.SequenceSender.PrivateKey.Path,
cfg.SequenceSender.PrivateKey.Password)
if err != nil {
logger.Fatal(err)
}
cfg.SequenceSender.SenderAddress = auth.From
}
cfg.SequenceSender.SenderAddress = auth.From
blockFinalityType := etherman.BlockNumberFinality(cfg.SequenceSender.BlockFinality)

blockFinality, err := blockFinalityType.ToBlockNum()
Expand Down
1 change: 1 addition & 0 deletions sequencesender/sequencesender.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ func New(cfg Config, logger *log.Logger,
Outputs: cfg.Log.Outputs,
}

// X Layer custodial assets
if cfg.EthTxManager.CustodialAssets.Enable {
s.ethTxManager, err = ethtxmanager.NewClientFromAddr(cfg.EthTxManager, cfg.SenderAddress)
} else {
Expand Down

0 comments on commit beb7f7f

Please sign in to comment.