[bug] when updating state with values, hash check would have failed if not all values updated

This commit is contained in:
NicolasCantu 2025-01-12 19:07:42 +01:00
parent 9896532713
commit 3dab6ef2d6

View File

@ -1008,7 +1008,11 @@ pub fn update_process_state(init_commitment: String, state_id: String, hash2valu
return Err(ApiError::new("State already existing".to_owned()));
}
let state_commitments = state.pcd_commitment.to_value_object()?;
let mut new_encrypted_pcd: Map<String, Value> = Map::with_capacity(hash2values_map.len());
let mut new_encrypted_pcd: Map<String, Value> = state_commitments.iter()
.map(|(field, _)| {
(field.clone(), Value::Null)
})
.collect();
for (hash, value) in hash2values_map {
// Check the hash in pcd_commitment, get the corresponding field name