Skip to content

Commit

Permalink
allow ethers bindings to be checked in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-maron committed Jan 16, 2025
1 parent 66d0743 commit bda2822
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ jobs:
- name: Build all contracts
run: nix develop --accept-flake-config -c forge build

- name: Check if bindings up to date
run: nix develop --accept-flake-config -c pre-commit run contract-bindings --all-files --show-diff-on-failure
- name: Check if ethers bindings are up to date
run: nix develop --accept-flake-config -c pre-commit run contract-bindings-ethers --all-files --show-diff-on-failure

- name: Print changes to bindings
if: ${{ failure() }}
Expand Down
6 changes: 3 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,10 @@
types_or = [ "solidity" ];
pass_filenames = true;
};
contract-bindings = {
contract-bindings-ethers = {
enable = true;
description = "Generate contract bindings";
entry = "just gen-bindings";
description = "Generate ethers contract bindings";
entry = "just check-bindings-ethers";
types_or = [ "solidity" ];
pass_filenames = false;
};
Expand Down
17 changes: 17 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,23 @@ dev-sequencer:
build-docker-images:
scripts/build-docker-images-native

# We need this to make sure the ethers bindings are up to date
# TODO: Remove this when we can use `alloy` without having to patch `foundry`
check-bindings-ethers:
forge bind --contracts ./contracts/src/ --crate-name contract-bindings-ethers --bindings-path contract-bindings-ethers --select "{{REGEXP}}" --overwrite --force

# Foundry doesn't include bytecode in the bindings for LightClient.sol, since it links with
# libraries. However, this bytecode is still needed to link and deploy the contract. Copy it to
# the source tree so that the deploy script can be compiled whenever the bindings are up to
# date, without needed to recompile the contracts.
mkdir -p contract-bindings/artifacts
jq '.bytecode.object' < contracts/out/LightClient.sol/LightClient.json > contract-bindings/artifacts/LightClient_bytecode.json
jq '.bytecode.object' < contracts/out/LightClientArbitrum.sol/LightClientArbitrum.json > contract-bindings/artifacts/LightClientArbitrum_bytecode.json
jq '.bytecode.object' < contracts/out/LightClientMock.sol/LightClientMock.json > contract-bindings/artifacts/LightClientMock_bytecode.json

cargo fmt --all
cargo sort -g -w

# generate rust bindings for contracts
REGEXP := "^LightClient$|^LightClientArbitrum$|^LightClientStateUpdateVK$|^FeeContract$|PlonkVerifier$|^ERC1967Proxy$|^LightClientMock$|^LightClientStateUpdateVKMock$|^PlonkVerifier2$|^PermissionedStakeTable$"
gen-bindings:
Expand Down

0 comments on commit bda2822

Please sign in to comment.