-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add address validations #96
feat: add address validations #96
Conversation
Is this still relevant? I thought the upstream stack leak issue was fixed. Honestly I haven't looked into it since it's been years since I originally reported the stack leak to the wasm-bindgen team |
@SebastienGllmt I'm currently getting the memory leak error both with cardano-multiplatform-lib and with @emurgo/cardano-serialization-lib |
@SebastienGllmt Also desptie the stack leak issue, which seems to still be happening, I think that having the 3 functions would be a nice feature, this way we can have a simple boolean function to know if an address is valid |
Ah, I looked back into it and now I remember what happened. They finally fixed the issue and then didn't make a release that included it for months so I gave up hope. It look like version Can you try bumping to 0.2.80 (or later) to see if this solves the issue for you? |
@SebastienGllmt I tried bumping the version but now I'm getting the following error, I'm not quite sure how to fix it as apparently there is a JsError implemented in
|
hmm, seems they made a breaking change in bindgen for the error type. Will have to look into it |
Okk great! If you think the function would be a good add feel free to merge it. Personally I believe there are some cases were it will be useful to have this kind of functions |
I think this was actually an issue half caused by the upgrade in bindgen/js-sys and half caused by #81 which moved some stuff calling So after refactoring Since only some places had use crate::error::JsError; so only some would use the definitions found at: #[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
pub type JsError = JsValue;
#[cfg(not(all(target_arch = "wasm32", not(target_os = "emscripten"))))]
#[derive(Debug, Clone)]
pub struct JsError {
msg: String,
} and others would use I wanted to just blanket switch these all to
Here's a PR (untested besides compiling it in rust+wasm/running rust tests) that updates with this fix so try that out: #98 |
@rooooooooob Thanks! I just checked it seems to have fixed the memory leak error. I left a small comment regarding an error on build but we can keep that discussion in the other PR. |
…dations # Conflicts: # rust/pkg/cardano_multiplatform_lib.js.flow
I slightly changed the API since unfortunately address encoding is a bit tricker than you may think. Should be good-to-go now |
Resolves #95
Address 3 extra functions to avoid wasm-bindgen memory leak ](rustwasm/wasm-bindgen#1963).
is_shelley -> validates if the string is a valid shelley address
is_byron -> validates if the string is a valid byron address
is_valid -> validates if the string is valid address both shelley or byron