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

Support compiling Subxt to WASM #649

Closed
amiyatulu opened this issue Sep 7, 2022 · 7 comments · Fixed by #700
Closed

Support compiling Subxt to WASM #649

amiyatulu opened this issue Sep 7, 2022 · 7 comments · Fixed by #700
Labels
ready to implement No significant design questions remain; this can be implemented now

Comments

@amiyatulu
Copy link

subxt is not supported in yew. It gives error on trunk serve

error[E0583]: file not found for module `sys`
   --> /home/amiya/.cargo/registry/src/github.jparrowsec.cn-1ecc6299db9ec823/socket2-0.4.7/src/lib.rs:124:1
    |
124 | mod sys;
    | ^^^^^^^^
    |
    = help: to create the module `sys`, create file "/home/amiya/.cargo/registry/src/github.jparrowsec.cn-1ecc6299db9ec823/socket2-0.4.7/src/sys.rs" or "/home/amiya/.cargo/registry/src/github.jparrowsec.cn-1ecc6299db9ec823/socket2-0.4.7/src/sys/mod.rs"

error: Socket2 doesn't support the compile target
   --> /home/amiya/.cargo/registry/src/github.jparrowsec.cn-1ecc6299db9ec823/socket2-0.4.7/src/lib.rs:127:1
    |
127 | compile_error!("Socket2 doesn't support the compile target");

@niklasad1
Copy link
Member

Yeah, it doesn't work at the moment.

You would have to disable to jsonrpsee feature and provide your own JSON-RPC transport for now to compile down to WASM.
It might be other things along the way too, I should look into that

@niklasad1
Copy link
Member

Blocked on paritytech/scale-decode#4 for now

@jsdw
Copy link
Collaborator

jsdw commented Sep 22, 2022

And now blocked on getting the right features etc enabled to make the substrate based crates play nicely.

So, the goal here should be to dig into the crate features and figure out how to get the library part of Subxt (including the codegen crate ideally; may be good to remove bitvec from here to support this) compiling. This may lead to tweaks in Substrate crates to expose the relevant features. We'll probably need a feature flag like "js" in Subxt which we can use to toggle various Substrate crate features on/off as needed.

So, we know what to do, but it may prove to be quite tricky getting this over the line.

@jsdw jsdw changed the title Support of subxt in yew.rs Support compiling Subxt to WASM Sep 23, 2022
@jsdw jsdw added the ready to implement No significant design questions remain; this can be implemented now label Sep 27, 2022
@Xanewok
Copy link
Contributor

Xanewok commented Oct 4, 2022

FYI I started working on it, hopefully this will not be blocked by any version releases upstream.

@niklasad1
Copy link
Member

niklasad1 commented Oct 4, 2022

@Xanewok I forgot to mention that I already have a branch working for WASM that https://github.com/paritytech/subxt/compare/na-wasm-support?expand=1 but I never committed that but did right now just in case it helps you.

Perhaps your stuff is better but feel free to use anything from there :P

@niklasad1
Copy link
Member

niklasad1 commented Oct 4, 2022

My stuff is using a special jsonrpsee branch to have async-wasm-feature but it should work on the latest release with a bunch of replace jsonrpsee with jsonrpsee-wasm-client instead of that feature I used.

EDIT: fixed again

@Xanewok
Copy link
Contributor

Xanewok commented Oct 4, 2022

Oh, that's great, thanks!

@Xanewok Xanewok linked a pull request Oct 26, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to implement No significant design questions remain; this can be implemented now
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants