#![allow(clippy::arithmetic_side_effects)]
#![deny(missing_docs)]
#![no_std]
#![cfg_attr(not(test), warn(unsafe_code))]
extern crate alloc;
pub mod error;
pub mod extension;
pub mod generic_token_account;
pub mod instruction;
pub mod native_mint;
pub mod pod;
#[cfg(feature = "serde")]
pub mod serialization;
pub mod state;
pub use solana_zk_elgamal_proof_interface;
use {
alloc::string::{String, ToString},
solana_address::Address,
solana_program_error::{ProgramError, ProgramResult},
};
solana_address::declare_id!("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb");
pub fn check_program_account(spl_token_program_id: &Address) -> ProgramResult {
if spl_token_program_id != &id() {
return Err(ProgramError::IncorrectProgramId);
}
Ok(())
}
pub mod inline_spl_token {
solana_address::declare_id!("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
}
pub fn check_spl_token_program_account(spl_token_program_id: &Address) -> ProgramResult {
if spl_token_program_id != &id() && spl_token_program_id != &inline_spl_token::id() {
return Err(ProgramError::IncorrectProgramId);
}
Ok(())
}
fn trim_ui_amount_string(mut ui_amount: String, decimals: u8) -> String {
if decimals > 0 {
let zeros_trimmed = ui_amount.trim_end_matches('0');
ui_amount = zeros_trimmed.trim_end_matches('.').to_string();
}
ui_amount
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_inline_spl_token_program_id() {
assert_eq!(inline_spl_token::id(), spl_token_interface::id());
}
}