Browse Source

Remove macro

Cesar Rodas 2 months ago
parent
commit
a3f8addb2f
1 changed files with 15 additions and 14 deletions
  1. 15 14
      crates/cdk/src/wallet/client.rs

+ 15 - 14
crates/cdk/src/wallet/client.rs

@@ -20,18 +20,6 @@ use crate::nuts::{
     RestoreResponse, SwapRequest, SwapResponse,
 };
 
-macro_rules! convert_http_response {
-    ($type:ty, $data:ident) => {
-        serde_json::from_str::<$type>(&$data).map_err(|err| {
-            tracing::warn!("Http Response error: {}", err);
-            match ErrorResponse::from_json(&$data) {
-                Ok(ok) => <ErrorResponse as Into<Error>>::into(ok),
-                Err(err) => err.into(),
-            }
-        })
-    };
-}
-
 /// Http Client
 #[derive(Debug, Clone)]
 pub struct HttpClient {
@@ -60,7 +48,13 @@ impl HttpClient {
             .await
             .map_err(|e| Error::HttpError(e.to_string()))?;
 
-        convert_http_response!(R, response)
+        serde_json::from_str::<R>(&response).map_err(|err| {
+            tracing::warn!("Http Response error: {}", err);
+            match ErrorResponse::from_json(&response) {
+                Ok(ok) => <ErrorResponse as Into<Error>>::into(ok),
+                Err(err) => err.into(),
+            }
+        })
     }
 
     #[inline]
@@ -79,7 +73,14 @@ impl HttpClient {
             .text()
             .await
             .map_err(|e| Error::HttpError(e.to_string()))?;
-        convert_http_response!(R, response)
+
+        serde_json::from_str::<R>(&response).map_err(|err| {
+            tracing::warn!("Http Response error: {}", err);
+            match ErrorResponse::from_json(&response) {
+                Ok(ok) => <ErrorResponse as Into<Error>>::into(ok),
+                Err(err) => err.into(),
+            }
+        })
     }
 
     #[cfg(not(target_arch = "wasm32"))]