Remove intermediate structs in cli arguments

These intermediate structs were creating unnecessary noise. The peer id
and multiaddr fields are going to be removed in the future further
reducing the need to have seperate structs for cancel, resume and
refund.
pull/237/head
rishflab 3 years ago
parent 9a32f7d405
commit 60de6a9219

@ -21,7 +21,7 @@ use swap::{
bitcoin,
bitcoin::Amount,
cli::{
command::{Arguments, Cancel, Command, Refund, Resume},
command::{Arguments, Command},
config::{read_config, Config},
},
database::Database,
@ -141,11 +141,11 @@ async fn main() -> Result<()> {
// Print the table to stdout
table.printstd();
}
Command::Resume(Resume::BuyXmr {
Command::Resume {
swap_id,
alice_peer_id,
alice_addr,
}) => {
} => {
let (bitcoin_wallet, monero_wallet) = init_wallets(
config,
bitcoin_network,
@ -171,12 +171,12 @@ async fn main() -> Result<()> {
tokio::spawn(async move { event_loop.run().await });
bob::run(swap).await?;
}
Command::Cancel(Cancel::BuyXmr {
Command::Cancel {
swap_id,
alice_peer_id,
alice_addr,
force,
}) => {
} => {
// TODO: Optimization: Only init the Bitcoin wallet, Monero wallet unnecessary
let (bitcoin_wallet, monero_wallet) = init_wallets(
config,
@ -223,12 +223,12 @@ async fn main() -> Result<()> {
}
}
}
Command::Refund(Refund::BuyXmr {
Command::Refund {
swap_id,
alice_peer_id,
alice_addr,
force,
}) => {
} => {
let (bitcoin_wallet, monero_wallet) = init_wallets(
config,
bitcoin_network,

@ -26,37 +26,28 @@ pub enum Command {
alice_peer_id: PeerId,
#[structopt(
long = "connect-addr",
default_value = DEFAULT_ALICE_MULTIADDR
long = "connect-addr",
default_value = DEFAULT_ALICE_MULTIADDR
)]
alice_addr: Multiaddr,
},
History,
Resume(Resume),
Cancel(Cancel),
Refund(Refund),
}
#[derive(structopt::StructOpt, Debug)]
pub enum Resume {
BuyXmr {
Resume {
#[structopt(long = "swap-id")]
swap_id: Uuid,
// TODO: Remove Alice peer-id/address, it should be saved in the database when running swap
// and loaded from the database when running resume/cancel/refund
#[structopt(long = "counterpart-peer-id", default_value = DEFAULT_ALICE_PEER_ID)]
alice_peer_id: PeerId,
#[structopt(
long = "counterpart-addr",
default_value = DEFAULT_ALICE_MULTIADDR
long = "counterpart-addr",
default_value = DEFAULT_ALICE_MULTIADDR
)]
alice_addr: Multiaddr,
},
}
#[derive(structopt::StructOpt, Debug)]
pub enum Cancel {
BuyXmr {
Cancel {
#[structopt(long = "swap-id")]
swap_id: Uuid,
@ -66,19 +57,15 @@ pub enum Cancel {
alice_peer_id: PeerId,
#[structopt(
long = "counterpart-addr",
default_value = DEFAULT_ALICE_MULTIADDR
)]
long = "counterpart-addr",
default_value = DEFAULT_ALICE_MULTIADDR
)]
alice_addr: Multiaddr,
#[structopt(short, long)]
force: bool,
},
}
#[derive(structopt::StructOpt, Debug)]
pub enum Refund {
BuyXmr {
Refund {
#[structopt(long = "swap-id")]
swap_id: Uuid,
@ -88,8 +75,8 @@ pub enum Refund {
alice_peer_id: PeerId,
#[structopt(
long = "counterpart-addr",
default_value = DEFAULT_ALICE_MULTIADDR
long = "counterpart-addr",
default_value = DEFAULT_ALICE_MULTIADDR
)]
alice_addr: Multiaddr,

Loading…
Cancel
Save