diff --git a/.docker/Dockerfile b/.docker/Dockerfile index 677d5f8152..467dc4ebc4 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -51,7 +51,8 @@ RUN apt-get install -y \ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --profile minimal --default-toolchain nightly-2023-06-01 -y ENV PATH="/root/.cargo/bin:$PATH" -RUN cargo install wasm-pack --version 0.10.3 +# TODO: Lock wasm-pack version +RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | bash -s -- -y RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v25.3/protoc-25.3-linux-x86_64.zip RUN unzip protoc-25.3-linux-x86_64.zip && mv ./include/google /usr/include/google diff --git a/.github/workflows/dev-build.yml b/.github/workflows/dev-build.yml index ccc959509d..8877bb518f 100644 --- a/.github/workflows/dev-build.yml +++ b/.github/workflows/dev-build.yml @@ -368,7 +368,8 @@ jobs: rustup target add wasm32-unknown-unknown - name: Install wasm-pack - run: CARGO_HOME=/root/.cargo cargo install wasm-pack --version 0.10.3 + # TODO: Lock wasm-pack version + run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh - name: Calculate commit hash for PR commit if: github.event_name == 'pull_request' diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 9cf66098bb..cae080b3d9 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -334,7 +334,8 @@ jobs: rustup target add wasm32-unknown-unknown - name: Install wasm-pack - run: CARGO_HOME=/root/.cargo cargo install wasm-pack --version 0.10.3 + # TODO: Lock wasm-pack version + run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh - name: Calculate commit hash for PR commit if: github.event_name == 'pull_request' diff --git a/Cargo.lock b/Cargo.lock index 60016ffc57..1e0790f40f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6963,6 +6963,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b102d4d896895d697f1dff4141dff28307532dac57a376b2b5665a55b280dc6" dependencies = [ "rustc-hash", + "web-time", ] [[package]] @@ -7784,6 +7785,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "web3" version = "0.19.0" diff --git a/docs/WASM_BUILD.md b/docs/WASM_BUILD.md index 718b8d5bd1..28355bbf80 100644 --- a/docs/WASM_BUILD.md +++ b/docs/WASM_BUILD.md @@ -21,7 +21,7 @@ To build WASM binary from source, the following prerequisites are required: 1. Install `wasm-pack` ``` - cargo install wasm-pack + curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh ``` 2. OSX specific: install `llvm` ``` diff --git a/mm2src/coins/eth/web3_transport/websocket_transport.rs b/mm2src/coins/eth/web3_transport/websocket_transport.rs index 6d19573781..36b13bdb78 100644 --- a/mm2src/coins/eth/web3_transport/websocket_transport.rs +++ b/mm2src/coins/eth/web3_transport/websocket_transport.rs @@ -52,8 +52,8 @@ pub struct WebsocketTransport { #[derive(Debug)] struct ControllerChannel { - tx: Arc>>, - rx: Arc>>, + tx: UnboundedSender, + rx: AsyncMutex>, } enum ControllerMessage { @@ -86,11 +86,10 @@ impl WebsocketTransport { node, event_handlers, request_id: Arc::new(AtomicUsize::new(1)), - controller_channel: ControllerChannel { - tx: Arc::new(AsyncMutex::new(req_tx)), - rx: Arc::new(AsyncMutex::new(req_rx)), - } - .into(), + controller_channel: Arc::new(ControllerChannel { + tx: req_tx, + rx: AsyncMutex::new(req_rx), + }), connection_guard: Arc::new(AsyncMutex::new(())), proxy_sign_keypair: None, last_request_failed: Arc::new(AtomicBool::new(false)), @@ -298,7 +297,7 @@ impl WebsocketTransport { } pub(crate) async fn stop_connection_loop(&self) { - let mut tx = self.controller_channel.tx.lock().await; + let mut tx = self.controller_channel.tx.clone(); tx.send(ControllerMessage::Close) .await .expect("receiver channel must be alive"); @@ -357,12 +356,11 @@ async fn send_request( serialized_request = serde_json::to_string(&wrapper)?; } - let mut tx = transport.controller_channel.tx.lock().await; - let (notification_sender, notification_receiver) = oneshot::channel::>(); event_handlers.on_outgoing_request(&request_bytes); + let mut tx = transport.controller_channel.tx.clone(); tx.send(ControllerMessage::Request(WsRequest { request_id, serialized_request, diff --git a/mm2src/coins/tendermint/rpc/tendermint_wasm_rpc.rs b/mm2src/coins/tendermint/rpc/tendermint_wasm_rpc.rs index 9224ea997f..4a5d13c05f 100644 --- a/mm2src/coins/tendermint/rpc/tendermint_wasm_rpc.rs +++ b/mm2src/coins/tendermint/rpc/tendermint_wasm_rpc.rs @@ -138,7 +138,7 @@ mod tests { #[wasm_bindgen_test] async fn test_get_abci_info() { - let client = HttpClient::new("https://rpc.sentry-02.theta-testnet.polypore.xyz", None).unwrap(); + let client = HttpClient::new("http://34.80.202.172:26657", None).unwrap(); client.abci_info().await.unwrap(); } } diff --git a/mm2src/mm2_p2p/Cargo.toml b/mm2src/mm2_p2p/Cargo.toml index 41a82c3c16..3fc156b6ca 100644 --- a/mm2src/mm2_p2p/Cargo.toml +++ b/mm2src/mm2_p2p/Cargo.toml @@ -46,7 +46,7 @@ tokio = { version = "1.20", default-features = false } futures-rustls = "0.22" instant = { version = "0.1.12", features = ["wasm-bindgen"] } libp2p = { git = "https://github.com/KomodoPlatform/rust-libp2p.git", tag = "k-0.52.11", default-features = false, features = ["identify", "floodsub", "noise", "gossipsub", "ping", "request-response", "secp256k1", "wasm-ext", "wasm-ext-websocket", "macros", "yamux"] } -timed-map = { version = "1.1.1", features = ["rustc-hash"] } +timed-map = { version = "1.1.1", features = ["rustc-hash", "wasm"] } [dev-dependencies] async-std = "1.6.2"