diff --git a/cmd/soroban-cli/src/commands/contract/extend.rs b/cmd/soroban-cli/src/commands/contract/extend.rs index 265b70f36..71590e13c 100644 --- a/cmd/soroban-cli/src/commands/contract/extend.rs +++ b/cmd/soroban-cli/src/commands/contract/extend.rs @@ -15,14 +15,14 @@ use crate::{ wasm, Pwd, }; -const MAX_LEDGERS_TO_EXPIRE: u32 = 535_679; +const MAX_LEDGERS_TO_EXTEND: u32 = 535_679; #[derive(Parser, Debug, Clone)] #[group(skip)] pub struct Cmd { /// Number of ledgers to extend the entries #[arg(long, required = true)] - pub ledgers_to_expire: u32, + pub ledgers_to_extend: u32, /// Only print the new expiration ledger #[arg(long)] @@ -97,11 +97,11 @@ impl Cmd { Ok(()) } - fn ledgers_to_expire(&self) -> u32 { - let res = u32::min(self.ledgers_to_expire, MAX_LEDGERS_TO_EXPIRE); - if res < self.ledgers_to_expire { + fn ledgers_to_extend(&self) -> u32 { + let res = u32::min(self.ledgers_to_extend, MAX_LEDGERS_TO_EXTEND); + if res < self.ledgers_to_extend { tracing::warn!( - "Ledgers to expire is too large, using max value of {MAX_LEDGERS_TO_EXPIRE}" + "Ledgers to extend is too large, using max value of {MAX_LEDGERS_TO_EXTEND}" ); } res @@ -114,7 +114,7 @@ impl Cmd { let network = &self.config.get_network()?; let client = Client::new(&network.rpc_url)?; let key = self.config.key_pair()?; - let extend_to = self.ledgers_to_expire(); + let extend_to = self.ledgers_to_extend(); // Get the account sequence number let public_strkey = @@ -175,9 +175,9 @@ impl Cmd { if operations[0].changes.is_empty() { let entry = client.get_full_ledger_entries(&keys).await?; - let expire = entry.entries[0].live_until_ledger_seq; - if entry.latest_ledger + i64::from(extend_to) < i64::from(expire) { - return Ok(expire); + let extension = entry.entries[0].live_until_ledger_seq; + if entry.latest_ledger + i64::from(extend_to) < i64::from(extension) { + return Ok(extension); } } @@ -220,7 +220,7 @@ impl Cmd { if keys.contains(&new_k) { // It must have an expiration since it's a contract data entry let old_expiration = v.1.unwrap(); - expiration_ledger_seq = Some(old_expiration + self.ledgers_to_expire); + expiration_ledger_seq = Some(old_expiration + self.ledgers_to_extend); expiration_ledger_seq } else { new_e diff --git a/cmd/soroban-cli/src/commands/contract/install.rs b/cmd/soroban-cli/src/commands/contract/install.rs index 5e0547230..f7c6fef3e 100644 --- a/cmd/soroban-cli/src/commands/contract/install.rs +++ b/cmd/soroban-cli/src/commands/contract/install.rs @@ -124,7 +124,7 @@ impl Cmd { }, config: self.config.clone(), fee: self.fee.clone(), - ledgers_to_expire: None, + ledgers_to_extend: None, } .run_against_rpc_server() .await?; diff --git a/cmd/soroban-cli/src/commands/contract/restore.rs b/cmd/soroban-cli/src/commands/contract/restore.rs index 735f5bdeb..1d778dcc9 100644 --- a/cmd/soroban-cli/src/commands/contract/restore.rs +++ b/cmd/soroban-cli/src/commands/contract/restore.rs @@ -26,7 +26,7 @@ pub struct Cmd { pub key: key::Args, /// Number of ledgers to extend the entry #[arg(long)] - pub ledgers_to_expire: Option, + pub ledgers_to_extend: Option, #[command(flatten)] pub config: config::Args, #[command(flatten)] @@ -90,10 +90,10 @@ impl Cmd { self.run_against_rpc_server().await? }; - if let Some(ledgers_to_expire) = self.ledgers_to_expire { + if let Some(ledgers_to_extend) = self.ledgers_to_extend { extend::Cmd { key: self.key.clone(), - ledgers_to_expire, + ledgers_to_extend, config: self.config.clone(), fee: self.fee.clone(), expiration_ledger_only: false, diff --git a/cmd/soroban-rpc/internal/test/cli_test.go b/cmd/soroban-rpc/internal/test/cli_test.go index a10624278..f1dcd644e 100644 --- a/cmd/soroban-rpc/internal/test/cli_test.go +++ b/cmd/soroban-rpc/internal/test/cli_test.go @@ -142,7 +142,7 @@ func TestCLIExtend(t *testing.T) { extendOutput := runSuccessfulCLICmd( t, fmt.Sprintf( - "contract extend --id %s --key COUNTER --durability persistent --ledgers-to-expire 20", + "contract extend --id %s --key COUNTER --durability persistent --ledgers-to-extend 20", strkeyContractID, ), ) @@ -330,7 +330,7 @@ func extend(t *testing.T, contractId string, amount string, rest string) uint64 res := runSuccessfulCLICmd( t, fmt.Sprintf( - "contract extend --expiration-ledger-only --id=%s --durability persistent --ledgers-to-expire=%s %s", + "contract extend --expiration-ledger-only --id=%s --durability persistent --ledgers-to-extend=%s %s", contractId, amount, rest, diff --git a/docs/soroban-cli-full-docs.md b/docs/soroban-cli-full-docs.md index f0170574b..3dafbf7c9 100644 --- a/docs/soroban-cli-full-docs.md +++ b/docs/soroban-cli-full-docs.md @@ -230,11 +230,11 @@ Extend the expiry ledger of a contract-data ledger entry. If no keys are specified the contract itself is extended. -**Usage:** `soroban contract extend [OPTIONS] --ledgers-to-expire --durability ` +**Usage:** `soroban contract extend [OPTIONS] --ledgers-to-extend --durability ` ###### **Options:** -* `--ledgers-to-expire ` — Number of ledgers to extend the entries +* `--ledgers-to-extend ` — Number of ledgers to extend the entries * `--expiration-ledger-only` — Only print the new expiration ledger * `--id ` — Contract ID to which owns the data entries. If no keys provided the Contract's instance will be extended * `--key ` — Storage key (symbols only) @@ -472,7 +472,7 @@ If no keys are specificed the contract itself is restored. - `temporary`: Temporary -* `--ledgers-to-expire ` — Number of ledgers to extend the entry +* `--ledgers-to-extend ` — Number of ledgers to extend the entry * `--rpc-url ` — RPC server endpoint * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config