Skip to content

Commit

Permalink
chore: cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
thesimplekid committed Nov 15, 2024
1 parent 03b4fa1 commit 21b4950
Show file tree
Hide file tree
Showing 41 changed files with 213 additions and 252 deletions.
5 changes: 1 addition & 4 deletions crates/cdk-axum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ mod swagger_imports {
pub use cdk::nuts::nut01::{Keys, KeysResponse, PublicKey, SecretKey};
pub use cdk::nuts::nut02::{Id, KeySet, KeySetInfo, KeySetVersion, KeysetResponse};
pub use cdk::nuts::nut03::{SwapRequest, SwapResponse};
pub use cdk::nuts::nut04;
pub use cdk::nuts::nut04::{
MintBolt11Request, MintBolt11Response, MintMethodSettings, MintQuoteBolt11Request,
MintQuoteBolt11Response,
};
pub use cdk::nuts::nut05;
pub use cdk::nuts::nut05::{
MeltBolt11Request, MeltMethodSettings, MeltQuoteBolt11Request, MeltQuoteBolt11Response,
};
Expand All @@ -41,9 +39,8 @@ mod swagger_imports {
pub use cdk::nuts::nut11::P2PKWitness;
pub use cdk::nuts::nut12::{BlindSignatureDleq, ProofDleq};
pub use cdk::nuts::nut14::HTLCWitness;
pub use cdk::nuts::nut15;
pub use cdk::nuts::nut15::{Mpp, MppMethodSettings};
pub use cdk::nuts::{MeltQuoteState, MintQuoteState};
pub use cdk::nuts::{nut04, nut05, nut15, MeltQuoteState, MintQuoteState};
}

#[cfg(feature = "swagger")]
Expand Down
6 changes: 4 additions & 2 deletions crates/cdk-axum/src/router_handlers.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use anyhow::Result;
use axum::extract::{ws::WebSocketUpgrade, Json, Path, State};
use axum::extract::ws::WebSocketUpgrade;
use axum::extract::{Json, Path, State};
use axum::http::StatusCode;
use axum::response::{IntoResponse, Response};
use cdk::error::ErrorResponse;
Expand All @@ -13,7 +14,8 @@ use cdk::util::unix_time;
use cdk::Error;
use paste::paste;

use crate::{ws::main_websocket, MintState};
use crate::ws::main_websocket;
use crate::MintState;

macro_rules! post_cache_wrapper {
($handler:ident, $request_type:ty, $response_type:ty) => {
Expand Down
3 changes: 2 additions & 1 deletion crates/cdk-axum/src/ws/handler.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use super::{WsContext, WsError, JSON_RPC_VERSION};
use serde::Serialize;

use super::{WsContext, WsError, JSON_RPC_VERSION};

impl From<WsError> for WsErrorResponse {
fn from(val: WsError) -> Self {
let (id, message) = match val {
Expand Down
6 changes: 4 additions & 2 deletions crates/cdk-axum/src/ws/mod.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
use crate::MintState;
use std::collections::HashMap;

use axum::extract::ws::{Message, WebSocket};
use cdk::nuts::nut17::{NotificationPayload, SubId};
use futures::StreamExt;
use handler::{WsHandle, WsNotification};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use subscribe::Notification;
use tokio::sync::mpsc;

use crate::MintState;

mod error;
mod handler;
mod subscribe;
Expand Down
13 changes: 5 additions & 8 deletions crates/cdk-axum/src/ws/subscribe.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
use super::{
handler::{WsHandle, WsNotification},
WsContext, WsError, JSON_RPC_VERSION,
};
use cdk::{
nuts::nut17::{NotificationPayload, Params},
pub_sub::SubId,
};
use cdk::nuts::nut17::{NotificationPayload, Params};
use cdk::pub_sub::SubId;

use super::handler::{WsHandle, WsNotification};
use super::{WsContext, WsError, JSON_RPC_VERSION};

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct Method(Params);
Expand Down
4 changes: 3 additions & 1 deletion crates/cdk-axum/src/ws/unsubscribe.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use super::{handler::WsHandle, WsContext, WsError};
use cdk::pub_sub::SubId;

use super::handler::WsHandle;
use super::{WsContext, WsError};

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct Method {
#[serde(rename = "subId")]
Expand Down
12 changes: 5 additions & 7 deletions crates/cdk-cli/src/sub_commands/create_request.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
use anyhow::Result;
use cdk::{
nuts::{
nut18::TransportType, CurrencyUnit, PaymentRequest, PaymentRequestPayload, Token, Transport,
},
wallet::MultiMintWallet,
};
use cdk::nuts::nut18::TransportType;
use cdk::nuts::{CurrencyUnit, PaymentRequest, PaymentRequestPayload, Token, Transport};
use cdk::wallet::MultiMintWallet;
use clap::Args;
use nostr_sdk::nips::nip19::Nip19Profile;
use nostr_sdk::prelude::*;
use nostr_sdk::{nips::nip19::Nip19Profile, Client as NostrClient, Filter, Keys, ToBech32};
use nostr_sdk::{Client as NostrClient, Filter, Keys, ToBech32};

#[derive(Args)]
pub struct CreateRequestSubCommand {
Expand Down
8 changes: 3 additions & 5 deletions crates/cdk-cli/src/sub_commands/list_mint_proofs.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
use std::collections::BTreeMap;

use anyhow::Result;
use cdk::{
mint_url::MintUrl,
nuts::{CurrencyUnit, Proof},
wallet::multi_mint_wallet::MultiMintWallet,
};
use cdk::mint_url::MintUrl;
use cdk::nuts::{CurrencyUnit, Proof};
use cdk::wallet::multi_mint_wallet::MultiMintWallet;

pub async fn proofs(multi_mint_wallet: &MultiMintWallet) -> Result<()> {
list_proofs(multi_mint_wallet).await?;
Expand Down
12 changes: 6 additions & 6 deletions crates/cdk-cli/src/sub_commands/pay_request.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use std::io::{self, Write};

use anyhow::{anyhow, Result};
use cdk::{
amount::SplitTarget,
nuts::{nut18::TransportType, PaymentRequest, PaymentRequestPayload},
wallet::{MultiMintWallet, SendKind},
};
use cdk::amount::SplitTarget;
use cdk::nuts::nut18::TransportType;
use cdk::nuts::{PaymentRequest, PaymentRequestPayload};
use cdk::wallet::{MultiMintWallet, SendKind};
use clap::Args;
use nostr_sdk::{nips::nip19::Nip19Profile, Client as NostrClient, EventBuilder, FromBech32, Keys};
use nostr_sdk::nips::nip19::Nip19Profile;
use nostr_sdk::{Client as NostrClient, EventBuilder, FromBech32, Keys};
use reqwest::Client;

#[derive(Args)]
Expand Down
3 changes: 2 additions & 1 deletion crates/cdk-integration-tests/src/bin/fake_wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use std::env;

use anyhow::Result;
use cdk::cdk_database::mint_memory::MintMemoryDatabase;
use cdk_integration_tests::{init_fake_wallet::start_fake_mint, init_regtest::get_temp_dir};
use cdk_integration_tests::init_fake_wallet::start_fake_mint;
use cdk_integration_tests::init_regtest::get_temp_dir;
use cdk_redb::MintRedbDatabase;
use cdk_sqlite::MintSqliteDatabase;

Expand Down
18 changes: 7 additions & 11 deletions crates/cdk-integration-tests/src/init_fake_wallet.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
use std::{
collections::{HashMap, HashSet},
sync::Arc,
};
use std::collections::{HashMap, HashSet};
use std::sync::Arc;

use anyhow::Result;
use axum::Router;
use cdk::{
cdk_database::{self, MintDatabase},
cdk_lightning::MintLightning,
mint::FeeReserve,
nuts::CurrencyUnit,
types::LnKey,
};
use cdk::cdk_database::{self, MintDatabase};
use cdk::cdk_lightning::MintLightning;
use cdk::mint::FeeReserve;
use cdk::nuts::CurrencyUnit;
use cdk::types::LnKey;
use cdk_fake_wallet::FakeWallet;
use tokio::sync::Notify;
use tower_http::cors::CorsLayer;
Expand Down
27 changes: 15 additions & 12 deletions crates/cdk-integration-tests/src/init_regtest.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
use std::{collections::HashMap, env, path::PathBuf, sync::Arc};
use std::collections::HashMap;
use std::env;
use std::path::PathBuf;
use std::sync::Arc;

use anyhow::Result;
use axum::Router;
use bip39::Mnemonic;
use cdk::{
cdk_database::{self, MintDatabase},
cdk_lightning::MintLightning,
mint::{FeeReserve, Mint},
nuts::{CurrencyUnit, MintInfo},
types::{LnKey, QuoteTTL},
};
use cdk::cdk_database::{self, MintDatabase};
use cdk::cdk_lightning::MintLightning;
use cdk::mint::{FeeReserve, Mint};
use cdk::nuts::{CurrencyUnit, MintInfo};
use cdk::types::{LnKey, QuoteTTL};
use cdk_cln::Cln as CdkCln;
use ln_regtest_rs::{
bitcoin_client::BitcoinClient, bitcoind::Bitcoind, cln::Clnd, cln_client::ClnClient, lnd::Lnd,
lnd_client::LndClient,
};
use ln_regtest_rs::bitcoin_client::BitcoinClient;
use ln_regtest_rs::bitcoind::Bitcoind;
use ln_regtest_rs::cln::Clnd;
use ln_regtest_rs::cln_client::ClnClient;
use ln_regtest_rs::lnd::Lnd;
use ln_regtest_rs::lnd_client::LndClient;
use tokio::sync::Notify;
use tower_http::cors::CorsLayer;
use tracing_subscriber::EnvFilter;
Expand Down
19 changes: 8 additions & 11 deletions crates/cdk-integration-tests/tests/fake_wallet.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
use std::{sync::Arc, time::Duration};
use std::sync::Arc;
use std::time::Duration;

use anyhow::Result;
use bip39::Mnemonic;
use cdk::{
amount::SplitTarget,
cdk_database::WalletMemoryDatabase,
nuts::{
CurrencyUnit, MeltBolt11Request, MeltQuoteState, MintQuoteState, PreMintSecrets, State,
},
wallet::{
client::{HttpClient, HttpClientMethods},
Wallet,
},
use cdk::amount::SplitTarget;
use cdk::cdk_database::WalletMemoryDatabase;
use cdk::nuts::{
CurrencyUnit, MeltBolt11Request, MeltQuoteState, MintQuoteState, PreMintSecrets, State,
};
use cdk::wallet::client::{HttpClient, HttpClientMethods};
use cdk::wallet::Wallet;
use cdk_fake_wallet::{create_fake_invoice, FakeInvoiceDescription};
use cdk_integration_tests::attempt_to_swap_pending;
use tokio::time::sleep;
Expand Down
7 changes: 4 additions & 3 deletions crates/cdk-integration-tests/tests/mint.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
//! Mint tests
use std::collections::HashMap;
use std::sync::Arc;
use std::time::Duration;

use anyhow::{bail, Result};
use bip39::Mnemonic;
use cdk::amount::{Amount, SplitTarget};
Expand All @@ -15,9 +19,6 @@ use cdk::nuts::{
use cdk::types::QuoteTTL;
use cdk::util::unix_time;
use cdk::Mint;
use std::collections::HashMap;
use std::sync::Arc;
use std::time::Duration;
use tokio::sync::OnceCell;
use tokio::time::sleep;

Expand Down
26 changes: 13 additions & 13 deletions crates/cdk-integration-tests/tests/regtest.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
use std::{fmt::Debug, str::FromStr, sync::Arc, time::Duration};
use std::fmt::Debug;
use std::str::FromStr;
use std::sync::Arc;
use std::time::Duration;

use anyhow::{bail, Result};
use bip39::Mnemonic;
use cdk::{
amount::{Amount, SplitTarget},
cdk_database::WalletMemoryDatabase,
nuts::{
CurrencyUnit, MeltQuoteState, MintBolt11Request, MintQuoteState, NotificationPayload,
PreMintSecrets, State,
},
wallet::{
client::{HttpClient, HttpClientMethods},
Wallet,
},
use cdk::amount::{Amount, SplitTarget};
use cdk::cdk_database::WalletMemoryDatabase;
use cdk::nuts::{
CurrencyUnit, MeltQuoteState, MintBolt11Request, MintQuoteState, NotificationPayload,
PreMintSecrets, State,
};
use cdk::wallet::client::{HttpClient, HttpClientMethods};
use cdk::wallet::Wallet;
use cdk_integration_tests::init_regtest::{
get_mint_url, get_mint_ws_url, init_cln_client, init_lnd_client,
};
Expand All @@ -22,7 +21,8 @@ use lightning_invoice::Bolt11Invoice;
use ln_regtest_rs::InvoiceStatus;
use serde_json::json;
use tokio::time::{sleep, timeout};
use tokio_tungstenite::{connect_async, tungstenite::protocol::Message};
use tokio_tungstenite::connect_async;
use tokio_tungstenite::tungstenite::protocol::Message;

async fn get_notification<T: StreamExt<Item = Result<Message, E>> + Unpin, E: Debug>(
reader: &mut T,
Expand Down
8 changes: 3 additions & 5 deletions crates/cdk-mintd/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ use bip39::Mnemonic;
use cdk::cdk_database::{self, MintDatabase};
use cdk::cdk_lightning;
use cdk::cdk_lightning::MintLightning;
use cdk::mint::{MeltQuote, Mint};
use cdk::mint::{MintBuilder, MintMeltLimits};
use cdk::mint::{MeltQuote, Mint, MintBuilder, MintMeltLimits};
use cdk::nuts::{ContactInfo, CurrencyUnit, MeltQuoteState, MintVersion, PaymentMethod};
use cdk::types::LnKey;
use cdk_mintd::cli::CLIArgs;
use cdk_mintd::config::{self, DatabaseEngine, LnBackend};
use cdk_mintd::setup::LnBackendSetup;
use cdk_redb::MintRedbDatabase;
use cdk_sqlite::MintSqliteDatabase;
Expand All @@ -28,9 +29,6 @@ use tracing_subscriber::EnvFilter;
#[cfg(feature = "swagger")]
use utoipa::OpenApi;

use cdk_mintd::cli::CLIArgs;
use cdk_mintd::config::{self, DatabaseEngine, LnBackend};

const CARGO_PKG_VERSION: Option<&'static str> = option_env!("CARGO_PKG_VERSION");
const DEFAULT_QUOTE_TTL_SECS: u64 = 1800;
const DEFAULT_CACHE_TTL_SECS: u64 = 1800;
Expand Down
18 changes: 8 additions & 10 deletions crates/cdk-mintd/src/setup.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
use std::{
collections::{HashMap, HashSet},
sync::Arc,
};
use std::collections::{HashMap, HashSet};
use std::sync::Arc;

use anyhow::{anyhow, bail};
use axum::{async_trait, Router};
use cdk::cdk_lightning::MintLightning;
use cdk::mint::FeeReserve;
use cdk::mint_url::MintUrl;
use cdk::nuts::CurrencyUnit;
use rand::Rng;

use cdk::{cdk_lightning::MintLightning, mint::FeeReserve, mint_url::MintUrl, nuts::CurrencyUnit};
use tokio::sync::Mutex;
use url::Url;

use crate::{
config::{self, Settings},
expand_path,
};
use crate::config::{self, Settings};
use crate::expand_path;

#[async_trait]
pub trait LnBackendSetup {
Expand Down
4 changes: 3 additions & 1 deletion crates/cdk/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
use serde_json::Value;
use thiserror::Error;

use crate::nuts::Id;
use crate::util::hex;
#[cfg(feature = "wallet")]
use crate::wallet::multi_mint_wallet::WalletKey;
use crate::{nuts::Id, util::hex, Amount};
use crate::Amount;

/// CDK Error
#[derive(Debug, Error)]
Expand Down
Loading

0 comments on commit 21b4950

Please sign in to comment.