From 96964004ad52a1f06e74fc563ffd373aad79c48c Mon Sep 17 00:00:00 2001 From: Andreas Wuerl Date: Tue, 23 May 2023 10:58:13 +0200 Subject: [PATCH 1/2] update library integration --- client/vendor/magic-wormhole.rs | 2 +- client/wasm/src/lib.rs | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/client/vendor/magic-wormhole.rs b/client/vendor/magic-wormhole.rs index 7c13ce88..e6ddc75c 160000 --- a/client/vendor/magic-wormhole.rs +++ b/client/vendor/magic-wormhole.rs @@ -1 +1 @@ -Subproject commit 7c13ce88b5ad5666ed084f9d1241159d0a1ad7d8 +Subproject commit e6ddc75c63ba030d5681cac04ca3e5a2262acc50 diff --git a/client/wasm/src/lib.rs b/client/wasm/src/lib.rs index 9d963fa6..af3163dc 100644 --- a/client/wasm/src/lib.rs +++ b/client/wasm/src/lib.rs @@ -10,7 +10,7 @@ use std::pin::Pin; use std::task::{Context, Poll}; use thiserror::Error; -use magic_wormhole::{transfer, transit, AppID, Code, Wormhole, WormholeError}; +use magic_wormhole::{transfer, transit, AppID, Code, Wormhole, WormholeError, MailboxConnection}; use wasm_bindgen::prelude::*; use wasm_bindgen_futures::JsFuture; @@ -120,10 +120,11 @@ pub async fn send(client: &Client, file: web_sys::File) -> Result Result x, + let connection = match MailboxConnection::connect(config, Code(code), false).await { + Ok(x) => x, Err(e) => return Err(WasmWormholeError::BadCode(e)), }; + let wormhole = match Wormhole::connect(connection).await { + Ok((_, x)) => x, + Err(e) => return Err(WasmWormholeError::WormholeConnectionFailed(e)), + }; + let req = transfer::request_file( wormhole, vec![transit::RelayHint::new( From baf871e542492d9d9f31471d0ab3c617f60f9e0f Mon Sep 17 00:00:00 2001 From: Andreas Wuerl Date: Tue, 23 May 2023 17:11:55 +0200 Subject: [PATCH 2/2] fix unwrapping --- client/wasm/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/wasm/src/lib.rs b/client/wasm/src/lib.rs index af3163dc..a08d6d0c 100644 --- a/client/wasm/src/lib.rs +++ b/client/wasm/src/lib.rs @@ -226,7 +226,7 @@ pub async fn receive(client: &Client, code: String) -> Result x, + Ok(x) => x, Err(e) => return Err(WasmWormholeError::WormholeConnectionFailed(e)), };