near_jsonrpc_primitives/types/
receipts.rs1#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
2#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
3pub struct ReceiptReference {
4 pub receipt_id: near_primitives::hash::CryptoHash,
5}
6
7#[derive(serde::Serialize, serde::Deserialize, Debug)]
8#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
9pub struct RpcReceiptRequest {
10 #[serde(flatten)]
11 pub receipt_reference: ReceiptReference,
12}
13
14#[derive(serde::Serialize, serde::Deserialize, Debug)]
15#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
16pub struct RpcReceiptResponse {
17 #[serde(flatten)]
18 pub receipt_view: near_primitives::views::ReceiptView,
19}
20
21#[derive(thiserror::Error, Debug, Clone, serde::Serialize, serde::Deserialize)]
22#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
23#[serde(tag = "name", content = "info", rename_all = "SCREAMING_SNAKE_CASE")]
24pub enum RpcReceiptError {
25 #[error("The node reached its limits. Try again later. More details: {error_message}")]
26 InternalError { error_message: String },
27 #[error("Receipt with id {receipt_id} has never been observed on this node")]
28 UnknownReceipt { receipt_id: near_primitives::hash::CryptoHash },
29}
30
31impl From<RpcReceiptError> for crate::errors::RpcError {
32 fn from(error: RpcReceiptError) -> Self {
33 let error_data = match serde_json::to_value(error) {
34 Ok(value) => value,
35 Err(err) => {
36 return Self::new_internal_error(
37 None,
38 format!("Failed to serialize RpcReceiptError: {:?}", err),
39 );
40 }
41 };
42 Self::new_internal_or_handler_error(Some(error_data.clone()), error_data)
43 }
44}