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

client: Add wasm support #2692

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

client: Add wasm support #2692

wants to merge 4 commits into from

Conversation

Aursen
Copy link
Contributor

@Aursen Aursen commented Nov 3, 2023

Problem

Currently, the anchor client cannot compile or be used in wasm.

Summary of changes

  • Reorganization a bit of the client code
  • Add wasm dependencies to the client
  • Add wasm tests

Copy link

vercel bot commented Nov 3, 2023

@Aursen is attempting to deploy a commit to the coral-xyz Team on Vercel.

A member of the Team first needs to authorize it.

@acheroncrypto
Copy link
Collaborator

The import error makes sense as we don't have MessageEvent feature enabled here

error[E0432]: unresolved import `web_sys::MessageEvent`
  --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/solana-client-wasm-1.17.2/src/pubsub.rs:10:15
   |
10 | use web_sys::{MessageEvent, WebSocket};
   |               ^^^^^^^^^^^^ no `MessageEvent` in the root

It's still strange that running wasm-pack test --chrome --features pubsub works locally for me even though MessageEvent feature is not enabled.

The errors about str is incorrect because MessageEvent is not enabled, and because the type is not available it doesn't get the correct return type of JsValue::as_string

error[E0277]: the size for values of type `str` cannot be known at compilation time
   --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/solana-client-wasm-1.17.2/src/pubsub.rs:129:75
    |
129 |             if let Some(Ok(notification)) = event.data().as_string().map(|data| {
    |                                                                           ^^^^ doesn't have a size known at compile-time
    |
    = help: the trait `Sized` is not implemented for `str`
    = note: all function arguments must have a statically known size

Will push a fix for solana-client-wasm.

acheroncrypto added a commit to solana-playground/solana-playground that referenced this pull request Nov 4, 2023
…ersions

* Enable `MessageEvent` feature of `web-sys`. The crate works without `MessageEvent` feature enabled in the repo but not with the published version as revealed in coral-xyz/anchor#2692

* Update Solana crates to `1.17.4`

* Update `wasm-bindgen` to `0.2.88` and other related crates to the latest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants