Skip to content

Commit

Permalink
Merge branch 'main' into feat/add_stellar_ledger
Browse files Browse the repository at this point in the history
  • Loading branch information
elizabethengelman authored Jan 29, 2025
2 parents f446605 + 42b41f8 commit 72c8b26
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 102 deletions.
169 changes: 90 additions & 79 deletions FULL_HELP_DOCS.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions cmd/soroban-cli/src/commands/container/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub struct Cmd {
pub container_args: Args,

/// Container to get logs from
#[arg(default_value = "local")]
pub name: String,
}

Expand Down
23 changes: 10 additions & 13 deletions cmd/soroban-cli/src/commands/container/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ pub struct Cmd {
#[command(flatten)]
pub container_args: Args,

/// Network to start
pub network: Network,
/// Network to start. Default is `local`
pub network: Option<Network>,

/// Optional argument to specify the container name
#[arg(long)]
Expand All @@ -62,6 +62,7 @@ impl Cmd {
pub async fn run(&self, global_args: &global::Args) -> Result<(), Error> {
let runner = Runner {
args: self.clone(),
network: self.network.unwrap_or(Network::Local),
print: print::Print::new(global_args.quiet),
};

Expand All @@ -71,13 +72,14 @@ impl Cmd {

struct Runner {
args: Cmd,
network: Network,
print: print::Print,
}

impl Runner {
async fn run_docker_command(&self) -> Result<(), Error> {
self.print
.infoln(format!("Starting {} network", &self.args.network));
.infoln(format!("Starting {} network", &self.network));

let docker = self
.args
Expand Down Expand Up @@ -151,7 +153,7 @@ impl Runner {

fn get_image_name(&self) -> String {
// this can be overriden with the `-t` flag
let mut image_tag = match &self.args.network {
let mut image_tag = match &self.network {
Network::Pubnet => "latest",
Network::Futurenet => "future",
_ => "testing", // default to testing for local and testnet
Expand All @@ -169,7 +171,7 @@ impl Runner {

fn get_container_args(&self) -> Vec<String> {
[
format!("--{}", self.args.network),
format!("--{}", self.network),
"--enable rpc,horizon".to_string(),
self.get_protocol_version_arg(),
self.get_limits_arg(),
Expand Down Expand Up @@ -201,12 +203,7 @@ impl Runner {
}

fn container_name(&self) -> Name {
Name(
self.args
.name
.clone()
.unwrap_or(self.args.network.to_string()),
)
Name(self.args.name.clone().unwrap_or(self.network.to_string()))
}

fn print_instructions(&self) {
Expand All @@ -226,7 +223,7 @@ impl Runner {
}

fn get_protocol_version_arg(&self) -> String {
if self.args.network == Network::Local && self.args.protocol_version.is_some() {
if self.network == Network::Local && self.args.protocol_version.is_some() {
let version = self.args.protocol_version.as_ref().unwrap();
format!("--protocol-version {version}")
} else {
Expand All @@ -235,7 +232,7 @@ impl Runner {
}

fn get_limits_arg(&self) -> String {
if self.args.network == Network::Local && self.args.limits.is_some() {
if self.network == Network::Local && self.args.limits.is_some() {
let limits = self.args.limits.as_ref().unwrap();
format!("--limits {limits}")
} else {
Expand Down
1 change: 1 addition & 0 deletions cmd/soroban-cli/src/commands/container/stop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub struct Cmd {
pub container_args: Args,

/// Container to stop
#[arg(default_value = "local")]
pub name: String,
}

Expand Down
5 changes: 3 additions & 2 deletions cmd/soroban-cli/src/commands/contract/deploy/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,12 @@ impl NetworkRunnable for Cmd {
return Ok(TxnResult::Txn(txn));
}

print.globeln("Submitting deploy transaction…");
print.log_transaction(&txn, &network, true)?;
let signed_txn = &config.sign_with_local_key(*txn).await?;
print.globeln("Submitting deploy transaction…");

let get_txn_resp = client
.send_transaction_polling(&config.sign_with_local_key(*txn).await?)
.send_transaction_polling(signed_txn)
.await?
.try_into()?;

Expand Down
7 changes: 3 additions & 4 deletions cmd/soroban-cli/src/commands/contract/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,10 @@ impl NetworkRunnable for Cmd {
return Ok(TxnResult::Txn(txn));
}

print.globeln("Submitting install transaction…");
let signed_txn = &self.config.sign_with_local_key(*txn).await?;

let txn_resp = client
.send_transaction_polling(&self.config.sign_with_local_key(*txn).await?)
.await?;
print.globeln("Submitting install transaction…");
let txn_resp = client.send_transaction_polling(signed_txn).await?;

if args.map_or(true, |a| !a.no_cache) {
data::write(txn_resp.clone().try_into().unwrap(), &network.rpc_uri()?)?;
Expand Down
32 changes: 29 additions & 3 deletions cmd/soroban-cli/src/commands/keys/secret.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
use clap::arg;

use crate::config::{key, locator};
use crate::config::{
key::{self, Key},
locator,
secret::Secret,
};

#[derive(thiserror::Error, Debug)]
pub enum Error {
Expand All @@ -9,6 +13,9 @@ pub enum Error {

#[error(transparent)]
Key(#[from] key::Error),

#[error("identity is not tied to a seed phrase")]
UnknownSeedPhrase,
}

#[derive(Debug, clap::Parser, Clone)]
Expand All @@ -18,8 +25,12 @@ pub struct Cmd {
/// Name of identity to lookup, default is test identity
pub name: String,

/// Output seed phrase instead of private key
#[arg(long, conflicts_with = "hd_path")]
pub phrase: bool,

/// If identity is a seed phrase use this hd path, default is 0
#[arg(long)]
#[arg(long, conflicts_with = "phrase")]
pub hd_path: Option<usize>,

#[command(flatten)]
Expand All @@ -28,10 +39,25 @@ pub struct Cmd {

impl Cmd {
pub fn run(&self) -> Result<(), Error> {
println!("{}", self.private_key()?.to_string());
if self.phrase {
println!("{}", self.seed_phrase()?);
} else {
println!("{}", self.private_key()?);
}

Ok(())
}

pub fn seed_phrase(&self) -> Result<String, Error> {
let key = self.locator.read_identity(&self.name)?;

if let Key::Secret(Secret::SeedPhrase { seed_phrase }) = key {
Ok(seed_phrase)
} else {
Err(Error::UnknownSeedPhrase)
}
}

pub fn private_key(&self) -> Result<stellar_strkey::ed25519::PrivateKey, Error> {
Ok(self
.locator
Expand Down
2 changes: 1 addition & 1 deletion cmd/soroban-cli/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub struct Args {
#[command(flatten)]
pub network: network::Args,

#[arg(long, visible_alias = "source", env = "STELLAR_ACCOUNT")]
#[arg(long, short = 's', visible_alias = "source", env = "STELLAR_ACCOUNT")]
/// Account that where transaction originates from. Alias `source`.
/// Can be an identity (--source alice), a public key (--source GDKW...),
/// a muxed account (--source MDA…), a secret key (--source SC36…),
Expand Down
1 change: 1 addition & 0 deletions cmd/soroban-cli/src/config/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ pub struct Args {
/// Name of network to use from config
#[arg(
long,
short = 'n',
env = "STELLAR_NETWORK",
help_heading = HEADING_RPC,
)]
Expand Down

0 comments on commit 72c8b26

Please sign in to comment.