use std::collections::BTreeSet;
use tari_template_lib::{
models::BucketId,
types::{Amount, NonFungibleId, ResourceAddress, ResourceType, VaultId},
};
use crate::resource_container::ResourceContainer;
#[derive(Debug, Clone)]
pub struct Proof {
locked: LockedResource,
}
impl Proof {
pub fn new(locked: LockedResource) -> Self {
Self { locked }
}
pub fn amount(&self) -> Amount {
self.locked.amount()
}
pub fn resource_address(&self) -> &ResourceAddress {
self.locked.resource_address()
}
pub fn non_fungible_token_ids(&self) -> &BTreeSet<NonFungibleId> {
self.locked.non_fungible_token_ids()
}
pub fn resource_type(&self) -> ResourceType {
self.locked.resource_type()
}
pub fn container(&self) -> &ContainerRef {
&self.locked.container
}
pub fn into_resource_container(self) -> ResourceContainer {
self.locked.into_resource_container()
}
}
#[derive(Debug, Clone, Copy)]
pub enum ContainerRef {
Bucket(BucketId),
Vault(VaultId),
Runtime,
}
#[derive(Debug, Clone)]
pub struct LockedResource {
container: ContainerRef,
locked: ResourceContainer,
}
impl LockedResource {
pub fn new(container: ContainerRef, locked: ResourceContainer) -> Self {
Self { container, locked }
}
pub fn amount(&self) -> Amount {
self.locked.unlocked_amount()
}
pub fn resource_address(&self) -> &ResourceAddress {
self.locked.resource_address()
}
pub fn non_fungible_token_ids(&self) -> &BTreeSet<NonFungibleId> {
self.locked.non_fungible_token_ids()
}
pub fn resource_type(&self) -> ResourceType {
self.locked.resource_type()
}
pub fn container(&self) -> &ContainerRef {
&self.container
}
pub fn into_resource_container(self) -> ResourceContainer {
self.locked
}
}