Skip to content

Commit

Permalink
Refactor/cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
elizabethengelman committed Aug 30, 2024
1 parent a4f5796 commit ecb207d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
18 changes: 5 additions & 13 deletions cmd/soroban-cli/src/commands/tx/sign.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
config::sign_with,
xdr::{self, Limits, TransactionEnvelope, WriteXdr},
xdr::{self, Limits, WriteXdr},
};

#[derive(thiserror::Error, Debug)]
Expand All @@ -25,19 +25,11 @@ impl Cmd {
pub async fn run(&self) -> Result<(), Error> {
let txn_env = super::xdr::tx_envelope_from_stdin()?;
if self.sign_with.sign_with_lab {
return self.sign_tx_env_with_lab(txn_env).await;
} else {
let envelope = self.sign_tx_env(txn_env).await?;
println!("{}", envelope.to_xdr_base64(Limits::none())?.trim());
return Ok(self.sign_with.sign_tx_env_with_lab(&txn_env)?);
}
Ok(())
}

pub async fn sign_tx_env(&self, tx: TransactionEnvelope) -> Result<TransactionEnvelope, Error> {
Ok(self.sign_with.sign_txn_env(tx).await?)
}

pub async fn sign_tx_env_with_lab(&self, tx: TransactionEnvelope) -> Result<(), Error> {
Ok(self.sign_with.sign_tx_env_with_lab(tx).await?)
let envelope = self.sign_with.sign_txn_env(txn_env).await?;
println!("{}", envelope.to_xdr_base64(Limits::none())?.trim());
Ok(())
}
}
4 changes: 2 additions & 2 deletions cmd/soroban-cli/src/config/sign_with.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub struct Args {
hide = true
)]
pub sign_with_lab: bool,
/// Lab URL for sign_with_lab
/// Lab URL for `sign_with_lab`
#[arg(
long,
env = "STELLAR_SIGN_WITH_LAB_URL",
Expand Down Expand Up @@ -105,7 +105,7 @@ impl Args {
Ok(sign_txn_env(signer, tx_env, &network).await?)
}

pub async fn sign_tx_env_with_lab(&self, tx_env: TransactionEnvelope) -> Result<(), Error> {
pub fn sign_tx_env_with_lab(&self, tx_env: &TransactionEnvelope) -> Result<(), Error> {
let passphrase = self.get_network()?.network_passphrase;
let xdr_buffer = tx_env.to_xdr_base64(Limits::none())?;

Expand Down

0 comments on commit ecb207d

Please sign in to comment.