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 solana_program::program_error::ProgramError;
use solana_program::pubkey::Pubkey;

pub fn get_oracle_address(vortex: &Pubkey) -> Result<(Pubkey, u8), ProgramError> {
    let seeds = &[b"oracle", vortex.as_ref()];

    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_oracle_address() {
        let vortex = Pubkey::from_str("2kJmUjxWBwL2NGPBV2PiA5hWtmLCqcKY6reQgkrPtaeS").unwrap();
        let oracle = Pubkey::from_str("5aKXJsVDk2RwGE8BZDQ5zPatnasbmQYp9HQnS7fXCgxo").unwrap();
        let (address, _) = get_oracle_address(&vortex).unwrap();
        assert_eq!(address, oracle);
    }
}