db/specs/models_heroledger/main/money.v
2025-08-06 13:44:21 +02:00

94 lines
2.9 KiB
V

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 @[index]
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 @[index] // Unique identifier for the asset (e.g., "USD", "BTC", "ETH")
asset_type string // "fiat", "crypto", "stablecoin", etc.
issuer u32 @[index] // 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 @[index] // Account ID of the recipient for clawback funds
}
pub enum AccountStatus {
active
inactive
suspended
archived
}
pub struct Transaction {
core.Base
pub mut:
txid u32 @[index] // Unique identifier for the transaction
source u32 @[index]
destination u32 @[index]
assetid u32 @[index]
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
}