1pub const CHARSET_SIZE: usize = 32;
9
10pub const RESERVED_BITS_MASK: u8 = 0xf8;
11
12pub const SIZE_MASK: u8 = 0x07;
25pub const SIZE_160: u8 = 0x00;
26
27pub const SIZE_192: u8 = 0x01;
30pub const SIZE_224: u8 = 0x02;
31pub const SIZE_256: u8 = 0x03;
32pub const SIZE_320: u8 = 0x04;
33pub const SIZE_384: u8 = 0x05;
34pub const SIZE_448: u8 = 0x06;
35pub const SIZE_512: u8 = 0x07;
36
37pub const BASE32_CHARS: &str = "abcdefghijklmnopqrstuvwxyz0123456789";
38pub const EXCLUDE_CHARS: [char; 4] = ['o', 'i', 'l', 'q'];
39
40pub const MAINNET_PREFIX: &str = "cfx";
42pub const TESTNET_PREFIX: &str = "cfxtest";
43pub const NETWORK_ID_PREFIX: &str = "net";
44
45pub const ADDRESS_TYPE_BUILTIN: &'static str = "builtin";
47pub const ADDRESS_TYPE_CONTRACT: &'static str = "contract";
48pub const ADDRESS_TYPE_NULL: &'static str = "null";
49pub const ADDRESS_TYPE_UNKNOWN: &'static str = "unknown";
50pub const ADDRESS_TYPE_USER: &'static str = "user";
51
52pub const RESERVED_NETWORK_IDS: [u64; 2] = [1, 1029];
54
55#[cfg(not(feature = "std"))]
56use alloc::{format, string::String, vec::Vec};
57use lazy_static::lazy_static;
58
59lazy_static! {
60 pub static ref REGEXP: String = format!{"(?i)[:=_-{}]*", BASE32_CHARS};
64
65 pub static ref CHARSET: Vec<u8> =
67 BASE32_CHARS.replace(&EXCLUDE_CHARS[..], "").into_bytes();
69
70 pub static ref CHAR_INDEX: [Option<u8>; 128] = (|| {
72 let mut index = [None; 128];
73 assert_eq!(CHARSET.len(), CHARSET_SIZE);
74 for i in 0..CHARSET_SIZE {
75 let c = CHARSET[i] as usize;
76 index[c] = Some(i as u8);
77 let u = (c as u8 as char).to_ascii_uppercase() as u8 as usize;
79 if u != c {
80 index[u] = Some(i as u8);
81 }
82 }
83 return index;
84 }) ();
85}