1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//! Returns the changes in a block.
//!
//! 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.
//!
//! ## Example
//!
//! Returns the changes in block for <https://explorer.unc.org/blocks/3Lq3Mtfpc3spH9oF5dXnUzvCBEqjTQwX1yCqKibwzgWR>
//!
//! 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.
//!
//! ```
//! use unc_jsonrpc_client::{methods, JsonRpcClient};
//! use unc_primitives::types::{BlockReference, BlockId};
//!
//! # #[tokio::main]
//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let client = JsonRpcClient::connect("https://archival-rpc.mainnet.unc.org");
//!
//! let request = methods::EXPERIMENTAL_changes_in_block::RpcStateChangesInBlockRequest {
//!     block_reference: BlockReference::BlockId(BlockId::Height(47988413))
//! };
//!
//! let response = client.call(request).await?;
//!
//! assert!(matches!(
//!     response,
//!     methods::EXPERIMENTAL_changes_in_block::RpcStateChangesInBlockByTypeResponse { .. }
//! ));
//! # Ok(())
//! # }
//! ```
use super::*;

pub use unc_jsonrpc_primitives::types::changes::{
    RpcStateChangesError, RpcStateChangesInBlockByTypeResponse, RpcStateChangesInBlockRequest,
};

impl RpcHandlerResponse for RpcStateChangesInBlockByTypeResponse {}

impl RpcMethod for RpcStateChangesInBlockRequest {
    type Response = RpcStateChangesInBlockByTypeResponse;
    type Error = RpcStateChangesError;

    fn method_name(&self) -> &str {
        "EXPERIMENTAL_changes_in_block"
    }

    fn params(&self) -> Result<serde_json::Value, io::Error> {
        Ok(json!(self))
    }
}

impl private::Sealed for RpcStateChangesInBlockRequest {}