casper_client/rpcs/
common.rs

1//! Common types associated with sending and receiving JSON-RPCs.
2
3use serde::{Deserialize, Serialize};
4
5#[cfg(doc)]
6use casper_types::Block;
7use casper_types::{
8    contract_messages::Messages, execution::Effects, BlockHash, Digest, Gas, Transfer,
9};
10
11/// Enum of possible ways to identify a [`Block`].
12#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Hash, Serialize, Deserialize, Debug)]
13#[serde(deny_unknown_fields)]
14pub enum BlockIdentifier {
15    /// Identify the block by its hash.
16    Hash(BlockHash),
17    /// Identify the block by its height.
18    Height(u64),
19}
20
21/// Identifier for possible ways to query global state.
22///
23/// Soon to be deprecated in favour of [`BlockIdentifier`].
24#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Hash, Serialize, Deserialize, Debug)]
25#[serde(deny_unknown_fields)]
26pub enum GlobalStateIdentifier {
27    /// Query using the state root hash in the given block, identified by its block hash.
28    BlockHash(BlockHash),
29    /// Query using the state root hash in the given block, identified by its block height.
30    BlockHeight(u64),
31    /// Query using the state root hash.
32    StateRootHash(Digest),
33}
34
35/// The result of a speculative execution.
36#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
37pub struct SpeculativeExecutionResult {
38    /// Block hash against which the execution was performed.
39    pub block_hash: BlockHash,
40    /// List of transfers that happened during execution.
41    pub transfers: Vec<Transfer>,
42    /// Gas limit.
43    pub limit: Gas,
44    /// Gas consumed.
45    pub consumed: Gas,
46    /// Execution effects.
47    pub effects: Effects,
48    /// Messages emitted during execution.
49    pub messages: Messages,
50    /// Did the wasm execute successfully?
51    pub error: Option<String>,
52}