Rework 'blueprint apply' command and wrap up wiring up validation.

The apply command now works only from a serialized CBOR data (instead of a UPLC syntax). So it is no longer possible to specify arbitrary cbor terms through the CLI. I believe it to be an acceptable limitation for now; especially given that Aiken will never generate blueprints with non-data terms at the interface boundary.
This commit is contained in:
KtorZ
2023-04-07 17:40:40 +02:00
parent bf222a3ea2
commit 4799af3242
4 changed files with 95 additions and 26 deletions

View File

@@ -154,11 +154,15 @@ impl Validator {
}
impl Validator {
pub fn apply(self, arg: &Term<DeBruijn>) -> Result<Self, Error> {
pub fn apply(
self,
definitions: &Definitions<Annotated<Schema>>,
arg: &Term<DeBruijn>,
) -> Result<Self, Error> {
match self.parameters.split_first() {
None => Err(Error::NoParametersToApply),
Some((head, tail)) => {
head.validate(&self.definitions, arg)?;
head.validate(definitions, arg)?;
Ok(Self {
program: self.program.apply_term(arg),
parameters: tail.to_vec(),