Skip to content

Commit

Permalink
WASM: change the PublicAddress.hex getter to PublicAddress.toHex()
Browse files Browse the repository at this point in the history
This is for consistency with other structs.
  • Loading branch information
andiflabs committed Feb 12, 2025
1 parent f0a55f6 commit 5226574
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions ironfish-rust-wasm/src/keys/public_address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ impl PublicAddress {
self.0.public_address().to_vec()
}

#[wasm_bindgen(js_name = "fromHex")]
#[wasm_bindgen(js_name = fromHex)]
pub fn from_hex(hex: &str) -> Result<Self, IronfishError> {
Ok(Self(ironfish::PublicAddress::from_hex(hex)?))
}

#[wasm_bindgen(getter)]
pub fn hex(&self) -> String {
#[wasm_bindgen(js_name = toHex)]
pub fn to_hex(&self) -> String {
self.0.hex_public_address()
}

#[wasm_bindgen(js_name = "isValid")]
#[wasm_bindgen(js_name = isValid)]
pub fn is_valid(hex: &str) -> bool {
Self::from_hex(hex).is_ok()
}
Expand All @@ -52,7 +52,7 @@ mod tests {
.expect("valid address deserialization should have succeeded");
assert_eq!(addr.serialize(), bytes);
assert_eq!(
addr.hex(),
addr.to_hex(),
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0"
);
}
Expand All @@ -71,9 +71,9 @@ mod tests {
let hex = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0";
let addr = PublicAddress::from_hex(hex)
.expect("valid address deserialization should have succeeded");
assert_eq!(addr.hex(), hex);
assert_eq!(addr.to_hex(), hex);
assert_eq!(
addr.hex(),
addr.to_hex(),
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0"
);
}
Expand Down

0 comments on commit 5226574

Please sign in to comment.