-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbindings.go
50 lines (44 loc) · 1.74 KB
/
bindings.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package chainio
import (
"github.com/Layr-Labs/eigensdk-go/chainio/clients/eth"
"github.com/Layr-Labs/eigensdk-go/logging"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
gethcommon "github.com/ethereum/go-ethereum/common"
regcoord "github.com/Layr-Labs/eigensdk-go/contracts/bindings/RegistryCoordinator"
csavs "github.com/zees-dev/blockless-avs/contracts/bindings/BlocklessAVS"
erc20mock "github.com/zees-dev/blockless-avs/contracts/bindings/ERC20Mock"
)
type AvsManagersBindings struct {
ServiceManager *csavs.ContractBlocklessAVS
ethClient eth.Client
logger logging.Logger
}
func NewAvsManagersBindings(registryCoordinatorAddr, operatorStateRetrieverAddr gethcommon.Address, ethclient eth.Client, logger logging.Logger) (*AvsManagersBindings, error) {
contractRegistryCoordinator, err := regcoord.NewContractRegistryCoordinator(registryCoordinatorAddr, ethclient)
if err != nil {
return nil, err
}
serviceManagerAddr, err := contractRegistryCoordinator.ServiceManager(&bind.CallOpts{})
if err != nil {
return nil, err
}
contractServiceManager, err := csavs.NewContractBlocklessAVS(serviceManagerAddr, ethclient)
if err != nil {
logger.Error("Failed to fetch IServiceManager contract", "err", err)
return nil, err
}
return &AvsManagersBindings{
ServiceManager: contractServiceManager,
ethClient: ethclient,
logger: logger,
}, nil
}
func (b *AvsManagersBindings) GetErc20Mock(tokenAddr common.Address) (*erc20mock.ContractERC20Mock, error) {
contractErc20Mock, err := erc20mock.NewContractERC20Mock(tokenAddr, b.ethClient)
if err != nil {
b.logger.Error("Failed to fetch ERC20Mock contract", "err", err)
return nil, err
}
return contractErc20Mock, nil
}