update_nut05.rs 1006 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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::UpdateNut05Request;
  7. #[derive(Args)]
  8. pub struct UpdateNut05Command {
  9. #[arg(short, long)]
  10. #[arg(default_value = "sat")]
  11. unit: String,
  12. #[arg(short, long)]
  13. #[arg(default_value = "bolt11")]
  14. method: String,
  15. #[arg(long)]
  16. min_amount: Option<u64>,
  17. #[arg(long)]
  18. max_amount: Option<u64>,
  19. #[arg(long)]
  20. disabled: Option<bool>,
  21. }
  22. pub async fn update_nut05(
  23. client: &mut CdkMintClient<Channel>,
  24. sub_command_args: &UpdateNut05Command,
  25. ) -> Result<()> {
  26. let _response = client
  27. .update_nut05(Request::new(UpdateNut05Request {
  28. method: sub_command_args.method.clone(),
  29. unit: sub_command_args.unit.clone(),
  30. disabled: sub_command_args.disabled,
  31. min: sub_command_args.min_amount,
  32. max: sub_command_args.max_amount,
  33. }))
  34. .await?;
  35. Ok(())
  36. }