Update create_response_prd
This commit is contained in:
parent
92f4d62c88
commit
1106d25ea1
11
src/api.rs
11
src/api.rs
@ -1541,13 +1541,6 @@ fn add_validation_token(init_commitment: String, merkle_root_hex: String, approv
|
|||||||
|
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
pub fn create_response_prd(init_commitment: String, merkle_root_hex: String) -> ApiResult<ApiReturn> {
|
pub fn create_response_prd(init_commitment: String, merkle_root_hex: String) -> ApiResult<ApiReturn> {
|
||||||
let mut merkle_root = [0u8; 32];
|
|
||||||
let pcd_commitment_vec = Vec::from_hex(&merkle_root_hex)?;
|
|
||||||
if pcd_commitment_vec.len() != 32 {
|
|
||||||
return Err(ApiError::new("pcd_commitment must be 32B long".to_owned()));
|
|
||||||
}
|
|
||||||
merkle_root.copy_from_slice(&pcd_commitment_vec);
|
|
||||||
|
|
||||||
let mut processes = lock_processes()?;
|
let mut processes = lock_processes()?;
|
||||||
|
|
||||||
let outpoint = OutPoint::from_str(&init_commitment)?;
|
let outpoint = OutPoint::from_str(&init_commitment)?;
|
||||||
@ -1555,10 +1548,10 @@ pub fn create_response_prd(init_commitment: String, merkle_root_hex: String) ->
|
|||||||
let process = processes.get_mut(&outpoint)
|
let process = processes.get_mut(&outpoint)
|
||||||
.ok_or(ApiError::new("Unknown process".to_owned()))?;
|
.ok_or(ApiError::new("Unknown process".to_owned()))?;
|
||||||
|
|
||||||
let update_state: &mut ProcessState = process.get_state_for_commitments_root(merkle_root)?;
|
let update_state: &mut ProcessState = process.get_state_for_commitments_root_mut(&merkle_root_hex)?;
|
||||||
|
|
||||||
// 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()?.to_value_object()?;
|
let clear_state = update_state.decrypt_pcd()?;
|
||||||
|
|
||||||
let roles = Value::Object(clear_state).extract_roles()?;
|
let roles = Value::Object(clear_state).extract_roles()?;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user