fedimint_mint_client/
cli.rsuse std::{ffi, iter};
use anyhow::bail;
use clap::Parser;
use futures::StreamExt;
use serde::Serialize;
use crate::{MintClientModule, OOBNotes, ReissueExternalNotesState};
#[derive(Parser, Serialize)]
enum Opts {
Reissue { notes: OOBNotes },
}
pub(crate) async fn handle_cli_command(
mint: &MintClientModule,
args: &[ffi::OsString],
) -> anyhow::Result<serde_json::Value> {
let opts = Opts::parse_from(iter::once(&ffi::OsString::from("mint")).chain(args.iter()));
match opts {
Opts::Reissue { notes } => {
let amount = notes.total_amount();
let operation_id = mint.reissue_external_notes(notes, ()).await?;
let mut updates = mint
.subscribe_reissue_external_notes(operation_id)
.await
.unwrap()
.into_stream();
while let Some(update) = updates.next().await {
if let ReissueExternalNotesState::Failed(e) = update {
bail!("Reissue failed: {e}");
}
}
Ok(serde_json::to_value(amount).expect("JSON serialization failed"))
}
}
}