Skip to content

Conversation

@jmg-duarte
Copy link
Contributor

@jmg-duarte jmg-duarte commented Oct 27, 2025

Description

Implements bindings generation in build.rs, adding this allows

  1. Generated code to be inspected manually and "cmd-click"ed into
  2. Faster incremental compilation since the code can be cached unlike macros

Changes

  • New contracts-generate crate to simplify build.rs code
  • Generate bindings in contracts build.rs
  • Migrate everything without changing any module paths
  • Moved away from the Provider re-export (contracts::alloy::Provider -> alloy::providers::DynProvider)
  • Removes the ethcontract re-export from the contracts crate
  • Removes now unused code (some inconsistent tests and dummy legacy things)

How to test

Run existing tests & compile

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no clue how to review this other than by asking AI.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can do them one by one. I did this whole with AI too and did multilple rounds with different contexts. But this was more about proving that I was able to migrate everything with minimal changes on the main codebase

@squadgazzz squadgazzz requested a review from Copilot November 6, 2025 12:31
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors contract binding generation to use a build script approach with auto-generated code. The migration moves from runtime contract instance creation to compile-time code generation.

Key changes:

  • Introduces contracts-generate crate with custom binding generation
  • Replaces runtime InstanceExt trait with compile-time generated deployment info
  • Removes legacy web3 dummy transport and macros
  • Updates type references from contracts::alloy::Provider to alloy::providers::DynProvider

Reviewed Changes

Copilot reviewed 29 out of 30 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
crates/contracts-generate/Cargo.toml New crate for build-time contract generation
crates/contracts-generate/src/lib.rs Core generation logic with network deployment mapping
crates/contracts/build.rs Build script defining all contract deployments
crates/contracts/src/lib.rs Simplified to export generated bindings only
crates/contracts/src/alloy.rs Deleted - replaced by generated code
crates/contracts/.gitignore Ignores generated src/alloy directory
Multiple usage files Updated to remove InstanceExt imports and use DynProvider

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@socket-security
Copy link

socket-security bot commented Nov 7, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedproc-macro2@​1.0.95 ⏵ 1.0.1038010093100100
Updatedquote@​1.0.36 ⏵ 1.0.4182 -1810093100100

View full report

Copy link
Contributor

@squadgazzz squadgazzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actions
Copy link

This pull request has been marked as stale because it has been inactive a while. Please update this pull request or it will be automatically closed.

@github-actions github-actions bot added the stale label Nov 25, 2025
@github-actions github-actions bot removed the stale label Nov 26, 2025
Copy link
Contributor

@MartinquaXD MartinquaXD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks nice with the build stuff being part of the contract crate now.

@jmg-duarte jmg-duarte enabled auto-merge November 26, 2025 16:02
@jmg-duarte jmg-duarte added this pull request to the merge queue Nov 26, 2025
Merged via the queue into main with commit bcb5e34 Nov 26, 2025
18 checks passed
@jmg-duarte jmg-duarte deleted the jmgd/alloy/generate branch November 26, 2025 16:21
@github-actions github-actions bot locked and limited conversation to collaborators Nov 26, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants