From bb5fb5e75f038778f68e4b843aaa145105f22d3d Mon Sep 17 00:00:00 2001 From: Sosthene Date: Fri, 11 Jul 2025 13:49:08 +0200 Subject: [PATCH] validate_merkle_proof takes a JsValue --- src/api.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/api.rs b/src/api.rs index 0631220..dc4cca1 100644 --- a/src/api.rs +++ b/src/api.rs @@ -1809,17 +1809,19 @@ pub fn get_merkle_proof(process_state: JsValue, attribute_name: String) -> ApiRe /// leads to the claimed root when combined with the attribute hash. /// /// # Arguments -/// * `proof_result` - The MerkleProofResult containing the proof and metadata +/// * `proof_result` - a JsValue expected to contain a MerkleProofResult with the proof and metadata /// * `hash` - The hash of the attribute data as a hex string (the leaf value) /// /// # Returns /// A boolean indicating whether the proof is valid /// /// # Errors +/// * "serde_wasm_bindgen deserialization error" - If the proof is not a valid MerkleProofResult /// * "Invalid proof format" - If the proof cannot be parsed /// * "Invalid hash format" - If the hash is not a valid 32-byte hex string /// * "Invalid root format" - If the root is not a valid 32-byte hex string -pub fn validate_merkle_proof(proof_result: MerkleProofResult, hash: String) -> ApiResult { +pub fn validate_merkle_proof(proof_result: JsValue, hash: String) -> ApiResult { + let proof_result: MerkleProofResult = serde_wasm_bindgen::from_value(proof_result)?; let root_bytes: [u8; 32] = Vec::from_hex(&proof_result.root)? .try_into() .map_err(|_| ApiError::new("Invalid root format".to_owned()))?;