Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/sign with lab #1579

Closed
wants to merge 16 commits into from
Closed
Prev Previous commit
Next Next commit
Handle unwraps
  • Loading branch information
elizabethengelman committed Sep 11, 2024
commit a122be309e8855f2aa6fa0ca2d1c25c357a06704
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