casper_storage/data_access_layer/
total_supply.rs

1use crate::tracking_copy::TrackingCopyError;
2use casper_types::{Digest, ProtocolVersion, U512};
3
4/// Request for total supply.
5#[derive(Debug, Clone, Copy, PartialEq, Eq)]
6pub struct TotalSupplyRequest {
7    state_hash: Digest,
8    protocol_version: ProtocolVersion,
9}
10
11impl TotalSupplyRequest {
12    /// Creates an instance of TotalSupplyRequest.
13    pub fn new(state_hash: Digest, protocol_version: ProtocolVersion) -> Self {
14        TotalSupplyRequest {
15            state_hash,
16            protocol_version,
17        }
18    }
19
20    /// Returns state root hash.
21    pub fn state_hash(&self) -> Digest {
22        self.state_hash
23    }
24
25    /// Returns the protocol version.
26    pub fn protocol_version(&self) -> ProtocolVersion {
27        self.protocol_version
28    }
29}
30
31/// Represents a result of a `total_supply` request.
32#[derive(Debug)]
33pub enum TotalSupplyResult {
34    /// Invalid state root hash.
35    RootNotFound,
36    /// The mint is not found.
37    MintNotFound,
38    /// Value not found.
39    ValueNotFound(String),
40    /// The total supply at the specified state hash.
41    Success {
42        /// The total supply in motes.
43        total_supply: U512,
44    },
45    /// Failed to get total supply.
46    Failure(TrackingCopyError),
47}