Skip to content

[FEATURE] Add NatSpec-style documentation to all contract functions #20

Description

@derbydaniels9-cpu

Summary

There is no contract documentation or NatSpec-equivalent comments. The contracts have no inline documentation explaining what each function does, what its parameters mean, what invariants it maintains, or what events it emits. This makes the code difficult to audit and contribute to.

Impact

  • External auditors spend more time understanding the code, increasing audit costs.
  • Contributors cannot understand the intended behavior vs actual behavior.
  • Users and integrators have no reference for what the contract does without reading raw Rust.

Proposed documentation standard

Add Rust doc comments to every public function and struct:

/// Deposits funds into a savings box with the specified lock configuration.
///
/// # Arguments
/// * `user` - The Stellar address of the depositor (must be KYC verified)
/// * `amount` - Amount in stroops (1 XLM = 10_000_000 stroops)
/// * `lock_type` - One of: "FLEXIBLE", "FIXED", "TARGET"
/// * `lock_until` - Unix timestamp for FIXED lock maturity (ignored for other types)
///
/// # Panics
/// * If contract is paused
/// * If user is not KYC verified
/// * If amount exceeds per-user cap
/// * If amount is zero or negative
///
/// # Events
/// Emits `("deposit", user, amount, lock_type)` on success
pub fn deposit(env: Env, user: Address, amount: i128, lock_type: Symbol, lock_until: u64) {

Also generate and publish HTML docs via cargo doc --no-deps --open and host on GitHub Pages.

Files affected:

  • All src/*/lib.rs files
  • New: docs/contract-api.md
  • New: .github/workflows/docs.yml

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions