casper_client/rpcs/v1_4_5/
query_global_state.rs

1use serde::{Deserialize, Serialize};
2
3use casper_types::{Key, ProtocolVersion};
4
5pub use crate::rpcs::common::GlobalStateIdentifier;
6use crate::types::{BlockHeader, StoredValue};
7#[cfg(doc)]
8use crate::BlockIdentifier;
9
10pub(crate) const QUERY_GLOBAL_STATE_METHOD: &str = "query_global_state";
11
12#[derive(Clone, Serialize, Deserialize, Debug)]
13#[serde(deny_unknown_fields)]
14pub(crate) struct QueryGlobalStateParams {
15    state_identifier: GlobalStateIdentifier,
16    // `Key` as formatted string.
17    key: String,
18    path: Vec<String>,
19}
20
21impl QueryGlobalStateParams {
22    pub(crate) fn new(
23        state_identifier: GlobalStateIdentifier,
24        key: Key,
25        path: Vec<String>,
26    ) -> Self {
27        QueryGlobalStateParams {
28            state_identifier,
29            key: key.to_formatted_string(),
30            path,
31        }
32    }
33}
34
35/// The `result` field of a successful JSON-RPC response to a `query_global_state` request.
36#[derive(Serialize, Deserialize, Debug)]
37#[serde(deny_unknown_fields)]
38pub struct QueryGlobalStateResult {
39    /// The JSON-RPC server version.
40    pub api_version: ProtocolVersion,
41    /// The block header if the query was made using a block hash.
42    pub block_header: Option<BlockHeader>,
43    /// The stored value.
44    pub stored_value: StoredValue,
45    /// The merkle proof of the value.
46    pub merkle_proof: String,
47}