Add reverse mapping for PlutusData constr

This commit is contained in:
Niels Mündler 2023-12-31 11:36:56 +01:00 committed by Kasey
parent 0ae631a1fe
commit 4bd8ab890a
1 changed files with 12 additions and 2 deletions

View File

@ -313,9 +313,19 @@ impl Constant {
// This feels a little awkward here; not sure if it should be upstreamed to pallas // This feels a little awkward here; not sure if it should be upstreamed to pallas
fn to_doc_list_plutus_data(data: &PlutusData) -> RcDoc<()> { fn to_doc_list_plutus_data(data: &PlutusData) -> RcDoc<()> {
match data { match data {
PlutusData::Constr(Constr { tag, fields, .. }) => RcDoc::text("Constr") PlutusData::Constr(Constr {
tag,
any_constructor,
fields,
..
}) => RcDoc::text("Constr")
.append(RcDoc::space()) .append(RcDoc::space())
.append(RcDoc::as_string(tag)) .append(RcDoc::as_string(match tag {
121..=127 => tag - 121,
1280..=1400 => tag - 1280 + 7,
102 => any_constructor.unwrap(),
_ => panic!("unknown tag {}", tag),
}))
.append(RcDoc::space()) .append(RcDoc::space())
.append(RcDoc::text("[")) .append(RcDoc::text("["))
.append(RcDoc::intersperse( .append(RcDoc::intersperse(