...
This commit is contained in:
		
							
								
								
									
										69
									
								
								specs/models_heroledger/main/dnsrecord.v
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										69
									
								
								specs/models_heroledger/main/dnsrecord.v
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,69 @@
 | 
			
		||||
module circle
 | 
			
		||||
 | 
			
		||||
import freeflowuniverse.herolib.hero.models.core
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
pub struct DNSZone {
 | 
			
		||||
	core.Base
 | 
			
		||||
pub mut:
 | 
			
		||||
	domain      string @[index] // The actual domain name
 | 
			
		||||
	dnsrecords []DNSRecord
 | 
			
		||||
	administrators []u32
 | 
			
		||||
	status DNSZoneStatus     // active, suspended, etc.
 | 
			
		||||
	metadata map[string]string
 | 
			
		||||
	soarecord []SOARecord  //one soa record per zone, last one is valid, rest is for history
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// Name represents a domain name configuration for a circle
 | 
			
		||||
pub struct DNSRecord {
 | 
			
		||||
pub mut:
 | 
			
		||||
	subdomain   string   // Optional subdomain e.g. main, means mail.example.com, example.com would be the domain, here only 'mail'
 | 
			
		||||
	record_type NameType // Type of DNS record
 | 
			
		||||
	value       string   // DNS record value/target
 | 
			
		||||
	priority    u32      // Priority for MX records
 | 
			
		||||
	ttl         u32      // Time to live in seconds
 | 
			
		||||
	is_active   bool     // Whether this record is currently active
 | 
			
		||||
	cat         NameCat  // Category of the DNS record, e.g., ipv4, ipv6, mycelium
 | 
			
		||||
	is_wildcard bool // Whether this is a wildcard record
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// NameType defines the supported DNS record types
 | 
			
		||||
pub enum NameType {
 | 
			
		||||
	a
 | 
			
		||||
	aaaa
 | 
			
		||||
	cname
 | 
			
		||||
	mx
 | 
			
		||||
	txt
 | 
			
		||||
	srv
 | 
			
		||||
	ptr
 | 
			
