From ecb207ddfa4cd99ceede8c50d0f70c37daea8e45 Mon Sep 17 00:00:00 2001 From: Elizabeth Engelman <4752801+elizabethengelman@users.noreply.github.com> Date: Fri, 30 Aug 2024 12:35:01 -0400 Subject: [PATCH] Refactor/cleanup --- cmd/soroban-cli/src/commands/tx/sign.rs | 18 +++++------------- cmd/soroban-cli/src/config/sign_with.rs | 4 ++-- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/cmd/soroban-cli/src/commands/tx/sign.rs b/cmd/soroban-cli/src/commands/tx/sign.rs index c5e18a85d0..ca91eae3f7 100644 --- a/cmd/soroban-cli/src/commands/tx/sign.rs +++ b/cmd/soroban-cli/src/commands/tx/sign.rs @@ -1,6 +1,6 @@ use crate::{ config::sign_with, - xdr::{self, Limits, TransactionEnvelope, WriteXdr}, + xdr::{self, Limits, WriteXdr}, }; #[derive(thiserror::Error, Debug)] @@ -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 { - 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(()) } } diff --git a/cmd/soroban-cli/src/config/sign_with.rs b/cmd/soroban-cli/src/config/sign_with.rs index a7f054e385..456e820870 100644 --- a/cmd/soroban-cli/src/config/sign_with.rs +++ b/cmd/soroban-cli/src/config/sign_with.rs @@ -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", @@ -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())?;