use crate::tracking_copy::TrackingCopyError;
use casper_types::{Digest, EntryPointValue, HashAddr};
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct EntryPointRequest {
state_hash: Digest,
entry_point_name: String,
contract_hash: HashAddr,
}
impl EntryPointRequest {
pub fn new(state_hash: Digest, entry_point_name: String, contract_hash: HashAddr) -> Self {
EntryPointRequest {
state_hash,
entry_point_name,
contract_hash,
}
}
pub fn state_hash(&self) -> Digest {
self.state_hash
}
pub fn entry_point_name(&self) -> &str {
&self.entry_point_name
}
pub fn contract_hash(&self) -> HashAddr {
self.contract_hash
}
}
impl From<EntryPointExistsRequest> for EntryPointRequest {
fn from(value: EntryPointExistsRequest) -> Self {
EntryPointRequest {
state_hash: value.state_hash,
entry_point_name: value.entry_point_name,
contract_hash: value.contract_hash,
}
}
}
#[derive(Debug)]
pub enum EntryPointResult {
RootNotFound,
ValueNotFound(String),
Success {
entry_point: EntryPointValue,
},
Failure(TrackingCopyError),
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct EntryPointExistsRequest {
state_hash: Digest,
entry_point_name: String,
contract_hash: HashAddr,
}
impl EntryPointExistsRequest {
pub fn new(state_hash: Digest, entry_point_name: String, contract_hash: HashAddr) -> Self {
EntryPointExistsRequest {
state_hash,
entry_point_name,
contract_hash,
}
}
pub fn state_hash(&self) -> Digest {
self.state_hash
}
pub fn entry_point_name(&self) -> &str {
&self.entry_point_name
}
pub fn contract_hash(&self) -> HashAddr {
self.contract_hash
}
}
#[derive(Debug)]
pub enum EntryPointExistsResult {
RootNotFound,
ValueNotFound(String),
Success,
Failure(TrackingCopyError),
}
impl EntryPointExistsResult {
pub fn is_success(self) -> bool {
matches!(self, Self::Success { .. })
}
}