		||||
	ns
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pub enum NameCat {
 | 
			
		||||
	ipv4
 | 
			
		||||
	ipv6
 | 
			
		||||
	mycelium
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pub enum DNSZoneStatus {
 | 
			
		||||
	active
 | 
			
		||||
	suspended
 | 
			
		||||
	archived
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// SOA (Start of Authority) record for a DNS zone
 | 
			
		||||
pub struct SOARecord {
 | 
			
		||||
pub mut:
 | 
			
		||||
	zone_id        u32     // Reference to DNSZone
 | 
			
		||||
	primary_ns     string  // Primary nameserver (e.g., ns1.example.com)
 | 
			
		||||
	admin_email    string  // Responsible party's email (e.g., admin.example.com)
 | 
			
		||||
	serial         u64     // Serial number of the zone file, needs to be incremented on changes
 | 
			
		||||
	refresh        u32 = 3600     // Time before zone should be refreshed (in seconds)
 | 
			
		||||
	retry          u32 = 600    // Time before retry if refresh fails (in seconds)
 | 
			
		||||
	expire         u32 = 604800    // Time before zone is considered no longer authoritative
 | 
			
		||||
	minimum_ttl    u32 = 3600     // Default TTL for records without explicit TTL
 | 
			
		||||
	is_active      bool = true   // Whether this SOA record is active
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										51
									
								
								specs/models_heroledger/main/group.v
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								specs/models_heroledger/main/group.v
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,51 @@
 | 
			
		||||
module group
 | 
			
		||||
 | 
			
		||||
import freeflowuniverse.herolib.hero.models.core
 | 
			
		||||
 | 
			
		||||
// Group represents a collaborative or access-controlled unit within the system
 | 
			
		||||
@[heap]
 | 
			
		||||
pub struct Group {
 | 
			
		||||
	core.Base
 | 
			
		||||
pub mut:
 | 
			
		||||
	name           string        // Human-readable name of the group @[index]
 | 
			
		||||
	description    string        // Detailed explanation of the group's purpose
 | 
			
		||||
	dnsrecords     []u32         // DNSRecord IDs associated with this group (if any)
 | 
			
		||||
	administrators []u32         // User IDs with admin rights over the group
 | 
			
		||||
	config         GroupConfig   // Configuration settings for group behavior
 | 
			
		||||
	status         GroupStatus   // Current operational state
 | 
			
		||||
	visibility     Visibility    // Who can see this group
 | 
			
		||||
	created        u64           // Unix timestamp when the group was created
 | 
			
		||||
	updated        u64           // Unix timestamp when the group was last updated
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@[heap]
 | 
			
		||||
pub struct UserGroupMembership {
 | 
			
		||||
	core.Base
 | 
			
		||||
pub mut:
 | 
			
		||||
	user_id      u32      @[index]    // Reference to the user entity 
 | 
			
		||||
	group_ids    []u32    @[index]      // Reference to the group entity
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GroupConfig holds rules that govern group membership and behavior
 | 
			
		||||
pub struct GroupConfig {
 | 
			
		||||
pub mut:
 | 
			
		||||
	max_members   u32    // Maximum number of users allowed
 | 
			
		||||
	allow_guests  bool   // Whether guest users (unregistered or read-only) can access
 | 
			
		||||
	auto_approve  bool   // Whether member join requests are auto-approved
 | 
			
		||||
	require_invite bool  // Whether joining the group requires an explicit invitation
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GroupStatus defines the lifecycle of a group
 | 
			
		||||
pub enum GroupStatus {
 | 
			
		||||
	active
 | 
			
		||||
	inactive
 | 
			
		||||
	suspended
 | 
			
		||||
	archived
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Visibility controls who can discover or view the group
 | 
			
		||||
pub enum Visibility {
 | 
			
		||||
	public          // Anyone can see and request to join
 | 
			
		||||
	private         // Only invited users can see the group
 | 
			
		||||
	unlisted        // Not visible in search; only accessible by direct link or DNS
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										34
									
								
								specs/models_heroledger/main/membership.v
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								specs/models_heroledger/main/membership.v
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,34 @@
 | 
			
		||||
module circle
 | 
			
		||||
 | 
			
		||||
import freeflowuniverse.herolib.hero.models.core
 | 
			
		||||
 | 
			
		||||
> STILL WRONG
 | 
			
		||||
 | 
			
		||||
// Member represents a member within a circle
 | 
			
		||||
pub struct Member {
 | 
			
		||||
	core.Base
 | 
			
		||||
pub mut:
 | 
			
		||||
	user_id     u32          // Reference to the user entity @[index]
 | 
			
		||||
	role        MemberRole   // Member's role within the circle
 | 
			
		||||
	status      MemberStatus // Current membership status
 | 
			
		||||
	joined_at   u64          // Unix timestamp when member joined
 | 
			
		||||
	invited_by  u32          // User ID of who invited this member
 | 
			
		||||
	permissions []string     // List of custom permissions
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// MemberRole defines the possible roles a member can have
 | 
			
		||||
pub enum MemberRole {
 | 
			
		||||
	owner
 | 
			
		||||
	admin
 | 
			
		||||
	moderator
 | 
			
		||||
	member
 | 
			
		||||
	guest
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// MemberStatus represents the current status of membership
 | 
			
		||||
pub enum MemberStatus {
 | 
			
		||||
	active
 | 
			
		||||
	pending
 | 
			
		||||
	suspended
 | 
			
		||||
	removed
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										94
									
								
								specs/models_heroledger/main/money.v
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										94
									
								
								specs/models_heroledger/main/money.v
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,94 @@
 | 
			
		||||
module circle
 | 
			
		||||
 | 
			
		||||
import freeflowuniverse.herolib.hero.models.core
 | 
			
		||||
 | 
			
		||||
// Wallet represents a wallet associated with a circle for financial operations
 | 
			
		||||
pub struct Account {
 | 
			
		||||
	core.Base
 | 
			
		||||
pub mut:
 | 
			
		||||
	owner_id     u32          // Reference to the user who owns this account, owner not necessarily has admin rights
 | 
			
		||||
	address       string       // Blockchain address for this wallet @[index]
 | 
			
		||||
	balance       f64          // Current balance in the wallet
 | 
			
		||||
	currency      string       // Currency type (e.g., "USD", "BTC", "ETH")
 | 
			
		||||
	assetid	   u32
 | 
			
		||||
	last_activity u64          // Unix timestamp of last transaction
 | 
			
		||||
	administrators []u32 	   // List of user IDs who are super admins, they have all rights, without any treashold
 | 
			
		||||
	accountpolicy u32 		   // Policy for signing transactions, 0 means none
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
pub struct Asset {
 | 
			
		||||
	core.Base
 | 
			
		||||
pub mut:
 | 
			
		||||
	address       string       // Blockchain address for this asset @[index]
 | 
			
		||||
	assetid      u32          // Unique identifier for the asset (e.g., "USD", "BTC", "ETH")
 | 
			
		||||
	asset_type    string    // "fiat", "crypto", "stablecoin", etc.
 | 
			
		||||
	issuer        u32       // Issuer account
 | 
			
		||||
	supply        f64       // Total circulating supply
 | 
			
		||||
	decimals      u8        // Decimal precision (e.g., 2 for cents)
 | 
			
		||||
	is_frozen     bool      // Whether the asset is frozen globally
 | 
			
		||||
	metadata     map[string]string // Additional metadata associated with the asset
 | 
			
		||||
	administrators []u32 	   
 | 
			
		||||
	min_signatures u32         // Minimum number of signatures required for change of properties, linked to administrators
 | 
			
		||||
 | 
			
		||||
	//BLOCKCHAIN 
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
pub struct AccountPolicy {
 | 
			
		||||
	core.Base
 | 
			
		||||
pub mut:
 | 
			
		||||
	transferpolicy  AccountPolicyItem //can transfer money
 | 
			
		||||
	adminpolicy  AccountPolicyItem   //can change other policies 
 | 
			
		||||
	clawbackpolicy AccountPolicyItem // Policy for clawback money
 | 
			
		||||
	freezepolicy   AccountPolicyItem // Policy for freezing, unfreezing funds
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pub struct AccountPolicyItem {
 | 
			
		||||
pub mut:
 | 
			
		||||
	signers       []u32       // List of user IDs who are authorized to sign transactions
 | 
			
		||||
	min_signatures u32         // Minimum number of signatures required for a transaction
 | 
			
		||||
	enabled      bool        // Whether clawback is enabled for this account
 | 
			
		||||
	threshold    f64         // Threshold amount for triggering clawback
 | 
			
		||||
	recipient    u32        // Account ID of the recipient for clawback funds
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pub enum AccountStatus {
 | 
			
		||||
	active
 | 
			
		||||
	inactive
 | 
			
		||||
	suspended
 | 
			
		||||
	archived
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
pub struct Transaction {
 | 
			
		||||
	core.Base
 | 
			
		||||
pub mut:
 | 
			
		||||
	txid u32 // Unique identifier for the transaction
 | 
			
		||||
	source        u32
 | 
			
		||||
	destination   u32
 | 
			
		||||
	assetid       u32
 | 
			
		||||
	amount        f64
 | 
			
		||||
	timestamp     u64
 | 
			
		||||
	status        string // pending, confirmed, failed
 | 
			
		||||
	memo          string
 | 
			
		||||
	tx_type       TransactionType // transfer, clawback, freeze, issue, etc.
 | 
			
		||||
	signatures     []Signature
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
pub enum AccountStatus {
 | 
			
		||||
	active
 | 
			
		||||
	inactive
 | 
			
		||||
	suspended
 | 
			
		||||
	archived
 | 
			
		||||
}
 | 
			
		||||
pub enum TransactionType {
 | 
			
		||||
	transfer
 | 
			
		||||
	clawback
 | 
			
		||||
	freeze
 | 
			
		||||
	unfreeze
 | 
			
		||||
	issue
 | 
			
		||||
	burn
 | 
			
		||||
}	
 | 
			
		||||
							
								
								
									
										31
									
								
								specs/models_heroledger/main/secretbox.v
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								specs/models_heroledger/main/secretbox.v
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,31 @@
 | 
			
		||||
module main
 | 
			
		||||
 | 
			
		||||
pub struct SecretBox {
 | 
			
		||||
pub mut:
 | 
			
		||||
	notary_id   u32 // person who is allowed to decrypt this info
 | 
			
		||||
	value	string //the actual incrypted value
 | 
			
		||||
	version u16 //version of the schema used to encrypt this value
 | 
			
		||||
	timestamp      u64
 | 
			
		||||
	cat SecretBoxCategory //category of the secret box, e.g. profile
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pub enum SecretBoxCategory {
 | 
			
		||||
	profile
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pub struct Notary {
 | 
			
		||||
	core.Base
 | 
			
		||||
pub mut:
 | 
			
		||||
	userid 	u32 // Reference to the user entity @[index]
 | 
			
		||||
	status        NotaryStatus // Current user status
 | 
			
		||||
	myceliumaddress string // Mycelium address of the notary
 | 
			
		||||
	pubkey string // Public key for cryptographic operations @[index]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pub enum NotaryStatus {
 | 
			
		||||
	active
 | 
			
		||||
	inactive
 | 
			
		||||
	suspended
 | 
			
		||||
	archived
 | 
			
		||||
	error
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										32
									
								
								specs/models_heroledger/main/signature.v
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								specs/models_heroledger/main/signature.v
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,32 @@
 | 
			
		||||
module circle
 | 
			
		||||
 | 
			
		||||
import freeflowuniverse.herolib.hero.models.core
 | 
			
		||||
 | 
			
		||||
// Wallet represents a wallet associated with a circle for financial operations
 | 
			
		||||
pub struct Signature {
 | 
			
		||||
	core.Base
 | 
			
		||||
pub mut:
 | 
			
		||||
	signature_id   u32 // Reference to the user who created the signature @[index]
 | 
			
		||||
	user_id		u32 // Reference to the user who created the signature @[index]
 | 
			
		||||
	value		  string // The actual signature value
 | 
			
		||||
	objectid       u32 // Reference to the user who created the signature @[index]
 | 
			
		||||
	objecttype     ObjectType // Type of object being signed (e.g.,
 | 
			
		||||
	status         SignatureStatus
 | 
			
		||||
	timestamp      u64
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pub enum SignatureStatus {
 | 
			
		||||
	active
 | 
			
		||||
	inactive
 | 
			
		||||
	pending
 | 
			
		||||
	revoked
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pub enum ObjectType {
 | 
			
		||||
	account
 | 
			
		||||
	dnsrecord
 | 
			
		||||
	membership
 | 
			
		||||
	user
 | 
			
		||||
	transaction
 | 
			
		||||
	kyc
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										58
									
								
								specs/models_heroledger/main/user.v
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								specs/models_heroledger/main/user.v
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,58 @@
 | 
			
		||||
module circle
 | 
			
		||||
 | 
			
		||||
import freeflowuniverse.herolib.hero.models.core
 | 
			
		||||
 | 
			
		||||
// Wallet represents a wallet associated with a circle for financial operations
 | 
			
		||||
pub struct User {
 | 
			
		||||
	core.Base
 | 
			
		||||
pub mut:
 | 
			
		||||
	username     string       // Unique username for the user @[index]
 | 
			
		||||
	pubkey 	 string       // Public key for cryptographic operations @[index]
 | 
			
		||||
	email        []string        @[index] // User's email addresses, needs to be considered unique and can be multiple
 | 
			
		||||
	status        UserStatus // Current user status
 | 
			
		||||
	userprofile      []SecretBox // User profile information stored in a secret box
 | 
			
		||||
	kyc 			 []SecretBox // KYC information stored in a secret box
 | 
			
		||||
 }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
pub enum UserStatus {
 | 
			
		||||
	active
 | 
			
		||||
	inactive
 | 
			
		||||
	suspended
 | 
			
		||||
	archived
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pub struct UserProfile {
 | 
			
		||||
pub mut:
 | 
			
		||||
	user_id      u32          // Reference to the user entity @[index]
 | 
			
		||||
	full_name    string       // Full name of the user
 | 
			
		||||
	bio          string       // Short biography or description
 | 
			
		||||
	profile_pic  string       // URL to the user's profile picture
 | 
			
		||||
	links        map[string]string // Social media or other relevant links
 | 
			
		||||
	metadata     map[string]string // Additional metadata associated with the user profile
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pub struct KYCInfo {
 | 
			
		||||
pub mut:
 | 
			
		||||
	user_id      u32          // Reference to the user entity @[index]
 | 
			
		||||
	full_name    string       // Full name of the user
 | 
			
		||||
	date_of_birth u64         // Unix timestamp of user's date of birth
 | 
			
		||||
	address      string       // User's residential address
 | 
			
		||||
	phone_number string       // User's phone number
 | 
			
		||||
	id_number    string       // Government-issued ID number (e.g., passport, driver's license)
 | 
			
		||||
	id_type      string       // Type of ID (e.g., "passport", "driver's license")
 | 
			
		||||
	id_expiry    u64          // Unix timestamp of ID expiry date
 | 
			
		||||
	kyc_status   KYCStatus    // Current KYC status
 | 
			
		||||
	kyc_verified bool         // Whether the KYC information has been verified
 | 
			
		||||
	kyc_verified_by u32       // User ID of the person who verified the KYC
 | 
			
		||||
	kyc_verified_at u64       // Unix timestamp when KYC was verified
 | 
			
		||||
	kyc_rejected_reason string // Reason for KYC rejection, if applicable
 | 
			
		||||
	kyc_signature u32 // Signature of the user for KYC verification
 | 
			
		||||
	metadata     map[string]string // Additional metadata associated with the user profile
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pub enum KYCStatus {
 | 
			
		||||
	pending
 | 
			
		||||
	approved
 | 
			
		||||
	rejected
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										22
									
								
								specs/models_heroledger/main/user_kvs.v
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								specs/models_heroledger/main/user_kvs.v
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,22 @@
 | 
			
		||||
module circle
 | 
			
		||||
 | 
			
		||||
import freeflowuniverse.herolib.hero.models.core
 | 
			
		||||
 | 
			
		||||
//a per user db
 | 
			
		||||
pub struct UserKVS {
 | 
			
		||||
	core.Base
 | 
			
		||||
pub mut:
 | 
			
		||||
	userid	 u32          // Reference to the user entity @[index]
 | 
			
		||||
	name string	   // Name of the key-value store
 | 
			
		||||
 }
 | 
			
		||||
 | 
			
		||||
pub struct UserKVSItem {
 | 
			
		||||
	core.Base
 | 
			
		||||
pub mut:
 | 
			
		||||
	userkvs_id	 u32          // Reference to the user entity @[index]
 | 
			
		||||
	key string
 | 
			
		||||
	value string       // Value associated with the key
 | 
			
		||||
	secretbox []SecretBox // Optional secret boxes for sensitive data
 | 
			
		||||
	timestamp      u64 // Timestamp when the item was created or last updated
 | 
			
		||||
 }
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user