Skip to content

Commit

Permalink
[feature] #3974: Add subcommand into client_cli to transfer domains
Browse files Browse the repository at this point in the history
Signed-off-by: Vladimir Pesterev <[email protected]>
  • Loading branch information
pesterev committed Nov 3, 2023
1 parent e692e19 commit 3360119
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion client_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,11 +363,13 @@ mod domain {
/// List domains
#[clap(subcommand)]
List(List),
/// Transfer domain
Transfer(Transfer),
}

impl RunArgs for Args {
fn run(self, context: &mut dyn RunContext) -> Result<()> {
match_all!((self, context), { Args::Register, Args::List })
match_all!((self, context), { Args::Register, Args::List, Args::Transfer })
}
}

Expand Down Expand Up @@ -420,6 +422,36 @@ mod domain {
Ok(())
}
}

/// Transfer a domain between accounts
#[derive(Debug, StructOpt)]
pub struct Transfer {
/// Domain name as double-quited string
#[structopt(short, long)]
pub id: DomainId,
/// Account from which to transfer (in form `name@domain_name')
#[structopt(short, long)]
pub from: AccountId,
/// Account from which to transfer (in form `name@domain_name')
#[structopt(short, long)]
pub to: AccountId,
/// The JSON/JSON5 file with key-value metadata pairs
#[structopt(short, long, default_value = "")]
pub metadata: super::Metadata,
}

impl RunArgs for Transfer {
fn run(self, context: &mut dyn RunContext) -> Result<()> {
let Self {
id,
from,
to,
metadata: Metadata(metadata),
} = self;
let transfer_domain = TransferExpr::new(from, id, to);
submit([transfer_domain], metadata, context).wrap_err("Failed to transfer domain")
}
}
}

mod account {
Expand Down

0 comments on commit 3360119

Please sign in to comment.