Rename process descriptions to public_data

This commit is contained in:
NicolasCantu 2025-03-03 23:19:10 +01:00 committed by Nicolas Cantu
parent 46d405f046
commit 58cc5081b2

View File

@ -27,18 +27,13 @@ pub struct ProcessState {
pub keys: Map<String, Value>, // We may not always have all the keys
pub validation_tokens: Vec<Proof>, // Signature of the hash of the encrypted pcd tagged with some decision like "yes" or "no"
#[tsify(type = "Record<string, string>")]
pub descriptions: Map<String, Value>, // long descriptions that can be used for the ihm
pub public_data: BTreeMap<String, String>, // long descriptions that can be used for the ihm
#[tsify(type = "Record<string, RoleDefinition>")]
pub roles: BTreeMap<String, RoleDefinition>,
}
impl ProcessState {
pub fn new(commited_in: OutPoint, clear_state: Map<String, Value>, descriptions: Map<String, Value>, roles: BTreeMap<String, RoleDefinition>) -> anyhow::Result<Self> {
// Check all descriptions matches clear_state
for (key, _) in &descriptions {
clear_state.get(key).ok_or(anyhow::Error::msg("Missing field in descriptions"))?;
}
pub fn new(commited_in: OutPoint, clear_state: Map<String, Value>, public_data: &BTreeMap<String, String>, roles: BTreeMap<String, RoleDefinition>) -> anyhow::Result<Self> {
let mut keys = Map::new();
let mut encrypted = Map::new();
@ -60,7 +55,7 @@ impl ProcessState {
encrypted_pcd: Value::Object(encrypted),
keys,
validation_tokens: vec![],
descriptions,
public_data: public_data.clone(),
roles,
};
@ -670,7 +665,7 @@ mod tests {
let outpoint = OutPoint::null();
ProcessState::new(outpoint, clear_pcd.as_object().unwrap().clone(), Map::new(), roles).unwrap()
ProcessState::new(outpoint, clear_pcd.as_object().unwrap().clone(), &BTreeMap::new(), roles).unwrap()
}
#[test]