From c83659f37841023f69099d236015fa766768a202 Mon Sep 17 00:00:00 2001 From: Luis Herasme Date: Thu, 25 Jul 2024 23:42:54 -0400 Subject: [PATCH] docs: Update README.md examples with new API --- README.md | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index ebfc1c8..cb9e538 100644 --- a/README.md +++ b/README.md @@ -38,15 +38,17 @@ use handlers::stader; #[tokio::main] async fn main() { - let mut indexer = ghost_crab::Indexer::new(); + let mut indexer = ghost_crab::Indexer::new().unwrap(); indexer .load_event_handler(etherfi::EtherFiTVLUpdated::new()) - .await; + .await + .unwrap(); indexer .load_block_handler(stader::StaderBlockHandler::new()) - .await; + .await + .unwrap(); indexer.start().await; } @@ -68,15 +70,7 @@ async fn EtherFiTVLUpdated(ctx: Context) { let current_tvl = event._currentTvl.to_string(); let log_index = ctx.log.log_index.unwrap() as i64; - let block = ctx - .provider - .get_block_by_number( - BlockNumberOrTag::Number(ctx.log.block_number.unwrap()), - false, - ) - .await - .unwrap() - .unwrap(); + let block = ctx.block().await.unwrap().unwrap(); let block_timestamp = block.header.timestamp as i64;