satrush-client 0.1.14

Rust client to interact with SatRush's on-chain program.
Documentation
//! The satrush-mint program: the token issuer `rotate_round` CPIs into. Its
//! id and the PDAs the CPI addresses are fixed on every cluster.

use solana_pubkey::Pubkey;

pub const SATRUSH_MINT_PROGRAM_ID: Pubkey = Pubkey::from_str_const("sAtmiNt6gsZ9GmaABzuUfTufpBtbQCuTiQN8yGJzeH6");

pub fn get_satmint_config_address() -> (Pubkey, u8) {
    Pubkey::find_program_address(&[b"config".as_ref()], &SATRUSH_MINT_PROGRAM_ID)
}

pub fn get_satmint_mine_address() -> (Pubkey, u8) {
    Pubkey::find_program_address(&[b"mine".as_ref()], &SATRUSH_MINT_PROGRAM_ID)
}

pub fn get_satmint_oracle_address() -> (Pubkey, u8) {
    Pubkey::find_program_address(&[b"oracle".as_ref()], &SATRUSH_MINT_PROGRAM_ID)
}

/// The token's mint authority.
pub fn get_satmint_authority_address() -> (Pubkey, u8) {
    Pubkey::find_program_address(&[b"authority".as_ref()], &SATRUSH_MINT_PROGRAM_ID)
}

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

    #[test]
    fn pdas_match_the_program_constants() {
        assert_eq!(get_satmint_config_address().0.to_string(), "3JNuLyfQ3K7ksgtmhGbTVqm4xSJCZZqSdxMUB8P8iQqw");
        assert_eq!(get_satmint_mine_address().0.to_string(), "3A4HAFY6GtUijGrospsjN4bEq2j3wtjwQWnocHDdDTWk");
        assert_eq!(get_satmint_oracle_address().0.to_string(), "FT7AjGeSS1ecbsiR4zivFtVJ2KqF2aJ3fQ2m9f1Atsf7");
        assert_eq!(get_satmint_authority_address().0.to_string(), "6jH2zPwY58uPjWQPif7XtZM5B1AQAvtuZm1ifMNWTJvR");
    }
}