From bce42c9022f4b3494a2336857a6fe3f119f75bd6 Mon Sep 17 00:00:00 2001 From: Willem Wyndham Date: Tue, 20 Aug 2024 16:39:05 -0400 Subject: [PATCH 1/3] fix: remove unneeded print statement fixes #1539 --- cmd/soroban-cli/src/commands/events.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/cmd/soroban-cli/src/commands/events.rs b/cmd/soroban-cli/src/commands/events.rs index a755c33d0..5e2bda66f 100644 --- a/cmd/soroban-cli/src/commands/events.rs +++ b/cmd/soroban-cli/src/commands/events.rs @@ -176,8 +176,6 @@ impl Cmd { OutputFormat::Pretty => event.pretty_print()?, } } - println!("Latest Ledger: {}", response.latest_ledger); - Ok(()) } From 1c3eb0974d59679768ce8abb0257aa047964706f Mon Sep 17 00:00:00 2001 From: Willem Wyndham Date: Thu, 29 Aug 2024 14:26:06 +0200 Subject: [PATCH 2/3] fix: return valid json --- cmd/soroban-cli/src/commands/events.rs | 34 +++++++++++--------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/cmd/soroban-cli/src/commands/events.rs b/cmd/soroban-cli/src/commands/events.rs index 5e2bda66f..cd3408307 100644 --- a/cmd/soroban-cli/src/commands/events.rs +++ b/cmd/soroban-cli/src/commands/events.rs @@ -1,4 +1,6 @@ use clap::{arg, command, Parser}; +use itertools::Itertools; +use soroban_rpc::Event; use std::io; use soroban_env_host::xdr::{self, Limits, ReadXdr}; @@ -155,27 +157,19 @@ impl Cmd { } let response = self.run_against_rpc_server(None, None).await?; - - for event in &response.events { - match self.output { - // Should we pretty-print the JSON like we're doing here or just - // dump an event in raw JSON on each line? The latter is easier - // to consume programmatically. - OutputFormat::Json => { - println!( - "{}", - serde_json::to_string_pretty(&event).map_err(|e| { - Error::InvalidJson { - debug: format!("{event:#?}"), - error: e, - } - })?, - ); - } - OutputFormat::Plain => println!("{event}"), - OutputFormat::Pretty => event.pretty_print()?, + let output = match self.output { + OutputFormat::Json => { + serde_json::to_string_pretty(&response.events).map_err(|e| Error::InvalidJson { + debug: format!("{:#?}", response.events), + error: e, + })? } - } + OutputFormat::Plain => response.events.iter().join("\n"), + OutputFormat::Pretty => { + return Ok(response.events.iter().try_for_each(Event::pretty_print)?); + } + }; + println!("{output}"); Ok(()) } From 52f30396b436e98281799db137913932efdc5b2d Mon Sep 17 00:00:00 2001 From: Willem Wyndham Date: Fri, 30 Aug 2024 07:39:31 +0200 Subject: [PATCH 3/3] Revert "fix: return valid json" This reverts commit 1c3eb0974d59679768ce8abb0257aa047964706f. --- cmd/soroban-cli/src/commands/events.rs | 34 +++++++++++++++----------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/cmd/soroban-cli/src/commands/events.rs b/cmd/soroban-cli/src/commands/events.rs index cd3408307..5e2bda66f 100644 --- a/cmd/soroban-cli/src/commands/events.rs +++ b/cmd/soroban-cli/src/commands/events.rs @@ -1,6 +1,4 @@ use clap::{arg, command, Parser}; -use itertools::Itertools; -use soroban_rpc::Event; use std::io; use soroban_env_host::xdr::{self, Limits, ReadXdr}; @@ -157,19 +155,27 @@ impl Cmd { } let response = self.run_against_rpc_server(None, None).await?; - let output = match self.output { - OutputFormat::Json => { - serde_json::to_string_pretty(&response.events).map_err(|e| Error::InvalidJson { - debug: format!("{:#?}", response.events), - error: e, - })? - } - OutputFormat::Plain => response.events.iter().join("\n"), - OutputFormat::Pretty => { - return Ok(response.events.iter().try_for_each(Event::pretty_print)?); + + for event in &response.events { + match self.output { + // Should we pretty-print the JSON like we're doing here or just + // dump an event in raw JSON on each line? The latter is easier + // to consume programmatically. + OutputFormat::Json => { + println!( + "{}", + serde_json::to_string_pretty(&event).map_err(|e| { + Error::InvalidJson { + debug: format!("{event:#?}"), + error: e, + } + })?, + ); + } + OutputFormat::Plain => println!("{event}"), + OutputFormat::Pretty => event.pretty_print()?, } - }; - println!("{output}"); + } Ok(()) }