From f5c5c3f46e2714ae7e3b6e25b69604c6b6473cd0 Mon Sep 17 00:00:00 2001 From: Femi Bankole Date: Fri, 22 Dec 2023 13:29:28 +0100 Subject: [PATCH] chore(docs): document the `sandbox_patch_state` RPC method (#81) --- src/methods/sandbox/patch_state.rs | 34 ++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/methods/sandbox/patch_state.rs b/src/methods/sandbox/patch_state.rs index 25f16290..0015e7b7 100644 --- a/src/methods/sandbox/patch_state.rs +++ b/src/methods/sandbox/patch_state.rs @@ -1,3 +1,37 @@ +//! 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 near_jsonrpc_client::{methods, JsonRpcClient}; +//! use near_primitives::{state_record::StateRecord, account, types::AccountId, hash::CryptoHash}; +//! +//! # #[tokio::main] +//! # async fn main() -> Result<(), Box> { +//! let client = JsonRpcClient::connect("http://localhost:3030"); +//! +//! let request = methods::sandbox_patch_state::RpcSandboxPatchStateRequest { +//! records: vec![ +//! StateRecord::Account { +//! account_id: "fido.testnet".parse::()?, +//! 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 near_jsonrpc_primitives::types::sandbox::{