Эх сурвалжийг харах

fix: remove to_string from payment req (#1557)

tsk 5 өдөр өмнө
parent
commit
2afc704261

+ 11 - 6
crates/cdk-ffi/src/types/payment_request.rs

@@ -309,11 +309,6 @@ impl PaymentRequestPayload {
         Ok(Arc::new(PaymentRequestPayload { inner }))
     }
 
-    /// Encode PaymentRequestPayload to JSON string
-    pub fn to_string(&self) -> Result<String, FfiError> {
-        Ok(serde_json::to_string(&self.inner)?)
-    }
-
     /// Get the ID
     pub fn id(&self) -> Option<String> {
         self.inner.id.clone()
@@ -340,6 +335,16 @@ impl PaymentRequestPayload {
     }
 }
 
+impl std::fmt::Display for PaymentRequestPayload {
+    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+        write!(
+            f,
+            "{}",
+            serde_json::to_string(&self.inner).map_err(|_| std::fmt::Error)?
+        )
+    }
+}
+
 #[cfg(test)]
 mod tests {
     use super::*;
@@ -385,7 +390,7 @@ mod tests {
 
         let payload = PaymentRequestPayload { inner };
 
-        let json = payload.to_string().unwrap();
+        let json = payload.to_string();
         let decoded = PaymentRequestPayload::from_string(json).unwrap();
 
         assert_eq!(decoded.id(), payload.id());