svmai is a Rust-based command-line interface (CLI) tool for managing Solana wallets. It provides secure wallet management, multi-threaded wallet search, balance tracking, and batch operations with a text-based user interface (TUI).
- Primary Language: Rust (Edition 2021)
- Build System: Cargo
- Key Frameworks:
ratatuiwithcrosstermfor TUIsolana-sdkfor Solana blockchain integrationkeyringfor secure credential storage
- Follow Rust's official style guide and idiomatic Rust patterns
- Use
cargo fmtto automatically format code before committing - Run
cargo clippy -- -D warningsto catch common mistakes and warnings - All clippy warnings must be addressed before PR approval
- Write clear, descriptive comments for complex logic
- Use rustdoc comments (
///) for all public API functions and structs
- Use
snake_casefor functions, variables, and module names - Use
PascalCasefor types, traits, and enum variants - Use
SCREAMING_SNAKE_CASEfor constants - Choose descriptive names that clearly indicate purpose
- Use
Result<T, E>for operations that can fail - Define custom error types using
thiserrorwhen appropriate - Provide meaningful error messages that help users understand what went wrong
- Handle errors gracefully in TUI components to prevent crashes
- Never log or display private keys in plain text
- Use secure storage mechanisms (system keychain) for sensitive data
- Validate all user inputs before processing
- Follow cryptographic best practices when handling encryption
- Use
zeroizeor similar for sensitive data in memory when appropriate
The project follows a modular architecture with clear separation of concerns:
main.rs: CLI entry point and argument parsingfile_searcher.rs: Multi-threaded wallet file discoverykey_validator.rs: Solana private key validationsecure_storage.rs: Encrypted storage using system keychainwallet_manager.rs: High-level wallet management operationstransaction_handler.rs: Transaction creation and batch operationsvanity_wallet.rs: Vanity address generationtui.rs: Text-based user interface using ratatuiconfig.rs: Configuration managementlogging.rs: Logging utilities
- Keep modules focused on a single responsibility
- Use public interfaces (
pub) only for necessary exports - Document module-level behavior with module comments
- Maintain clear boundaries between modules
- Only add dependencies that are actively maintained and widely used
- Prefer pure Rust implementations when available
- Check for security advisories before adding new crates
- Document why a dependency is needed in commit messages
- Update
Cargo.tomlwith appropriate version constraints
- Use semantic versioning for dependencies
- Prefer exact versions for cryptographic libraries
- Use
~or^operators for other dependencies as appropriate
- Write unit tests for all new functionality
- Place tests in a
testsmodule within each source file - Use
#[cfg(test)]to conditionally compile tests - Aim for high code coverage, especially for critical paths
- Test edge cases and error conditions
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_descriptive_name() {
// Test implementation
}
}- Run
cargo testbefore submitting PRs - Run
cargo test --verbosefor detailed output - Ensure all tests pass; do not disable or remove existing tests
- Use
tempfilecrate for temporary file operations in tests
- For TUI changes, include manual testing steps in PR description
- Test on multiple platforms when possible (Linux, macOS, Windows)
- Verify keychain integration works correctly on target platforms
# Development build
cargo build
# Release build
cargo build --release
# Clean build artifacts
cargo cleanAlways run these commands before committing:
# Format code
cargo fmt
# Check for common issues
cargo clippy -- -D warnings
# Run tests
cargo test- Use rustdoc comments (
///) for public APIs - Include examples in documentation when helpful
- Document panics, errors, and safety requirements
- Keep documentation up-to-date with code changes
- Update README.md for user-facing changes
- Update architecture.md for architectural changes
- Update CONTRIBUTING.md for process changes
- Maintain CHANGELOG.md for version history
- Use
rayonfor parallel processing where appropriate - Avoid unnecessary allocations in hot paths
- Profile code before optimizing (don't prematurely optimize)
- Consider memory usage for operations on large wallet collections
- Support Linux, macOS, and Windows
- Test keychain integration on all target platforms
- Handle platform-specific paths using the
dirscrate - Document any platform-specific limitations
- Use clear, descriptive commit messages
- Start with a verb in present tense (e.g., "Add", "Fix", "Update")
- Reference issue numbers when applicable
- Keep commits focused and atomic
- Include a clear description of changes
- Link to related issues
- Include test results and manual testing steps
- Ensure CI passes before requesting review
- Address review feedback promptly
- Always validate wallet data before operations
- Use secure storage for private keys
- Provide progress feedback for long-running operations
- Allow cancellation of long-running operations
- Use the
Appstruct to manage application state - Handle keyboard events in the main event loop
- Update UI state before rendering
- Provide visual feedback for all user actions
- Handle terminal resize events gracefully
- Use threads for CPU-bound operations (e.g., vanity generation)
- Provide progress updates for user feedback
- Implement cancellation for long-running tasks
- Clean up resources properly on completion or cancellation
- Use
solana-sdkversion 3.x API patterns - Validate keypairs before use
- Handle network errors gracefully
- Cache RPC responses when appropriate
- Respect rate limits for RPC endpoints
- Do not commit private keys or sensitive data
- Do not disable security features
- Do not remove or skip existing tests without justification
- Do not introduce dependencies with known vulnerabilities
- Do not bypass error handling
- Do not use
unwrap()orexpect()in production code paths (prefer?operator and proper error handling)
- Review existing issues in the GitHub repository
- Check documentation in the
docs/directory and markdown files - Refer to the architecture.md file for design decisions
- Consult CONTRIBUTING.md for contribution guidelines