refactor(parser): drop alloy-ethers-typecast for alloy Provider#511
Conversation
The rainlang_parser crate carried a git dep on the rainlanguage/alloy-ethers-typecast fork purely for ReadableClient + ReadContractParametersBuilder. Those wrap a trivial eth_call + abi_decode_returns pattern that maps onto alloy::providers::Provider directly. Replaces ReadableClient parameters on Parser2::parse, parse_pragma, parse_text, parse_pragma_text with a generic P: Provider bound. Error variants collapse to Transport + AbiDecode (re-exported alloy types). Removes the workspace-level alloy-ethers-typecast entry. Tests now build a mocked provider via ProviderBuilder::new().connect_mocked_client(asserter). Breaking change for downstream consumers (raindex). Required for publishing rainlang_parser to crates.io. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
📝 WalkthroughWalkthroughThis PR replaces the alloy-ethers-typecast dependency with native alloy library integration for the Rainlang v2 parser. Workspace and crate manifests are updated, error types are refactored to use alloy primitives, the Parser2 trait is generalized to accept any Provider implementation via eth_call helper, and all tests are migrated to use ProviderBuilder mocks. ChangesAlloy Provider Trait Migration
🎯 3 (Moderate) | ⏱️ ~25 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/parser/src/v2.rs (1)
147-207: 💤 Low valueConsider reducing duplication between wasm and non-wasm impls.
The two
Parser2implementations are nearly identical, differing only in the+ Syncbound. A declarative macro could generate both variants from a single definition.This is optional and can be deferred—the current approach is straightforward and the migration goal is already achieved.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/parser/src/v2.rs` around lines 147 - 207, The two impl blocks for Parser2 on ParserV2 duplicate parse and parse_pragma, differing only by the Provider + Sync bound and cfg; extract the shared implementation into a small declarative macro that emits an impl Parser2 for ParserV2 with a configurable provider bound and cfg attribute. Create a macro (e.g. impl_parser2!) that takes the cfg attribute and the provider bound token(s), expands to the impl containing the existing bodies that call eth_call with parse2Call and parsePragma1Call and return parse2Return/parsePragma1Return, then invoke that macro twice: once under #[cfg(not(target_family = "wasm"))] with P: Provider + Sync and once under #[cfg(target_family = "wasm")] with P: Provider. This removes duplication while keeping function bodies (parse, parse_pragma) and symbols (Parser2, ParserV2, eth_call, parse2Call, parsePragma1Call, parse2Return, parsePragma1Return) unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@crates/parser/src/v2.rs`:
- Around line 147-207: The two impl blocks for Parser2 on ParserV2 duplicate
parse and parse_pragma, differing only by the Provider + Sync bound and cfg;
extract the shared implementation into a small declarative macro that emits an
impl Parser2 for ParserV2 with a configurable provider bound and cfg attribute.
Create a macro (e.g. impl_parser2!) that takes the cfg attribute and the
provider bound token(s), expands to the impl containing the existing bodies that
call eth_call with parse2Call and parsePragma1Call and return
parse2Return/parsePragma1Return, then invoke that macro twice: once under
#[cfg(not(target_family = "wasm"))] with P: Provider + Sync and once under
#[cfg(target_family = "wasm")] with P: Provider. This removes duplication while
keeping function bodies (parse, parse_pragma) and symbols (Parser2, ParserV2,
eth_call, parse2Call, parsePragma1Call, parse2Return, parsePragma1Return)
unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 78dc1965-9520-44fe-84aa-cef84be10616
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (4)
Cargo.tomlcrates/parser/Cargo.tomlcrates/parser/src/error.rscrates/parser/src/v2.rs
💤 Files with no reviewable changes (1)
- Cargo.toml
|
@coderabbitai assess this PR size classification for the totality of the PR with the following criterias and report it in your comment: S/M/L PR Classification Guidelines:This guide helps classify merged pull requests by effort and complexity rather than just line count. The goal is to assess the difficulty and scope of changes after they have been completed. Small (S)Characteristics:
Review Effort: Would have taken 5-10 minutes Examples:
Medium (M)Characteristics:
Review Effort: Would have taken 15-30 minutes Examples:
Large (L)Characteristics:
Review Effort: Would have taken 45+ minutes Examples:
Additional Factors to ConsiderWhen deciding between sizes, also consider:
Notes:
|
|
Tip For best results, initiate chat on the files or code changes. SIZE=M |
Summary
Why
The git dep on the rainlanguage typecast fork prevented publishing `rainlang_parser` to crates.io. Drops the dep entirely by inlining the only thing the parser was using it for (an `eth_call` + ABI-decode round-trip).
Tracks #510 (rainlang Rust crate publishing).
Breaking change
Downstream callers — currently raindex — pass an alloy provider instead of `ReadableClient`. Migration is replacing `ReadableClient::new_from_http_urls(rpcs)` with `ProviderBuilder::new().connect_http(url)` (or any other alloy provider).
Test plan
Summary by CodeRabbit