diff --git a/FULL_HELP_DOCS.md b/FULL_HELP_DOCS.md index 8c151cb84..2d4123fc6 100644 --- a/FULL_HELP_DOCS.md +++ b/FULL_HELP_DOCS.md @@ -148,6 +148,7 @@ Deploy builtin Soroban Asset Contract * `--cost` — Output the cost execution to stderr * `--instructions ` — Number of instructions to simulate * `--build-only` — Build the transaction and only write the base64 xdr to stdout +* `--sequence-number ` — Optionally set the sequence number for the transaction; default is the current sequence number of the source account incremented by one * `--sim-only` — (Deprecated) simulate the transaction and only write the base64 xdr to stdout @@ -379,6 +380,7 @@ If no keys are specified the contract itself is extended. * `--cost` — Output the cost execution to stderr * `--instructions ` — Number of instructions to simulate * `--build-only` — Build the transaction and only write the base64 xdr to stdout +* `--sequence-number ` — Optionally set the sequence number for the transaction; default is the current sequence number of the source account incremented by one * `--sim-only` — (Deprecated) simulate the transaction and only write the base64 xdr to stdout @@ -408,6 +410,7 @@ Deploy a wasm contract * `--cost` — Output the cost execution to stderr * `--instructions ` — Number of instructions to simulate * `--build-only` — Build the transaction and only write the base64 xdr to stdout +* `--sequence-number ` — Optionally set the sequence number for the transaction; default is the current sequence number of the source account incremented by one * `--sim-only` — (Deprecated) simulate the transaction and only write the base64 xdr to stdout * `-i`, `--ignore-checks` — Whether to ignore safety checks when deploying contracts @@ -689,6 +692,7 @@ Install a WASM file to the ledger without creating a contract instance * `--cost` — Output the cost execution to stderr * `--instructions ` — Number of instructions to simulate * `--build-only` — Build the transaction and only write the base64 xdr to stdout +* `--sequence-number ` — Optionally set the sequence number for the transaction; default is the current sequence number of the source account incremented by one * `--sim-only` — (Deprecated) simulate the transaction and only write the base64 xdr to stdout * `--wasm ` — Path to wasm binary * `-i`, `--ignore-checks` — Whether to ignore safety checks when deploying contracts @@ -729,6 +733,7 @@ stellar contract invoke ... -- --help * `--cost` — Output the cost execution to stderr * `--instructions ` — Number of instructions to simulate * `--build-only` — Build the transaction and only write the base64 xdr to stdout +* `--sequence-number ` — Optionally set the sequence number for the transaction; default is the current sequence number of the source account incremented by one * `--sim-only` — (Deprecated) simulate the transaction and only write the base64 xdr to stdout * `--send ` — Whether or not to send a transaction @@ -843,6 +848,7 @@ If no keys are specificed the contract itself is restored. * `--cost` — Output the cost execution to stderr * `--instructions ` — Number of instructions to simulate * `--build-only` — Build the transaction and only write the base64 xdr to stdout +* `--sequence-number ` — Optionally set the sequence number for the transaction; default is the current sequence number of the source account incremented by one * `--sim-only` — (Deprecated) simulate the transaction and only write the base64 xdr to stdout @@ -1422,6 +1428,7 @@ Transfers the XLM balance of an account to another account and removes the sourc * `--cost` — Output the cost execution to stderr * `--instructions ` — Number of instructions to simulate * `--build-only` — Build the transaction and only write the base64 xdr to stdout +* `--sequence-number ` — Optionally set the sequence number for the transaction; default is the current sequence number of the source account incremented by one * `--sim-only` — (Deprecated) simulate the transaction and only write the base64 xdr to stdout * `--rpc-url ` — RPC server endpoint * `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider @@ -1449,6 +1456,7 @@ Bumps forward the sequence number of the source account to the given sequence nu * `--cost` — Output the cost execution to stderr * `--instructions ` — Number of instructions to simulate * `--build-only` — Build the transaction and only write the base64 xdr to stdout +* `--sequence-number ` — Optionally set the sequence number for the transaction; default is the current sequence number of the source account incremented by one * `--sim-only` — (Deprecated) simulate the transaction and only write the base64 xdr to stdout * `--rpc-url ` — RPC server endpoint * `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider @@ -1476,6 +1484,7 @@ Creates, updates, or deletes a trustline Learn more about trustlines https://dev * `--cost` — Output the cost execution to stderr * `--instructions ` — Number of instructions to simulate * `--build-only` — Build the transaction and only write the base64 xdr to stdout +* `--sequence-number ` — Optionally set the sequence number for the transaction; default is the current sequence number of the source account incremented by one * `--sim-only` — (Deprecated) simulate the transaction and only write the base64 xdr to stdout * `--rpc-url ` — RPC server endpoint * `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider @@ -1506,6 +1515,7 @@ Creates and funds a new account with the specified starting balance * `--cost` — Output the cost execution to stderr * `--instructions ` — Number of instructions to simulate * `--build-only` — Build the transaction and only write the base64 xdr to stdout +* `--sequence-number ` — Optionally set the sequence number for the transaction; default is the current sequence number of the source account incremented by one * `--sim-only` — (Deprecated) simulate the transaction and only write the base64 xdr to stdout * `--rpc-url ` — RPC server endpoint * `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider @@ -1536,6 +1546,7 @@ Sets, modifies, or deletes a data entry (name/value pair) that is attached to an * `--cost` — Output the cost execution to stderr * `--instructions ` — Number of instructions to simulate * `--build-only` — Build the transaction and only write the base64 xdr to stdout +* `--sequence-number ` — Optionally set the sequence number for the transaction; default is the current sequence number of the source account incremented by one * `--sim-only` — (Deprecated) simulate the transaction and only write the base64 xdr to stdout * `--rpc-url ` — RPC server endpoint * `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider @@ -1564,6 +1575,7 @@ Sends an amount in a specific asset to a destination account * `--cost` — Output the cost execution to stderr * `--instructions ` — Number of instructions to simulate * `--build-only` — Build the transaction and only write the base64 xdr to stdout +* `--sequence-number ` — Optionally set the sequence number for the transaction; default is the current sequence number of the source account incremented by one * `--sim-only` — (Deprecated) simulate the transaction and only write the base64 xdr to stdout * `--rpc-url ` — RPC server endpoint * `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider @@ -1595,6 +1607,7 @@ Set option for an account such as flags, inflation destination, signers, home do * `--cost` — Output the cost execution to stderr * `--instructions ` — Number of instructions to simulate * `--build-only` — Build the transaction and only write the base64 xdr to stdout +* `--sequence-number ` — Optionally set the sequence number for the transaction; default is the current sequence number of the source account incremented by one * `--sim-only` — (Deprecated) simulate the transaction and only write the base64 xdr to stdout * `--rpc-url ` — RPC server endpoint * `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider @@ -1637,6 +1650,7 @@ Allows issuing account to configure authorization and trustline flags to an asse * `--cost` — Output the cost execution to stderr * `--instructions ` — Number of instructions to simulate * `--build-only` — Build the transaction and only write the base64 xdr to stdout +* `--sequence-number ` — Optionally set the sequence number for the transaction; default is the current sequence number of the source account incremented by one * `--sim-only` — (Deprecated) simulate the transaction and only write the base64 xdr to stdout * `--rpc-url ` — RPC server endpoint * `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider diff --git a/cmd/soroban-cli/src/assembled.rs b/cmd/soroban-cli/src/assembled.rs index 312863d52..312c4771b 100644 --- a/cmd/soroban-cli/src/assembled.rs +++ b/cmd/soroban-cli/src/assembled.rs @@ -1,4 +1,5 @@ use sha2::{Digest, Sha256}; +use soroban_sdk::xdr::SequenceNumber; use stellar_xdr::curr::{ self as xdr, ExtensionPoint, Hash, InvokeHostFunctionOp, LedgerFootprint, Limits, Memo, Operation, OperationBody, Preconditions, ReadXdr, RestoreFootprintOp, @@ -102,6 +103,12 @@ impl Assembled { self } + #[must_use] + pub fn set_seq_num(mut self, seq_num: impl Into) -> Self { + self.txn.seq_num = seq_num.into(); + self + } + /// /// # Errors #[must_use] diff --git a/cmd/soroban-cli/src/commands/tx/args.rs b/cmd/soroban-cli/src/commands/tx/args.rs index 7e032fd53..5c85a1fd4 100644 --- a/cmd/soroban-cli/src/commands/tx/args.rs +++ b/cmd/soroban-cli/src/commands/tx/args.rs @@ -37,10 +37,13 @@ pub enum Error { impl Args { pub async fn tx(&self, body: impl Into) -> Result { let source_account = self.source_account()?; - let seq_num = self - .config - .next_sequence_number(&source_account.to_string()) - .await?; + let seq_num = if let Some(seq_num) = self.fee.sequence_number { + seq_num.into() + } else { + self.config + .next_sequence_number(&source_account.to_string()) + .await? + }; // Once we have a way to add operations this will be updated to allow for a different source account let operation = xdr::Operation { source_account: None, diff --git a/cmd/soroban-cli/src/fee.rs b/cmd/soroban-cli/src/fee.rs index ea968870f..119142de7 100644 --- a/cmd/soroban-cli/src/fee.rs +++ b/cmd/soroban-cli/src/fee.rs @@ -24,6 +24,9 @@ pub struct Args { /// Build the transaction and only write the base64 xdr to stdout #[arg(long, help_heading = HEADING_RPC)] pub build_only: bool, + #[arg(long, visible_alias = "seq-num", help_heading = HEADING_RPC)] + /// Optionally set the sequence number for the transaction; default is the current sequence number of the source account incremented by one + pub sequence_number: Option, /// (Deprecated) simulate the transaction and only write the base64 xdr to stdout #[arg( long, @@ -37,10 +40,15 @@ pub struct Args { impl Args { pub fn apply_to_assembled_txn(&self, txn: Assembled) -> Assembled { - if let Some(instructions) = self.instructions { + let txn = if let Some(instructions) = self.instructions { txn.set_max_instructions(instructions) } else { add_padding_to_instructions(txn) + }; + if let Some(sequence_number) = self.sequence_number { + txn.set_seq_num(sequence_number) + } else { + txn } } } @@ -66,6 +74,7 @@ impl Default for Args { instructions: None, build_only: false, sim_only: false, + sequence_number: None, } } }