diff --git a/swap/src/bin/swap.rs b/swap/src/bin/swap.rs index 547a7436..b74371f4 100644 --- a/swap/src/bin/swap.rs +++ b/swap/src/bin/swap.rs @@ -291,10 +291,18 @@ async fn main() -> Result<()> { .await?; for seller in sellers { - // TODO: Do not use tracing for printing this information - // TODO: Print on stdout - // TODO: Decide if the json flag should still be honoured - tracing::info!(peer_id=%seller.peer_id, multiaddr=%seller.multiaddr, price=%seller.quote.price, max_quantity=%seller.quote.max_quantity, min_quantity=%seller.quote.min_quantity); + if json { + println!("{}", serde_json::to_string(&seller)?); + } else { + println!( + "Seller: peer-id={}, addr={}, price={}, min_quantity={}, max_quantity={}", + seller.peer_id, + seller.multiaddr, + seller.quote.price, + seller.quote.min_quantity, + seller.quote.max_quantity + ); + } } } }; diff --git a/swap/src/cli/list_sellers.rs b/swap/src/cli/list_sellers.rs index 1ce6dd3b..3895da60 100644 --- a/swap/src/cli/list_sellers.rs +++ b/swap/src/cli/list_sellers.rs @@ -9,6 +9,8 @@ use libp2p::rendezvous::{Namespace, Rendezvous}; use libp2p::request_response::{RequestResponseEvent, RequestResponseMessage}; use libp2p::swarm::SwarmEvent; use libp2p::{identity, rendezvous, Multiaddr, PeerId, Swarm}; +use serde::Serialize; +use serde_with::{serde_as, DisplayFromStr}; use std::collections::HashMap; use std::time::Duration; @@ -43,7 +45,10 @@ pub async fn list_sellers( Ok(sellers) } +#[serde_as] +#[derive(Debug, Serialize)] pub struct Seller { + #[serde_as(as = "DisplayFromStr")] pub peer_id: PeerId, pub multiaddr: Multiaddr, pub quote: BidQuote,