Skip to content

Conversation

JasoonS
Copy link
Contributor

@JasoonS JasoonS commented Aug 26, 2025

This is an older example I wrote, just noticed I didn't push.

Summary by CodeRabbit

  • New Features
    • Added an EIP-7702 example demonstrating how to query and retrieve EIP-7702 transactions, including filtering by address and selecting fields like transaction hash and authorization lists. Runs asynchronously and prints results with basic logging.
  • Documentation
    • Provided a runnable example to guide users in constructing queries for EIP-7702 data and iterating through results, helping users integrate similar logic into their applications.

@JasoonS JasoonS marked this pull request as ready for review August 26, 2025 10:45
Copy link

coderabbitai bot commented Aug 26, 2025

Walkthrough

Adds a new Rust example crate at examples/eip7702. Cargo.toml defines dependencies and project metadata. main.rs implements an async example using hypersync-client to query EIP-7702-related transactions from https://eth.hypersync.xyz, prints authorization_list fields, and uses Tokio, serde_json, ruint, and env_logger.

Changes

Cohort / File(s) Summary of Changes
New example crate setup
examples/eip7702/Cargo.toml
Introduces a new example crate configured with edition 2021 and dependencies: local hypersync-client (path: ../../hypersync-client), tokio (full), serde_json, ruint, and env_logger.
EIP-7702 example implementation
examples/eip7702/src/main.rs
Adds an async example binary that constructs a query filtering transactions by authorization_list address, calls client.get(...) against https://eth.hypersync.xyz, and iterates response batches to print authorization_list data. Initializes logging; uses Arc and Tokio runtime.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant App as eip7702 example (main.rs)
  participant Client as hypersync-client
  participant API as Hypersync API

  User->>App: Run binary
  App->>Client: new Client("https://eth.hypersync.xyz")
  App->>App: Build JSON query (blocks, txs.authorization_list, field selection)
  App->>Client: get(query) (async)
  Client->>API: HTTP request with query
  API-->>Client: Response (transactions batches)
  Client-->>App: Result { data.transactions }
  loop For each batch
    App->>App: Iterate txs and print authorization_list
  end
  App-->>User: Console output
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

In burrows of code, I hop with glee,
A nibble at 7702—what do I see?
Queries sprout, logs softly glow,
Batches bloom where transactions flow.
With Tokio time and JSON bright,
I thump the ground—“It works!”—just right. 🐇✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch eip7702-example

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (9)
examples/eip7702/Cargo.toml (3)

1-5: Mark the example crate as non-publishable to avoid accidental release to crates.io

Add publish = false under [package]. Optional: include license and repository metadata for consistency with the workspace.

 [package]
 name = "eip7702"
 version = "0.1.0"
 edition = "2021"
+publish = false

9-9: Avoid Tokio “full” feature set in examples to reduce compile times and binary size

This example needs only the runtime and macros. Consider trimming the features.

-tokio = { version = "1", features = ["full"] }
+tokio = { version = "1", features = ["rt-multi-thread", "macros"] }

11-11: ruint isn’t used — remove it or put it to use (e.g., parsing U256 chain IDs)

If you don’t use it in the example, drop the dependency to keep the example lean.

-ruint = "1"

If you intend to decode chain IDs or other 256-bit ints here, I can add a small snippet that demonstrates that and keeps ruint.

examples/eip7702/src/main.rs (6)

1-2: Header comment doesn’t match the actual query (limited block range vs. “all”)

Either change the header to reflect a range-based example, or adjust the query to truly fetch “all”.

-// Example of getting all EIP-7702 transactions
+// Example: fetch EIP-7702 transactions in a specific block range

3-3: Remove unused Arc import

Arc isn’t needed — the client isn’t shared across threads/tasks.

-use std::sync::Arc;

33-34: Drop the unnecessary Arc wrapping of the client

You construct an Arc<Client> but never clone or share it. Keep it as a plain Client.

-    let client = Arc::new(client);
+    // No Arc needed; keep the client as-is.

17-31: Make the query more robust and clean up comments/typos

  • Inline block comment inside json! is odd; move notes above the JSON.
  • Typo: “filterring” → “filtering”.
  • The “start from block 0…” comment contradicts the actual range; update it here or remove it.

