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

fix(wasm): support ws #1481

Merged
merged 2 commits into from
Oct 15, 2024
Merged

fix(wasm): support ws #1481

merged 2 commits into from
Oct 15, 2024

Conversation

ethernomad
Copy link
Contributor

@ethernomad ethernomad commented Oct 15, 2024

Motivation

When attempting to make a browser dapp with Dioxus I found that Alloy would not build with WebSocket support:

error[E0599]: no function or associated item named `new` found for struct `WsConnect` in the current scope
  --> /home/jbrown/alloy/crates/rpc-client/src/builtin.rs:84:64
   |
84 |             Self::Ws(url, _) => alloy_transport_ws::WsConnect::new(url.clone())
   |                                                                ^^^ function or associated item not found in `WsConnect`

It is critical that Alloy supports building browser dapps with WebSocket support.

Solution

All that is required to fix this is adding missing function new() to WsConnect in crates/transport-ws/src/wasm.rs.

With this fix I verified that Alloy could connect to a local node from the browser via WS.

Additionally I updated scripts/check_no_std.sh to check affected crates and ws feature. The target was changed from riscv32imac-unknown-none-elf to wasm32-unknown-unknown to facilitate this.

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems okay

scripts/check_no_std.sh Outdated Show resolved Hide resolved
Copy link
Member

@DaniPopes DaniPopes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@DaniPopes DaniPopes merged commit 52bee71 into alloy-rs:main Oct 15, 2024
26 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.

3 participants