@@ -5,12 +5,13 @@ import (
55
66 "github.com/Layr-Labs/eigenlayer-contracts/pkg/bindings/EigenPod"
77 "github.com/Layr-Labs/eigenpod-proofs-generation/cli/core"
8- "github.com/Layr-Labs/eigenpod-proofs-generation/cli/utils"
8+ "github.com/Layr-Labs/eigenpod-proofs-generation/cli/core/ utils"
99 "github.com/ethereum/go-ethereum/accounts/abi/bind"
1010 "github.com/ethereum/go-ethereum/common"
1111 "github.com/ethereum/go-ethereum/core/types"
1212 "github.com/fatih/color"
1313 "github.com/pkg/errors"
14+ lo "github.com/samber/lo"
1415)
1516
1617type TCheckpointCommandArgs struct {
@@ -36,31 +37,31 @@ func CheckpointCommand(args TCheckpointCommandArgs) error {
3637 isGasEstimate := args .SimulateTransaction && args .Sender != ""
3738 isVerbose := ! args .SimulateTransaction || args .Verbose
3839
39- eth , beaconClient , chainId , err := core .GetClients (ctx , args .Node , args .BeaconNode , isVerbose )
40- core .PanicOnError ("failed to reach ethereum clients" , err )
40+ eth , beaconClient , chainId , err := utils .GetClients (ctx , args .Node , args .BeaconNode , isVerbose )
41+ utils .PanicOnError ("failed to reach ethereum clients" , err )
4142
42- currentCheckpoint , err := core .GetCurrentCheckpoint (args .EigenpodAddress , eth )
43- core .PanicOnError ("failed to load checkpoint" , err )
43+ currentCheckpoint , err := utils .GetCurrentCheckpoint (args .EigenpodAddress , eth )
44+ utils .PanicOnError ("failed to load checkpoint" , err )
4445
4546 eigenpod , err := EigenPod .NewEigenPod (common .HexToAddress (args .EigenpodAddress ), eth )
46- core .PanicOnError ("failed to connect to eigenpod" , err )
47+ utils .PanicOnError ("failed to connect to eigenpod" , err )
4748
4849 if currentCheckpoint == 0 {
4950 if len (args .Sender ) > 0 || args .SimulateTransaction {
5051 if ! args .NoPrompt && ! args .SimulateTransaction {
51- core .PanicIfNoConsent (core .StartCheckpointProofConsent ())
52+ utils .PanicIfNoConsent (utils .StartCheckpointProofConsent ())
5253 }
5354
54- txn , err := core .StartCheckpoint (ctx , args .EigenpodAddress , args .Sender , chainId , eth , args .ForceCheckpoint , args .SimulateTransaction )
55- core .PanicOnError ("failed to start checkpoint" , err )
55+ txn , err := utils .StartCheckpoint (ctx , args .EigenpodAddress , args .Sender , chainId , eth , args .ForceCheckpoint , args .SimulateTransaction )
56+ utils .PanicOnError ("failed to start checkpoint" , err )
5657
5758 if ! args .SimulateTransaction {
5859 color .Green ("starting checkpoint: %s.. (waiting for txn to be mined)" , txn .Hash ().Hex ())
5960 bind .WaitMined (ctx , eth , txn )
6061 color .Green ("started checkpoint! txn: %s" , txn .Hash ().Hex ())
6162 } else {
6263 gas := txn .Gas ()
63- printAsJSON ([]Transaction {
64+ PrintAsJSON ([]Transaction {
6465 {
6566 Type : "checkpoint_start" ,
6667 To : txn .To ().Hex (),
@@ -78,11 +79,11 @@ func CheckpointCommand(args TCheckpointCommandArgs) error {
7879 }
7980
8081 newCheckpoint , err := eigenpod .CurrentCheckpointTimestamp (nil )
81- core .PanicOnError ("failed to fetch current checkpoint" , err )
82+ utils .PanicOnError ("failed to fetch current checkpoint" , err )
8283
8384 currentCheckpoint = newCheckpoint
8485 } else {
85- core .PanicOnError ("no checkpoint active and no private key provided to start one" , errors .New ("no checkpoint" ))
86+ utils .PanicOnError ("no checkpoint active and no private key provided to start one" , errors .New ("no checkpoint" ))
8687 }
8788 }
8889
@@ -91,24 +92,24 @@ func CheckpointCommand(args TCheckpointCommandArgs) error {
9192 }
9293
9394 proof , err := core .GenerateCheckpointProof (ctx , args .EigenpodAddress , eth , chainId , beaconClient , isVerbose )
94- core .PanicOnError ("failed to generate checkpoint proof" , err )
95+ utils .PanicOnError ("failed to generate checkpoint proof" , err )
9596
9697 txns , err := core .SubmitCheckpointProof (ctx , args .Sender , args .EigenpodAddress , chainId , proof , eth , args .BatchSize , args .NoPrompt , args .SimulateTransaction , args .Verbose )
9798 if args .SimulateTransaction {
98- printableTxns := utils .Map (txns , func (txn * types.Transaction , _ uint64 ) Transaction {
99+ printableTxns := lo .Map (txns , func (txn * types.Transaction , _ int ) Transaction {
99100 return Transaction {
100101 To : txn .To ().Hex (),
101102 CallData : common .Bytes2Hex (txn .Data ()),
102103 Type : "checkpoint_proof" ,
103104 }
104105 })
105- printAsJSON (printableTxns )
106+ PrintAsJSON (printableTxns )
106107 } else {
107108 for i , txn := range txns {
108109 color .Green ("transaction(%d): %s" , i , txn .Hash ().Hex ())
109110 }
110111 }
111- core .PanicOnError ("an error occurred while submitting your checkpoint proofs" , err )
112+ utils .PanicOnError ("an error occurred while submitting your checkpoint proofs" , err )
112113
113114 return nil
114115}
0 commit comments