Skip to content

Commit

Permalink
Handle unwraps
Browse files Browse the repository at this point in the history
  • Loading branch information
elizabethengelman committed Aug 30, 2024
1 parent 5f4b010 commit a4f5796
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions cmd/soroban-cli/src/config/sign_with.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
};
use clap::arg;
use soroban_env_host::xdr::WriteXdr;
use soroban_sdk::xdr::{self, Limits};
use soroban_sdk::xdr::Limits;
use url::Url;

use super::{
Expand All @@ -29,6 +29,12 @@ pub enum Error {
Rpc(#[from] soroban_rpc::Error),
#[error("No sign with key provided")]
NoSignWithKey,
#[error(transparent)]
Xdr(#[from] soroban_env_host::xdr::Error),
#[error(transparent)]
Url(#[from] url::ParseError),
#[error(transparent)]
Open(#[from] std::io::Error),
}

#[derive(Debug, clap::Args, Clone, Default)]
Expand Down Expand Up @@ -100,21 +106,18 @@ impl Args {
}

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

let mut url = Url::parse(&self.lab_url).unwrap();
let mut url = Url::parse(&self.lab_url)?;
url.query_pairs_mut()
.append_pair("networkPassphrase", &passphrase)
.append_pair("xdr", &xdr_buffer);

let txn_sign_url = url.to_string();

println!("Opening lab to sign transaction: {}", &txn_sign_url);
open::that(txn_sign_url).unwrap(); //todo: handle unwrap
open::that(txn_sign_url)?;

Ok(())
}
Expand Down

0 comments on commit a4f5796

Please sign in to comment.