Skip to content

Commit c08dede

Browse files
committed
fix: wrongly expectd 0x for hex strings
1 parent edb82d1 commit c08dede

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

packages/wasm-sdk/src/queries/identity.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -866,11 +866,9 @@ impl WasmSdk {
866866
#[wasm_bindgen(unchecked_param_type = "string | Uint8Array")]
867867
public_key_hash: JsValue,
868868
) -> Result<IdentityWasm, WasmSdkError> {
869-
// TODO: This is incorrect. If string we just decode from hex
870869
use dash_sdk::platform::types::identity::PublicKeyHash;
871870
let hash_bytes: Vec<u8> = if let Some(hex_str) = public_key_hash.as_string() {
872-
let s = hex_str.strip_prefix("0x").unwrap_or(&hex_str).to_string();
873-
hex::decode(&s).map_err(|e| {
871+
hex::decode(&hex_str).map_err(|e| {
874872
WasmSdkError::invalid_argument(format!("Invalid public key hash hex: {}", e))
875873
})?
876874
} else {
@@ -970,10 +968,8 @@ impl WasmSdk {
970968
#[wasm_bindgen(unchecked_param_type = "Identifier | Uint8Array | string | undefined")]
971969
start_after_id: JsValue,
972970
) -> Result<Array, WasmSdkError> {
973-
// TODO: Same here
974971
let hash_bytes: Vec<u8> = if let Some(hex_str) = public_key_hash.as_string() {
975-
let s = hex_str.strip_prefix("0x").unwrap_or(&hex_str).to_string();
976-
hex::decode(&s).map_err(|e| {
972+
hex::decode(&hex_str).map_err(|e| {
977973
WasmSdkError::invalid_argument(format!("Invalid public key hash hex: {}", e))
978974
})?
979975
} else {
@@ -1247,11 +1243,9 @@ impl WasmSdk {
12471243
#[wasm_bindgen(unchecked_param_type = "string | Uint8Array")]
12481244
public_key_hash: JsValue,
12491245
) -> Result<IdentityProofResponseWasm, WasmSdkError> {
1250-
// TODO: Incorrect
12511246
use dash_sdk::platform::types::identity::PublicKeyHash;
12521247
let hash_bytes: Vec<u8> = if let Some(hex_str) = public_key_hash.as_string() {
1253-
let s = hex_str.strip_prefix("0x").unwrap_or(&hex_str).to_string();
1254-
hex::decode(&s).map_err(|e| {
1248+
hex::decode(&hex_str).map_err(|e| {
12551249
WasmSdkError::invalid_argument(format!("Invalid public key hash hex: {}", e))
12561250
})?
12571251
} else {
@@ -1293,10 +1287,8 @@ impl WasmSdk {
12931287
#[wasm_bindgen(unchecked_param_type = "Identifier | Uint8Array | string | undefined")]
12941288
start_after_id: JsValue,
12951289
) -> Result<ProofMetadataResponseWasm, WasmSdkError> {
1296-
// TODO: Incorrect
12971290
let hash_bytes: Vec<u8> = if let Some(hex_str) = public_key_hash.as_string() {
1298-
let s = hex_str.strip_prefix("0x").unwrap_or(&hex_str).to_string();
1299-
hex::decode(&s).map_err(|e| {
1291+
hex::decode(&hex_str).map_err(|e| {
13001292
WasmSdkError::invalid_argument(format!("Invalid public key hash hex: {}", e))
13011293
})?
13021294
} else {

0 commit comments

Comments
 (0)