Skip to content

Commit fed6fcf

Browse files
committed
fix: remove to_string from payment req
1 parent 059286c commit fed6fcf

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

crates/cdk-ffi/src/types/payment_request.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -309,11 +309,6 @@ impl PaymentRequestPayload {
309309
Ok(Arc::new(PaymentRequestPayload { inner }))
310310
}
311311

312-
/// Encode PaymentRequestPayload to JSON string
313-
pub fn to_string(&self) -> Result<String, FfiError> {
314-
Ok(serde_json::to_string(&self.inner)?)
315-
}
316-
317312
/// Get the ID
318313
pub fn id(&self) -> Option<String> {
319314
self.inner.id.clone()
@@ -340,6 +335,16 @@ impl PaymentRequestPayload {
340335
}
341336
}
342337

338+
impl std::fmt::Display for PaymentRequestPayload {
339+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
340+
write!(
341+
f,
342+
"{}",
343+
serde_json::to_string(&self.inner).map_err(|_| std::fmt::Error::default())?
344+
)
345+
}
346+
}
347+
343348
#[cfg(test)]
344349
mod tests {
345350
use super::*;
@@ -385,7 +390,7 @@ mod tests {
385390

386391
let payload = PaymentRequestPayload { inner };
387392

388-
let json = payload.to_string().unwrap();
393+
let json = payload.to_string();
389394
let decoded = PaymentRequestPayload::from_string(json).unwrap();
390395

391396
assert_eq!(decoded.id(), payload.id());

0 commit comments

Comments
 (0)