Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Makefile target to generate bindings (main branch) #208

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 54 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ deploy-contracts-to-anvil-and-save-state: ##

__TESTING__: ##

start-anvil: reset-anvil ##
$(MAKE) start-anvil-chain-with-contracts-deployed

reset-anvil:
-docker stop anvil
-docker rm anvil
Expand All @@ -30,5 +33,54 @@ lint:
cargo fmt --all -- --check \
&& cargo clippy --workspace --all-features --benches --examples --tests -- -D warnings

start-anvil: reset-anvil ##
$(MAKE) start-anvil-chain-with-contracts-deployed
__BINDINGS__: ##

### SDK bindings ###
SDK_CONTRACTS:="MockAvsServiceManager ContractsRegistry"
SDK_CONTRACTS_LOCATION:=crates/contracts
SDK_BINDINGS_PATH:=crates/utils/src/sdk
# The echo is to remove quotes, and the patsubst to make the regex match the full text only
SDK_CONTRACTS_ARGS:=$(patsubst %, --select '^%$$', $(shell echo $(SDK_CONTRACTS)))


### Middleware bindings ###
MIDDLEWARE_CONTRACTS:="RegistryCoordinator IndexRegistry OperatorStateRetriever StakeRegistry BLSApkRegistry IBLSSignatureChecker ServiceManagerBase IERC20"
MIDDLEWARE_CONTRACTS_LOCATION:=$(SDK_CONTRACTS_LOCATION)/lib/eigenlayer-middleware
MIDDLEWARE_BINDINGS_PATH:=crates/utils/src/middleware
# The echo is to remove quotes, and the patsubst to make the regex match the full text only
MIDDLEWARE_CONTRACTS_ARGS:=$(patsubst %, --select '^%$$', $(shell echo $(MIDDLEWARE_CONTRACTS)))


### Core bindings ###
CORE_CONTRACTS:="DelegationManager IRewardsCoordinator StrategyManager IEigenPod EigenPod IEigenPodManager EigenPodManager IStrategy AVSDirectory AllocationManager PermissionController"
CORE_CONTRACTS_LOCATION:=$(MIDDLEWARE_CONTRACTS_LOCATION)/lib/eigenlayer-contracts
CORE_BINDINGS_PATH:=crates/utils/src/core
# The echo is to remove quotes, and the patsubst to make the regex match the full text only
CORE_CONTRACTS_ARGS:=$(patsubst %, --select '^%$$', $(shell echo $(CORE_CONTRACTS)))


.PHONY: bindings
bindings:
@echo "Generating bindings..."
# Fetch submoduless
cd $(SDK_CONTRACTS_LOCATION) && forge install

# Generate SDK bindings
cd $(SDK_CONTRACTS_LOCATION) && forge build --force --skip test --skip script
forge bind --alloy --skip-build --bindings-path $(SDK_BINDINGS_PATH) --overwrite \
--root $(SDK_CONTRACTS_LOCATION) --module \
$(SDK_CONTRACTS_ARGS)

# Generate middleware bindings
cd $(MIDDLEWARE_CONTRACTS_LOCATION) && forge build --force --skip test --skip script
forge bind --alloy --skip-build --bindings-path $(MIDDLEWARE_BINDINGS_PATH) --overwrite \
--root $(MIDDLEWARE_CONTRACTS_LOCATION) --module \
$(MIDDLEWARE_CONTRACTS_ARGS)

# Generate core bindings
cd $(CORE_CONTRACTS_LOCATION) && forge build --force --skip test --skip script
forge bind --alloy --skip-build --bindings-path $(CORE_BINDINGS_PATH) --overwrite \
--root $(CORE_CONTRACTS_LOCATION) --module \
$(CORE_CONTRACTS_ARGS)

@echo "Bindings generated"
14 changes: 4 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,15 @@ cargo run --example get_quorum_count

The main branch of this repo is intended to be syncronized with mainnet version of core contracts.

To update the bindings of this repo:

- Inside the `crates/contracts` folder, run:
To update the bindings of this repo, run:

```bash
forge bind --alloy --bindings-path <path-eigensdk-rs>/crates/utils --overwrite -C src/contracts
make bindings
```

where `path-eigensdk-rs` is the full path to the eigensdk-rs (this) repo.

This command will generate the bindings files in the folder: `<path-eigensdk-rs>/crates/utils`.

⚠️ It rewrites Cargo.toml file, this file must be restored to the current version.
This command will generate the bindings files in the folder: `crates/utils`.

- Fix all compilation warnings.
⚠️ Remember to fix all compilation warnings.

## Contributor Guidelines

Expand Down
14 changes: 4 additions & 10 deletions crates/eigensdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,15 @@ cargo run --example get_quorum_count

The main branch of this repo is intended to be syncronized with mainnet version of core contracts.

To update the bindings of this repo:

- Inside the `crates/contracts` folder, run:
To update the bindings of this repo, run:

```bash
forge bind --alloy --bindings-path <path-eigensdk-rs>/crates/utils --overwrite -C src/contracts
make bindings
```

where `path-eigensdk-rs` is the full path to the eigensdk-rs (this) repo.

This command will generate the bindings files in the folder: `<path-eigensdk-rs>/crates/utils`.

⚠️ It rewrites Cargo.toml file, this file must be restored to the current version.
This command will generate the bindings files in the folder: `crates/utils`.

- Fix all compilation warnings.
⚠️ Remember to fix all compilation warnings.

## Contributor Guidelines

Expand Down
Loading