diff --git a/cmd/soroban-cli/src/commands/contract/deploy/asset.rs b/cmd/soroban-cli/src/commands/contract/deploy/asset.rs index dbca1940c7..aa002a25c7 100644 --- a/cmd/soroban-cli/src/commands/contract/deploy/asset.rs +++ b/cmd/soroban-cli/src/commands/contract/deploy/asset.rs @@ -101,6 +101,7 @@ impl NetworkRunnable for Cmd { network_passphrase, &key, )?; + self.fee.exit_if_build_only(&tx)?; let txn = client.create_assembled_transaction(&tx).await?; let txn = self.fee.apply_to_assembled_txn(txn); client diff --git a/cmd/soroban-cli/src/commands/contract/deploy/wasm.rs b/cmd/soroban-cli/src/commands/contract/deploy/wasm.rs index bac7fe2f0e..14963b1224 100644 --- a/cmd/soroban-cli/src/commands/contract/deploy/wasm.rs +++ b/cmd/soroban-cli/src/commands/contract/deploy/wasm.rs @@ -113,10 +113,12 @@ impl NetworkRunnable for Cmd { ) -> Result { let config = config.unwrap_or(&self.config); let wasm_hash = if let Some(wasm) = &self.wasm { + let mut fee = self.fee.clone(); + fee.build_only = false; let hash = install::Cmd { wasm: wasm::Args { wasm: wasm.clone() }, config: config.clone(), - fee: self.fee.clone(), + fee, ignore_checks: self.ignore_checks, } .run_against_rpc_server(global_args, Some(config)) @@ -164,6 +166,7 @@ impl NetworkRunnable for Cmd { salt, &key, )?; + self.fee.exit_if_build_only(&txn)?; let txn = client.create_assembled_transaction(&txn).await?; let txn = self.fee.apply_to_assembled_txn(txn); client diff --git a/cmd/soroban-cli/src/commands/contract/extend.rs b/cmd/soroban-cli/src/commands/contract/extend.rs index bcf8a90d5b..237065158b 100644 --- a/cmd/soroban-cli/src/commands/contract/extend.rs +++ b/cmd/soroban-cli/src/commands/contract/extend.rs @@ -154,7 +154,7 @@ impl NetworkRunnable for Cmd { resource_fee: 0, }), }; - + self.fee.exit_if_build_only(&tx)?; let res = client .prepare_and_send_transaction(&tx, &key, &[], &network.network_passphrase, None, None) .await?; diff --git a/cmd/soroban-cli/src/commands/contract/install.rs b/cmd/soroban-cli/src/commands/contract/install.rs index 47a47e1d2f..d834c9cd35 100644 --- a/cmd/soroban-cli/src/commands/contract/install.rs +++ b/cmd/soroban-cli/src/commands/contract/install.rs @@ -119,13 +119,13 @@ impl NetworkRunnable for Cmd { let (tx_without_preflight, hash) = build_install_contract_code_tx(&contract, sequence + 1, self.fee.fee, &key)?; + self.fee.exit_if_build_only(&tx_without_preflight)?; let code_key = xdr::LedgerKey::ContractCode(xdr::LedgerKeyContractCode { hash: hash.clone() }); let contract_data = client.get_ledger_entries(&[code_key]).await?; if !contract_data.entries.unwrap_or_default().is_empty() { return Ok(hash); } - let txn = client .create_assembled_transaction(&tx_without_preflight) .await?; diff --git a/cmd/soroban-cli/src/commands/contract/invoke.rs b/cmd/soroban-cli/src/commands/contract/invoke.rs index cd42d818f8..21b3ab550c 100644 --- a/cmd/soroban-cli/src/commands/contract/invoke.rs +++ b/cmd/soroban-cli/src/commands/contract/invoke.rs @@ -334,6 +334,7 @@ impl NetworkRunnable for Cmd { self.fee.fee, &key, )?; + self.fee.exit_if_build_only(&tx)?; let txn = client.create_assembled_transaction(&tx).await?; let txn = self.fee.apply_to_assembled_txn(txn); let (return_value, events) = if self.is_view() { diff --git a/cmd/soroban-cli/src/commands/contract/restore.rs b/cmd/soroban-cli/src/commands/contract/restore.rs index 869d260154..7ff6e45aa7 100644 --- a/cmd/soroban-cli/src/commands/contract/restore.rs +++ b/cmd/soroban-cli/src/commands/contract/restore.rs @@ -158,7 +158,7 @@ impl NetworkRunnable for Cmd { resource_fee: 0, }), }; - + self.fee.exit_if_build_only(&tx)?; let res = client .prepare_and_send_transaction(&tx, &key, &[], &network.network_passphrase, None, None) .await?; diff --git a/cmd/soroban-cli/src/fee.rs b/cmd/soroban-cli/src/fee.rs index 9503af4f18..f3f8520561 100644 --- a/cmd/soroban-cli/src/fee.rs +++ b/cmd/soroban-cli/src/fee.rs @@ -19,11 +19,11 @@ pub struct Args { pub instructions: Option, /// Build the transaction only write the output to stdout #[arg(long, help_heading = HEADING_RPC)] - build_only: bool, + pub build_only: bool, } impl Args { - pub fn build_only(&self, txn: &xdr::Transaction) -> Result<(), xdr::Error> { + pub fn exit_if_build_only(&self, txn: &xdr::Transaction) -> Result<(), xdr::Error> { if self.build_only { println!("{}", txn.to_xdr_base64(xdr::Limits::none())?); std::process::exit(0); diff --git a/docs/soroban-cli-full-docs.md b/docs/soroban-cli-full-docs.md index 9c493761be..cfb12e5444 100644 --- a/docs/soroban-cli-full-docs.md +++ b/docs/soroban-cli-full-docs.md @@ -579,6 +579,10 @@ Deploy builtin Soroban Asset Contract Possible values: `true`, `false` * `--instructions ` — Number of instructions to simulate +* `--build-only` — Build the transaction only write the output to stdout + + Possible values: `true`, `false` + @@ -730,6 +734,10 @@ If no keys are specified the contract itself is extended. Possible values: `true`, `false` * `--instructions ` — Number of instructions to simulate +* `--build-only` — Build the transaction only write the output to stdout + + Possible values: `true`, `false` + @@ -762,6 +770,10 @@ Deploy a wasm contract Possible values: `true`, `false` * `--instructions ` — Number of instructions to simulate +* `--build-only` — Build the transaction only write the output to stdout + + Possible values: `true`, `false` + * `-i`, `--ignore-checks` — Whether to ignore safety checks when deploying contracts Default value: `false` @@ -926,6 +938,10 @@ Install a WASM file to the ledger without creating a contract instance Possible values: `true`, `false` * `--instructions ` — Number of instructions to simulate +* `--build-only` — Build the transaction only write the output to stdout + + Possible values: `true`, `false` + * `--wasm ` — Path to wasm binary * `-i`, `--ignore-checks` — Whether to ignore safety checks when deploying contracts @@ -975,6 +991,10 @@ soroban contract invoke ... -- --help Possible values: `true`, `false` * `--instructions ` — Number of instructions to simulate +* `--build-only` — Build the transaction only write the output to stdout + + Possible values: `true`, `false` + @@ -1087,6 +1107,10 @@ If no keys are specificed the contract itself is restored. Possible values: `true`, `false` * `--instructions ` — Number of instructions to simulate +* `--build-only` — Build the transaction only write the output to stdout + + Possible values: `true`, `false` + @@ -1376,6 +1400,10 @@ Deploy a token contract to wrap an existing Stellar classic asset for smart cont Possible values: `true`, `false` * `--instructions ` — Number of instructions to simulate +* `--build-only` — Build the transaction only write the output to stdout + + Possible values: `true`, `false` +