multiversx_chain_vm/
display_util.rs1use crate::types::VMAddress;
2
3pub fn address_hex(address: &VMAddress) -> String {
4 alloc::format!("0x{}", hex::encode(address.as_bytes()))
5}
6
7pub fn key_hex(key: &[u8]) -> String {
8 alloc::format!("0x{}", hex::encode(key))
9}
10
11pub fn verbose_hex(value: &[u8]) -> String {
12 alloc::format!("0x{}", hex::encode(value))
13}
14
15pub fn verbose_hex_list(values: &[Vec<u8>]) -> String {
16 let mut s = String::new();
17 s.push('[');
18 for (i, topic) in values.iter().enumerate() {
19 if i > 0 {
20 s.push(',');
21 }
22 s.push_str(verbose_hex(topic).as_str());
23 }
24 s.push(']');
25 s
26}
27
28pub fn bytes_to_string(bytes: &[u8]) -> String {
30 String::from_utf8(bytes.to_vec()).unwrap_or_else(|_| verbose_hex(bytes))
31}