Skip to content

Commit

Permalink
Merge pull request #34 from MostroP2P/admin-cancel-order
Browse files Browse the repository at this point in the history
Cancel order by admin support
  • Loading branch information
grunch authored May 3, 2023
2 parents e414a2d + fd0f71e commit d1368c0
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 17 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ uuid = { version = "1.3.0", features = [
dotenvy = "0.15.6"
lightning-invoice = "0.23.0"
reqwest = { version = "0.11", features = ["json"] }
mostro-core = "0.2.4"
mostro-core = "0.2.6"
bitcoin_hashes = "0.12.0"
29 changes: 16 additions & 13 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,6 @@ pub mod send_msg;
pub mod take_buy;
pub mod take_sell;

use clap::{Parser, Subcommand};

use mostro_core::{Kind, Status};
use uuid::Uuid;

use std::env::{set_var, var};

use anyhow::Result;

use nostr_sdk::prelude::FromBech32;
use nostr_sdk::secp256k1::XOnlyPublicKey;

use crate::cli::add_invoice::execute_add_invoice;
use crate::cli::get_dm::execute_get_dm;
use crate::cli::list_orders::execute_list_orders;
Expand All @@ -29,6 +17,14 @@ use crate::cli::take_buy::execute_take_buy;
use crate::cli::take_sell::execute_take_sell;
use crate::util;

use anyhow::Result;
use clap::{Parser, Subcommand};
use mostro_core::{Kind, Status};
use nostr_sdk::prelude::FromBech32;
use nostr_sdk::secp256k1::XOnlyPublicKey;
use std::env::{set_var, var};
use uuid::Uuid;

#[derive(Parser)]
#[command(
name = "mostro-cli",
Expand Down Expand Up @@ -157,12 +153,18 @@ pub enum Commands {
#[arg(short, long)]
rating: u8,
},
/// Send dispute message to start a dispute
/// Start a dispute
Dispute {
/// Order id number
#[arg(short, long)]
order_id: Uuid,
},
/// Cancel an order (only admin)
AdminCancel {
/// Order id number
#[arg(short, long)]
order_id: Uuid,
},
}

/// Check range simple version for just a single value
Expand Down Expand Up @@ -212,6 +214,7 @@ pub async fn run() -> Result<()> {
Commands::FiatSent { order_id }
| Commands::Release { order_id }
| Commands::Dispute { order_id }
| Commands::AdminCancel { order_id }
| Commands::Cancel { order_id } => {
execute_send_msg(cmd.clone(), order_id, &my_key, mostro_key, &client).await?
}
Expand Down
6 changes: 5 additions & 1 deletion src/cli/send_msg.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use crate::cli::Commands;
use crate::util::get_keys;
use crate::util::send_order_id_cmd;

use anyhow::Result;
use log::info;
use mostro_core::Action;
use mostro_core::Message as MostroMessage;
use nostr_sdk::prelude::ToBech32;
Expand All @@ -23,6 +25,7 @@ pub async fn execute_send_msg(
Commands::Release { order_id: _ } => Action::Release,
Commands::Cancel { order_id: _ } => Action::Cancel,
Commands::Dispute { order_id: _ } => Action::Dispute,
Commands::AdminCancel { order_id: _ } => Action::AdminCancel,
_ => {
println!("Not a valid command!");
process::exit(0);
Expand All @@ -48,7 +51,8 @@ pub async fn execute_send_msg(
)
.as_json()
.unwrap();

info!("Sending message: {}", message);
send_order_id_cmd(client, my_key, mostro_key, message, false).await?;

Ok(())
}

0 comments on commit d1368c0

Please sign in to comment.