....
This commit is contained in:
		@@ -2,33 +2,12 @@ use serde::{Deserialize, Serialize};
 | 
			
		||||
use crate::db::{SledModel, Storable};
 | 
			
		||||
use std::collections::HashMap;
 | 
			
		||||
 | 
			
		||||
/// Role represents the role of a member in a circle
 | 
			
		||||
#[derive(Debug, Clone, Serialize, Deserialize)]
 | 
			
		||||
pub enum Role {
 | 
			
		||||
    Admin,
 | 
			
		||||
    Stakeholder,
 | 
			
		||||
    Member,
 | 
			
		||||
    Contributor,
 | 
			
		||||
    Guest,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Member represents a member of a circle
 | 
			
		||||
#[derive(Debug, Clone, Serialize, Deserialize)]
 | 
			
		||||
pub struct Member {
 | 
			
		||||
    pub pubkeys: Vec<String>,     // public keys of the member
 | 
			
		||||
    pub emails: Vec<String>,      // list of emails
 | 
			
		||||
    pub name: String,             // name of the member
 | 
			
		||||
    pub description: String,      // optional description
 | 
			
		||||
    pub role: Role,               // role of the member in the circle
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Circle represents a collection of members (users or other circles)
 | 
			
		||||
#[derive(Debug, Clone, Serialize, Deserialize)]
 | 
			
		||||
pub struct Circle {
 | 
			
		||||
    pub id: u32,                 // unique id
 | 
			
		||||
    pub name: String,            // name of the circle
 | 
			
		||||
    pub description: String,     // optional description
 | 
			
