Skip to content
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

Cmj.wasm test #327

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft

Cmj.wasm test #327

wants to merge 6 commits into from

Conversation

ChiaMineJP
Copy link
Contributor

@ChiaMineJP ChiaMineJP commented Nov 30, 2023

Experimental PR to make chia-protocol available as a wasm module.
Current status:


Building wasm module only with struct / enum succeeded

Steps to reproduce:

  1. Make sure you have wasm-pack installed on your system. (Just invoke cargo add wasm-pack to install)
  2. cd chia-protocol
  3. wasm-pack build

To convert methods with fixed sized byte array arguments/return value like &[u8; 4], we need to wait wasm-bindgen' update

rustwasm/wasm-bindgen#3458


u128 not supported yet by wasm-bindgen

wasm-bindgen does not yet support u128 so only when compiling for wasm32 the type will be converted to u64 temporarily by #[wasm_patch::conv_u128_to_u64_for_wasm] proc macro attritute.


BytesImpl should not be used outside chia-protocol/src/bytes.rs

BytesImpl<T> is basically aliased to types like Bytes32, Bytes48, and so on.
Since wasm-bindgen cannot treat generic parameters well when it is converting rust code to wasm, please do not use BytesImpl<T> notation outside bytes.rs.

@ChiaMineJP ChiaMineJP self-assigned this Dec 4, 2023
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.

None yet

1 participant