diff --git a/packages/wasm-sdk/src/queries/voting.rs b/packages/wasm-sdk/src/queries/voting.rs index e108bdb320..4910e8cf5e 100644 --- a/packages/wasm-sdk/src/queries/voting.rs +++ b/packages/wasm-sdk/src/queries/voting.rs @@ -457,6 +457,7 @@ pub async fn get_contested_resource_voters_for_identity_with_proof_info( data_contract_id: &str, document_type_name: &str, index_name: &str, + index_values: Vec, contestant_id: &str, start_at_identifier_info: Option, count: Option, @@ -475,6 +476,21 @@ pub async fn get_contested_resource_voters_for_identity_with_proof_info( dash_sdk::dpp::platform_value::string_encoding::Encoding::Base58, )?; + // Convert JsValue index values to Vec> using bincode serialization + let mut index_values_bytes: Vec> = Vec::new(); + for value in index_values { + if let Some(s) = value.as_string() { + // Create a platform Value from the string + let platform_value = Value::Text(s); + // Serialize using bincode + let serialized = bincode::encode_to_vec(&platform_value, BINCODE_CONFIG) + .map_err(|e| JsError::new(&format!("Failed to serialize index value: {}", e)))?; + index_values_bytes.push(serialized); + } else { + return Err(JsError::new("Index values must be strings")); + } + } + // Parse start_at_identifier_info if provided let start_at_identifier_info = if let Some(info_str) = start_at_identifier_info { let info: serde_json::Value = serde_json::from_str(&info_str) @@ -505,7 +521,7 @@ pub async fn get_contested_resource_voters_for_identity_with_proof_info( contract_id: contract_id.to_vec(), document_type_name: document_type_name.to_string(), index_name: index_name.to_string(), - index_values: vec![], // Empty to query all contested resources + index_values: index_values_bytes, contestant_id: contestant_identifier.to_vec(), start_at_identifier_info, count, diff --git a/packages/wasm-sdk/test/ui-automation/tests/query-execution.spec.js b/packages/wasm-sdk/test/ui-automation/tests/query-execution.spec.js index 4cc8d7661e..6a03e604f3 100644 --- a/packages/wasm-sdk/test/ui-automation/tests/query-execution.spec.js +++ b/packages/wasm-sdk/test/ui-automation/tests/query-execution.spec.js @@ -829,7 +829,7 @@ test.describe('WASM SDK Query Execution Tests', () => { }, { name: 'getContestedResourceVotersForIdentity', - hasProofSupport: false, // Not working + hasProofSupport: true, needsParameters: true, validateFn: (result) => { expect(() => JSON.parse(result)).not.toThrow();