Skip to content

Commit

Permalink
Show strings as UTF-8 text string during type reification
Browse files Browse the repository at this point in the history
  Instead of defaulting to hex-encoded bytearrays.
  • Loading branch information
KtorZ committed Sep 13, 2024
1 parent 9cf908d commit 799546b
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions crates/aiken-lang/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 799546b

Please sign in to comment.