Skip to content

Commit

Permalink
feat(CLI): add --no-fund to generate
Browse files Browse the repository at this point in the history
  • Loading branch information
willemneal committed Nov 26, 2023
1 parent b8a7176 commit c136fc7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
2 changes: 2 additions & 0 deletions cmd/crates/soroban-test/tests/it/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ fn generate_identity() {
sandbox
.new_assert_cmd("identity")
.arg("generate")
.arg("--network=futurenet")
.arg("--no-fund")
.arg("--seed")
.arg("0000000000000000")
.arg("test")
Expand Down
12 changes: 11 additions & 1 deletion cmd/crates/soroban-test/tests/it/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,17 @@ pub async fn invoke_custom(
arg: &str,
wasm: &Path,
) -> Result<String, contract::invoke::Error> {
let mut i: contract::invoke::Cmd = sandbox.cmd_arr(&["--id", id, "--", func, arg]);
let mut i: contract::invoke::Cmd = sandbox.cmd_arr(&[
"--id",
id,
"--network",
"futurenet",
"--source",
"default",
"--",
func,
arg,
]);
i.wasm = Some(wasm.to_path_buf());
i.config.network.network = Some("futurenet".to_owned());
i.invoke(&soroban_cli::commands::global::Args::default())
Expand Down
16 changes: 10 additions & 6 deletions cmd/soroban-cli/src/commands/identity/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ pub enum Error {
pub struct Cmd {
/// Name of identity
pub name: String,

/// Do not fund address
#[arg(long)]
pub no_fund: bool,
/// Optional seed to use when generating seed phrase.
/// Random otherwise.
#[arg(long, conflicts_with = "default_seed")]
Expand Down Expand Up @@ -61,11 +63,13 @@ impl Cmd {
seed_phrase
};
self.config_locator.write_identity(&self.name, &secret)?;
let addr = secret.public_key(self.hd_path)?;
let network = self.network.get(&self.config_locator)?;
network.fund_address(&addr).await.unwrap_or_else(|_| {
tracing::warn!("Failed to fund address: {addr} on at {}", network.rpc_url);
});
if !self.no_fund {
let addr = secret.public_key(self.hd_path)?;
let network = self.network.get(&self.config_locator)?;
network.fund_address(&addr).await.unwrap_or_else(|_| {
tracing::warn!("Failed to fund address: {addr} on at {}", network.rpc_url);
});
}
Ok(())
}
}

0 comments on commit c136fc7

Please sign in to comment.