use serde::{Deserialize, Serialize};
use tari_bor::from_value;
use tari_template_abi::rust::collections::BTreeMap;
use tari_template_lib_types::ResourceAddress;
use crate::models::Vault;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Account {
vaults: BTreeMap<ResourceAddress, Vault>,
}
impl Account {
pub fn from_value(value: &tari_bor::Value) -> Result<Self, tari_bor::BorError> {
from_value(value)
}
pub fn vaults(&self) -> &BTreeMap<ResourceAddress, Vault> {
&self.vaults
}
pub fn get_vault_by_resource(&self, resource_address: &ResourceAddress) -> Option<&Vault> {
self.vaults.get(resource_address)
}
pub fn all_resources_iter(&self) -> impl Iterator<Item = &ResourceAddress> {
self.vaults.keys()
}
}