1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use crate::tracking_copy::TrackingCopyError;
use casper_types::{Contract, Digest, Key};
/// Represents a request to obtain contract.
pub struct ContractRequest {
state_hash: Digest,
key: Key,
}
impl ContractRequest {
/// ctor
pub fn new(state_hash: Digest, key: Key) -> Self {
ContractRequest { state_hash, key }
}
/// Returns key.
pub fn key(&self) -> Key {
self.key
}
/// Returns state root hash.
pub fn state_hash(&self) -> Digest {
self.state_hash
}
}
/// Represents a result of a `contract` request.
#[derive(Debug)]
pub enum ContractResult {
/// Invalid state root hash.
RootNotFound,
/// Value not found.
ValueNotFound(String),
/// This variant will be returned if the contract was found.
Success {
/// A contract.
contract: Contract,
},
/// Failure result.
Failure(TrackingCopyError),
}