diff --git a/go.mod b/go.mod index 1559405..df6f620 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/Layr-Labs/eigenlayer-contracts v0.3.2-mainnet-rewards github.com/Layr-Labs/eigenlayer-rewards-proofs v0.2.12 github.com/Layr-Labs/eigenpod-proofs-generation v0.0.14-stable.0.20240730152248-5c11a259293e - github.com/Layr-Labs/eigensdk-go v0.1.13-0.20240927005004-ed4b05c87610 + github.com/Layr-Labs/eigensdk-go v0.1.13-0.20241023200243-565bb4438918 github.com/blang/semver/v4 v4.0.0 github.com/consensys/gnark-crypto v0.12.1 github.com/ethereum/go-ethereum v1.14.5 @@ -19,6 +19,7 @@ require ( github.com/tyler-smith/go-bip39 v1.1.0 github.com/urfave/cli/v2 v2.27.2 github.com/wagslane/go-password-validator v0.3.0 + github.com/wk8/go-ordered-map/v2 v2.1.8 go.uber.org/mock v0.4.0 gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.1 @@ -100,7 +101,6 @@ require ( github.com/tklauser/go-sysconf v0.3.12 // indirect github.com/tklauser/numcpus v0.6.1 // indirect github.com/wealdtech/go-merkletree/v2 v2.5.2-0.20240302222400-69219c450662 // indirect - github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 // indirect go.opentelemetry.io/otel v1.24.0 // indirect go.opentelemetry.io/otel/metric v1.24.0 // indirect diff --git a/go.sum b/go.sum index a58cf60..1784a9a 100644 --- a/go.sum +++ b/go.sum @@ -12,9 +12,8 @@ github.com/Layr-Labs/eigenlayer-rewards-proofs v0.2.12 h1:G5Q1SnLmFbEjhOkky3vIHk github.com/Layr-Labs/eigenlayer-rewards-proofs v0.2.12/go.mod h1:OlJd1QjqEW53wfWG/lJyPCGvrXwWVEjPQsP4TV+gttQ= github.com/Layr-Labs/eigenpod-proofs-generation v0.0.14-stable.0.20240730152248-5c11a259293e h1:DvW0/kWHV9mZsbH2KOjEHKTSIONNPUj6X05FJvUohy4= github.com/Layr-Labs/eigenpod-proofs-generation v0.0.14-stable.0.20240730152248-5c11a259293e/go.mod h1:T7tYN8bTdca2pkMnz9G2+ZwXYWw5gWqQUIu4KLgC/vM= -github.com/Layr-Labs/eigensdk-go v0.1.11/go.mod h1:XcLVDtlB1vOPj63D236b451+SC75B8gwgkpNhYHSxNs= -github.com/Layr-Labs/eigensdk-go v0.1.13-0.20240927005004-ed4b05c87610 h1:lGy4uSImJyOiaM8vSx0CEbsL3rbVfw0uEIuhGey/ubc= -github.com/Layr-Labs/eigensdk-go v0.1.13-0.20240927005004-ed4b05c87610/go.mod h1:bA21qMfmUFZcUe+a1RsDeOGm25xZO802Kfll2GlS8Us= +github.com/Layr-Labs/eigensdk-go v0.1.13-0.20241023200243-565bb4438918 h1:Itl141PoMFzq58ZTo4Nu/CyH+x8f4BH6OmBNhZ6Z2/I= +github.com/Layr-Labs/eigensdk-go v0.1.13-0.20241023200243-565bb4438918/go.mod h1:aYdNURUhaqeYOS+Cq12TfSdPbjFfiLaHkxPdR4Exq/s= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= github.com/Microsoft/hcsshim v0.11.4 h1:68vKo2VN8DE9AdN4tnkWnmdhqdbpUFM8OF3Airm7fz8= diff --git a/pkg/operator/get_delegation_approval.go b/pkg/operator/get_delegation_approval.go index 98dfb29..e5320de 100644 --- a/pkg/operator/get_delegation_approval.go +++ b/pkg/operator/get_delegation_approval.go @@ -20,7 +20,6 @@ import ( elContracts "github.com/Layr-Labs/eigensdk-go/chainio/clients/elcontracts" eigenSdkUtils "github.com/Layr-Labs/eigensdk-go/utils" - "github.com/ethereum/go-ethereum/accounts/abi/bind" gethcommon "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethclient" @@ -117,10 +116,8 @@ Use the --expiry flag to override the default expiration of 3600 seconds. } expiry := new(big.Int).SetInt64(time.Now().Unix() + approvalConfig.Expiry) - callOpts := &bind.CallOpts{Context: context.Background()} - hash, err := reader.CalculateDelegationApprovalDigestHash( - callOpts, + context.Background(), staker, operator, delegationApprover, diff --git a/pkg/operator/register.go b/pkg/operator/register.go index 964649a..c202e08 100644 --- a/pkg/operator/register.go +++ b/pkg/operator/register.go @@ -13,7 +13,6 @@ import ( elContracts "github.com/Layr-Labs/eigensdk-go/chainio/clients/elcontracts" eigenSdkUtils "github.com/Layr-Labs/eigensdk-go/utils" - "github.com/ethereum/go-ethereum/accounts/abi/bind" gethcommon "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethclient" @@ -91,7 +90,7 @@ func RegisterCmd(p utils.Prompter) *cli.Command { return err } - status, err := elReader.IsOperatorRegistered(&bind.CallOpts{Context: ctx}, operatorCfg.Operator) + status, err := elReader.IsOperatorRegistered(ctx, operatorCfg.Operator) if err != nil { return err } @@ -101,6 +100,7 @@ func RegisterCmd(p utils.Prompter) *cli.Command { if err != nil { return err } + common.PrintRegistrationInfo( receipt.TxHash.String(), gethcommon.HexToAddress(operatorCfg.Operator.Address), diff --git a/pkg/operator/status.go b/pkg/operator/status.go index 7f63350..16a9fff 100644 --- a/pkg/operator/status.go +++ b/pkg/operator/status.go @@ -13,7 +13,6 @@ import ( elContracts "github.com/Layr-Labs/eigensdk-go/chainio/clients/elcontracts" eigensdkTypes "github.com/Layr-Labs/eigensdk-go/types" - "github.com/ethereum/go-ethereum/accounts/abi/bind" gethcommon "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethclient" @@ -97,9 +96,7 @@ func StatusCmd(p utils.Prompter) *cli.Command { return err } - callOpts := &bind.CallOpts{Context: context.Background()} - - status, err := reader.IsOperatorRegistered(callOpts, operatorCfg.Operator) + status, err := reader.IsOperatorRegistered(context.Background(), operatorCfg.Operator) if err != nil { return err } @@ -107,7 +104,7 @@ func StatusCmd(p utils.Prompter) *cli.Command { if status { fmt.Println() fmt.Printf("%s Operator is registered on EigenLayer\n", utils.EmojiCheckMark) - operatorDetails, err := reader.GetOperatorDetails(callOpts, operatorCfg.Operator) + operatorDetails, err := reader.GetOperatorDetails(context.Background(), operatorCfg.Operator) if err != nil { return err } diff --git a/pkg/rewards/claim.go b/pkg/rewards/claim.go index f4b34d6..2e8d384 100644 --- a/pkg/rewards/claim.go +++ b/pkg/rewards/claim.go @@ -27,7 +27,6 @@ import ( "github.com/Layr-Labs/eigensdk-go/logging" eigenSdkUtils "github.com/Layr-Labs/eigensdk-go/utils" - "github.com/ethereum/go-ethereum/accounts/abi/bind" gethcommon "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethclient" @@ -36,12 +35,12 @@ import ( ) type elChainReader interface { - GetDistributionRootsLength(opts *bind.CallOpts) (*big.Int, error) - GetRootIndexFromHash(opts *bind.CallOpts, hash [32]byte) (uint32, error) + GetDistributionRootsLength(ctx context.Context) (*big.Int, error) + GetRootIndexFromHash(ctx context.Context, hash [32]byte) (uint32, error) GetCurrentClaimableDistributionRoot( - opts *bind.CallOpts, + ctx context.Context, ) (rewardscoordinator.IRewardsCoordinatorDistributionRoot, error) - CurrRewardsCalculationEndTimestamp(opts *bind.CallOpts) (uint32, error) + CurrRewardsCalculationEndTimestamp(ctx context.Context) (uint32, error) } func ClaimCmd(p utils.Prompter) *cli.Command { @@ -153,7 +152,7 @@ func Claim(cCtx *cli.Context, p utils.Prompter) error { } logger.Info("Validating claim proof...") - ok, err := elReader.CheckClaim(&bind.CallOpts{Context: ctx}, elClaim) + ok, err := elReader.CheckClaim(ctx, elClaim) if err != nil { return err } @@ -278,13 +277,13 @@ func getClaimDistributionRoot( logger logging.Logger, ) (string, uint32, error) { if claimTimestamp == LatestTimestamp { - latestSubmittedTimestamp, err := elReader.CurrRewardsCalculationEndTimestamp(&bind.CallOpts{Context: ctx}) + latestSubmittedTimestamp, err := elReader.CurrRewardsCalculationEndTimestamp(ctx) if err != nil { return "", 0, eigenSdkUtils.WrapError("failed to get latest submitted timestamp", err) } claimDate := time.Unix(int64(latestSubmittedTimestamp), 0).UTC().Format(time.DateOnly) - rootCount, err := elReader.GetDistributionRootsLength(&bind.CallOpts{Context: ctx}) + rootCount, err := elReader.GetDistributionRootsLength(ctx) if err != nil { return "", 0, eigenSdkUtils.WrapError("failed to get number of published roots", err) } @@ -293,11 +292,11 @@ func getClaimDistributionRoot( logger.Debugf("Latest active rewards snapshot timestamp: %s, root index: %d", claimDate, rootIndex) return claimDate, rootIndex, nil } else if claimTimestamp == LatestActiveTimestamp { - latestClaimableRoot, err := elReader.GetCurrentClaimableDistributionRoot(&bind.CallOpts{Context: ctx}) + latestClaimableRoot, err := elReader.GetCurrentClaimableDistributionRoot(ctx) if err != nil { return "", 0, eigenSdkUtils.WrapError("failed to get latest claimable root", err) } - rootIndex, err := elReader.GetRootIndexFromHash(&bind.CallOpts{Context: ctx}, latestClaimableRoot.Root) + rootIndex, err := elReader.GetRootIndexFromHash(ctx, latestClaimableRoot.Root) if err != nil { return "", 0, eigenSdkUtils.WrapError("failed to get root index from hash", err) } diff --git a/pkg/rewards/claim_test.go b/pkg/rewards/claim_test.go index 6a3f453..77d83ad 100644 --- a/pkg/rewards/claim_test.go +++ b/pkg/rewards/claim_test.go @@ -19,7 +19,6 @@ import ( rewardscoordinator "github.com/Layr-Labs/eigensdk-go/contracts/bindings/IRewardsCoordinator" "github.com/Layr-Labs/eigensdk-go/logging" - "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/assert" @@ -65,11 +64,11 @@ func newFakeELReader(now time.Time) *fakeELReader { } } -func (f *fakeELReader) GetDistributionRootsLength(opts *bind.CallOpts) (*big.Int, error) { +func (f *fakeELReader) GetDistributionRootsLength(ctx context.Context) (*big.Int, error) { return big.NewInt(int64(len(f.roots))), nil } -func (f *fakeELReader) GetRootIndexFromHash(opts *bind.CallOpts, hash [32]byte) (uint32, error) { +func (f *fakeELReader) GetRootIndexFromHash(ctx context.Context, hash [32]byte) (uint32, error) { for i, root := range f.roots { if root.Root == hash { return uint32(i), nil @@ -79,7 +78,7 @@ func (f *fakeELReader) GetRootIndexFromHash(opts *bind.CallOpts, hash [32]byte) } func (f *fakeELReader) GetCurrentClaimableDistributionRoot( - opts *bind.CallOpts, + ctx context.Context, ) (rewardscoordinator.IRewardsCoordinatorDistributionRoot, error) { // iterate from end to start since we want the latest active root // and the roots are sorted in ascending order of activation time @@ -92,8 +91,8 @@ func (f *fakeELReader) GetCurrentClaimableDistributionRoot( return rewardscoordinator.IRewardsCoordinatorDistributionRoot{}, errors.New("no active distribution root found") } -func (f *fakeELReader) CurrRewardsCalculationEndTimestamp(opts *bind.CallOpts) (uint32, error) { - rootLen, err := f.GetDistributionRootsLength(opts) +func (f *fakeELReader) CurrRewardsCalculationEndTimestamp(ctx context.Context) (uint32, error) { + rootLen, err := f.GetDistributionRootsLength(ctx) if err != nil { return 0, err } diff --git a/pkg/rewards/show.go b/pkg/rewards/show.go index fe170be..e86b934 100644 --- a/pkg/rewards/show.go +++ b/pkg/rewards/show.go @@ -22,7 +22,6 @@ import ( "github.com/Layr-Labs/eigensdk-go/logging" eigenSdkUtils "github.com/Layr-Labs/eigensdk-go/utils" - "github.com/ethereum/go-ethereum/accounts/abi/bind" gethcommon "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethclient" @@ -32,7 +31,7 @@ import ( type ClaimType string type ELReader interface { - GetCumulativeClaimed(opts *bind.CallOpts, earnerAddress, tokenAddress gethcommon.Address) (*big.Int, error) + GetCumulativeClaimed(ctx context.Context, earnerAddress, tokenAddress gethcommon.Address) (*big.Int, error) } const ( @@ -170,7 +169,7 @@ func getClaimedRewards( ) (map[gethcommon.Address]*big.Int, error) { claimedRewards := make(map[gethcommon.Address]*big.Int) for address := range allRewards { - claimed, err := elReader.GetCumulativeClaimed(&bind.CallOpts{Context: ctx}, earnerAddress, address) + claimed, err := elReader.GetCumulativeClaimed(ctx, earnerAddress, address) if err != nil { return nil, err } diff --git a/pkg/rewards/show_test.go b/pkg/rewards/show_test.go index 9b9b48a..6099493 100644 --- a/pkg/rewards/show_test.go +++ b/pkg/rewards/show_test.go @@ -6,7 +6,6 @@ import ( "math/big" "testing" - "github.com/ethereum/go-ethereum/accounts/abi/bind" gethcommon "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/assert" ) @@ -88,7 +87,7 @@ type FakeELReader struct { } func (f *FakeELReader) GetCumulativeClaimed( - opts *bind.CallOpts, + ctx context.Context, earnerAddress, tokenAddress gethcommon.Address, ) (*big.Int, error) { if f.shouldError {