From 58578450f3b3d95d891489c22bd642a0d1f35315 Mon Sep 17 00:00:00 2001 From: Sosthene Date: Thu, 12 Dec 2024 16:03:21 +0100 Subject: [PATCH] Add descriptions field in ProcessState --- src/process.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/process.rs b/src/process.rs index 5498ddd..edd89ad 100644 --- a/src/process.rs +++ b/src/process.rs @@ -24,10 +24,16 @@ pub struct ProcessState { pub encrypted_pcd: Value, // Some fields may be clear, if the owner of the process decides so pub keys: Map, // We may not always have all the keys pub validation_tokens: Vec, // Signature of the hash of the encrypted pcd tagged with some decision like "yes" or "no" + pub descriptions: Map, // long descriptions that can be used for the ihm } impl ProcessState { - pub fn new(commited_in: OutPoint, clear_state: Map) -> anyhow::Result { + pub fn new(commited_in: OutPoint, clear_state: Map, descriptions: Map) -> anyhow::Result { + // Check all descriptions matches clear_state + for (key, _) in &descriptions { + clear_state.get(key).ok_or(anyhow::Error::msg("Missing field in descriptions"))?; + } + let mut keys = Map::new(); let mut encrypted = Map::new(); @@ -49,6 +55,7 @@ impl ProcessState { encrypted_pcd: Value::Object(encrypted), keys, validation_tokens: vec![], + descriptions, }; Ok(res) @@ -627,7 +634,7 @@ mod tests { let outpoint = OutPoint::null(); - ProcessState::new(outpoint, clear_pcd.as_object().unwrap().clone()).unwrap() + ProcessState::new(outpoint, clear_pcd.as_object().unwrap().clone(), Map::new()).unwrap() } #[test]