Write method to apply a UPLC term to an existing 'Validator'
This commit is contained in:
@@ -10,7 +10,7 @@ use std::{
|
||||
collections::HashMap,
|
||||
fmt::{self, Display},
|
||||
};
|
||||
use uplc::ast::{DeBruijn, Program};
|
||||
use uplc::ast::{DeBruijn, Program, Term};
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize)]
|
||||
pub struct Validator<T> {
|
||||
@@ -122,6 +122,18 @@ impl Validator<Schema> {
|
||||
.unwrap(),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn apply(&mut self, arg: &Term<DeBruijn>) -> Result<(), Error> {
|
||||
match self.parameters.split_first() {
|
||||
None => Err(Error::NoParametersToApply),
|
||||
Some((_, tail)) => {
|
||||
// TODO: Ideally, we should control that the applied term matches its schema.
|
||||
self.program = self.program.apply_term(arg);
|
||||
self.parameters = tail.to_vec();
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Purpose {
|
||||
|
||||
Reference in New Issue
Block a user