solana_kite/
lib.rs

1//! # Solana Kite
2//!
3//! A Rust library that works great with [LiteSVM](https://litesvm.org) for testing your Solana programs.
4//! This crate offers high-level abstractions for common Solana operations like program deployment,
5//! transaction sending, token operations, and account management.
6//!
7//! ## Features
8//!
9//! - **Program Deployment**: Deploy programs to a test environment
10//! - **Transaction Utilities**: Send transactions from instructions with proper signing
11//! - **Token Operations**: Create mints, associated token accounts, and mint tokens
12//! - **Account Management**: Create wallets, check balances, and manage account state
13//! - **PDA Utilities**: Generate Program Derived Addresses with type-safe seed handling
14//!
15//! ## Example
16//!
17//! ```rust
18//! use solana_kite::{create_wallet, create_token_mint};
19//! use litesvm::LiteSVM;
20//!
21//! let mut litesvm = LiteSVM::new();
22//! let wallet = create_wallet(&mut litesvm, 1_000_000_000).unwrap(); // 1 SOL
23//! let mint = create_token_mint(&mut litesvm, &wallet, 6, None).unwrap(); // 6 decimals
24//! ```
25
26pub mod error;
27pub mod program;
28pub mod token;
29pub mod transaction;
30pub mod wallet;
31pub mod pda;
32
33pub use error::SolanaKiteError;
34pub use program::deploy_program;
35pub use token::{
36    create_associated_token_account, create_token_mint, get_token_account_balance,
37    assert_token_balance, mint_tokens_to_account,
38};
39pub use transaction::send_transaction_from_instructions;
40pub use wallet::{create_wallet, create_wallets};
41pub use pda::{get_pda_and_bump, Seed};
42
43// The seeds! macro is automatically available at the crate root due to #[macro_export]
44
45/// Verifies that an account is closed (either doesn't exist or has empty data)
46///
47/// # Arguments
48///
49/// * `litesvm` - The LiteSVM instance to query
50/// * `account` - The account address to check
51/// * `message` - Error message to display if the account is not closed
52///
53/// # Panics
54///
55/// Panics if the account exists and has non-empty data, with the provided message.
56///
57/// # Example
58///
59/// ```rust
60/// use solana_kite::check_account_is_closed;
61/// use litesvm::LiteSVM;
62/// use solana_pubkey::Pubkey;
63///
64/// let litesvm = LiteSVM::new();
65/// let account = Pubkey::new_unique();
66/// check_account_is_closed(&litesvm, &account, "Account should be closed");
67/// ```
68pub fn check_account_is_closed(
69    litesvm: &litesvm::LiteSVM,
70    account: &solana_pubkey::Pubkey,
71    message: &str,
72) {
73    let account_data = litesvm.get_account(account);
74    assert!(
75        account_data.is_none() || account_data.unwrap().data.is_empty(),
76        "{}",
77        message
78    );
79}