#![allow(warnings)] use anyhow::Error; use sdk_common::crypto::AnkSharedSecret; use sdk_common::network::CachedMessage; use sdk_common::pcd::AnkPcdHash; use sdk_common::prd::Prd; use sdk_common::process::Process; use sdk_common::signature::Proof; use sdk_common::sp_client::bitcoin::OutPoint; use sdk_common::uuid::Uuid; use sdk_common::MutexExt; use serde::{Deserialize, Serialize}; use serde_json::{Map, Value}; use std::collections::{HashMap, HashSet}; use std::fmt::Debug; use std::ops::Index; use std::sync::{Mutex, MutexGuard, OnceLock}; use tsify::Tsify; pub mod api; mod peers; mod user; mod wallet; pub static CACHEDMESSAGES: OnceLock>> = OnceLock::new(); pub fn lock_messages() -> Result>, Error> { CACHEDMESSAGES .get_or_init(|| Mutex::new(vec![])) .lock_anyhow() } // TODO move to sdk-common #[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)] pub struct ProcessState { pub commited_in: OutPoint, pub encrypted_pcd: Value, pub keys: Map, // We may not always have all the keys pub validation_token: Vec, // This signs the encrypted pcd } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct RelevantProcess { states: Vec, shared_secrets: HashMap, impending_requests: Vec, } impl RelevantProcess { pub fn get_status_at(&self, index: usize) -> Option { self.states.get(index).cloned() } pub fn get_latest_state(&self) -> Option { self.states.last().cloned() } pub fn get_impending_requests(&self) -> Vec { self.impending_requests.clone() } } pub static CACHEDPROCESSES: OnceLock>> = OnceLock::new(); pub fn lock_processes() -> Result>, Error> { CACHEDPROCESSES .get_or_init(|| Mutex::new(HashMap::new())) .lock_anyhow() }