-
Notifications
You must be signed in to change notification settings - Fork 40
Support WASM #55
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
Support WASM #55
Conversation
wasm/src/lib.rs
Outdated
| h256_to_str(h) | ||
| } | ||
|
|
||
| pub fn update(&mut self, key: &str, val: &str) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In rust str is only designed to hold a valid utf-8 string, what if a user want to hash a Uint8Array?
wasm/src/lib.rs
Outdated
| } | ||
|
|
||
| fn parse_leaves(leaves: wasm_bindgen::JsValue) -> Vec<(H256, H256)> { | ||
| let leaves = leaves.dyn_ref::<js_sys::Array>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may use serde_wasm_bindgen to deserialize JS objects to Rust objects
wasm/src/lib.rs
Outdated
| type Smt = SparseMerkleTree<CkbBlake2bHasher, H256, DefaultStore<H256>>; | ||
|
|
||
| #[wasm_bindgen] | ||
| pub fn hash_data(d: wasm_bindgen::JsValue) -> Uint8Array { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
support d with type 'Uint8Array'. Rename this function name to blake2b_256
b74ea1b
No description provided.