1pub const DISCRIMINATOR_AS_HEX: &str = "22f123639d7ef4cd";
3pub const DISCRIMINATOR_AS_BYTES: &[i32; 8] = &[0x22, 0xF1, 0x23, 0x63, 0x9D, 0x7E, 0xF4, 0xCD];
4
5pub type PubkeyBytes = [u8; 32];
8
9pub fn hex_to_bytes(hex: &str) -> Vec<u8> {
11 hex.as_bytes()
12 .chunks(2)
13 .map(|chunk| {
14 let high = chunk[0] as char;
15 let low = chunk[1] as char;
16 let high = high.to_digit(16).expect("Invalid hex character") as u8;
17 let low = low.to_digit(16).expect("Invalid hex character") as u8;
18 (high << 4) | low
19 })
20 .collect()
21}
22
23pub fn interpret_bytes_as_i64(bytes: &[u8]) -> i64 {
25 let mut arr = [0u8; 8];
26 arr.copy_from_slice(bytes);
27 i64::from_le_bytes(arr)
28}
29
30pub fn interpret_bytes_as_i32(bytes: &[u8]) -> i32 {
32 let mut arr = [0u8; 4];
33 arr.copy_from_slice(bytes);
34 i32::from_le_bytes(arr)
35}
36
37pub fn interpret_bytes_as_u64(bytes: &[u8]) -> u64 {
39 let mut arr = [0u8; 8];
40 arr.copy_from_slice(bytes);
41 u64::from_le_bytes(arr)
42}