Browse Source

Fix build for wasm

Cesar Rodas 2 months ago
parent
commit
0b8ce2ab88

+ 1 - 1
crates/cdk-ffi/src/wallet.rs

@@ -404,7 +404,7 @@ impl Wallet {
 }
 
 /// BIP353 methods for Wallet
-#[cfg(feature = "bip353")]
+#[cfg(all(feature = "bip353", not(target_arch = "wasm32")))]
 #[uniffi::export(async_runtime = "tokio")]
 impl Wallet {
     /// Get a quote for a BIP353 melt

+ 1 - 1
crates/cdk/Cargo.toml

@@ -57,9 +57,9 @@ bech32 = "0.9.1"
 arc-swap = "1.7.1"
 zeroize = "1"
 tokio-util.workspace = true
-hickory-resolver = { version = "0.25.2", optional = true, features = ["dnssec-ring"] }
 
 [target.'cfg(not(target_arch = "wasm32"))'.dependencies]
+hickory-resolver = { version = "0.25.2", optional = true, features = ["dnssec-ring"] }
 tokio = { workspace = true, features = [
     "rt-multi-thread",
     "time",

+ 1 - 1
crates/cdk/examples/mint-token-bolt12-with-custom-http.rs

@@ -40,7 +40,7 @@ impl Default for CustomHttp {
 #[cfg_attr(target_arch = "wasm32", async_trait::async_trait(?Send))]
 #[cfg_attr(not(target_arch = "wasm32"), async_trait::async_trait)]
 impl HttpTransport for CustomHttp {
-    #[cfg(feature = "bip353")]
+    #[cfg(all(feature = "bip353", not(target_arch = "wasm32")))]
     async fn resolve_dns_txt(&self, _domain: &str) -> Result<Vec<String>, Error> {
         panic!("Not supported");
     }

+ 1 - 1
crates/cdk/src/lib.rs

@@ -22,7 +22,7 @@ pub mod mint;
 #[cfg(feature = "wallet")]
 pub mod wallet;
 
-#[cfg(feature = "bip353")]
+#[cfg(all(feature = "bip353", not(target_arch = "wasm32")))]
 mod bip353;
 
 #[cfg(all(any(feature = "wallet", feature = "mint"), feature = "auth"))]

+ 2 - 2
crates/cdk/src/wallet/melt/melt_bip353.rs

@@ -7,7 +7,7 @@ use std::str::FromStr;
 use cdk_common::wallet::MeltQuote;
 use tracing::instrument;
 
-#[cfg(feature = "bip353")]
+#[cfg(all(feature = "bip353", not(target_arch = "wasm32")))]
 use crate::bip353::{Bip353Address, PaymentType};
 use crate::nuts::MeltOptions;
 use crate::{Amount, Error, Wallet};
@@ -47,7 +47,7 @@ impl Wallet {
     /// # Ok(())
     /// # }
     /// ```
-    #[cfg(feature = "bip353")]
+    #[cfg(all(feature = "bip353", not(target_arch = "wasm32")))]
     #[instrument(skip(self, amount_msat), fields(address = %bip353_address))]
     pub async fn melt_bip353_quote(
         &self,

+ 1 - 1
crates/cdk/src/wallet/melt/mod.rs

@@ -7,7 +7,7 @@ use tracing::instrument;
 
 use crate::Wallet;
 
-#[cfg(feature = "bip353")]
+#[cfg(all(feature = "bip353", not(target_arch = "wasm32")))]
 mod melt_bip353;
 mod melt_bolt11;
 mod melt_bolt12;

+ 1 - 1
crates/cdk/src/wallet/mint_connector/http_client.rs

@@ -187,7 +187,7 @@ impl<T> MintConnector for HttpClient<T>
 where
     T: Transport + Send + Sync + 'static,
 {
-    #[cfg(feature = "bip353")]
+    #[cfg(all(feature = "bip353", not(target_arch = "wasm32")))]
     #[instrument(skip(self), fields(mint_url = %self.mint_url))]
     async fn resolve_dns_txt(&self, domain: &str) -> Result<Vec<String>, Error> {
         self.transport.resolve_dns_txt(domain).await

+ 1 - 1
crates/cdk/src/wallet/mint_connector/mod.rs

@@ -28,7 +28,7 @@ pub type HttpClient = http_client::HttpClient<transport::Async>;
 #[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
 #[cfg_attr(not(target_arch = "wasm32"), async_trait)]
 pub trait MintConnector: Debug {
-    #[cfg(feature = "bip353")]
+    #[cfg(all(feature = "bip353", not(target_arch = "wasm32")))]
     /// Resolve the DNS record getting the TXT value
     async fn resolve_dns_txt(&self, _domain: &str) -> Result<Vec<String>, Error>;
 

+ 5 - 5
crates/cdk/src/wallet/mint_connector/transport.rs

@@ -2,11 +2,11 @@
 use std::fmt::Debug;
 
 use cdk_common::AuthToken;
-#[cfg(feature = "bip353")]
+#[cfg(all(feature = "bip353", not(target_arch = "wasm32")))]
 use hickory_resolver::config::ResolverConfig;
-#[cfg(feature = "bip353")]
+#[cfg(all(feature = "bip353", not(target_arch = "wasm32")))]
 use hickory_resolver::name_server::TokioConnectionProvider;
-#[cfg(feature = "bip353")]
+#[cfg(all(feature = "bip353", not(target_arch = "wasm32")))]
 use hickory_resolver::Resolver;
 use reqwest::Client;
 use serde::de::DeserializeOwned;
@@ -20,7 +20,7 @@ use crate::error::ErrorResponse;
 #[cfg_attr(target_arch = "wasm32", async_trait::async_trait(?Send))]
 #[cfg_attr(not(target_arch = "wasm32"), async_trait::async_trait)]
 pub trait Transport: Default + Send + Sync + Debug + Clone {
-    #[cfg(feature = "bip353")]
+    #[cfg(all(feature = "bip353", not(target_arch = "wasm32")))]
     /// DNS resolver to get a TXT record from a domain name
     async fn resolve_dns_txt(&self, _domain: &str) -> Result<Vec<String>, Error>;
 
@@ -113,7 +113,7 @@ impl Transport for Async {
     }
 
     /// DNS resolver to get a TXT record from a domain name
-    #[cfg(feature = "bip353")]
+    #[cfg(all(feature = "bip353", not(target_arch = "wasm32")))]
     async fn resolve_dns_txt(&self, domain: &str) -> Result<Vec<String>, Error> {
         let resolver = Resolver::builder_with_config(
             ResolverConfig::default(),