constants are back. I had broke them when switching how data casting works

This commit is contained in:
microproofs
2023-07-28 18:37:16 -04:00
committed by Kasey
parent 0b8266dfd1
commit 5aecb96668
3 changed files with 79 additions and 11 deletions

View File

@@ -1424,3 +1424,26 @@ pub fn wrap_validator_condition(air_tree: AirTree) -> AirTree {
AirTree::if_branches(success_branch, void(), otherwise)
}
pub fn extract_constant(term: &Term<Name>) -> Option<Rc<UplcConstant>> {
let mut constant = None;
if let Term::Constant(c) = term {
constant = Some(c.clone());
} else if let Term::Apply { function, argument } = term {
if let Term::Constant(c) = argument.as_ref() {
if let Term::Builtin(b) = function.as_ref() {
if matches!(
b,
DefaultFunction::BData
| DefaultFunction::IData
| DefaultFunction::MapData
| DefaultFunction::ListData
) {
constant = Some(c.clone());
}
}
}
}
constant
}