Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

WASM: change the PublicAddress.hex getter to PublicAddress.toHex() #5728

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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