Skip to content
Open
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
12 changes: 12 additions & 0 deletions examples/eip7702/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "eip7702"
version = "0.1.0"
edition = "2021"

[dependencies]
hypersync-client = { path = "../../hypersync-client" }

tokio = { version = "1", features = ["full"] }
serde_json = "1"
ruint = "1"
env_logger = "0.4"
44 changes: 44 additions & 0 deletions examples/eip7702/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Example of getting all EIP-7702 transactions

use std::sync::Arc;

use hypersync_client::{net_types::Query, Client, ClientConfig};

#[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.


let client = Client::new(ClientConfig {
url: Some("https://eth.hypersync.xyz".parse().unwrap()),
..Default::default()
})
.unwrap();

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).
"from_block": 22490287,
"to_block": 22490297,
"transactions": [
{"authorization_list": [{/*"chain_id": [1], // chain_id filterring isn't working currently*/ "address": ["0x80296ff8d1ed46f8e3c7992664d13b833504c2bb"]}]}
],
// Select the fields we are interested in, notice topics are selected as topic0,1,2,3
"field_selection": {
"transaction": [
"hash","authorization_list"
]
},
}))
.unwrap();

let client = Arc::new(client);

println!("Fetching Data");

let res = client.get(&query).await.unwrap();

for batch in res.data.transactions {
for tx in batch {
println!("Transaction: {:?}", tx.authorization_list);
}
}
}
Loading