diff --git a/crates/aiken-project/src/blueprint/validator.rs b/crates/aiken-project/src/blueprint/validator.rs index 61db8c5f..5a748eac 100644 --- a/crates/aiken-project/src/blueprint/validator.rs +++ b/crates/aiken-project/src/blueprint/validator.rs @@ -52,34 +52,32 @@ impl Validator { def: &TypedValidator, plutus_version: &PlutusVersion, ) -> Vec> { - let is_multi_validator = def.other_fun.is_some(); - let mut program = MemoProgram::new(); - let mut validators = vec![Validator::create_validator_blueprint( - generator, - modules, - module, - def, - &def.fun, - is_multi_validator, - &mut program, - plutus_version, - )]; + let mut validators = vec![]; - if let Some(ref other_func) = def.other_fun { + for handler in &def.handlers { validators.push(Validator::create_validator_blueprint( generator, modules, module, def, - other_func, - is_multi_validator, + hander, &mut program, plutus_version, )); } + validators.push(Validator::create_validator_blueprint( + generator, + modules, + module, + def, + &def.fallback, + &mut program, + plutus_version, + )); + validators } @@ -90,7 +88,6 @@ impl Validator { module: &CheckedModule, def: &TypedValidator, func: &TypedFunction, - is_multi_validator: bool, program: &mut MemoProgram, plutus_version: &PlutusVersion, ) -> Result { @@ -160,16 +157,11 @@ impl Validator { }) .map(|schema| Parameter { title: Some(redeemer.arg_name.get_label()), - schema: match datum { - Some(..) if is_multi_validator => { - Annotated::as_wrapped_redeemer(&mut definitions, schema, redeemer.tipo.clone()) - } - _ => schema, - }, + schema, })?; Ok(Validator { - title: format!("{}.{}", &module.name, &func.name), + title: format!("{}.{}_{}", &module.name, &def.name, &func.name), description: func.doc.clone(), parameters, datum, @@ -848,11 +840,13 @@ mod tests { let mut definitions = fixture_definitions(); definitions.insert( &schema, - Schema::Data(Data::AnyOf(vec![Constructor { - index: 0, - fields: vec![Declaration::Referenced(Reference::new("Bool")).into()], - } - .into()])) + Schema::Data(Data::AnyOf(vec![ + Constructor { + index: 0, + fields: vec![Declaration::Referenced(Reference::new("Bool")).into()], + } + .into(), + ])) .into(), ); diff --git a/crates/aiken-project/src/module.rs b/crates/aiken-project/src/module.rs index cb28ff5c..37a62a91 100644 --- a/crates/aiken-project/src/module.rs +++ b/crates/aiken-project/src/module.rs @@ -390,8 +390,8 @@ impl CheckedModule { } Definition::Validator(Validator { params, - fun, - other_fun, + handlers, + fallback, .. }) => { for param in params { @@ -404,18 +404,8 @@ impl CheckedModule { } } - for argument in fun.arguments.iter_mut() { - let docs: Vec<&str> = - comments_before(&mut doc_comments, argument.location.start, &self.code); - - if !docs.is_empty() { - let doc = docs.join("\n"); - argument.put_doc(doc); - } - } - - if let Some(fun) = other_fun { - for argument in fun.arguments.iter_mut() { + for handler in handlers.iter_mut() { + for argument in handler.arguments.iter_mut() { let docs: Vec<&str> = comments_before( &mut doc_comments, argument.location.start, @@ -428,6 +418,16 @@ impl CheckedModule { } } } + + for argument in fallback.arguments.iter_mut() { + let docs: Vec<&str> = + comments_before(&mut doc_comments, argument.location.start, &self.code); + + if !docs.is_empty() { + let doc = docs.join("\n"); + argument.put_doc(doc); + } + } } _ => (), } @@ -463,6 +463,7 @@ impl CheckedModules { modules } + // todo: this might need fixing pub fn validators(&self) -> impl Iterator { let mut items = vec![];