		||||
    pub members: Vec<Member>,    // members of the circle
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl Circle {
 | 
			
		||||
@@ -38,15 +17,9 @@ impl Circle {
 | 
			
		||||
            id,
 | 
			
		||||
            name,
 | 
			
		||||
            description,
 | 
			
		||||
            members: Vec::new(),
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /// Add a member to the circle
 | 
			
		||||
    pub fn add_member(&mut self, member: Member) {
 | 
			
		||||
        self.members.push(member);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /// Returns a map of index keys for this circle
 | 
			
		||||
    pub fn index_keys(&self) -> HashMap<String, String> {
 | 
			
		||||
        let mut keys = HashMap::new();
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										82
									
								
								herodb/src/models/circle/member.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										82
									
								
								herodb/src/models/circle/member.rs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,82 @@
 | 
			
		||||
use serde::{Deserialize, Serialize};
 | 
			
		||||
use crate::db::{SledModel, Storable};
 | 
			
		||||
use std::collections::HashMap;
 | 
			
		||||
 | 
			
		||||
/// Role represents the role of a member in a circle
 | 
			
		||||
#[derive(Debug, Clone, Serialize, Deserialize)]
 | 
			
		||||
pub enum Role {
 | 
			
		||||
    Admin,
 | 
			
		||||
    Stakeholder,
 | 
			
		||||
    Member,
 | 
			
		||||
    Contributor,
 | 
			
		||||
    Guest,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Member represents a member of a circle
 | 
			
		||||
#[derive(Debug, Clone, Serialize, Deserialize)]
 | 
			
		||||
pub struct Member {
 | 
			
		||||
    pub id: u32,                  // unique id
 | 
			
		||||
    pub emails: Vec<String>,      // list of emails
 | 
			
		||||
    pub name: String,             // name of the member
 | 
			
		||||
    pub description: String,      // optional description
 | 
			
		||||
    pub role: Role,               // role of the member in the circle
 | 
			
		||||
    pub contact_ids: Vec<u32>,    // IDs of contacts linked to this member
 | 
			
		||||
    pub wallet_ids: Vec<u32>,     // IDs of wallets owned by this member
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl Member {
 | 
			
		||||
    /// Create a new member
 | 
			
		||||
    pub fn new(id: u32, name: String, description: String, role: Role) -> Self {
 | 
			
		||||
        Self {
 | 
			
		||||
            id,
 | 
			
		||||
            emails: Vec::new(),
 | 
			
		||||
            name,
 | 
			
		||||
            description,
 | 
			
		||||
            role,
 | 
			
		||||
            contact_ids: Vec::new(),
 | 
			
		||||
            wallet_ids: Vec::new(),
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /// Add an email to this member
 | 
			
		||||
    pub fn add_email(&mut self, email: String) {
 | 
			
		||||
        if !self.emails.contains(&email) {
 | 
			
		||||
            self.emails.push(email);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /// Link a contact to this member
 | 
			
		||||
    pub fn link_contact(&mut self, contact_id: u32) {
 | 
			
		||||
        if !self.contact_ids.contains(&contact_id) {
 | 
			
		||||
            self.contact_ids.push(contact_id);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /// Link a wallet to this member
 | 
			
		||||
    pub fn link_wallet(&mut self, wallet_id: u32) {
 | 
			
		||||
        if !self.wallet_ids.contains(&wallet_id) {
 | 
			
		||||
            self.wallet_ids.push(wallet_id);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /// Returns a map of index keys for this member
 | 
			
		||||
    pub fn index_keys(&self) -> HashMap<String, String> {
 | 
			
		||||
        let mut keys = HashMap::new();
 | 
			
		||||
        keys.insert("name".to_string(), self.name.clone());
 | 
			
		||||
        keys
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Implement Storable trait (provides default dump/load)
 | 
			
		||||
impl Storable for Member {}
 | 
			
		||||
 | 
			
		||||
// Implement SledModel trait
 | 
			
		||||
impl SledModel for Member {
 | 
			
		||||
    fn get_id(&self) -> String {
 | 
			
		||||
        self.id.to_string()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn db_prefix() -> &'static str {
 | 
			
		||||
        "member"
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,9 +1,13 @@
 | 
			
		||||
pub mod circle;
 | 
			
		||||
pub mod member;
 | 
			
		||||
pub mod name;
 | 
			
		||||
pub mod wallet;
 | 
			
		||||
 | 
			
		||||
// Re-export all model types for convenience
 | 
			
		||||
pub use circle::{Circle, Member, Role};
 | 
			
		||||
pub use circle::Circle;
 | 
			
		||||
pub use member::{Member, Role};
 | 
			
		||||
pub use name::{Name, Record, RecordType};
 | 
			
		||||
pub use wallet::{Wallet, Asset};
 | 
			
		||||
 | 
			
		||||
// Re-export database components from db module
 | 
			
		||||
pub use crate::db::{SledDB, SledDBError, SledDBResult, Storable, SledModel, DB};
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										84
									
								
								herodb/src/models/circle/wallet.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										84
									
								
								herodb/src/models/circle/wallet.rs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,84 @@
 | 
			
		||||
use serde::{Deserialize, Serialize};
 | 
			
		||||
use crate::db::{SledModel, Storable};
 | 
			
		||||
use std::collections::HashMap;
 | 
			
		||||
 | 
			
		||||
/// Asset represents a cryptocurrency asset in a wallet
 | 
			
		||||
#[derive(Debug, Clone, Serialize, Deserialize)]
 | 
			
		||||
pub struct Asset {
 | 
			
		||||
    pub name: String,     // Asset name (e.g., "USDC")
 | 
			
		||||
    pub amount: f64,      // Amount of the asset
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl Asset {
 | 
			
		||||
    /// Create a new asset
 | 
			
		||||
    pub fn new(name: String, amount: f64) -> Self {
 | 
			
		||||
        Self {
 | 
			
		||||
            name,
 | 
			
		||||
            amount,
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Wallet represents a cryptocurrency wallet
 | 
			
		||||
#[derive(Debug, Clone, Serialize, Deserialize)]
 | 
			
		||||
pub struct Wallet {
 | 
			
		||||
    pub id: u32,                  // unique id
 | 
			
		||||
    pub name: String,             // name of the wallet
 | 
			
		||||
    pub description: String,      // optional description
 | 
			
		||||
    pub blockchain_name: String,  // name of the blockchain
 | 
			
		||||
    pub pubkey: String,           // public key of the wallet
 | 
			
		||||
    pub assets: Vec<Asset>,       // assets in the wallet
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl Wallet {
 | 
			
		||||
    /// Create a new wallet
 | 
			
		||||
    pub fn new(id: u32, name: String, description: String, blockchain_name: String, pubkey: String) -> Self {
 | 
			
		||||
        Self {
 | 
			
		||||
            id,
 | 
			
		||||
            name,
 | 
			
		||||
            description,
 | 
			
		||||
            blockchain_name,
 | 
			
		||||
            pubkey,
 | 
			
		||||
            assets: Vec::new(),
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /// Set an asset in the wallet (replaces if exists, adds if not)
 | 
			
		||||
    pub fn set_asset(&mut self, name: String, amount: f64) {
 | 
			
		||||
        // Check if the asset already exists
 | 
			
		||||
        if let Some(asset) = self.assets.iter_mut().find(|a| a.name == name) {
 | 
			
		||||
            // Update the amount
 | 
			
		||||
            asset.amount = amount;
 | 
			
		||||
        } else {
 | 
			
		||||
            // Add a new asset
 | 
			
		||||
            self.assets.push(Asset::new(name, amount));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /// Get the total value of all assets in the wallet
 | 
			
		||||
    pub fn total_value(&self) -> f64 {
 | 
			
		||||
        self.assets.iter().map(|a| a.amount).sum()
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /// Returns a map of index keys for this wallet
 | 
			
		||||
    pub fn index_keys(&self) -> HashMap<String, String> {
 | 
			
		||||
        let mut keys = HashMap::new();
 | 
			
		||||
        keys.insert("name".to_string(), self.name.clone());
 | 
			
		||||
        keys.insert("blockchain".to_string(), self.blockchain_name.clone());
 | 
			
		||||
        keys
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Implement Storable trait (provides default dump/load)
 | 
			
		||||
impl Storable for Wallet {}
 | 
			
		||||
 | 
			
		||||
// Implement SledModel trait
 | 
			
		||||
impl SledModel for Wallet {
 | 
			
		||||
    fn get_id(&self) -> String {
 | 
			
		||||
        self.id.to_string()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn db_prefix() -> &'static str {
 | 
			
		||||
        "wallet"
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										18
									
								
								herodb/src/models/instructions.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								herodb/src/models/instructions.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
			
		||||
in  @src/models/circle/circle.rs 
 | 
			
		||||
 | 
			
		||||
- member us now new rootobject, check implementation
 | 
			
		||||
- a member is linked to one or more contacts id's (from src/models/mcc/contacts.rs)
 | 
			
		||||
- a member has one or more wallets
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
in@src/models/biz add a ticket module
 | 
			
		||||
 | 
			
		||||
user can have more than 1 ticket which is to ask support from the org
 | 
			
		||||
 | 
			
		||||
a ticket has following fields
 | 
			
		||||
 | 
			
		||||
- subject
 | 
			
		||||
- description
 | 
			
		||||
- creation/update date
 | 
			
		||||
- assignees (based on memberid see above)
 | 
			
		||||
- 
 | 
			
		||||
		Reference in New Issue
	
	Block a user