diff --git a/crates/aiken-project/src/blueprint/error.rs b/crates/aiken-project/src/blueprint/error.rs index a7f93555..0fceaab4 100644 --- a/crates/aiken-project/src/blueprint/error.rs +++ b/crates/aiken-project/src/blueprint/error.rs @@ -44,7 +44,7 @@ pub enum Error { #[diagnostic(code("aiken::blueprint::interface"))] Schema { error: schema::Error, - #[label("invalid contract's boundary")] + #[label("invalid validator's boundary")] location: Span, #[source_code] source_code: NamedSource, @@ -58,6 +58,11 @@ pub enum Error { #[error("I didn't find any parameters to apply in the given validator.")] #[diagnostic(code("aiken::blueprint::apply::no_parameters"))] NoParametersToApply, + + #[error("I couldn't compute the address of the given validator because it's parameterized by {} parameter(s)!", format!("{n}").purple())] + #[diagnostic(code("aiken::blueprint::address::parameterized"))] + #[diagnostic(help("I can only compute addresses of validators that are fully applied. For example, a {keyword_spend} validator must have exactly 3 arguments: a datum, a redeemer and a context. If it has more, they need to be provided beforehand and applied directly in the validator. Applying parameters change the validator's compiled code, and thus the address.\n\nThis is why I need you to apply parmeters first.", keyword_spend = "spend".purple()))] + ParameterizedValidator { n: usize }, } pub fn assert_return_bool(module: &CheckedModule, def: &TypedFunction) -> Result<(), Error> { diff --git a/crates/aiken-project/src/lib.rs b/crates/aiken-project/src/lib.rs index d54c2ff4..da0923ef 100644 --- a/crates/aiken-project/src/lib.rs +++ b/crates/aiken-project/src/lib.rs @@ -316,9 +316,14 @@ where |known_validators| Error::MoreThanOneValidatorFound { known_validators }; let when_missing = |known_validators| Error::NoValidatorNotFound { known_validators }; blueprint.with_validator(title, purpose, when_too_many, when_missing, |validator| { - Ok(validator - .program - .address(Network::Testnet, delegation_part.to_owned())) + let n = validator.parameters.len(); + if n > 0 { + Err(blueprint::error::Error::ParameterizedValidator { n }.into()) + } else { + Ok(validator + .program + .address(Network::Testnet, delegation_part.to_owned())) + } }) }