start on registering redeemer wrapper type in definitions
This commit is contained in:
parent
7e1403a3b2
commit
bb6fc76971
|
@ -23,6 +23,7 @@ pub const RESULT: &str = "Result";
|
||||||
pub const STRING: &str = "String";
|
pub const STRING: &str = "String";
|
||||||
pub const OPTION: &str = "Option";
|
pub const OPTION: &str = "Option";
|
||||||
pub const ORDERING: &str = "Ordering";
|
pub const ORDERING: &str = "Ordering";
|
||||||
|
pub const REDEEMER_WRAPPER: &str = "RedeemerWrapper";
|
||||||
|
|
||||||
/// Build a prelude that can be injected
|
/// Build a prelude that can be injected
|
||||||
/// into a compiler pipeline
|
/// into a compiler pipeline
|
||||||
|
@ -1057,3 +1058,12 @@ pub fn unbound_var(id: u64) -> Arc<Type> {
|
||||||
|
|
||||||
Arc::new(Type::Var { tipo })
|
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],
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
definitions::{Definitions, Reference},
|
definitions::{Definitions, Reference},
|
||||||
error::Error,
|
error::Error,
|
||||||
|
@ -6,6 +8,7 @@ use super::{
|
||||||
use crate::module::{CheckedModule, CheckedModules};
|
use crate::module::{CheckedModule, CheckedModules};
|
||||||
use aiken_lang::{
|
use aiken_lang::{
|
||||||
ast::{TypedArg, TypedFunction, TypedValidator},
|
ast::{TypedArg, TypedFunction, TypedValidator},
|
||||||
|
builtins::wrapped_redeemer,
|
||||||
uplc::CodeGenerator,
|
uplc::CodeGenerator,
|
||||||
};
|
};
|
||||||
use miette::NamedSource;
|
use miette::NamedSource;
|
||||||
|
@ -144,7 +147,11 @@ impl Validator<Reference, Annotated<Schema>> {
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
.map(|schema| match datum {
|
.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 {
|
_ => Argument {
|
||||||
title: Some(redeemer.arg_name.get_label()),
|
title: Some(redeemer.arg_name.get_label()),
|
||||||
schema,
|
schema,
|
||||||
|
@ -305,11 +312,12 @@ mod test {
|
||||||
let validator = validators
|
let validator = validators
|
||||||
.get(0)
|
.get(0)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
.as_ref()
|
||||||
.expect("Failed to create validator blueprint");
|
.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]
|
#[test]
|
||||||
|
|
Loading…
Reference in New Issue