Do not compute addresses of parameterized validators

And leave a proper notice.
This commit is contained in:
KtorZ
2023-02-04 11:49:56 +01:00
parent 9b8ff590b8
commit b04fb5962a
2 changed files with 14 additions and 4 deletions

View File

@@ -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> {