Skip to content

Commit

Permalink
Add warning on no fund flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Ifropc committed Sep 27, 2024
1 parent c3aebe0 commit 46c3238
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
3 changes: 3 additions & 0 deletions FULL_HELP_DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,9 @@ Generate a new identity with a seed phrase, currently 12 words
* `--rpc-url <RPC_URL>` — RPC server endpoint
* `--network-passphrase <NETWORK_PASSPHRASE>` — Network passphrase to sign the transaction sent to the rpc server
* `--network <NETWORK>` — Name of network to use from config
* `--fund` — Fund generated key pair

Default value: `false`



Expand Down
16 changes: 15 additions & 1 deletion cmd/soroban-cli/src/commands/keys/generate.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use crate::commands::global;
use crate::print::Print;
use clap::{arg, command};

use super::super::config::{
Expand Down Expand Up @@ -46,10 +48,22 @@ pub struct Cmd {

#[command(flatten)]
pub network: network::Args,

/// Fund generated key pair
#[arg(long, default_value = "false")]
pub fund: bool,
}

impl Cmd {
pub async fn run(&self) -> Result<(), Error> {
pub async fn run(&self, global_args: &global::Args) -> Result<(), Error> {
if !self.fund {
Print::new(global_args.quiet).warnln(
"Behavior of `generate` will change in the \
future, and it will no longer fund by default. If you want to fund please \
provide `--fund` flag. If you don't need to fund your keys in the future, ignore this \
warning. It can be suppressed with -q flag.",
)
}
let seed_phrase = if self.default_seed {
Secret::test_seed_phrase()
} else {
Expand Down
5 changes: 3 additions & 2 deletions cmd/soroban-cli/src/commands/keys/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::commands::global;
use clap::Parser;

pub mod add;
Expand Down Expand Up @@ -48,12 +49,12 @@ pub enum Error {
}

impl Cmd {
pub async fn run(&self) -> Result<(), Error> {
pub async fn run(&self, global_args: &global::Args) -> Result<(), Error> {
match self {
Cmd::Add(cmd) => cmd.run()?,
Cmd::Address(cmd) => cmd.run()?,
Cmd::Fund(cmd) => cmd.run().await?,
Cmd::Generate(cmd) => cmd.run().await?,
Cmd::Generate(cmd) => cmd.run(global_args).await?,
Cmd::Ls(cmd) => cmd.run()?,
Cmd::Rm(cmd) => cmd.run()?,
Cmd::Show(cmd) => cmd.run()?,
Expand Down
2 changes: 1 addition & 1 deletion cmd/soroban-cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl Root {
Cmd::Network(network) => network.run(&self.global_args).await?,
Cmd::Snapshot(snapshot) => snapshot.run(&self.global_args).await?,
Cmd::Version(version) => version.run(),
Cmd::Keys(id) => id.run().await?,
Cmd::Keys(id) => id.run(&self.global_args).await?,
Cmd::Tx(tx) => tx.run(&self.global_args).await?,
Cmd::Cache(data) => data.run()?,
};
Expand Down

0 comments on commit 46c3238

Please sign in to comment.