Closed louisjmorgan closed 10 months ago
I was unable to chain the error mapping method that most of the other bindings seem to be using
set_root_key_id()
cannot fail, so you don't need to return a Result
, and it does not return any value, it just modifies the object on which it is called, so returning ()
is fine. The merge
method on BlockBuilder
is like this.
I've added the wasm bindings for
set_root_key_id
as well as a test to ensure it works.Currently the errors aren't being handled as far as I can tell. I assume if you pass the native function a string instead of an int you get a type error, but in the current implementation it seems to set the root key id to 0.
I was unable to chain the error mapping method that most of the other bindings seem to be using:
Would give the following compiler/rust analyzer error:
I did make it work the following way:
But I wasn't sure if this is redundant without an accompanying
Err
statement. I certainly couldn't see any other methods constructed this way. I assume theJsValue
refers to the way thatwasm-bindgen
returns the rust errors to javascript, but I'm not sure exactly how to make that happen without themap_err
method chain.Having said that I'm probably just missing something very obvious, so let me know and I'll make the relevant change.
I also notice my javascript formatter config disagrees with yours, if you let me know exactly what you're using (some kind of global prettier config?) I will try to match it and avoid inconsistencies.