diff --git a/.github/workflows/test-workspace-against-dev.yml b/.github/workflows/test-workspace-against-dev.yml new file mode 100644 index 000000000..d43367b7d --- /dev/null +++ b/.github/workflows/test-workspace-against-dev.yml @@ -0,0 +1,44 @@ +name: Test Workspace +on: + push: + branches: + - main + pull_request: + # only run tests when related changes are made + paths: + - ".github/workflows/test-workspace-against-dev.yml" + - "dev/**" + - "mls_validation_service/**" + - "xmtp_api_grpc/**" + - "xmtp_cryptography/**" + - "xmtp_id/**" + - "xmtp_mls/**" + - "xmtp_proto/**" + - "xmtp_v2/**" + - "Cargo.toml" + - "Cargo.lock" + - "rust-toolchain" +env: + CARGO_TERM_COLOR: always +jobs: + test: + name: Test + runs-on: warp-ubuntu-latest-x64-16x + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Update rust toolchains + run: rustup update + - name: Install Foundry + uses: foundry-rs/foundry-toolchain@v1 + - name: Cache + uses: Swatinem/rust-cache@v2 + with: + workspaces: | + . + - name: Install nextest + uses: taiki-e/install-action@nextest + - name: build tests + run: cargo nextest run --features test-dev --no-run --workspace --tests --exclude xmtpv3 --exclude bindings_node --exclude bindings_wasm + - name: cargo test + run: cargo nextest run --features test-dev --workspace --test-threads 2 --exclude xmtpv3 --exclude bindings_node --exclude bindings_wasm diff --git a/Cargo.lock b/Cargo.lock index f62c5eea8..be8268540 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1206,7 +1206,7 @@ dependencies = [ [[package]] name = "diesel" version = "2.2.0" -source = "git+https://github.com/diesel-rs/diesel?branch=master#efd59557a15322f1a54a5c263b1eb4ec0b5a0783" +source = "git+https://github.com/diesel-rs/diesel?branch=master#b170af753cc3c6774f578aae1081711a09dfa2ac" dependencies = [ "diesel_derives", "downcast-rs", @@ -1236,7 +1236,7 @@ dependencies = [ [[package]] name = "diesel_derives" version = "2.2.0" -source = "git+https://github.com/diesel-rs/diesel?branch=master#efd59557a15322f1a54a5c263b1eb4ec0b5a0783" +source = "git+https://github.com/diesel-rs/diesel?branch=master#b170af753cc3c6774f578aae1081711a09dfa2ac" dependencies = [ "diesel_table_macro_syntax", "dsl_auto_type", @@ -1248,7 +1248,7 @@ dependencies = [ [[package]] name = "diesel_migrations" version = "2.2.0" -source = "git+https://github.com/diesel-rs/diesel?branch=master#efd59557a15322f1a54a5c263b1eb4ec0b5a0783" +source = "git+https://github.com/diesel-rs/diesel?branch=master#b170af753cc3c6774f578aae1081711a09dfa2ac" dependencies = [ "diesel", "migrations_internals", @@ -1258,7 +1258,7 @@ dependencies = [ [[package]] name = "diesel_table_macro_syntax" version = "0.2.0" -source = "git+https://github.com/diesel-rs/diesel?branch=master#efd59557a15322f1a54a5c263b1eb4ec0b5a0783" +source = "git+https://github.com/diesel-rs/diesel?branch=master#b170af753cc3c6774f578aae1081711a09dfa2ac" dependencies = [ "syn 2.0.79", ] @@ -1341,7 +1341,7 @@ checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" [[package]] name = "dsl_auto_type" version = "0.1.0" -source = "git+https://github.com/diesel-rs/diesel?branch=master#efd59557a15322f1a54a5c263b1eb4ec0b5a0783" +source = "git+https://github.com/diesel-rs/diesel?branch=master#b170af753cc3c6774f578aae1081711a09dfa2ac" dependencies = [ "darling", "either", @@ -2598,19 +2598,6 @@ dependencies = [ "tower-service", ] -[[package]] -name = "hyper-tls" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" -dependencies = [ - "bytes", - "hyper 0.14.31", - "native-tls", - "tokio", - "tokio-native-tls", -] - [[package]] name = "hyper-tls" version = "0.6.0" @@ -2964,9 +2951,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.159" +version = "0.2.161" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" +checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" [[package]] name = "libloading" @@ -3114,7 +3101,7 @@ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "migrations_internals" version = "2.2.0" -source = "git+https://github.com/diesel-rs/diesel?branch=master#efd59557a15322f1a54a5c263b1eb4ec0b5a0783" +source = "git+https://github.com/diesel-rs/diesel?branch=master#b170af753cc3c6774f578aae1081711a09dfa2ac" dependencies = [ "serde", "toml 0.8.19", @@ -3123,7 +3110,7 @@ dependencies = [ [[package]] name = "migrations_macros" version = "2.2.0" -source = "git+https://github.com/diesel-rs/diesel?branch=master#efd59557a15322f1a54a5c263b1eb4ec0b5a0783" +source = "git+https://github.com/diesel-rs/diesel?branch=master#b170af753cc3c6774f578aae1081711a09dfa2ac" dependencies = [ "migrations_internals", "proc-macro2", @@ -3619,9 +3606,9 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.68" +version = "0.10.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" +checksum = "bac25ee399abb46215765b1cb35bc0212377e58a061560d8b29b024fd0430e7c" dependencies = [ "bitflags 2.6.0", "cfg-if", @@ -3651,18 +3638,18 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-src" -version = "300.3.2+3.3.2" +version = "111.28.2+1.1.1w" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a211a18d945ef7e648cc6e0058f4c548ee46aab922ea203e0d30e966ea23647b" +checksum = "bb1830e20a48a975ca898ca8c1d036a36c3c6c5cb7dabc1c216706587857920f" dependencies = [ "cc", ] [[package]] name = "openssl-sys" -version = "0.9.104" +version = "0.9.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" +checksum = "db7e971c2c2bba161b2d2fdf37080177eff520b3bc044787c7f1f5f9e78d869b" dependencies = [ "cc", "libc", @@ -4424,12 +4411,10 @@ dependencies = [ "http-body 0.4.6", "hyper 0.14.31", "hyper-rustls 0.24.2", - "hyper-tls 0.5.0", "ipnet", "js-sys", "log", "mime", - "native-tls", "once_cell", "percent-encoding", "pin-project-lite", @@ -4441,7 +4426,6 @@ dependencies = [ "sync_wrapper 0.1.2", "system-configuration 0.5.1", "tokio", - "tokio-native-tls", "tokio-rustls 0.24.1", "tower-service", "url", @@ -4469,7 +4453,7 @@ dependencies = [ "http-body-util", "hyper 1.5.0", "hyper-rustls 0.27.3", - "hyper-tls 0.6.0", + "hyper-tls", "hyper-util", "ipnet", "js-sys", @@ -4976,9 +4960,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.128" +version = "1.0.129" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" +checksum = "6dbcf9b78a125ee667ae19388837dd12294b858d101fdd393cb9d5501ef09eb2" dependencies = [ "itoa", "memchr", @@ -5695,10 +5679,8 @@ checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c" dependencies = [ "futures-util", "log", - "native-tls", "rustls 0.21.12", "tokio", - "tokio-native-tls", "tokio-rustls 0.24.1", "tungstenite 0.20.1", "webpki-roots 0.25.4", @@ -5973,7 +5955,6 @@ dependencies = [ "http 0.2.12", "httparse", "log", - "native-tls", "rand", "rustls 0.21.12", "sha1", @@ -6842,7 +6823,9 @@ dependencies = [ "base64 0.22.1", "futures", "hex", + "http 1.1.0", "prost", + "thiserror", "tokio", "tonic", "tracing", @@ -7019,6 +7002,7 @@ dependencies = [ "pbjson-types", "prost", "serde", + "thiserror", "tonic", "trait-variant", "wasm-bindgen-test", diff --git a/Cargo.toml b/Cargo.toml index 03be9ffb3..907f2b32c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ members = [ resolver = "2" [workspace.package] -version = "0.0.1" +version = "0.1.0" [workspace.dependencies] anyhow = "1.0" @@ -72,8 +72,8 @@ web-sys = "0.3" js-sys = "0.3" # NOTE: A regression in openssl-sys exists where libatomic is dynamically linked # for i686-linux-android targets. https://github.com/sfackler/rust-openssl/issues/2163 -openssl-sys = "0.9.104" -openssl = "0.10.68" +openssl-sys = "=0.9.92" +openssl = "=0.10.57" libsqlite3-sys = { version = "0.29", features = ["bundled-sqlcipher-vendored-openssl" ] } dyn-clone = "1" trait-variant = "0.1.2" @@ -120,9 +120,7 @@ inherits = "release-with-lto" # optimize for binary size opt-level = "s" -# patch needed until some items -# are made public for third-party dependencies: https://github.com/diesel-rs/diesel/pull/4236 -# (cfg-specific patche support does not exist) +# patch needed until diesel makes a release past `2.2.4` [patch.crates-io] diesel-wasm-sqlite = { git = "https://github.com/xmtp/diesel-wasm-sqlite", branch = "main" } diesel = { git = "https://github.com/diesel-rs/diesel", branch = "master" } diff --git a/bindings_ffi/Cargo.toml b/bindings_ffi/Cargo.toml index c2dd3ff8e..c1754a02d 100644 --- a/bindings_ffi/Cargo.toml +++ b/bindings_ffi/Cargo.toml @@ -31,7 +31,7 @@ name = "ffi-uniffi-bindgen" path = "src/bin.rs" [dev-dependencies] -ethers = { workspace = true, features = ["openssl"] } +ethers.workspace = true rand.workspace = true tokio = { workspace = true, features = ["rt-multi-thread"] } uniffi = { version = "0.28.0", features = ["bindgen-tests"] } diff --git a/xmtp_api_grpc/Cargo.toml b/xmtp_api_grpc/Cargo.toml index 63976306a..db6f84b7e 100644 --- a/xmtp_api_grpc/Cargo.toml +++ b/xmtp_api_grpc/Cargo.toml @@ -4,6 +4,7 @@ name = "xmtp_api_grpc" version.workspace = true [dependencies] +thiserror.workspace = true async-stream.workspace = true base64.workspace = true futures.workspace = true @@ -14,6 +15,7 @@ tonic = { workspace = true, features = [ "tls-native-roots", "tls-webpki-roots", ] } +http = "1.1" # for error msgs from tonic tracing.workspace = true xmtp_proto = { path = "../xmtp_proto", features = ["proto_full"] } xmtp_v2 = { path = "../xmtp_v2" } diff --git a/xmtp_api_grpc/src/grpc_api_helper.rs b/xmtp_api_grpc/src/grpc_api_helper.rs index e45916424..be5970897 100644 --- a/xmtp_api_grpc/src/grpc_api_helper.rs +++ b/xmtp_api_grpc/src/grpc_api_helper.rs @@ -29,9 +29,37 @@ use xmtp_proto::{ }, }; -async fn create_tls_channel(address: String) -> Result { +#[derive(thiserror::Error, Debug)] +pub enum GrpcError { + #[error("failed to create channel {0}")] + SetupCreateChannel(#[from] http::uri::InvalidUri), + #[error("tls configuration failed: {0}")] + SetupTLSConfig(tonic::transport::Error, String), + #[error("connection setup failed {0}")] + SetupConnection(tonic::transport::Error), + #[error(transparent)] + Transport(#[from] tonic::transport::Error), + #[error("metadata error {0}")] + MetadataValueConversion(#[from] tonic::metadata::errors::InvalidMetadataValue), + // #[error("publish error {0}")] + // Publish(#[from] PublishError), +} + +#[derive(thiserror::Error, Debug)] +pub enum V2ApiError { + #[error("metadata error {0}")] + MetadataValueConversion(#[from] tonic::metadata::errors::InvalidMetadataValue), + #[error("Publish request failed with status {0}")] + Publish(tonic::Status), + #[error("Subcribe request failed with status {0}")] + Subscribe(tonic::Status), + #[error("Query request failed with status {0}")] + Query(tonic::Status), +} + +async fn create_tls_channel(address: String) -> Result { let channel = Channel::from_shared(address) - .map_err(|e| Error::new(ErrorKind::SetupCreateChannelError).with(e))? + .map_err(GrpcError::SetupCreateChannel)? // Purpose: This setting controls the size of the initial connection-level flow control window for HTTP/2, which is the underlying protocol for gRPC. // Functionality: Flow control in HTTP/2 manages how much data can be in flight on the network. Setting the initial connection window size to (1 << 31) - 1 (the maximum possible value for a 32-bit integer, which is 2,147,483,647 bytes) essentially allows the client to receive a very large amount of data from the server before needing to acknowledge receipt and permit more data to be sent. This can be particularly useful in high-latency networks or when transferring large amounts of data. // Impact: Increasing the window size can improve throughput by allowing more data to be in transit at a time, but it may also increase memory usage and can potentially lead to inefficient use of bandwidth if the network is unreliable. @@ -57,10 +85,10 @@ async fn create_tls_channel(address: String) -> Result { // Impact: This setting is crucial for quickly detecting unresponsive connections and freeing up resources associated with them. It ensures that the client has up-to-date information on the status of connections and can react accordingly. .keep_alive_timeout(Duration::from_secs(25)) .tls_config(ClientTlsConfig::new().with_enabled_roots()) - .map_err(|e| Error::new(ErrorKind::SetupTLSConfigError).with(e))? + .map_err(|e| GrpcError::Transport(e))? .connect() .await - .map_err(|e| Error::new(ErrorKind::SetupConnectionError).with(e))?; + .map_err(|e| GrpcError::SetupConnection(e))?; Ok(channel) } @@ -75,20 +103,18 @@ pub struct Client { } impl Client { - pub async fn create(host: String, is_secure: bool) -> Result { + pub async fn create(host: String, is_secure: bool) -> Result { let host = host.to_string(); - let app_version = MetadataValue::try_from(&String::from("0.0.0")) - .map_err(|e| Error::new(ErrorKind::MetadataError).with(e))?; - let libxmtp_version = MetadataValue::try_from(&String::from("0.0.0")) - .map_err(|e| Error::new(ErrorKind::MetadataError).with(e))?; + let app_version = MetadataValue::try_from(&String::from("0.0.0"))?; + let libxmtp_version = MetadataValue::try_from(&String::from("0.0.0"))?; let channel = match is_secure { true => create_tls_channel(host).await?, false => Channel::from_shared(host) - .map_err(|e| Error::new(ErrorKind::SetupCreateChannelError).with(e))? + .map_err(GrpcError::SetupCreateChannel)? .connect() .await - .map_err(|e| Error::new(ErrorKind::SetupConnectionError).with(e))?, + .map_err(GrpcError::SetupConnection)?, }; let client = MessageApiClient::new(channel.clone()); @@ -120,16 +146,15 @@ impl Client { } impl ClientWithMetadata for Client { - fn set_libxmtp_version(&mut self, version: String) -> Result<(), Error> { - self.libxmtp_version = MetadataValue::try_from(&version) - .map_err(|e| Error::new(ErrorKind::MetadataError).with(e))?; + type Error = GrpcError; + fn set_libxmtp_version(&mut self, version: String) -> Result<(), Self::Error> { + self.libxmtp_version = MetadataValue::try_from(&version)?; Ok(()) } - fn set_app_version(&mut self, version: String) -> Result<(), Error> { - self.app_version = MetadataValue::try_from(&version) - .map_err(|e| Error::new(ErrorKind::MetadataError).with(e))?; + fn set_app_version(&mut self, version: String) -> Result<(), Self::Error> { + self.app_version = MetadataValue::try_from(&version)?; Ok(()) } @@ -138,16 +163,15 @@ impl ClientWithMetadata for Client { impl XmtpApiClient for Client { type Subscription = Subscription; type MutableSubscription = GrpcMutableSubscription; + type Error = V2ApiError; async fn publish( &self, token: String, request: PublishRequest, - ) -> Result { + ) -> Result { let auth_token_string = format!("Bearer {}", token); - let token: MetadataValue<_> = auth_token_string - .parse() - .map_err(|e| Error::new(ErrorKind::PublishError).with(e))?; + let token: MetadataValue<_> = auth_token_string.parse()?; let mut tonic_request = self.build_request(request); tonic_request.metadata_mut().insert("authorization", token); @@ -157,15 +181,15 @@ impl XmtpApiClient for Client { .publish(tonic_request) .await .map(|r| r.into_inner()) - .map_err(|e| Error::new(ErrorKind::PublishError).with(e)) + .map_err(V2ApiError::Publish) } - async fn subscribe(&self, request: SubscribeRequest) -> Result { + async fn subscribe(&self, request: SubscribeRequest) -> Result { let client = &mut self.client.clone(); let stream = client .subscribe(self.build_request(request)) .await - .map_err(|e| Error::new(ErrorKind::SubscribeError).with(e))? + .map_err(V2ApiError::Subscribe)? .into_inner(); Ok(Subscription::start(stream).await) @@ -174,7 +198,7 @@ impl XmtpApiClient for Client { async fn subscribe2( &self, request: SubscribeRequest, - ) -> Result { + ) -> Result { let (sender, mut receiver) = futures::channel::mpsc::unbounded::(); let input_stream = async_stream::stream! { @@ -200,7 +224,7 @@ impl XmtpApiClient for Client { )) } - async fn query(&self, request: QueryRequest) -> Result { + async fn query(&self, request: QueryRequest) -> Result { let client = &mut self.client.clone(); let res = client.query(self.build_request(request)).await; @@ -211,7 +235,10 @@ impl XmtpApiClient for Client { } } - async fn batch_query(&self, request: BatchQueryRequest) -> Result { + async fn batch_query( + &self, + request: BatchQueryRequest, + ) -> Result { let client = &mut self.client.clone(); let res = client.batch_query(self.build_request(request)).await; diff --git a/xmtp_api_grpc/src/lib.rs b/xmtp_api_grpc/src/lib.rs index 265f6f107..59b6120fa 100644 --- a/xmtp_api_grpc/src/lib.rs +++ b/xmtp_api_grpc/src/lib.rs @@ -20,7 +20,7 @@ mod utils { } async fn create_dev() -> Self { - crate::Client::create("https://grpc.dev.xmtp.network:443".into(), false) + crate::Client::create("https://grpc.dev.xmtp.network:443".into(), true) .await .unwrap() } diff --git a/xmtp_id/Cargo.toml b/xmtp_id/Cargo.toml index 9210c997d..a324eaf39 100644 --- a/xmtp_id/Cargo.toml +++ b/xmtp_id/Cargo.toml @@ -27,15 +27,14 @@ tracing.workspace = true xmtp_cryptography.workspace = true xmtp_proto = { workspace = true, features = ["proto_full"] } wasm-timer.workspace = true +ethers = {workspace = true, features = ["rustls"] } [target.'cfg(target_arch = "wasm32")'.dependencies] getrandom = { version = "0.2", features = ["js"] } openmls = { workspace = true, features = ["js"] } -ethers = { workspace = true, features = ["rustls"] } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] openmls.workspace = true -ethers = { workspace = true, features = ["openssl"] } [dev-dependencies] xmtp_v2 = { path = "../xmtp_v2" } diff --git a/xmtp_mls/Cargo.toml b/xmtp_mls/Cargo.toml index f30977038..08f40cfe1 100644 --- a/xmtp_mls/Cargo.toml +++ b/xmtp_mls/Cargo.toml @@ -1,7 +1,7 @@ [package] edition = "2021" name = "xmtp_mls" -version = "0.1.0" +version.workspace = true [package.metadata.docs.rs] all-features = true @@ -11,6 +11,7 @@ targets = ["x86_64-unknown-linux-gnu", "wasm32-unknown-unknown", "aarch64-apple- [features] default = ["grpc-api"] test-utils = ["tracing-subscriber", "dep:tracing-wasm", "dep:console_error_panic_hook", "xmtp_id/test-utils", "xmtp_proto/test-utils", "xmtp_api_http/test-utils", "xmtp_api_grpc/test-utils"] +test-dev = ["test-utils"] # test against the XMTP Dev Server bench = ["test-utils", "indicatif", "tracing-subscriber", "anyhow", "tracing-flame", "once_cell", "dep:xmtp_api_grpc", "criterion"] update-schema = ["toml"] http-api = ["dep:xmtp_api_http"] @@ -41,6 +42,7 @@ async-trait.workspace = true futures.workspace = true dyn-clone = "1" wasm-timer.workspace = true +ethers = { workspace = true, features = ["rustls"] } # XMTP/Local xmtp_cryptography = { workspace = true } @@ -102,7 +104,6 @@ xmtp_proto = { workspace = true, features = ["test-utils" ]} anyhow.workspace = true [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] -ethers = { workspace = true, features = ["openssl"] } xmtp_api_grpc = { path = "../xmtp_api_grpc", features = ["test-utils"] } xmtp_api_http = { path = "../xmtp_api_http", features = ["test-utils"] } tracing-subscriber = { workspace = true, features = ["env-filter", "fmt", "ansi"] } @@ -111,7 +112,6 @@ mockito = "1.4.0" ctor.workspace = true [target.'cfg(target_arch = "wasm32")'.dev-dependencies] -ethers = { workspace = true, features = ["rustls"] } xmtp_api_http = { path = "../xmtp_api_http", features = ["test-utils"] } tracing-wasm = { version = "0.2" } diesel-wasm-sqlite = { workspace = true, features = ["unsafe-debug-query", "r2d2"] } diff --git a/xmtp_mls/src/utils/test/mod.rs b/xmtp_mls/src/utils/test/mod.rs index 8e9801d5e..331b0bd2e 100755 --- a/xmtp_mls/src/utils/test/mod.rs +++ b/xmtp_mls/src/utils/test/mod.rs @@ -153,7 +153,11 @@ impl ClientBuilder { /// Add the local client to this builder pub async fn local_client(self) -> Self { - self.api_client(::create_local().await) + if cfg!(feature = "test-dev") { + self.api_client(::create_dev().await) + } else { + self.api_client(::create_local().await) + } } pub async fn dev_client(self) -> Self { @@ -187,6 +191,7 @@ where client } + /// wrapper over a `Notify` with a 60-scond timeout for waiting #[derive(Clone, Default)] pub struct Delivery { diff --git a/xmtp_proto/Cargo.toml b/xmtp_proto/Cargo.toml index 108923546..f3da2ee8b 100644 --- a/xmtp_proto/Cargo.toml +++ b/xmtp_proto/Cargo.toml @@ -11,6 +11,7 @@ prost = { workspace = true, features = ["prost-derive"] } serde = { workspace = true } openmls = { workspace = true, optional = true } trait-variant = "0.1.2" +thiserror.workspace = true [target.'cfg(not(target_arch = "wasm32"))'.dependencies] tonic = { workspace = true } diff --git a/xmtp_proto/src/api_client.rs b/xmtp_proto/src/api_client.rs index 2ee341a6a..50dd4effb 100644 --- a/xmtp_proto/src/api_client.rs +++ b/xmtp_proto/src/api_client.rs @@ -236,14 +236,16 @@ pub trait XmtpApiSubscription { } #[allow(async_fn_in_trait)] -pub trait MutableApiSubscription: Stream> + Send { +pub trait MutableApiSubscription: Stream> + Send { + type Error; async fn update(&mut self, req: SubscribeRequest) -> Result<(), Error>; fn close(&self); } pub trait ClientWithMetadata { - fn set_libxmtp_version(&mut self, version: String) -> Result<(), Error>; - fn set_app_version(&mut self, version: String) -> Result<(), Error>; + type Error; + fn set_libxmtp_version(&mut self, version: String) -> Result<(), Self::Error>; + fn set_app_version(&mut self, version: String) -> Result<(), Self::Error>; } /// Global Marker trait for WebAssembly @@ -257,6 +259,7 @@ impl Wasm for T {} #[cfg_attr(not(target_arch = "wasm32"), trait_variant::make(XmtpApiClient: Send))] #[cfg_attr(target_arch = "wasm32", trait_variant::make(XmtpApiClient: Wasm))] pub trait LocalXmtpApiClient { + type Error; type Subscription: XmtpApiSubscription; type MutableSubscription: MutableApiSubscription; @@ -264,18 +267,22 @@ pub trait LocalXmtpApiClient { &self, token: String, request: PublishRequest, - ) -> Result; + ) -> Result; - async fn subscribe(&self, request: SubscribeRequest) -> Result; + async fn subscribe(&self, request: SubscribeRequest) + -> Result; async fn subscribe2( &self, request: SubscribeRequest, - ) -> Result; + ) -> Result; - async fn query(&self, request: QueryRequest) -> Result; + async fn query(&self, request: QueryRequest) -> Result; - async fn batch_query(&self, request: BatchQueryRequest) -> Result; + async fn batch_query( + &self, + request: BatchQueryRequest, + ) -> Result; } // Wasm futures don't have `Send` or `Sync` bounds. diff --git a/xtask/src/build.rs b/xtask/src/build.rs index aa8bc0c9f..b75165141 100644 --- a/xtask/src/build.rs +++ b/xtask/src/build.rs @@ -77,6 +77,7 @@ pub fn build_bindings_wasm(extra_args: &[String], flags: flags::BindingsWasm) -> sp.text("running wasm-opt").update(); step_run_wasm_opt(&pkg_directory, spinner_update)?; + sp.success(); Ok(()) }