dojo icon indicating copy to clipboard operation
dojo copied to clipboard

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

Open elton-cs opened this issue 1 year ago • 5 comments

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();
}

  1. 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" }
  1. Setup necessary wasm requirements to run a bevy app on the browser
  2. 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 avatar Aug 23 '24 22:08 elton-cs

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

elton-cs avatar Aug 23 '24 22:08 elton-cs

Please can I be assigned to this issue ?

ShantelPeters avatar Aug 24 '24 13:08 ShantelPeters

Hello @elton-cs can i work on this?

ScottyDavies avatar Aug 24 '24 18:08 ScottyDavies

@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 🤞

elton-cs avatar Sep 10 '24 18:09 elton-cs

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

glihm avatar Sep 24 '24 20:09 glihm

Will close @elton-cs please re-open if the behavior is still observed. 👍

glihm avatar Nov 11 '24 21:11 glihm