gateway_cli/
config_commands.rs1use clap::Subcommand;
2use fedimint_core::Amount;
3use fedimint_core::config::FederationId;
4use fedimint_gateway_client::{get_config, get_info, set_fees};
5use fedimint_gateway_common::{ConfigPayload, SetFeesPayload};
6use fedimint_ln_common::client::GatewayRpcClient;
7
8use crate::print_response;
9
10#[derive(Subcommand)]
11pub enum ConfigCommands {
12 ClientConfig {
14 #[clap(long)]
15 federation_id: Option<FederationId>,
16 },
17 Display {
19 #[clap(long)]
20 federation_id: Option<FederationId>,
21 },
22 SetFees {
24 #[clap(long)]
25 federation_id: Option<FederationId>,
26
27 #[clap(long)]
28 ln_base: Option<Amount>,
29
30 #[clap(long)]
31 ln_ppm: Option<u64>,
32
33 #[clap(long)]
34 tx_base: Option<Amount>,
35
36 #[clap(long)]
37 tx_ppm: Option<u64>,
38 },
39}
40
41impl ConfigCommands {
42 pub async fn handle(self, client: &GatewayRpcClient) -> anyhow::Result<()> {
43 match self {
44 Self::ClientConfig { federation_id } => {
45 let response = get_config(client, ConfigPayload { federation_id }).await?;
46
47 print_response(response);
48 }
49 Self::Display { federation_id } => {
50 let info = get_info(client).await?;
51 let federations = info
52 .federations
53 .into_iter()
54 .filter_map(|f| match federation_id {
55 Some(id) if id == f.federation_id => Some(f.config),
56 Some(_) => None,
57 None => Some(f.config),
58 })
59 .collect::<Vec<_>>();
60 print_response(federations);
61 }
62 Self::SetFees {
63 federation_id,
64 ln_base,
65 ln_ppm,
66 tx_base,
67 tx_ppm,
68 } => {
69 set_fees(
70 client,
71 SetFeesPayload {
72 federation_id,
73 lightning_base: ln_base,
74 lightning_parts_per_million: ln_ppm,
75 transaction_base: tx_base,
76 transaction_parts_per_million: tx_ppm,
77 },
78 )
79 .await?;
80 }
81 }
82
83 Ok(())
84 }
85}