pub mod exceptions;
#[cfg(feature = "models")]
pub mod get_nftoken_id;
#[cfg(feature = "models")]
pub mod get_xchain_claim_id;
#[cfg(feature = "models")]
pub mod parse_nftoken_id;
pub mod str_conversion;
#[cfg(test)]
pub mod testing;
pub mod time_conversion;
#[cfg(feature = "models")]
pub(crate) mod transactions;
#[cfg(feature = "models")]
pub mod txn_parser;
pub mod xrpl_conversion;
pub use self::time_conversion::*;
pub use self::xrpl_conversion::*;
use crate::constants::*;
use alloc::vec::Vec;
use regex::Regex;
pub fn is_hex_address(value: &str) -> bool {
let regex = Regex::new(HEX_CURRENCY_REGEX).expect("is_hex_address");
regex.is_match(value)
}
pub fn is_iso_code(value: &str) -> bool {
let regex = Regex::new(ISO_CURRENCY_REGEX).expect("is_iso_code");
regex.is_match(value)
}
pub fn is_iso_hex(value: &str) -> bool {
let regex = Regex::new(HEX_CURRENCY_REGEX).expect("_is_hex");
regex.is_match(value)
}
pub trait ToBytes {
fn to_bytes(&self) -> Vec<u8>;
}
#[cfg(test)]
mod test {
use super::*;
const HEX_ENCODING: &str = "5E7B112523F68D2F5E879DB4EAC51C6698A69304";
#[test]
fn test_is_hex_address() {
assert!(is_hex_address(HEX_ENCODING));
}
#[test]
fn test_is_iso_code() {
let valid_code = "ABC";
let valid_code_numeric = "123";
let invalid_code_long = "LONG";
let invalid_code_short = "NO";
assert!(is_iso_code(valid_code));
assert!(is_iso_code(valid_code_numeric));
assert!(!is_iso_code(invalid_code_long));
assert!(!is_iso_code(invalid_code_short));
}
#[test]
fn test_is_hex() {
let valid_hex: &str = "0000000000000000000000005553440000000000";
let invalid_hex_chars: &str = "USD0000000000000000000005553440000000000";
let invalid_hex_long: &str = "0000000000000000000000005553440000000000123455";
let invalid_hex_short: &str = "1234";
assert!(is_iso_hex(valid_hex));
assert!(!is_iso_hex(invalid_hex_long));
assert!(!is_iso_hex(invalid_hex_short));
assert!(!is_iso_hex(invalid_hex_chars));
}
}