Skip to content

Commit

Permalink
reduce the output formats
Browse files Browse the repository at this point in the history
  • Loading branch information
leighmcculloch committed Dec 10, 2024
1 parent 72c6169 commit e46db6d
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions cmd/soroban-cli/src/commands/tx/decode.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use stellar_xdr::cli::{decode::OutputFormat, Channel};
use clap::ValueEnum;
use stellar_xdr::cli::{decode::InputFormat, Channel};

#[derive(thiserror::Error, Debug)]
pub enum Error {
Expand All @@ -15,13 +16,29 @@ pub struct Cmd {
pub output: OutputFormat,
}

#[derive(Default, Clone, Copy, Debug, Eq, Hash, PartialEq, ValueEnum)]
pub enum OutputFormat {
#[default]
Json,
JsonFormatted,
}

impl From<OutputFormat> for stellar_xdr::cli::decode::OutputFormat {
fn from(v: OutputFormat) -> Self {
match v {
OutputFormat::Json => Self::Json,
OutputFormat::JsonFormatted => Self::JsonFormatted,
}
}
}

impl Cmd {
pub fn run(&self) -> Result<(), Error> {
let cmd = stellar_xdr::cli::decode::Cmd {
files: vec![],
r#type: "TransactionEnvelope".to_string(),
input: stellar_xdr::cli::decode::InputFormat::SingleBase64,
output: self.output,
input: InputFormat::SingleBase64,
output: self.output.into(),
};
cmd.run(&Channel::Curr)?;
Ok(())
Expand Down

0 comments on commit e46db6d

Please sign in to comment.