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

Add warning on no fund flag #1637

Merged
merged 8 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions FULL_HELP_DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,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
17 changes: 16 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};

Ifropc marked this conversation as resolved.
Show resolved Hide resolved
use super::super::config::{
Expand All @@ -17,6 +19,7 @@ pub enum Error {

#[derive(Debug, clap::Parser, Clone)]
#[group(skip)]
#[allow(clippy::struct_excessive_bools)]
pub struct Cmd {
/// Name of identity
pub name: String,
Expand Down Expand Up @@ -46,10 +49,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
2 changes: 1 addition & 1 deletion cookbook/contract-lifecycle.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ To manage the lifecycle of a Stellar smart contract using the CLI, follow these
1. Create an identity for Alice:

```bash
stellar keys generate alice
stellar keys generate alice -q
```

2. Fund the identity:
Expand Down
4 changes: 2 additions & 2 deletions cookbook/payments-and-assets.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ By setting the `STELLAR_NETWORK` environment variable, we will not have to set t
2. Fund the accounts:

```bash
stellar keys generate alice
stellar keys generate alice -q
```

```bash
stellar keys generate bob
stellar keys generate bob -q
```

```bash
Expand Down
Loading