neo_solidity/cli/cli_parts/cli_manifest/permissions/
literals.rs

1fn descriptor_from_literal(lit: &ir::LiteralValue) -> Option<String> {
2    let bytes_le: &[u8] = match lit {
3        ir::LiteralValue::Address(bytes) => bytes.as_slice(),
4        ir::LiteralValue::ByteArray(bytes) if bytes.len() == 20 => bytes.as_slice(),
5        _ => return None,
6    };
7
8    if bytes_le.len() != 20 {
9        return None;
10    }
11
12    let bytes_be: Vec<u8> = bytes_le.iter().rev().copied().collect();
13    Some(format!("0x{}", hex::encode(bytes_be)))
14}
15
16fn method_name_from_literal(lit: &ir::LiteralValue) -> Option<String> {
17    match lit {
18        ir::LiteralValue::String(bytes) => {
19            let name = String::from_utf8_lossy(bytes).to_string();
20            let name = name.trim().to_string();
21            if name.is_empty() {
22                None
23            } else {
24                Some(name)
25            }
26        }
27        _ => None,
28    }
29}