soroban_cli/commands/tx/new/
clawback.rs1use clap::Parser;
2
3use crate::{commands::tx, config::address, tx::builder, xdr};
4
5#[derive(Parser, Debug, Clone)]
6#[group(skip)]
7pub struct Cmd {
8 #[command(flatten)]
9 pub tx: tx::Args,
10 #[clap(flatten)]
11 pub op: Args,
12}
13
14#[derive(Debug, clap::Args, Clone)]
15pub struct Args {
16 #[arg(long)]
18 pub from: address::UnresolvedMuxedAccount,
19 #[arg(long)]
21 pub asset: builder::Asset,
22 #[arg(long)]
24 pub amount: builder::Amount,
25}
26
27impl TryFrom<&Cmd> for xdr::OperationBody {
28 type Error = tx::args::Error;
29 fn try_from(
30 Cmd {
31 tx,
32 op:
33 Args {
34 from,
35 asset,
36 amount,
37 },
38 }: &Cmd,
39 ) -> Result<Self, Self::Error> {
40 Ok(xdr::OperationBody::Clawback(xdr::ClawbackOp {
41 from: tx.resolve_muxed_address(from)?,
42 asset: tx.resolve_asset(asset)?,
43 amount: amount.into(),
44 }))
45 }
46}