Skip to content

Commit

Permalink
fied
Browse files Browse the repository at this point in the history
  • Loading branch information
Sidu28 committed Feb 13, 2025
1 parent ccd7242 commit 6809157
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
13 changes: 13 additions & 0 deletions chainio/clients/elcontracts/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ func (r *ChainReader) GetMaxRewardsDuration(
return r.rewardsCoordinator.MAXREWARDSDURATION(&bind.CallOpts{Context: ctx})
}

// Get the max amount of time (seconds) that a rewards submission can start in the past
func (r *ChainReader) GetMaxRetroactiveLength(
ctx context.Context,
) (uint32, error) {
Expand All @@ -444,6 +445,7 @@ func (r *ChainReader) GetMaxRetroactiveLength(
return r.rewardsCoordinator.MAXRETROACTIVELENGTH(&bind.CallOpts{Context: ctx})
}

// Get the max amount of time (seconds) that a rewards submission can start in the future
func (r *ChainReader) GetMaxFutureLength(
ctx context.Context,
) (uint32, error) {
Expand All @@ -453,6 +455,7 @@ func (r *ChainReader) GetMaxFutureLength(
return r.rewardsCoordinator.MAXFUTURELENGTH(&bind.CallOpts{Context: ctx})
}

// Get absolute min timestamp (seconds) that a rewards submission can start at
func (r *ChainReader) GetGenesisRewardsTimestamp(
ctx context.Context,
) (uint32, error) {
Expand All @@ -462,6 +465,16 @@ func (r *ChainReader) GetGenesisRewardsTimestamp(
return r.rewardsCoordinator.GENESISREWARDSTIMESTAMP(&bind.CallOpts{Context: ctx})
}

// Get the address of the entity that can update the contract with new merkle roots
func (r *ChainReader) GetRewardsUpdater(
ctx context.Context,
) (gethcommon.Address, error) {
if r.rewardsCoordinator == nil {
return gethcommon.Address{}, errors.New("RewardsCoordinator contract not provided")
}
return r.rewardsCoordinator.RewardsUpdater(&bind.CallOpts{Context: ctx})
}

// Returns the amount of magnitude on a strategy not currently allocated to any operator set,
// by an operator.
// Can return an error if the `AllocationManager` contract address was not provided, or due to
Expand Down
22 changes: 13 additions & 9 deletions chainio/clients/elcontracts/reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package elcontracts_test

import (
"context"
"fmt"
"math/big"
"os"
"testing"
Expand Down Expand Up @@ -900,35 +901,38 @@ func TestInvalidConfig(t *testing.T) {
// currently this is configured to zero but may be configured to 1 week in a future release, based on this
// comment:
// https://github.com/Layr-Labs/eigenlayer-contracts/blob/441339cbd570ad0d650a9c11bea9eed7f70a490d/src/contracts/core/RewardsCoordinatorStorage.sol#L64
require.Zero(t, interval)
require.NotZero(t, interval)
})

//Get the maximum amount of time (seconds) that a rewards submission can span over
t.Run("get max duration seconds", func(t *testing.T) {
duration, err := chainReader.GetMaxRewardsDuration(context.Background())
require.Error(t, err)
require.Zero(t, duration)
require.NotZero(t, duration)
})

/// Get the max amount of time (seconds) that a rewards submission can start in the past
t.Run("get max retroactive length", func(t *testing.T) {
length, err := chainReader.GetMaxRetroactiveLength(context.Background())
require.Error(t, err)
require.Zero(t, length)
require.NotZero(t, length)
})

/// Get the max amount of time (seconds) that a rewards submission can start in the future
t.Run("get max future length", func(t *testing.T) {
length, err := chainReader.GetMaxFutureLength(context.Background())
require.Error(t, err)
require.Zero(t, length)
require.NotZero(t, length)
})

/// Get the absolute min timestamp (seconds) that a rewards submission can start at
t.Run("get genesis rewards timestamp", func(t *testing.T) {
timestamp, err := chainReader.GetGenesisRewardsTimestamp(context.Background())
require.Error(t, err)
require.Zero(t, timestamp)
require.NotZero(t, timestamp)
})

t.Run("Get rewards updater", func(t *testing.T) {
addr, err := chainReader.GetRewardsUpdater(context.Background())
require.Error(t, err)
fmt.Print("addr: ", addr)
require.NotNil(t, addr)
})

t.Run("try to get strategy and underlying token with wrong strategy address", func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion contracts/anvil/contracts-deployed-anvil-state.json

Large diffs are not rendered by default.

0 comments on commit 6809157

Please sign in to comment.