Skip to main content

casper_client/rpcs/v1_6_0/
query_global_state.rs

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