valiant_vortex_client 0.2.1

Rust client to interact with Valiant's on-chain Vortex program.
Documentation
use crate::generated::programs::VORTEX_ID;
use fogo_sessions_sdk::token::PROGRAM_SIGNER_SEED;
use solana_program::program_error::ProgramError;
use solana_program::pubkey::Pubkey;

/// Gets the program signer address for the fogo-session-sdk
/// This is a PDA derived from the PROGRAM_SIGNER_SEED for the given program
pub fn get_program_signer_address() -> Result<(Pubkey, u8), ProgramError> {
    let seeds = &[PROGRAM_SIGNER_SEED];
    Pubkey::try_find_program_address(seeds, &VORTEX_ID).ok_or(ProgramError::InvalidSeeds)
}

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

    #[test]
    fn test_get_program_signer_address() {
        let program_signer =
            Pubkey::from_str("3Kdtda8zcXjuC6n69xfuXtyZt2kEwLE6ghvubGbKfsFv").unwrap();
        let (address, _) = get_program_signer_address().unwrap();
        assert_eq!(address, program_signer);
    }

    #[test]
    fn test_program_signer_seed_constant() {
        assert_eq!(PROGRAM_SIGNER_SEED, b"fogo_session_program_signer");
    }
}