Skip to content

Commit

Permalink
start on registering redeemer wrapper type in definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
MicroProofs committed Mar 17, 2023
1 parent 1c29ba0 commit ae03d0b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
10 changes: 10 additions & 0 deletions crates/aiken-lang/src/builtins.rs
Expand Up @@ -23,6 +23,7 @@ pub const RESULT: &str = "Result";
pub const STRING: &str = "String";
pub const OPTION: &str = "Option";
pub const ORDERING: &str = "Ordering";
pub const REDEEMER_WRAPPER: &str = "RedeemerWrapper";

/// Build a prelude that can be injected
/// into a compiler pipeline
Expand Down Expand Up @@ -1057,3 +1058,12 @@ pub fn unbound_var(id: u64) -> Arc<Type> {

Arc::new(Type::Var { tipo })
}

pub fn wrapped_redeemer(redeemer: Arc<Type>) -> Arc<Type> {
Arc::new(Type::App {
public: true,
module: "".to_string(),
name: REDEEMER_WRAPPER.to_string(),
args: vec![redeemer],
})
}
14 changes: 11 additions & 3 deletions crates/aiken-project/src/blueprint/validator.rs
@@ -1,3 +1,5 @@
use std::collections::HashMap;

use super::{
definitions::{Definitions, Reference},
error::Error,
Expand All @@ -6,6 +8,7 @@ use super::{
use crate::module::{CheckedModule, CheckedModules};
use aiken_lang::{
ast::{TypedArg, TypedFunction, TypedValidator},
builtins::wrapped_redeemer,
uplc::CodeGenerator,
};
use miette::NamedSource;
Expand Down Expand Up @@ -144,7 +147,11 @@ impl Validator<Reference, Annotated<Schema>> {
),
})
.map(|schema| match datum {
Some(..) if is_multi_validator => todo!(),
Some(..) if is_multi_validator => {
let wrap_redeemer_type = wrapped_redeemer(redeemer.tipo);

definitions.register(&wrap_redeemer_type, &HashMap::new(), todo!());
}
_ => Argument {
title: Some(redeemer.arg_name.get_label()),
schema,
Expand Down Expand Up @@ -305,11 +312,12 @@ mod test {
let validator = validators
.get(0)
.unwrap()
.as_ref()
.expect("Failed to create validator blueprint");

println!("{}", serde_json::to_string_pretty(&validator).unwrap());
println!("{}", serde_json::to_string_pretty(validator).unwrap());

assert_json_eq!(serde_json::to_value(&validator).unwrap(), expected);
assert_json_eq!(serde_json::to_value(validator).unwrap(), expected);
}

#[test]
Expand Down

0 comments on commit ae03d0b

Please sign in to comment.