Show strings as UTF-8 text string during type reification

Instead of defaulting to hex-encoded bytearrays.
This commit is contained in:
KtorZ 2024-09-13 18:33:23 +02:00
parent 9cf908d07f
commit 799546b654
No known key found for this signature in database
GPG Key ID: 33173CB6F77F4277
1 changed files with 14 additions and 5 deletions

View File

@ -1063,11 +1063,20 @@ impl UntypedExpr {
value: from_pallas_bigint(i).to_string(),
}),
PlutusData::BoundedBytes(bytes) => Ok(UntypedExpr::ByteArray {
location: Span::empty(),
bytes: bytes.into(),
preferred_format: ByteArrayFormatPreference::HexadecimalString,
}),
PlutusData::BoundedBytes(bytes) => {
if tipo.is_string() {
Ok(UntypedExpr::String {
location: Span::empty(),
value: String::from_utf8(bytes.to_vec()).expect("invalid UTF-8 string"),
})
} else {
Ok(UntypedExpr::ByteArray {
location: Span::empty(),
bytes: bytes.into(),
preferred_format: ByteArrayFormatPreference::HexadecimalString,
})
}
}
PlutusData::Array(args) => match tipo {
Type::App {