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
54
55
56
//! Returns the proofs for a transaction execution.
//!
//! ```
//! use unc_jsonrpc_client::{methods, JsonRpcClient};
//! use unc_primitives::types::TransactionOrReceiptId;
//!
//! # #[tokio::main]
//! # async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
//! let client = JsonRpcClient::connect("https://archival-rpc.mainnet.unc.org");
//!
//! let request = methods::light_client_proof::RpcLightClientExecutionProofRequest {
//!     id: TransactionOrReceiptId::Transaction {
//!         transaction_hash: "47sXP4jKXCMpkUS6kcxsfNU7tqysYr5fxWFdEXQkZh6z".parse()?,
//!         sender_id: "aurora.pool.unc".parse()?,
//!     },
//!     light_client_head: "ANm3jm5wq1Z4rJv6tXWyiDtC3wYKpXVHY4iq6bE1te7B".parse()?,
//! };
//!
//! let response = client.call(request).await?;
//!
//! assert!(matches!(
//!     response,
//!     methods::light_client_proof::RpcLightClientExecutionProofResponse { .. }
//! ));
//! Ok(())
//! # }
//! ```
use super::*;

pub use unc_jsonrpc_primitives::types::light_client::{
    RpcLightClientExecutionProofRequest, RpcLightClientExecutionProofResponse,
    RpcLightClientProofError,
};

impl RpcHandlerResponse for RpcLightClientExecutionProofResponse {}

impl RpcHandlerError for RpcLightClientProofError {
    fn parse(value: serde_json::Value) -> Result<Self, serde_json::Error> {
        common::parse_unknown_block!(value => Self)
    }
}

impl RpcMethod for RpcLightClientExecutionProofRequest {
    type Response = RpcLightClientExecutionProofResponse;
    type Error = RpcLightClientProofError;

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

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

impl private::Sealed for RpcLightClientExecutionProofRequest {}