pub const DISCRIMINATOR_AS_HEX: &str = "22f123639d7ef4cd";
pub type PubkeyBytes = [u8; 32];
pub fn hex_to_bytes(hex: &str) -> Vec<u8> {
hex.as_bytes()
.chunks(2)
.map(|chunk| {
let high = chunk[0] as char;
let low = chunk[1] as char;
let high = high.to_digit(16).expect("Invalid hex character") as u8;
let low = low.to_digit(16).expect("Invalid hex character") as u8;
(high << 4) | low
})
.collect()
}
pub fn interpret_bytes_as_i64(bytes: &[u8]) -> i64 {
let mut arr = [0u8; 8];
arr.copy_from_slice(bytes);
i64::from_le_bytes(arr)
}
pub fn interpret_bytes_as_i32(bytes: &[u8]) -> i32 {
let mut arr = [0u8; 4];
arr.copy_from_slice(bytes);
i32::from_le_bytes(arr)
}
pub fn interpret_bytes_as_u64(bytes: &[u8]) -> u64 {
let mut arr = [0u8; 8];
arr.copy_from_slice(bytes);
u64::from_le_bytes(arr)
}