-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(protos-examples): clean up rust doc landing page
- Loading branch information
1 parent
39e8fe7
commit 6103a38
Showing
3 changed files
with
47 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
//! # Firehose Protos Examples | ||
//! | ||
//! Examples that use methods implemented on the Rust-compiled Firehose | ||
//! protobuffer types from [Firehose Protos](../firehose_protos/index.html). | ||
//! | ||
//! ## Running Examples | ||
//! | ||
//! To run the examples, you need access to a Firehose provider for each chain from which you want | ||
//! to extract data - an endpoint and an API key (if the latter is required). | ||
//! | ||
//! Add your endpoint and API key to a `.env` file in the root of the repository. See `.env.examples` for | ||
//! a configuration template. | ||
//! | ||
//! To run individual examples, use the following command: | ||
//! | ||
//! ```bash | ||
//! cargo run -p firehose-protos-examples --example <example_name> | ||
//! ``` | ||
//! | ||
//! ## Calculate a Block Receipts Root and Compare it to the Receipts Root in the Block Header | ||
//! | ||
//! ### Example name: `receipt_root` | ||
//! | ||
//! ```no_run | ||
//! //! examples/receipt_root.rs | ||
//! | ||
//! # use alloy_primitives::FixedBytes; | ||
//! # use firehose_client::{Chain, FirehoseClient}; | ||
//! # use firehose_protos::EthBlock as Block; | ||
//! # const BLOCK_NUMBER: u64 = 20672593; | ||
//! # #[tokio::main] | ||
//! # async fn main() { | ||
//! # let mut client = FirehoseClient::new(Chain::Ethereum); | ||
//! # let response = client.fetch_block(BLOCK_NUMBER).await.unwrap().unwrap(); | ||
//! # let block = Block::try_from(response.into_inner()).unwrap(); | ||
//! let calculated_receipts_root = block.calculate_receipt_root().unwrap(); | ||
//! // Compare the calculated receipts root to the receipts root in the block header | ||
//! assert_eq!( | ||
//! FixedBytes::<32>::from_slice(block.header.as_ref().unwrap().receipt_root.as_slice()), | ||
//! calculated_receipts_root | ||
//! ); | ||
//! # } | ||
//! ``` | ||
//! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters