dojoengine / dojo

Dojo is a toolchain for building provable games and applications
https://dojoengine.org
Apache License 2.0
416 stars 169 forks source link

Running Bevy app with wasm target leads to error when importing`torii-client` #2338

Open elton-cs opened 2 months ago

elton-cs commented 2 months ago

Describe the bug Bevy app will not compile when targeting wasm if torii-client is imported

To Reproduce

  1. Create a brand new rust binary: cargo new {example_project}
  2. Add bevy dependency: cargo add bevy
  3. Add the following in main.rs:
    
    use bevy::prelude::*;

fn main() { App::new().add_plugins(DefaultPlugins).run(); }

5. Add the following torii dependency and starknet core patch to the `Cargo.toml` file:

[dependencies] bevy = "0.14.0" torii-client = { git = "https://github.com/dojoengine/dojo.git" }

[patch.crates-io] starknet-core = { git = "https://github.com/kariy/starknet-rs", branch = "dojo-patch" }


6. Setup necessary wasm [requirements](https://bevy-cheatbook.github.io/platforms/wasm.html) to run a bevy app on the browser
7. Run bevy app in browser with : `cargo run --target wasm32-unknown-unknown`

**Expected behavior**
Compilation should not fail, and a black/gray window should show up on the browser.
elton-cs commented 2 months ago

@glihm @Larkooo would love some help to at least get a temporary patch on this issue for the game jam if possible haha 🙏

ShantelPeters commented 2 months ago

Please can I be assigned to this issue ?

ScottyDavies commented 2 months ago

Hello @elton-cs can i work on this?

elton-cs commented 1 month ago

@glihm @Larkooo looks like there was a fix recently to handle this issue. Updating all the libp2p related dependencies in torii-libp2p's Cargo.toml to the appropriate commit above allows rust/bevy to now run compile and run on wasm when importing the torii-client crate.

As for temporary fixes go, I'm currently using a fork of v1-alpha.11 where I just updated the 5 related deps, which you can view here. I'm hoping these changes don't affect the rest of torii tho 🤞

glihm commented 1 month ago

@elton-cs is still relevant or fixed recent merges?