From e6be899b2ad4bb1ef04d8d75970f4992eeae6016 Mon Sep 17 00:00:00 2001 From: rvcas Date: Thu, 4 Aug 2022 12:22:14 -0400 Subject: [PATCH] feat: fill in encode constant todos --- crates/uplc/src/flat.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/crates/uplc/src/flat.rs b/crates/uplc/src/flat.rs index d7a44a85..4ee52881 100644 --- a/crates/uplc/src/flat.rs +++ b/crates/uplc/src/flat.rs @@ -240,10 +240,16 @@ fn encode_constant_value(x: &Constant, e: &mut Encoder) -> Result<(), en::Error> } Constant::ProtoPair(_, _, a, b) => { encode_constant_value(a, e)?; - encode_constant_value(b, e)?; - Ok(()) + + encode_constant_value(b, e) + } + Constant::Data(data) => { + let cbor = data + .encode_fragment() + .map_err(|err| en::Error::Message(err.to_string()))?; + + cbor.encode(e) } - Constant::Data(_) => todo!(), } } @@ -263,7 +269,7 @@ fn encode_type(typ: &Type, bytes: &mut Vec) { encode_type(type1, bytes); encode_type(type2, bytes); } - Type::Data => todo!(), + Type::Data => bytes.push(8), } }