update_ttl.rs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. use anyhow::Result;
  2. use clap::Args;
  3. use tonic::transport::Channel;
  4. use tonic::Request;
  5. use crate::cdk_mint_client::CdkMintClient;
  6. use crate::UpdateQuoteTtlRequest;
  7. /// Command to update the time-to-live (TTL) settings for quotes
  8. ///
  9. /// This command configures how long mint and melt quotes remain valid before
  10. /// automatically expiring. Quote TTL settings help manage pending operations and
  11. /// resource usage on the mint.
  12. #[derive(Args)]
  13. pub struct UpdateQuoteTtlCommand {
  14. /// The TTL (in seconds) for mint quotes
  15. #[arg(long)]
  16. mint_ttl: Option<u64>,
  17. /// The TTL (in seconds) for melt quotes
  18. #[arg(long)]
  19. melt_ttl: Option<u64>,
  20. }
  21. /// Executes the update_quote_ttl command against the mint server
  22. ///
  23. /// This function sends an RPC request to update the TTL settings for mint and melt quotes.
  24. ///
  25. /// # Arguments
  26. /// * `client` - The RPC client used to communicate with the mint
  27. /// * `sub_command_args` - The new TTL values to set for quotes
  28. pub async fn update_quote_ttl(
  29. client: &mut CdkMintClient<Channel>,
  30. sub_command_args: &UpdateQuoteTtlCommand,
  31. ) -> Result<()> {
  32. let _response = client
  33. .update_quote_ttl(Request::new(UpdateQuoteTtlRequest {
  34. mint_ttl: sub_command_args.mint_ttl,
  35. melt_ttl: sub_command_args.melt_ttl,
  36. }))
  37. .await?;
  38. Ok(())
  39. }