native_mint.rs 592 B

12345678910111213141516171819202122232425
  1. //! The Mint that represents the native token
  2. /// There are 10^9 lamports in one SOL
  3. pub const DECIMALS: u8 = 9;
  4. // The Mint for native SOL Token accounts
  5. solana_sdk::declare_id!("So11111111111111111111111111111111111111111");
  6. #[cfg(test)]
  7. mod tests {
  8. use super::*;
  9. use solana_sdk::native_token::*;
  10. #[test]
  11. fn test_decimals() {
  12. assert_eq!(
  13. lamports_to_sol(42),
  14. crate::amount_to_ui_amount(42, DECIMALS)
  15. );
  16. assert_eq!(
  17. sol_to_lamports(42.),
  18. crate::ui_amount_to_amount(42., DECIMALS)
  19. );
  20. }
  21. }