mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-10-01 01:45:40 -04:00
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.
This commit is contained in:
parent
9a32f7d405
commit
60de6a9219
@ -21,7 +21,7 @@ use swap::{
|
|||||||
bitcoin,
|
bitcoin,
|
||||||
bitcoin::Amount,
|
bitcoin::Amount,
|
||||||
cli::{
|
cli::{
|
||||||
command::{Arguments, Cancel, Command, Refund, Resume},
|
command::{Arguments, Command},
|
||||||
config::{read_config, Config},
|
config::{read_config, Config},
|
||||||
},
|
},
|
||||||
database::Database,
|
database::Database,
|
||||||
@ -141,11 +141,11 @@ async fn main() -> Result<()> {
|
|||||||
// Print the table to stdout
|
// Print the table to stdout
|
||||||
table.printstd();
|
table.printstd();
|
||||||
}
|
}
|
||||||
Command::Resume(Resume::BuyXmr {
|
Command::Resume {
|
||||||
swap_id,
|
swap_id,
|
||||||
alice_peer_id,
|
alice_peer_id,
|
||||||
alice_addr,
|
alice_addr,
|
||||||
}) => {
|
} => {
|
||||||
let (bitcoin_wallet, monero_wallet) = init_wallets(
|
let (bitcoin_wallet, monero_wallet) = init_wallets(
|
||||||
config,
|
config,
|
||||||
bitcoin_network,
|
bitcoin_network,
|
||||||
@ -171,12 +171,12 @@ async fn main() -> Result<()> {
|
|||||||
tokio::spawn(async move { event_loop.run().await });
|
tokio::spawn(async move { event_loop.run().await });
|
||||||
bob::run(swap).await?;
|
bob::run(swap).await?;
|
||||||
}
|
}
|
||||||
Command::Cancel(Cancel::BuyXmr {
|
Command::Cancel {
|
||||||
swap_id,
|
swap_id,
|
||||||
alice_peer_id,
|
alice_peer_id,
|
||||||
alice_addr,
|
alice_addr,
|
||||||
force,
|
force,
|
||||||
}) => {
|
} => {
|
||||||
// TODO: Optimization: Only init the Bitcoin wallet, Monero wallet unnecessary
|
// TODO: Optimization: Only init the Bitcoin wallet, Monero wallet unnecessary
|
||||||
let (bitcoin_wallet, monero_wallet) = init_wallets(
|
let (bitcoin_wallet, monero_wallet) = init_wallets(
|
||||||
config,
|
config,
|
||||||
@ -223,12 +223,12 @@ async fn main() -> Result<()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Command::Refund(Refund::BuyXmr {
|
Command::Refund {
|
||||||
swap_id,
|
swap_id,
|
||||||
alice_peer_id,
|
alice_peer_id,
|
||||||
alice_addr,
|
alice_addr,
|
||||||
force,
|
force,
|
||||||
}) => {
|
} => {
|
||||||
let (bitcoin_wallet, monero_wallet) = init_wallets(
|
let (bitcoin_wallet, monero_wallet) = init_wallets(
|
||||||
config,
|
config,
|
||||||
bitcoin_network,
|
bitcoin_network,
|
||||||
|
@ -26,37 +26,13 @@ pub enum Command {
|
|||||||
alice_peer_id: PeerId,
|
alice_peer_id: PeerId,
|
||||||
|
|
||||||
#[structopt(
|
#[structopt(
|
||||||
long = "connect-addr",
|
long = "connect-addr",
|
||||||
default_value = DEFAULT_ALICE_MULTIADDR
|
default_value = DEFAULT_ALICE_MULTIADDR
|
||||||
)]
|
)]
|
||||||
alice_addr: Multiaddr,
|
alice_addr: Multiaddr,
|
||||||
},
|
},
|
||||||
History,
|
History,
|
||||||
Resume(Resume),
|
Resume {
|
||||||
Cancel(Cancel),
|
|
||||||
Refund(Refund),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(structopt::StructOpt, Debug)]
|
|
||||||
pub enum Resume {
|
|
||||||
BuyXmr {
|
|
||||||
#[structopt(long = "swap-id")]
|
|
||||||
swap_id: Uuid,
|
|
||||||
|
|
||||||
#[structopt(long = "counterpart-peer-id", default_value = DEFAULT_ALICE_PEER_ID)]
|
|
||||||
alice_peer_id: PeerId,
|
|
||||||
|
|
||||||
#[structopt(
|
|
||||||
long = "counterpart-addr",
|
|
||||||
default_value = DEFAULT_ALICE_MULTIADDR
|
|
||||||
)]
|
|
||||||
alice_addr: Multiaddr,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(structopt::StructOpt, Debug)]
|
|
||||||
pub enum Cancel {
|
|
||||||
BuyXmr {
|
|
||||||
#[structopt(long = "swap-id")]
|
#[structopt(long = "swap-id")]
|
||||||
swap_id: Uuid,
|
swap_id: Uuid,
|
||||||
|
|
||||||
@ -66,19 +42,12 @@ pub enum Cancel {
|
|||||||
alice_peer_id: PeerId,
|
alice_peer_id: PeerId,
|
||||||
|
|
||||||
#[structopt(
|
#[structopt(
|
||||||
long = "counterpart-addr",
|
long = "counterpart-addr",
|
||||||
default_value = DEFAULT_ALICE_MULTIADDR
|
default_value = DEFAULT_ALICE_MULTIADDR
|
||||||
)]
|
)]
|
||||||
alice_addr: Multiaddr,
|
alice_addr: Multiaddr,
|
||||||
|
|
||||||
#[structopt(short, long)]
|
|
||||||
force: bool,
|
|
||||||
},
|
},
|
||||||
}
|
Cancel {
|
||||||
|
|
||||||
#[derive(structopt::StructOpt, Debug)]
|
|
||||||
pub enum Refund {
|
|
||||||
BuyXmr {
|
|
||||||
#[structopt(long = "swap-id")]
|
#[structopt(long = "swap-id")]
|
||||||
swap_id: Uuid,
|
swap_id: Uuid,
|
||||||
|
|
||||||
@ -88,8 +57,26 @@ pub enum Refund {
|
|||||||
alice_peer_id: PeerId,
|
alice_peer_id: PeerId,
|
||||||
|
|
||||||
#[structopt(
|
#[structopt(
|
||||||
long = "counterpart-addr",
|
long = "counterpart-addr",
|
||||||
default_value = DEFAULT_ALICE_MULTIADDR
|
default_value = DEFAULT_ALICE_MULTIADDR
|
||||||
|
)]
|
||||||
|
alice_addr: Multiaddr,
|
||||||
|
|
||||||
|
#[structopt(short, long)]
|
||||||
|
force: bool,
|
||||||
|
},
|
||||||
|
Refund {
|
||||||
|
#[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
|
||||||
)]
|
)]
|
||||||
alice_addr: Multiaddr,
|
alice_addr: Multiaddr,
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user