diff --git a/crates/tx3-lang/src/applying.rs b/crates/tx3-lang/src/applying.rs index f517be69..5ce38481 100644 --- a/crates/tx3-lang/src/applying.rs +++ b/crates/tx3-lang/src/applying.rs @@ -294,6 +294,11 @@ 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 9f16de8f..d40662cc 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,8 @@ pub enum ArgValue { Address(Vec), UtxoSet(UtxoSet), UtxoRef(UtxoRef), + List(Vec), + Custom(CustomValue), } impl From> for ArgValue { 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())) + } } } }