Skip to content

Conversation

@joii2020
Copy link
Contributor

@joii2020 joii2020 commented Sep 3, 2025

No description provided.

wasm/src/lib.rs Outdated
h256_to_str(h)
}

pub fn update(&mut self, key: &str, val: &str) {

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>();

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 {
Copy link
Collaborator

@XuJiandong XuJiandong Sep 4, 2025

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

@joii2020 joii2020 requested a review from XuJiandong September 4, 2025 07:05
@joii2020 joii2020 requested a review from quake September 16, 2025 02:52
@quake quake added this pull request to the merge queue Sep 16, 2025
Merged via the queue into nervosnetwork:master with commit b74ea1b Sep 16, 2025
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants