Skip to content

Commit

Permalink
Tie into bindings.
Browse files Browse the repository at this point in the history
Signed-off-by: Cody Littley <[email protected]>
  • Loading branch information
cody-littley committed Dec 18, 2024
1 parent 3580bed commit f6b008f
Showing 1 changed file with 34 additions and 3 deletions.
37 changes: 34 additions & 3 deletions core/eth/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ package eth
import (
"context"
"crypto/ecdsa"
"fmt"
"math/big"
"strings"

"github.com/Layr-Labs/eigenda/common"
avsdir "github.com/Layr-Labs/eigenda/contracts/bindings/AVSDirectory"
blsapkreg "github.com/Layr-Labs/eigenda/contracts/bindings/BLSApkRegistry"
delegationmgr "github.com/Layr-Labs/eigenda/contracts/bindings/DelegationManager"
disperserreg "github.com/Layr-Labs/eigenda/contracts/bindings/EigenDADisperserRegistry"
relayreg "github.com/Layr-Labs/eigenda/contracts/bindings/EigenDARelayRegistry"
eigendasrvmg "github.com/Layr-Labs/eigenda/contracts/bindings/EigenDAServiceManager"
thresholdreg "github.com/Layr-Labs/eigenda/contracts/bindings/EigenDAThresholdRegistry"
Expand Down Expand Up @@ -45,6 +47,7 @@ type ContractBindings struct {
PaymentVault *paymentvault.ContractPaymentVault
RelayRegistry *relayreg.ContractEigenDARelayRegistry
ThresholdRegistry *thresholdreg.ContractEigenDAThresholdRegistry
DisperserRegistry *disperserreg.ContractEigenDADisperserRegistry
}

type Reader struct {
Expand Down Expand Up @@ -225,6 +228,21 @@ func (t *Reader) updateContractBindings(blsOperatorStateRetrieverAddr, eigenDASe

}

var contractEigenDADisperserRegistry *disperserreg.ContractEigenDADisperserRegistry
disperserRegistryAddr, err := contractEigenDAServiceManager.EigenDADisperserRegistry(&bind.CallOpts{})
if err != nil {
t.logger.Error("Failed to fetch EigenDADisperserRegistry address", "err", err)
// TODO(cody-littley): return err when the contract is deployed
// return err
} else {
contractEigenDADisperserRegistry, err =
disperserreg.NewContractEigenDADisperserRegistry(disperserRegistryAddr, t.ethClient)
if err != nil {
t.logger.Error("Failed to fetch EigenDADisperserRegistry contract", "err", err)
return err
}
}

t.bindings = &ContractBindings{
ServiceManagerAddr: eigenDAServiceManagerAddr,
RegCoordinatorAddr: registryCoordinatorAddr,
Expand All @@ -241,6 +259,7 @@ func (t *Reader) updateContractBindings(blsOperatorStateRetrieverAddr, eigenDASe
RelayRegistry: contractRelayRegistry,
PaymentVault: contractPaymentVault,
ThresholdRegistry: contractThresholdRegistry,
DisperserRegistry: contractEigenDADisperserRegistry,
}
return nil
}
Expand Down Expand Up @@ -918,8 +937,20 @@ func (t *Reader) GetRelayURLs(ctx context.Context) (map[uint32]string, error) {
}

func (t *Reader) GetDisperserAddress(ctx context.Context, disperserID uint32) (gethcommon.Address, error) {
// TODO(cody-littley/arch): this is just a place holder until we register dispersers on chain
bytes := make([]byte, gethcommon.AddressLength)
address := gethcommon.BytesToAddress(bytes)
registry := t.bindings.DisperserRegistry
if registry == nil {
return gethcommon.Address{}, errors.New("disperser registry not deployed")
}

address, err := registry.DisperserKeyToAddress(
&bind.CallOpts{
Context: ctx,
},
disperserID)

if err != nil {
return gethcommon.Address{}, fmt.Errorf("failed to get disperser address: %w", err)
}

return address, nil
}

0 comments on commit f6b008f

Please sign in to comment.