If the typed Query has a builder API, prefer that over from_value to catch shape errors at compile time. Otherwise, at least keep comments outside the JSON.

-    let query: Query = serde_json::from_value(serde_json::json!( {
-        // start from block 0 and go to the end of the chain (we don't specify a toBlock).
+    // NOTE: chain_id filtering is currently not working.
+    let query: Query = serde_json::from_value(serde_json::json!({
+        // Fetch a small block range for the example
         "from_block": 22490287,
         "to_block": 22490297,
         "transactions": [
-            {"authorization_list": [{/*"chain_id": [1], // chain_id filterring isn't working currently*/ "address": ["0x80296ff8d1ed46f8e3c7992664d13b833504c2bb"]}]}
+            {
+                "authorization_list": [{
+                    "address": ["0x80296ff8d1ed46f8e3c7992664d13b833504c2bb"]
+                }]
+            }
         ],
-        // Select the fields we are interested in, notice topics are selected as topic0,1,2,3
+        // Select the fields we are interested in
         "field_selection": {
             "transaction": [
-                "hash","authorization_list"
+                "hash", "authorization_list"
             ]
         },
-    }))
+    }))

37-43: Avoid panicking on network/parse errors; log and exit gracefully. Also include tx hash in output for context

This improves the example’s ergonomics and makes failures clearer.

-    let res = client.get(&query).await.unwrap();
+    let res = match client.get(&query).await {
+        Ok(r) => r,
+        Err(err) => {
+            eprintln!("Request failed: {err}");
+            return;
+        }
+    };
 
     for batch in res.data.transactions {
         for tx in batch {
-            println!("Transaction: {:?}", tx.authorization_list);
+            println!("Transaction {:?}: {:?}", tx.hash, tx.authorization_list);
         }
     }

11-15: Optional: allow overriding the service URL via env for easier testing

Keeping the default as eth mainnet is fine; this just makes the example more flexible without adding complexity.

-    let client = Client::new(ClientConfig {
-        url: Some("https://eth.hypersync.xyz".parse().unwrap()),
+    let default_url = "https://eth.hypersync.xyz".to_string();
+    let url = std::env::var("HYPERSYNC_URL").unwrap_or(default_url);
+    let client = Client::new(ClientConfig {
+        url: Some(url.parse().unwrap()),
         ..Default::default()
     })
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 9ebffa2 and 793cd7d.

📒 Files selected for processing (2)
  • examples/eip7702/Cargo.toml (1 hunks)
  • examples/eip7702/src/main.rs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: test_release
  • GitHub Check: test_dev
🔇 Additional comments (2)
examples/eip7702/Cargo.toml (1)

12-12: No change needed: env_logger 0.4’s init() already returns a Result

Our inspection of env_logger v0.4.3 shows that both the builder’s init(&mut self) -> Result<(), SetLoggerError> and the free init() -> Result<(), SetLoggerError> return a Result, so calling .unwrap() on init() compiles fine. You can keep env_logger = "0.4" in Cargo.toml and retain env_logger::init().unwrap() in main.rs without errors.

Likely an incorrect or invalid review comment.

examples/eip7702/src/main.rs (1)

39-43: Minor: handle empty batches defensively (no action required)

If res.data.transactions can be empty, the loop is already safe. Just noting it; no change needed.


#[tokio::main]
async fn main() {
env_logger::init().unwrap();
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix env_logger initialization

env_logger::init() shouldn’t be unwrapped; with env_logger 0.4 it returns (). If you upgraded env_logger (per Cargo.toml comment), init() still returns (). Use try_init() only if you want to handle the error.

-    env_logger::init().unwrap();
+    env_logger::init();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
env_logger::init().unwrap();
env_logger::init();
🤖 Prompt for AI Agents
In examples/eip7702/src/main.rs around line 9, the call
env_logger::init().unwrap() is incorrect because init() returns () (or if
upgraded you should use try_init() to handle errors); remove the .unwrap() and
call env_logger::init() directly, or if you need to handle initialization
failures use env_logger::try_init() and handle the Result (e.g., log or
propagate the error) instead of unwrapping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants