From 4a5c3fc0c4d3def3305b1bbee97f67e622e62623 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Ludue=C3=B1a?= Date: Tue, 2 Dec 2025 00:14:41 -0300 Subject: [PATCH 1/3] feat: deserializable custom type params --- crates/tx3-lang/src/applying.rs | 4 ++++ crates/tx3-lang/src/lib.rs | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/crates/tx3-lang/src/applying.rs b/crates/tx3-lang/src/applying.rs index f517be69..e19ed7f5 100644 --- a/crates/tx3-lang/src/applying.rs +++ b/crates/tx3-lang/src/applying.rs @@ -294,6 +294,10 @@ fn arg_value_into_expr(arg: ArgValue) -> ir::Expression { ArgValue::Bytes(x) => ir::Expression::Bytes(x), ArgValue::UtxoSet(x) => ir::Expression::UtxoSet(x), ArgValue::UtxoRef(x) => ir::Expression::UtxoRefs(vec![x]), + ArgValue::Custom(x) => ir::Expression::Struct(ir::StructExpr { + constructor: x.constructor, + fields: x.fields.into_iter().map(arg_value_into_expr).collect(), + }), } } diff --git a/crates/tx3-lang/src/lib.rs b/crates/tx3-lang/src/lib.rs index 9f16de8f..e68aa3d4 100644 --- a/crates/tx3-lang/src/lib.rs +++ b/crates/tx3-lang/src/lib.rs @@ -92,6 +92,12 @@ impl Eq for Utxo {} pub type UtxoSet = HashSet; +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] +pub struct CustomValue { + pub constructor: usize, + pub fields: Vec, +} + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] pub enum ArgValue { Int(i128), @@ -101,6 +107,7 @@ pub enum ArgValue { Address(Vec), UtxoSet(UtxoSet), UtxoRef(UtxoRef), + Custom(CustomValue), } impl From> for ArgValue { From 46ae7f062c28399f9a0ef5abd4acfb01a58ed8bc Mon Sep 17 00:00:00 2001 From: sofia-bobbiesi Date: Fri, 5 Dec 2025 15:20:28 -0300 Subject: [PATCH 2/3] feat: add support for List type in ArgValue --- crates/tx3-lang/src/applying.rs | 1 + crates/tx3-lang/src/lib.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/crates/tx3-lang/src/applying.rs b/crates/tx3-lang/src/applying.rs index e19ed7f5..5ce38481 100644 --- a/crates/tx3-lang/src/applying.rs +++ b/crates/tx3-lang/src/applying.rs @@ -294,6 +294,7 @@ fn arg_value_into_expr(arg: ArgValue) -> ir::Expression { ArgValue::Bytes(x) => ir::Expression::Bytes(x), ArgValue::UtxoSet(x) => ir::Expression::UtxoSet(x), ArgValue::UtxoRef(x) => ir::Expression::UtxoRefs(vec![x]), + ArgValue::List(x) => ir::Expression::List(x.into_iter().map(arg_value_into_expr).collect()), ArgValue::Custom(x) => ir::Expression::Struct(ir::StructExpr { constructor: x.constructor, fields: x.fields.into_iter().map(arg_value_into_expr).collect(), diff --git a/crates/tx3-lang/src/lib.rs b/crates/tx3-lang/src/lib.rs index e68aa3d4..d40662cc 100644 --- a/crates/tx3-lang/src/lib.rs +++ b/crates/tx3-lang/src/lib.rs @@ -107,6 +107,7 @@ pub enum ArgValue { Address(Vec), UtxoSet(UtxoSet), UtxoRef(UtxoRef), + List(Vec), Custom(CustomValue), } From 1c8f3d9d89d55aafab2bfe191ed78482f9766340 Mon Sep 17 00:00:00 2001 From: sofia-bobbiesi Date: Thu, 11 Dec 2025 13:57:09 -0300 Subject: [PATCH 3/3] enhance type lowering for custom types with alias support --- crates/tx3-lang/src/lowering.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/crates/tx3-lang/src/lowering.rs b/crates/tx3-lang/src/lowering.rs index 32abf290..9fee3bcc 100644 --- a/crates/tx3-lang/src/lowering.rs +++ b/crates/tx3-lang/src/lowering.rs @@ -336,8 +336,7 @@ impl IntoLower for ast::PolicyDef { impl IntoLower for ast::Type { type Output = ir::Type; - - fn into_lower(&self, _: &Context) -> Result { + fn into_lower(&self, ctx: &Context) -> Result { match self { ast::Type::Undefined => Ok(ir::Type::Undefined), ast::Type::Unit => Ok(ir::Type::Unit), @@ -350,7 +349,15 @@ impl IntoLower for ast::Type { ast::Type::AnyAsset => Ok(ir::Type::AnyAsset), ast::Type::List(_) => Ok(ir::Type::List), ast::Type::Map(_, _) => Ok(ir::Type::Map), - ast::Type::Custom(x) => Ok(ir::Type::Custom(x.value.clone())), + ast::Type::Custom(x) => { + // Check if this custom type is actually a type alias + if let Some(symbol) = &x.symbol { + if let Some(alias_def) = symbol.as_alias_def() { + return alias_def.alias_type.into_lower(ctx); + } + } + Ok(ir::Type::Custom(x.value.clone())) + } } } }