Skip to main content

cdk_mint_rpc/mint_rpc_cli/subcommands/
update_contact.rs

1use anyhow::Result;
2use clap::Args;
3use tonic::Request;
4
5use crate::{InterceptedCdkMintClient, UpdateContactRequest};
6
7/// Command to add a contact method to the mint
8///
9/// This command adds a new contact method with associated information to the mint.
10/// Contact methods allow users to reach the mint operators through various channels.
11#[derive(Args, Debug)]
12pub struct AddContactCommand {
13    /// The contact method type (e.g., "email", "twitter", "telegram")
14    method: String,
15    /// The contact information for the specified method
16    info: String,
17}
18
19/// Executes the add_contact command against the mint server
20///
21/// This function sends an RPC request to add a new contact method to the mint.
22///
23/// # Arguments
24/// * `client` - The RPC client used to communicate with the mint
25/// * `sub_command_args` - The contact method and information to add
26pub async fn add_contact(
27    client: &mut InterceptedCdkMintClient,
28    sub_command_args: &AddContactCommand,
29) -> Result<()> {
30    let _response = client
31        .add_contact(Request::new(UpdateContactRequest {
32            method: sub_command_args.method.clone(),
33            info: sub_command_args.info.clone(),
34        }))
35        .await?;
36
37    Ok(())
38}
39
40/// Command to remove a contact method from the mint
41///
42/// This command removes an existing contact method and its associated information
43/// from the mint's available contact methods.
44#[derive(Args, Debug)]
45pub struct RemoveContactCommand {
46    /// The contact method type to remove (e.g., "email", "twitter", "telegram")
47    method: String,
48    /// The specific contact information to remove for the specified method
49    info: String,
50}
51
52/// Executes the remove_contact command against the mint server
53///
54/// This function sends an RPC request to remove an existing contact method from the mint.
55///
56/// # Arguments
57/// * `client` - The RPC client used to communicate with the mint
58/// * `sub_command_args` - The contact method and information to remove
59pub async fn remove_contact(
60    client: &mut InterceptedCdkMintClient,
61    sub_command_args: &RemoveContactCommand,
62) -> Result<()> {
63    let _response = client
64        .remove_contact(Request::new(UpdateContactRequest {
65            method: sub_command_args.method.clone(),
66            info: sub_command_args.info.clone(),
67        }))
68        .await?;
69
70    Ok(())
71}