//! Governance, vesting, and multisig support for Synor blockchain.
//!
//! This crate provides:
//! - **Vesting**: Token lockup with cliff and linear release
//! - **Multisig**: Multi-signature wallets requiring N-of-M approvals
//! - **DAO**: On-chain governance with proposals and voting
//! - **Treasury**: Managed fund pools with spending rules
//!
//! # Architecture
//!
//! ```text
//! ┌─────────────────────────────────────────────────────────────┐
//! │                    GOVERNANCE SYSTEM                         │
//! ├─────────────────────────────────────────────────────────────┤
//! │                                                              │
//! │  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐       │
//! │  │   Vesting    │  │   Multisig   │  │     DAO      │       │
//! │  │  Contracts   │  │   Wallets    │  │  Governance  │       │
//! │  └──────┬───────┘  └──────┬───────┘  └──────┬───────┘       │
//! │         │                 │                 │                │
//! │         └─────────────────┼─────────────────┘                │
//! │                           │                                  │
//! │                    ┌──────▼───────┐                         │
//! │                    │   Treasury   │                         │
//! │                    │  Management  │                         │
//! │                    └──────────────┘                         │
//! │                                                              │
//! └─────────────────────────────────────────────────────────────┘
//! ```

#![allow(dead_code)]

pub mod dao;
pub mod multisig;
pub mod treasury;
pub mod vesting;

pub use dao::{
    DaoStats, Proposal, ProposalId, ProposalState, ProposalSummary, ProposalType, Vote, VoteChoice,
    VotingConfig, VotingPower, DAO,
};
pub use multisig::{
    MultisigConfig, MultisigTransaction, MultisigTxId, MultisigTxState, MultisigWallet,
};
pub use treasury::{SpendingLimit, Treasury, TreasuryConfig, TreasuryPool, TreasuryPoolId};
pub use vesting::{VestingContract, VestingSchedule, VestingState};

/// Governance configuration parameters.
#[derive(Clone, Debug)]
pub struct GovernanceConfig {
    /// Minimum tokens required to create a proposal.
    pub proposal_threshold: u64,
    /// Minimum participation rate for quorum (basis points, 1000 = 10%).
    pub quorum_bps: u32,
    /// Voting period in blocks.
    pub voting_period_blocks: u64,
    /// Execution delay after proposal passes (blocks).
    pub execution_delay_blocks: u64,
    /// Default vesting cliff in months.
    pub default_cliff_months: u32,
    /// Default vesting duration in months.
    pub default_vesting_months: u32,
}

impl Default for GovernanceConfig {
    fn default() -> Self {
        GovernanceConfig {
            proposal_threshold: 100_000 * 100_000_000, // 100,000 SYNOR
            quorum_bps: 1000,                          // 10% quorum
            voting_period_blocks: 864_000,             // ~1 day at 10 bps
            execution_delay_blocks: 172_800,           // ~4.8 hours
            default_cliff_months: 12,
            default_vesting_months: 48,
        }
    }
}

impl GovernanceConfig {
    /// Creates a configuration for faster governance (testnet/devnet).
    pub fn fast() -> Self {
        GovernanceConfig {
            proposal_threshold: 1000 * 100_000_000, // 1,000 SYNOR
            quorum_bps: 500,                        // 5% quorum
            voting_period_blocks: 1000,             // ~100 seconds
            execution_delay_blocks: 100,            // ~10 seconds
            default_cliff_months: 1,
            default_vesting_months: 6,
        }
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_default_config() {
        let config = GovernanceConfig::default();
        assert!(config.proposal_threshold > 0);
        assert!(config.quorum_bps <= 10000);
    }
}
