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 57 58
//! Patch account, access keys, contract code, or contract state.
//!
//! Only additions and mutations are supported. No deletions.
//!
//! Account, access keys, contract code, and contract states have different formats. See the example and docs for details about their format.
//!
//! ## Examples
//!
//! ```
//! use unc_jsonrpc_client::{methods, JsonRpcClient};
//! use unc_primitives::{state_record::StateRecord, account, types::AccountId, hash::CryptoHash};
//!
//! # #[tokio::main]
//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let client = JsonRpcClient::connect("http://localhost:3030");
//!
//! let request = methods::sandbox_patch_state::RpcSandboxPatchStateRequest {
//! records: vec![
//! StateRecord::Account {
//! account_id: "fido.testnet".parse::<AccountId>()?,
//! account: account::Account::new(179, 0, CryptoHash::default(), 264)
//! }
//! ],
//! };
//!
//! let response = client.call(request).await?;
//!
//! assert!(matches!(
//! response,
//! methods::sandbox_patch_state::RpcSandboxPatchStateResponse { .. }
//! ));
//! # Ok(())
//! # }
//! ```
use super::*;
pub use unc_jsonrpc_primitives::types::sandbox::{
RpcSandboxPatchStateError, RpcSandboxPatchStateRequest, RpcSandboxPatchStateResponse,
};
impl RpcHandlerResponse for RpcSandboxPatchStateResponse {}
impl RpcHandlerError for RpcSandboxPatchStateError {}
impl RpcMethod for RpcSandboxPatchStateRequest {
type Response = RpcSandboxPatchStateResponse;
type Error = RpcSandboxPatchStateError;
fn method_name(&self) -> &str {
"sandbox_patch_state"
}
fn params(&self) -> Result<serde_json::Value, io::Error> {
Ok(json!(self))
}
}
impl private::Sealed for RpcSandboxPatchStateRequest {}