Skip to content

Commit

Permalink
Merge pull request #4 from Layr-Labs/sm-stakerDelegations
Browse files Browse the repository at this point in the history
Add support for staker delegations
  • Loading branch information
seanmcgary authored Sep 6, 2024
2 parents d09876d + 7580508 commit d09a779
Show file tree
Hide file tree
Showing 10 changed files with 703 additions and 78 deletions.
8 changes: 1 addition & 7 deletions internal/eigenState/avsOperators/avsOperators.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,7 @@ func (a *AvsOperators) getContractAddressesForEnvironment() map[string][]string
// Given a log, determine if it is interesting to the state model
func (a *AvsOperators) IsInterestingLog(log *storage.TransactionLog) bool {
addresses := a.getContractAddressesForEnvironment()
logAddress := strings.ToLower(log.Address)
if eventNames, ok := addresses[logAddress]; ok {
if slices.Contains(eventNames, log.EventName) {
return true
}
}
return false
return a.BaseEigenState.IsInterestingLog(addresses, log)
}

// Handle the state change for the given log
Expand Down
12 changes: 12 additions & 0 deletions internal/eigenState/base/baseEigenState.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"github.com/Layr-Labs/sidecar/internal/parser"
"github.com/Layr-Labs/sidecar/internal/storage"
"go.uber.org/zap"
"slices"
"strings"
)

type BaseEigenState struct {
Expand Down Expand Up @@ -49,3 +51,13 @@ func (b *BaseEigenState) InitializeMerkleTreeBaseStateWithBlock(blockNumber uint
[]byte(fmt.Sprintf("%d", blockNumber)),
}
}

func (b *BaseEigenState) IsInterestingLog(contractsEvents map[string][]string, log *storage.TransactionLog) bool {
logAddress := strings.ToLower(log.Address)
if eventNames, ok := contractsEvents[logAddress]; ok {
if slices.Contains(eventNames, log.EventName) {
return true
}
}
return false
}
8 changes: 1 addition & 7 deletions internal/eigenState/operatorShares/operatorShares.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,7 @@ func (osm *OperatorSharesModel) getContractAddressesForEnvironment() map[string]

func (osm *OperatorSharesModel) IsInterestingLog(log *storage.TransactionLog) bool {
addresses := osm.getContractAddressesForEnvironment()
logAddress := strings.ToLower(log.Address)
if eventNames, ok := addresses[logAddress]; ok {
if slices.Contains(eventNames, log.EventName) {
return true
}
}
return false
return osm.BaseEigenState.IsInterestingLog(addresses, log)
}

func (osm *OperatorSharesModel) HandleStateChange(log *storage.TransactionLog) (interface{}, error) {
Expand Down
Loading

0 comments on commit d09a779

Please sign in to comment.