Skip to content

Commit

Permalink
fund and generate too
Browse files Browse the repository at this point in the history
  • Loading branch information
leighmcculloch committed Dec 19, 2024
1 parent de5dc13 commit a36c101
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions cmd/soroban-cli/src/commands/keys/fund.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use clap::command;

use crate::config::network;
use crate::{commands::global, config::network, print::Print};

use super::address;

Expand All @@ -23,12 +23,17 @@ pub struct Cmd {
}

impl Cmd {
pub async fn run(&self) -> Result<(), Error> {
pub async fn run(&self, global_args: &global::Args) -> Result<(), Error> {
let print = Print::new(global_args.quiet);
let addr = self.address.public_key()?;
self.network
.get(&self.address.locator)?
.fund_address(&addr)
.await?;
print.checkln(format!(
"Account {:?} funded on {:?}",
self.address.name, self.network.network_passphrase
));
Ok(())
}
}
7 changes: 6 additions & 1 deletion cmd/soroban-cli/src/commands/keys/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ impl Cmd {
seed_phrase
};

self.config_locator.write_identity(&self.name, &secret)?;
let path = self.config_locator.write_identity(&self.name, &secret)?;
print.checkln(format!("Key saved with alias {:?} in {path:?}", self.name));

if !self.no_fund {
let addr = secret.public_key(self.hd_path)?;
Expand All @@ -108,6 +109,10 @@ impl Cmd {
tracing::warn!("fund_address failed: {e}");
})
.unwrap_or_default();
print.checkln(format!(
"Account {:?} funded on {:?}",
self.name, network.network_passphrase
));
}

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion cmd/soroban-cli/src/commands/keys/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl Cmd {
match self {
Cmd::Add(cmd) => cmd.run()?,
Cmd::Address(cmd) => cmd.run()?,
Cmd::Fund(cmd) => cmd.run().await?,
Cmd::Fund(cmd) => cmd.run(global_args).await?,
Cmd::Generate(cmd) => cmd.run(global_args).await?,
Cmd::Ls(cmd) => cmd.run()?,
Cmd::Rm(cmd) => cmd.run()?,
Expand Down

0 comments on commit a36c101

Please sign in to comment.