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

(poc) feat: experimental web #396

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions godot/.godot/global_script_class_cache.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,6 @@ list=Array[Dictionary]([{
"language": &"GDScript",
"path": "res://src/logic/realm.gd"
}, {
"base": &"RefCounted",
"class": &"RustHttpRequesterWrapper",
"icon": "",
"language": &"GDScript",
"path": "res://src/logic/rust_http_requester_wrapper.gd"
}, {
"base": &"MarginContainer",
"class": &"SafeMarginContainer",
"icon": "",
Expand Down
2 changes: 2 additions & 0 deletions godot/decentraland_godot_lib.gdextension
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ android.debug.x86_64 = "res://lib/android/x86_64/libdecentraland_godot_lib.so"
android.release.x86_64 = "res://lib/android/x86_64/libdecentraland_godot_lib.so"
ios.debug.arm64 = "res://lib/ios/libdecentralandgodot.dylib"
ios.release.arm64 = "res://lib/ios/libdecentralandgodot.dylib"
web.debug = "res://lib/decentraland_godot_lib.wasm"
web.release = "res://lib/decentraland_godot_lib.wasm"
38 changes: 38 additions & 0 deletions godot/export_presets.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -484,3 +484,41 @@ portrait_launch_screens/iphone_1125x2436=""
portrait_launch_screens/ipad_768x1024=""
portrait_launch_screens/ipad_1536x2048=""
portrait_launch_screens/iphone_1242x2208=""

[preset.5]

name="Web"
platform="Web"
runnable=true
dedicated_server=false
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path="./dcl-explorer-godot.html"
encryption_include_filters=""
encryption_exclude_filters=""
encrypt_pck=false
encrypt_directory=false

[preset.5.options]

custom_template/debug="./../.bin/godot/templates/templates/web_dlink_debug.zip"
custom_template/release="./../.bin/godot/templates/templates/web_dlink_debug.zip"
variant/extensions_support=false
vram_texture_compression/for_desktop=true
vram_texture_compression/for_mobile=false
html/export_icon=true
html/custom_html_shell=""
html/head_include=""
html/canvas_resize_policy=2
html/focus_canvas_on_start=true
html/experimental_virtual_keyboard=false
progressive_web_app/enabled=false
progressive_web_app/offline_page=""
progressive_web_app/display=1
progressive_web_app/orientation=0
progressive_web_app/icon_144x144=""
progressive_web_app/icon_180x180=""
progressive_web_app/icon_512x512=""
progressive_web_app/background_color=Color(0, 0, 0, 1)
3 changes: 2 additions & 1 deletion godot/lib/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.dll
*.so
*.dylib
*.exe
*.exe
*.wasm
121 changes: 0 additions & 121 deletions godot/src/logic/rust_http_requester_wrapper.gd

This file was deleted.

26 changes: 0 additions & 26 deletions godot/src/test/integration_rust/rust_requester.gd

This file was deleted.

6 changes: 0 additions & 6 deletions godot/src/test/integration_rust/rust_requester.tscn

This file was deleted.

13 changes: 12 additions & 1 deletion rust/decentraland-godot-lib/.cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,15 @@ rustflags = ["-C", "target-feature=+crt-static"]
rustflags = ["-C", "link-args=-ObjC"]

[target.aarch64-apple-darwin]
rustflags = ["-C", "link-args=-ObjC"]
rustflags = ["-C", "link-args=-ObjC"]

[target.wasm32-unknown-emscripten]
rustflags = [
"-C", "link-args=-sSIDE_MODULE=2 -sEXPORT_ALL=1",
"-Zlink-native-libraries=no",
"-C", "link-args=-pthread",
"-C", "target-feature=+bulk-memory",
"-C", "target-feature=+atomics",
"-C", "target-feature=+mutable-globals",
"-C", "link-args=-sSHARED_MEMORY=1",
]
19 changes: 10 additions & 9 deletions rust/decentraland-godot-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@ publish = false
crate-type = ["cdylib"]

[dependencies]
godot = { git = "https://github.com/leanmendoza/gdext", branch = "fix/ios", features=["experimental-threads", "serde"] }
godot = { git = "https://github.com/leanmendoza/gdext", branch = "text/exclude-openxr", features=["experimental-threads", "serde", "experimental-wasm"] }
rand = "0.8"
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0.92", features = ["raw_value"] }
tokio = { version = "1.26.0", features = ["full"] }

tokio = { version = "1.37.0", features = ["sync", "macros", "io-util", "rt", "time"] } # tokio wasm support: https://docs.rs/tokio/latest/tokio/#wasm-support

protobuf = "3.2.0"
prost = "0.11.8"
once_cell = "1.16.0"
futures-lite = "1.12.0"

hyper = { version = "1.0.0-rc.3", features = ["full"] }
hyper = { version = "1.2.0", features = ["http1"] } # looks like we are not using hyper... just for the inspector
http-body-util = "0.1.0-rc.2"
reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls", "blocking"] }
regex = "*"
urn = "0.7.0"

ethers-core = { version = "2.0" }
ethers-signers = { version = "2.0" }
ethers-providers = { version = "2.0", features = ["ws","rustls"] }

async-trait = "0.1.68"
ethers-providers = { version = "2.0", features = ["ws","rustls"] } # disable-wasm: ethers-providers uses jsonwebtoken, that is not compatible with wasm

cpal = { version = "0.15.2", optional = true }
ffmpeg-next = { git = "https://github.com/decentraland/rust-ffmpeg/", branch="audioline-and-mobile-fix-6.1", optional = true }
Expand All @@ -52,7 +52,7 @@ num = "0.4"
http = "0.2.9"
bytes = "1.4.0"

tokio-tungstenite = "0.20.1"
tokio-tungstenite = "0.21.0" # disable-wasm: this is adding the `mio` library to tokio, because it requires `net` from tokio
futures-util = "0.3.30"

livekit = { git = "https://github.com/robtfm/client-sdk-rust", branch="h264-false", features=["rustls-tls-webpki-roots"], optional = true }
Expand All @@ -75,16 +75,17 @@ jni = { version = "0.21.1", features = ["invocation"] }
paranoid-android = "0.2.1"

[features]
default = ["use_ffmpeg", "use_livekit", "use_deno"]
default = ["use_ffmpeg", "use_deno", "use_livekit"]
use_ffmpeg = ["dep:ffmpeg-next", "dep:cpal"]
use_livekit = ["use_ffmpeg", "dep:livekit"]
use_deno = ["dep:deno_core", "dep:v8"]
enable_inspector = ["use_deno", "dep:uuid", "dep:fastwebsockets", "dep:hyper1"]

[build-dependencies]
webrtc-sys-build = "0.2.0"
webrtc-sys-build = "0.2.0" # disable-wasm: this requires mio, even when it is disabled is being compiled
prost-build = "0.11.8"

[patch."https://github.com/godot-rust/godot4-prebuilt".godot4-prebuilt]
git = "https://github.com//godot-rust/godot4-prebuilt"
branch = "4.2.1"

2 changes: 1 addition & 1 deletion rust/decentraland-godot-lib/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ fn main() -> io::Result<()> {

#[cfg(feature = "use_livekit")]
if env::var("CARGO_CFG_TARGET_OS").unwrap() == "android" {
webrtc_sys_build::configure_jni_symbols().unwrap();
webrtc_sys_build::configure_jni_symbols().unwrap(); // disable-wasm
}

for source in proto_files {
Expand Down
16 changes: 9 additions & 7 deletions rust/decentraland-godot-lib/src/auth/auth_identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ use std::str::FromStr;
use super::{
decentraland_auth_server::{do_request, CreateRequest, RemoteReportState},
ephemeral_auth_chain::EphemeralAuthChain,
wallet::{AsH160, ObjSafeWalletSigner, SimpleAuthChain, Wallet},
wallet::{AsH160, SimpleAuthChain, Wallet, WalletType},
};
use chrono::{DateTime, Utc};
use ethers_core::types::Signature;
use ethers_signers::LocalWallet;
use ethers_signers::{LocalWallet, Signer};
use rand::thread_rng;

pub fn get_ephemeral_message(ephemeral_address: &str, expiration: std::time::SystemTime) -> String {
Expand All @@ -23,7 +23,7 @@ pub async fn try_create_remote_ephemeral(
) -> Result<(EphemeralAuthChain, u64), anyhow::Error> {
let local_wallet = LocalWallet::new(&mut thread_rng());
let signing_key_bytes = local_wallet.signer().to_bytes().to_vec();
let ephemeral_wallet = Wallet::new_from_inner(Box::new(local_wallet));
let ephemeral_wallet = Wallet::new_from_inner(WalletType::Local(local_wallet));
let ephemeral_address = format!("{:#x}", ephemeral_wallet.address());
let expiration = std::time::SystemTime::now() + std::time::Duration::from_secs(30 * 24 * 3600);
let ephemeral_message = get_ephemeral_message(ephemeral_address.as_str(), expiration);
Expand Down Expand Up @@ -54,14 +54,16 @@ pub async fn try_create_remote_ephemeral(
pub fn create_local_ephemeral(signer_wallet: &LocalWallet) -> EphemeralAuthChain {
let local_wallet = LocalWallet::new(&mut thread_rng());
let signing_key_bytes = local_wallet.signer().to_bytes().to_vec();
let ephemeral_wallet = Wallet::new_from_inner(Box::new(local_wallet));
let ephemeral_wallet = Wallet::new_from_inner(WalletType::Local(local_wallet));
let ephemeral_address = format!("{:#x}", ephemeral_wallet.address());
let expiration = std::time::SystemTime::now() + std::time::Duration::from_secs(30 * 24 * 3600);
let ephemeral_message = get_ephemeral_message(ephemeral_address.as_str(), expiration);

let signature =
futures_lite::future::block_on(signer_wallet.sign_message(ephemeral_message.as_bytes()))
.expect("signing with local wallet failed");
let signature = futures_lite::future::block_on(Signer::sign_message(
signer_wallet,
ephemeral_message.as_bytes(),
))
.expect("signing with local wallet failed");

let auth_chain = SimpleAuthChain::new_ephemeral_identity_auth_chain(
signer_wallet.address(),
Expand Down
Loading
Loading