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
use near_primitives_v01::state_record::StateRecord;
use serde::{Deserialize, Serialize};
use serde_json::Value;
#[derive(Deserialize, Serialize)]
pub struct RpcSandboxPatchStateRequest {
pub records: Vec<StateRecord>,
}
impl RpcSandboxPatchStateRequest {
pub fn parse(value: Option<Value>) -> Result<Self, crate::errors::RpcParseError> {
Ok(crate::utils::parse_params::<RpcSandboxPatchStateRequest>(value)?)
}
}
#[derive(Deserialize, Serialize)]
pub struct RpcSandboxPatchStateResponse {}
#[derive(thiserror::Error, Debug, Serialize, Deserialize)]
#[serde(tag = "name", content = "info", rename_all = "SCREAMING_SNAKE_CASE")]
pub enum RpcSandboxPatchStateError {
#[error("The node reached its limits. Try again later. More details: {error_message}")]
InternalError { error_message: String },
}
impl From<actix::MailboxError> for RpcSandboxPatchStateError {
fn from(error: actix::MailboxError) -> Self {
Self::InternalError { error_message: error.to_string() }
}
}
impl From<RpcSandboxPatchStateError> for crate::errors::RpcError {
fn from(error: RpcSandboxPatchStateError) -> Self {
let error_data = match serde_json::to_value(error) {
Ok(value) => value,
Err(err) => {
return Self::new_internal_error(
None,
format!("Failed to serialize RpcSandboxPatchStateError: {:?}", err),
)
}
};
Self::new_internal_or_handler_error(Some(error_data.clone()), error_data)
}
}