near_jsonrpc_client/methods/light_client_proof.rs
1//! Returns the proofs for a transaction execution.
2//!
3//! ```
4//! use near_jsonrpc_client::{methods, JsonRpcClient};
5//! use near_primitives::types::TransactionOrReceiptId;
6//!
7//! # #[tokio::main]
8//! # async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
9//! let client = JsonRpcClient::connect("https://archival-rpc.mainnet.fastnear.com");
10//!
11//! let request = methods::light_client_proof::RpcLightClientExecutionProofRequest {
12//! id: TransactionOrReceiptId::Transaction {
13//! transaction_hash: "47sXP4jKXCMpkUS6kcxsfNU7tqysYr5fxWFdEXQkZh6z".parse()?,
14//! sender_id: "aurora.pool.near".parse()?,
15//! },
16//! light_client_head: "ANm3jm5wq1Z4rJv6tXWyiDtC3wYKpXVHY4iq6bE1te7B".parse()?,
17//! };
18//!
19//! let response = client.call(request).await?;
20//!
21//! assert!(matches!(
22//! response,
23//! methods::light_client_proof::RpcLightClientExecutionProofResponse { .. }
24//! ));
25//! Ok(())
26//! # }
27//! ```
28use super::*;
29
30pub use near_jsonrpc_primitives::types::light_client::{
31 RpcLightClientExecutionProofRequest, RpcLightClientExecutionProofResponse,
32 RpcLightClientProofError,
33};
34
35impl RpcHandlerResponse for RpcLightClientExecutionProofResponse {}
36
37impl RpcHandlerError for RpcLightClientProofError {
38 fn parse(value: serde_json::Value) -> Result<Self, serde_json::Error> {
39 common::parse_unknown_block!(value => Self)
40 }
41}
42
43impl RpcMethod for RpcLightClientExecutionProofRequest {
44 type Response = RpcLightClientExecutionProofResponse;
45 type Error = RpcLightClientProofError;
46
47 fn method_name(&self) -> &str {
48 "light_client_proof"
49 }
50
51 fn params(&self) -> Result<serde_json::Value, io::Error> {
52 Ok(json!(self))
53 }
54}
55
56impl private::Sealed for RpcLightClientExecutionProofRequest {}