-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7c76ea7
commit ad8090d
Showing
8 changed files
with
4,590 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,10 @@ help: | |
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' | ||
|
||
bindings: ## generates contract bindings | ||
cd contracts && rm -rf bindings/* && ./generate-bindings.sh | ||
cd contracts && rm -rf bindings/* && ./generate-bindings.sh | ||
|
||
eigenpod-bindings: ## generates contract bindings for eigenpod | ||
cd chainio/clients/eigenpod && ./generate.sh | ||
|
||
mocks: ## generates mocks | ||
go install go.uber.org/mock/[email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package eigenpod | ||
|
||
import ( | ||
"github.com/Layr-Labs/eigensdk-go/chainio/clients/eigenpod/bindings" | ||
"github.com/Layr-Labs/eigensdk-go/chainio/clients/eth" | ||
|
||
"github.com/ethereum/go-ethereum/common" | ||
) | ||
|
||
type ContractBindings struct { | ||
Address common.Address | ||
*bindings.IEigenPod | ||
} | ||
|
||
type ContractCallerBindings struct { | ||
Address common.Address | ||
*bindings.IEigenPodCaller | ||
} | ||
|
||
type ManagerContractBindings struct { | ||
Address common.Address | ||
*bindings.IEigenPodManager | ||
} | ||
|
||
type ManagerContractCallerBindings struct { | ||
Address common.Address | ||
*bindings.IEigenPodManagerCaller | ||
} | ||
|
||
func NewContractBindings( | ||
address common.Address, | ||
ethClient eth.HttpBackend, | ||
) (*ContractBindings, error) { | ||
pod, err := bindings.NewIEigenPod(address, ethClient) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &ContractBindings{ | ||
Address: address, | ||
IEigenPod: pod, | ||
}, nil | ||
} | ||
|
||
func NewContractCallerBindings( | ||
address common.Address, | ||
ethClient eth.HttpBackend, | ||
) (*ContractCallerBindings, error) { | ||
pod, err := bindings.NewIEigenPodCaller(address, ethClient) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &ContractCallerBindings{ | ||
Address: address, | ||
IEigenPodCaller: pod, | ||
}, nil | ||
} | ||
|
||
func NewManagerContractBindings( | ||
address common.Address, | ||
ethClient eth.HttpBackend, | ||
) (*ManagerContractBindings, error) { | ||
manager, err := bindings.NewIEigenPodManager(address, ethClient) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &ManagerContractBindings{ | ||
Address: address, | ||
IEigenPodManager: manager, | ||
}, nil | ||
} | ||
|
||
func NewManagerContractCallerBindings( | ||
address common.Address, | ||
ethClient eth.HttpBackend, | ||
) (*ManagerContractCallerBindings, error) { | ||
manager, err := bindings.NewIEigenPodManagerCaller(address, ethClient) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &ManagerContractCallerBindings{ | ||
Address: address, | ||
IEigenPodManagerCaller: manager, | ||
}, nil | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
1,956 changes: 1,956 additions & 0 deletions
1,956
chainio/clients/eigenpod/bindings/IEigenPodManager.go
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package eigenpod | ||
|
||
import ( | ||
"github.com/Layr-Labs/eigensdk-go/chainio/clients/eth" | ||
"github.com/Layr-Labs/eigensdk-go/chainio/txmgr" | ||
"github.com/Layr-Labs/eigensdk-go/logging" | ||
"github.com/ethereum/go-ethereum/common" | ||
) | ||
|
||
func BuildEigenPodClients( | ||
address common.Address, | ||
client eth.HttpBackend, | ||
txMgr txmgr.TxManager, | ||
logger logging.Logger, | ||
) (*ChainReader, *ChainWriter, *ContractBindings, error) { | ||
eigenPodBindings, err := NewContractBindings(address, client) | ||
if err != nil { | ||
return nil, nil, nil, err | ||
} | ||
|
||
eigenPodChainReader := newChainReader( | ||
&eigenPodBindings.IEigenPodCaller, | ||
client, | ||
logger, | ||
) | ||
|
||
eigenPodChainWriter := newChainWriter( | ||
eigenPodBindings.IEigenPod, | ||
client, | ||
logger, | ||
txMgr, | ||
) | ||
|
||
return eigenPodChainReader, eigenPodChainWriter, eigenPodBindings, nil | ||
} | ||
|
||
func BuildEigenPodManagerClients( | ||
address common.Address, | ||
client eth.HttpBackend, | ||
txMgr txmgr.TxManager, | ||
logger logging.Logger, | ||
) (*ManagerChainReader, *ManagerChainWriter, *ManagerContractBindings, error) { | ||
eigenPodManagerBindings, err := NewManagerContractBindings(address, client) | ||
if err != nil { | ||
return nil, nil, nil, err | ||
} | ||
|
||
eigenPodManagerChainReader := newManagerChainReader( | ||
&eigenPodManagerBindings.IEigenPodManagerCaller, | ||
client, | ||
logger, | ||
) | ||
|
||
eigenPodManagerChainWriter := newManagerChainWriter( | ||
eigenPodManagerBindings.IEigenPodManager, | ||
client, | ||
logger, | ||
txMgr, | ||
) | ||
|
||
return eigenPodManagerChainReader, eigenPodManagerChainWriter, eigenPodManagerBindings, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/bin/bash | ||
|
||
TMP_DIR=tmp | ||
BINDINGS_DIR=bindings | ||
|
||
cleanup_bindings_dir() { | ||
echo "Cleaning up the bindings directory" | ||
rm -rf ${BINDINGS_DIR} | ||
} | ||
|
||
create_tmp_dir() { | ||
echo "Creating a temporary directory" | ||
mkdir -p ${TMP_DIR} | ||
} | ||
|
||
clone() { | ||
echo "Cloning the EigenLayer contracts repository" | ||
git clone -b feat/partial-withdrawal-batching --depth=1 [email protected]:Layr-Labs/eigenlayer-contracts.git ${TMP_DIR} | ||
} | ||
|
||
generate_bindings() { | ||
echo "Generating bindings for the EigenPods contracts" | ||
cd ${TMP_DIR} && make bindings | ||
cd .. | ||
mkdir -p ${BINDINGS_DIR} | ||
generate_go ${TMP_DIR}/out/IEigenPod.sol/IEigenPod.json IEigenPod | ||
generate_go ${TMP_DIR}/out/IEigenPodManager.sol/IEigenPodManager.json IEigenPodManager | ||
} | ||
|
||
generate_go() { | ||
# Check if jq is installed | ||
if ! command -v jq &> /dev/null; then | ||
echo "jq is required but not installed. Please install jq (brew install jq)." | ||
exit 1 | ||
fi | ||
|
||
temp_file=$(mktemp) | ||
echo "Generating Go bindings for the $1 contract" | ||
jq '.abi' "$1" > "$temp_file" && mv "$temp_file" "$1" | ||
|
||
abigen --abi "$1" --pkg bindings --type "$2" --out "$BINDINGS_DIR"/"$2".go | ||
} | ||
|
||
cleanup() { | ||
echo "Cleaning up the temporary directory" | ||
rm -rf ${TMP_DIR} | ||
} | ||
|
||
main() { | ||
cleanup_bindings_dir | ||
create_tmp_dir | ||
clone | ||
generate_bindings | ||
cleanup | ||
} | ||
|
||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package eigenpod | ||
|
||
import ( | ||
"github.com/Layr-Labs/eigensdk-go/chainio/clients/eigenpod/bindings" | ||
"github.com/Layr-Labs/eigensdk-go/chainio/clients/eth" | ||
"github.com/Layr-Labs/eigensdk-go/logging" | ||
"github.com/ethereum/go-ethereum/common" | ||
) | ||
|
||
type ChainReader struct { | ||
logger logging.Logger | ||
ethClient eth.HttpBackend | ||
*bindings.IEigenPodCaller | ||
} | ||
|
||
type ManagerChainReader struct { | ||
logger logging.Logger | ||
ethClient eth.HttpBackend | ||
*bindings.IEigenPodManagerCaller | ||
} | ||
|
||
func newChainReader( | ||
eigenPod *bindings.IEigenPodCaller, | ||
ethClient eth.HttpBackend, | ||
logger logging.Logger, | ||
) *ChainReader { | ||
logger = logger.With(logging.ComponentKey, "eigenpod/reader") | ||
|
||
return &ChainReader{ | ||
logger: logger, | ||
ethClient: ethClient, | ||
IEigenPodCaller: eigenPod, | ||
} | ||
} | ||
|
||
func newManagerChainReader( | ||
manager *bindings.IEigenPodManagerCaller, | ||
ethClient eth.HttpBackend, | ||
logger logging.Logger, | ||
) *ManagerChainReader { | ||
logger = logger.With(logging.ComponentKey, "eigenpodmanager/reader") | ||
|
||
return &ManagerChainReader{ | ||
logger: logger, | ||
ethClient: ethClient, | ||
IEigenPodManagerCaller: manager, | ||
} | ||
} | ||
|
||
func NewReader( | ||
address common.Address, | ||
ethClient eth.HttpBackend, | ||
logger logging.Logger, | ||
) (*ChainReader, error) { | ||
pod, err := NewContractCallerBindings(address, ethClient) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return newChainReader(pod.IEigenPodCaller, ethClient, logger), nil | ||
} | ||
|
||
func NewManagerReader( | ||
address common.Address, | ||
ethClient eth.HttpBackend, | ||
logger logging.Logger, | ||
) (*ManagerChainReader, error) { | ||
manager, err := NewManagerContractCallerBindings(address, ethClient) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return newManagerChainReader(manager.IEigenPodManagerCaller, ethClient, logger), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package eigenpod | ||
|
||
import ( | ||
"github.com/Layr-Labs/eigensdk-go/chainio/clients/eigenpod/bindings" | ||
"github.com/Layr-Labs/eigensdk-go/chainio/clients/eth" | ||
"github.com/Layr-Labs/eigensdk-go/chainio/txmgr" | ||
"github.com/Layr-Labs/eigensdk-go/logging" | ||
"github.com/ethereum/go-ethereum/common" | ||
) | ||
|
||
type ChainWriter struct { | ||
logger logging.Logger | ||
ethClient eth.HttpBackend | ||
eigenPod *bindings.IEigenPod | ||
txMgr txmgr.TxManager | ||
} | ||
|
||
type ManagerChainWriter struct { | ||
logger logging.Logger | ||
ethClient eth.HttpBackend | ||
manager *bindings.IEigenPodManager | ||
txMgr txmgr.TxManager | ||
} | ||
|
||
func newChainWriter( | ||
eigenPod *bindings.IEigenPod, | ||
ethClient eth.HttpBackend, | ||
logger logging.Logger, | ||
txMgr txmgr.TxManager, | ||
) *ChainWriter { | ||
logger = logger.With(logging.ComponentKey, "eigenpod/writer") | ||
|
||
return &ChainWriter{ | ||
logger: logger, | ||
ethClient: ethClient, | ||
eigenPod: eigenPod, | ||
txMgr: txMgr, | ||
} | ||
} | ||
|
||
func newManagerChainWriter( | ||
manager *bindings.IEigenPodManager, | ||
ethClient eth.HttpBackend, | ||
logger logging.Logger, | ||
txMgr txmgr.TxManager, | ||
) *ManagerChainWriter { | ||
logger = logger.With(logging.ComponentKey, "eigenpodmanager/writer") | ||
|
||
return &ManagerChainWriter{ | ||
logger: logger, | ||
ethClient: ethClient, | ||
manager: manager, | ||
txMgr: txMgr, | ||
} | ||
} | ||
|
||
func NewWriter( | ||
address common.Address, | ||
ethClient eth.HttpBackend, | ||
txMgr txmgr.TxManager, | ||
logger logging.Logger, | ||
) (*ChainWriter, error) { | ||
pod, err := bindings.NewIEigenPod(address, ethClient) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return newChainWriter(pod, ethClient, logger, txMgr), nil | ||
} | ||
|
||
func NewManagerWriter( | ||
address common.Address, | ||
ethClient eth.HttpBackend, | ||
txMgr txmgr.TxManager, | ||
logger logging.Logger, | ||
) (*ManagerChainWriter, error) { | ||
manager, err := bindings.NewIEigenPodManager(address, ethClient) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return newManagerChainWriter(manager, ethClient, logger, txMgr), nil | ||
} | ||
|
||
// TODO(madhur): Add methods to ChainWriter and ManagerChainWriter to interact with the contracts. |