Skip to content

Commit

Permalink
Cosmetics (#384)
Browse files Browse the repository at this point in the history
  • Loading branch information
grunch authored Nov 7, 2024
1 parent 2915f37 commit d855021
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions src/nip33.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use std::vec;

use crate::Settings;
use chrono::Duration;
use mostro_core::order::{Order, Status};
use mostro_core::rating::Rating;
use mostro_core::NOSTR_REPLACEABLE_EVENT_KIND;
use nostr::event::builder::Error;
use nostr_sdk::prelude::*;
use std::borrow::Cow;
use std::vec;

/// Creates a new mostro nip33 event
///
Expand Down Expand Up @@ -70,55 +70,55 @@ fn create_fiat_amt_array(order: &Order) -> Vec<String> {
pub fn order_to_tags(order: &Order, reputation: Option<Rating>) -> Tags {
let tags: Vec<Tag> = vec![
Tag::custom(
TagKind::Custom(std::borrow::Cow::Borrowed("k")),
TagKind::Custom(Cow::Borrowed("k")),
vec![order.kind.to_string()],
),
Tag::custom(
TagKind::Custom(std::borrow::Cow::Borrowed("f")),
TagKind::Custom(Cow::Borrowed("f")),
vec![order.fiat_code.to_string()],
),
Tag::custom(
TagKind::Custom(std::borrow::Cow::Borrowed("s")),
TagKind::Custom(Cow::Borrowed("s")),
vec![order.status.to_string()],
),
Tag::custom(
TagKind::Custom(std::borrow::Cow::Borrowed("amt")),
TagKind::Custom(Cow::Borrowed("amt")),
vec![order.amount.to_string()],
),
Tag::custom(
TagKind::Custom(std::borrow::Cow::Borrowed("fa")),
TagKind::Custom(Cow::Borrowed("fa")),
create_fiat_amt_array(order),
),
Tag::custom(
TagKind::Custom(std::borrow::Cow::Borrowed("pm")),
TagKind::Custom(Cow::Borrowed("pm")),
vec![order.payment_method.to_string()],
),
Tag::custom(
TagKind::Custom(std::borrow::Cow::Borrowed("premium")),
TagKind::Custom(Cow::Borrowed("premium")),
vec![order.premium.to_string()],
),
Tag::custom(
TagKind::Custom(std::borrow::Cow::Borrowed("rating")),
TagKind::Custom(Cow::Borrowed("rating")),
vec![create_rating_string(reputation)],
),
Tag::custom(
TagKind::Custom(std::borrow::Cow::Borrowed("network")),
TagKind::Custom(Cow::Borrowed("network")),
vec!["mainnet".to_string()],
),
Tag::custom(
TagKind::Custom(std::borrow::Cow::Borrowed("layer")),
TagKind::Custom(Cow::Borrowed("layer")),
vec!["lightning".to_string()],
),
Tag::custom(
TagKind::Custom(std::borrow::Cow::Borrowed("expiration")),
TagKind::Custom(Cow::Borrowed("expiration")),
vec![(order.expires_at + Duration::hours(12).num_seconds()).to_string()],
),
Tag::custom(
TagKind::Custom(std::borrow::Cow::Borrowed("y")),
TagKind::Custom(Cow::Borrowed("y")),
vec!["mostro".to_string()],
),
Tag::custom(
TagKind::Custom(std::borrow::Cow::Borrowed("z")),
TagKind::Custom(Cow::Borrowed("z")),
vec!["order".to_string()],
),
];
Expand All @@ -135,64 +135,64 @@ pub fn info_to_tags(mostro_pubkey: &PublicKey) -> Tags {
let mostro_settings = Settings::get_mostro();
let ln_settings = Settings::get_ln();

let tags: Vec<Tag> = vec![
let tags: Tags = Tags::new(vec![
Tag::custom(
TagKind::Custom(std::borrow::Cow::Borrowed("mostro_pubkey")),
TagKind::Custom(Cow::Borrowed("mostro_pubkey")),
vec![mostro_pubkey.to_string()],
),
Tag::custom(
TagKind::Custom(std::borrow::Cow::Borrowed("mostro_version")),
TagKind::Custom(Cow::Borrowed("mostro_version")),
vec![env!("CARGO_PKG_VERSION").to_string()],
),
Tag::custom(
TagKind::Custom(std::borrow::Cow::Borrowed("mostro_commit_id")),
TagKind::Custom(Cow::Borrowed("mostro_commit_id")),
vec![env!("GIT_HASH").to_string()],
),
Tag::custom(
TagKind::Custom(std::borrow::Cow::Borrowed("max_order_amount")),
TagKind::Custom(Cow::Borrowed("max_order_amount")),
vec![mostro_settings.max_order_amount.to_string()],
),
Tag::custom(
TagKind::Custom(std::borrow::Cow::Borrowed("min_order_amount")),
TagKind::Custom(Cow::Borrowed("min_order_amount")),
vec![mostro_settings.min_payment_amount.to_string()],
),
Tag::custom(
TagKind::Custom(std::borrow::Cow::Borrowed("expiration_hours")),
TagKind::Custom(Cow::Borrowed("expiration_hours")),
vec![mostro_settings.expiration_hours.to_string()],
),
Tag::custom(
TagKind::Custom(std::borrow::Cow::Borrowed("expiration_seconds")),
TagKind::Custom(Cow::Borrowed("expiration_seconds")),
vec![mostro_settings.expiration_seconds.to_string()],
),
Tag::custom(
TagKind::Custom(std::borrow::Cow::Borrowed("fee")),
TagKind::Custom(Cow::Borrowed("fee")),
vec![mostro_settings.fee.to_string()],
),
Tag::custom(
TagKind::Custom(std::borrow::Cow::Borrowed("pow")),
TagKind::Custom(Cow::Borrowed("pow")),
vec![mostro_settings.pow.to_string()],
),
Tag::custom(
TagKind::Custom(std::borrow::Cow::Borrowed("hold_invoice_expiration_window")),
TagKind::Custom(Cow::Borrowed("hold_invoice_expiration_window")),
vec![ln_settings.hold_invoice_expiration_window.to_string()],
),
Tag::custom(
TagKind::Custom(std::borrow::Cow::Borrowed("hold_invoice_cltv_delta")),
TagKind::Custom(Cow::Borrowed("hold_invoice_cltv_delta")),
vec![ln_settings.hold_invoice_cltv_delta.to_string()],
),
Tag::custom(
TagKind::Custom(std::borrow::Cow::Borrowed("invoice_expiration_window")),
TagKind::Custom(Cow::Borrowed("invoice_expiration_window")),
vec![ln_settings.hold_invoice_expiration_window.to_string()],
),
Tag::custom(
TagKind::Custom(std::borrow::Cow::Borrowed("y")),
TagKind::Custom(Cow::Borrowed("y")),
vec!["mostrop2p".to_string()],
),
Tag::custom(
TagKind::Custom(std::borrow::Cow::Borrowed("z")),
TagKind::Custom(Cow::Borrowed("z")),
vec!["info".to_string()],
),
];
]);

Tags::new(tags)
tags
}

0 comments on commit d855021

Please sign in to comment.