Remove unecessary check in create_update_message

This commit is contained in:
NicolasCantu 2025-01-22 10:46:24 +01:00
parent b2f7f68726
commit bdf75a6114

View File

@ -1350,17 +1350,17 @@ pub fn update_process(
#[wasm_bindgen] #[wasm_bindgen]
pub fn create_update_message( pub fn create_update_message(
init_commitment: String, process_id: String,
merkle_root_hex: String, state_id: String,
) -> ApiResult<ApiReturn> { ) -> ApiResult<ApiReturn> {
let mut processes = lock_processes()?; let mut processes = lock_processes()?;
let outpoint = OutPoint::from_str(&init_commitment)?; let process_id = OutPoint::from_str(&process_id)?;
let process = processes.get_mut(&outpoint) let process = processes.get_mut(&process_id)
.ok_or(ApiError::new("Unknown process".to_owned()))?; .ok_or(ApiError::new("Unknown process".to_owned()))?;
let update_state = process.get_state_for_id(&merkle_root_hex)?; let update_state = process.get_state_for_id(&state_id)?;
// We must have at least the key for the roles field, otherwise we don't know who to send the message to // We must have at least the key for the roles field, otherwise we don't know who to send the message to
let clear_state = update_state.decrypt_pcd()?; let clear_state = update_state.decrypt_pcd()?;
@ -1402,7 +1402,7 @@ pub fn create_update_message(
.to_member(); .to_member();
let full_prd = Prd::new_update( let full_prd = Prd::new_update(
outpoint, process_id,
sender, sender,
roles, roles,
update_state.keys.clone(), update_state.keys.clone(),
@ -1430,10 +1430,6 @@ pub fn create_update_message(
} }
} }
if ciphers.is_empty() {
return Err(ApiError::new("Empty ciphers list".to_owned()));
}
Ok(ApiReturn { Ok(ApiReturn {
ciphers_to_send: ciphers, ciphers_to_send: ciphers,
..Default::default() ..Default::default()