unc_jsonrpc_client/methods/experimental/changes_in_block.rs
1//! Returns the changes in a block.
2//!
3//! The `RpcStateChangesInBlockRequest` takes in a [`BlockReference`](https://docs.rs/unc-primitives/0.12.0/unc_primitives/types/enum.BlockReference.html) enum which has multiple variants.
4//!
5//! ## Example
6//!
7//! Returns the changes in block for <https://explorer.unc.org/blocks/3Lq3Mtfpc3spH9oF5dXnUzvCBEqjTQwX1yCqKibwzgWR>
8//!
9//! You can also use the `Finality` and `SyncCheckpoint` variants of [`BlockReference`](https://docs.rs/unc-primitives/0.12.0/unc_primitives/types/enum.BlockReference.html) to return block change details.
10//!
11//! ```
12//! use unc_jsonrpc_client::{methods, JsonRpcClient};
13//! use unc_primitives::types::{BlockReference, BlockId};
14//!
15//! # #[tokio::main]
16//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
17//! let client = JsonRpcClient::connect("https://archival-rpc.mainnet.unc.org");
18//!
19//! let request = methods::EXPERIMENTAL_changes_in_block::RpcStateChangesInBlockRequest {
20//! block_reference: BlockReference::BlockId(BlockId::Height(47988413))
21//! };
22//!
23//! let response = client.call(request).await?;
24//!
25//! assert!(matches!(
26//! response,
27//! methods::EXPERIMENTAL_changes_in_block::RpcStateChangesInBlockByTypeResponse { .. }
28//! ));
29//! # Ok(())
30//! # }
31//! ```
32use super::*;
33
34pub use unc_jsonrpc_primitives::types::changes::{
35 RpcStateChangesError, RpcStateChangesInBlockByTypeResponse, RpcStateChangesInBlockRequest,
36};
37
38impl RpcHandlerResponse for RpcStateChangesInBlockByTypeResponse {}
39
40impl RpcMethod for RpcStateChangesInBlockRequest {
41 type Response = RpcStateChangesInBlockByTypeResponse;
42 type Error = RpcStateChangesError;
43
44 fn method_name(&self) -> &str {
45 "EXPERIMENTAL_changes_in_block"
46 }
47
48 fn params(&self) -> Result<serde_json::Value, io::Error> {
49 Ok(json!(self))
50 }
51}
52
53impl private::Sealed for RpcStateChangesInBlockRequest {}