-
Notifications
You must be signed in to change notification settings - Fork 38
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 remaining node types for wasm #476
base: main
Are you sure you want to change the base?
Conversation
143630b
to
a9b69cd
Compare
types/src/extended_header.rs
Outdated
/// ``` | ||
#[derive(Debug, Clone, PartialEq, Eq)] | ||
#[cfg(all(feature = "wasm-bindgen", target_arch = "wasm32"))] | ||
#[wasm_bindgen] |
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.
I think the main point of making it wasm bindgenable was to also expose some methods on it, also getters for jsoned fields. without that, this looks less usable than just a json we had before
types/src/extended_header.rs
Outdated
#[wasm_bindgen(skip)] | ||
pub validator_set: ValidatorSet, | ||
/// Header of the block data availability. | ||
#[wasm_bindgen(skip)] |
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 the above code you had this as #[wasm_bindgen(getter_with_clone)]
, which one is the correct?
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.
Since DAH is our own struct, we could wasm_bindgen it, so getter with clone is correct here, I believe.
Co-authored-by: Yiannis Marangos <[email protected]> Signed-off-by: Mikołaj Florkiewicz <[email protected]>
Co-authored-by: Yiannis Marangos <[email protected]> Signed-off-by: Mikołaj Florkiewicz <[email protected]>
8e27863
to
2abc466
Compare
const squareRows = networkHead.dah.row_roots().length; | ||
const squareCols = networkHead.dah.column_roots().length; |
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.
I'm not sure if I like this breaking change because JS it doesn't give even a runtime error if user does not migrate.
const squareRows = networkHead.dah.row_roots.length;
const squareCols = networkHead.dah.column_roots.length;
The above will actually give squareRows = 0
and squareCols = 0
.
/// This function will also return an error if untrusted headers are not adjacent | ||
/// to each other. | ||
#[wasm_bindgen(js_name = verify_range)] | ||
pub fn js_verify_range(&self, untrusted: Vec<ExtendedHeader>) -> Result<(), JsValue> { |
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.
Because we move the value here, the JS value will be zeroed. Which is not nice.
Consider this example:
let h1 = await window.node.requestHeaderByHeight(BigInt(3109600));
let hdrs = await window.node.requestVerifiedHeaders(h1, BigInt(2));
h1.verify_range(hdrs);
let height = hdrs[0].height(); // This will panic because the headers were moved.
No description provided.