Skip to main content

soroban_cli/commands/tx/new/
manage_data.rs

1use clap::Parser;
2
3use crate::{commands::tx, 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    /// String up to 64 bytes long.
17    /// If this is a new Name it will add the given name/value pair to the account.
18    /// If this Name is already present then the associated value will be modified.
19    #[arg(long)]
20    pub data_name: xdr::StringM<64>,
21    /// Up to 64 bytes long hex string
22    /// If not present then the existing Name will be deleted.
23    /// If present then this value will be set in the `DataEntry`.
24    #[arg(long)]
25    pub data_value: Option<xdr::BytesM<64>>,
26}
27
28impl From<&Cmd> for xdr::OperationBody {
29    fn from(cmd: &Cmd) -> Self {
30        let data_value = cmd.op.data_value.clone().map(Into::into);
31        let data_name = cmd.op.data_name.clone().into();
32        xdr::OperationBody::ManageData(xdr::ManageDataOp {
33            data_name,
34            data_value,
35        })
36    }
37}