near_jsonrpc_client/methods/experimental/validators_ordered.rs
1//! Returns the ordered validators of a block.
2//!
3//! ## Example
4//!
5//! Returns the ordered validators for this [block](https://explorer.near.org/blocks/3Lq3Mtfpc3spH9oF5dXnUzvCBEqjTQwX1yCqKibwzgWR).
6//!
7//! ```
8//! use near_jsonrpc_client::{methods, JsonRpcClient};
9//! use near_primitives::types::BlockId;
10//!
11//! # #[tokio::main]
12//! # async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
13//! let client = JsonRpcClient::connect("https://archival-rpc.mainnet.fastnear.com");
14//!
15//! let request = methods::EXPERIMENTAL_validators_ordered::RpcValidatorsOrderedRequest {
16//! block_id: Some(BlockId::Hash("Brj839ta6ffccCvDcXzEh7iRak2jCxuc7M3U1cEmRH9k".parse()?))
17//! };
18//!
19//! let response = client.call(request).await?;
20//!
21//! assert!(matches!(
22//! response,
23//! methods::EXPERIMENTAL_validators_ordered::RpcValidatorsOrderedResponse { .. }
24//! ));
25//! # Ok(())
26//! # }
27//! ```
28use super::*;
29
30pub use near_jsonrpc_primitives::types::validator::{
31 RpcValidatorError, RpcValidatorsOrderedRequest, RpcValidatorsOrderedResponse,
32};
33
34impl RpcHandlerResponse for RpcValidatorsOrderedResponse {}
35
36impl RpcMethod for RpcValidatorsOrderedRequest {
37 type Response = RpcValidatorsOrderedResponse;
38 type Error = RpcValidatorError;
39
40 fn method_name(&self) -> &str {
41 "EXPERIMENTAL_validators_ordered"
42 }
43
44 fn params(&self) -> Result<serde_json::Value, io::Error> {
45 Ok(json!(self))
46 }
47}
48
49impl private::Sealed for RpcValidatorsOrderedRequest {}