Skip to content

Commit

Permalink
Merge branch 'main' into ok300-consolidate-workspace-metadata
Browse files Browse the repository at this point in the history
# Conflicts:
#	crates/cdk-cln/Cargo.toml
#	crates/cdk-integration-tests/Cargo.toml
  • Loading branch information
ok300 committed Oct 3, 2024
2 parents 7340f03 + c0967d8 commit 15fffcd
Show file tree
Hide file tree
Showing 89 changed files with 7,209 additions and 4,109 deletions.
59 changes: 58 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ jobs:
-p cdk-phoenixd,
-p cdk-strike,
-p cdk-lnbits,
-p cdk-integration-tests,
-p cdk-fake-wallet,
--bin cdk-cli,
--bin cdk-mintd
Expand All @@ -75,6 +74,64 @@ jobs:
- name: Test
run: nix develop -i -L .#stable --command cargo test ${{ matrix.build-args }}

itest:
name: "Integration regtest tests"
runs-on: ubuntu-latest
strategy:
matrix:
build-args:
[
-p cdk-integration-tests,
]
database:
[
REDB,
SQLITE,
MEMORY
]
steps:
- name: checkout
uses: actions/checkout@v4
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v11
- name: Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@v6
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Clippy
run: nix develop -i -L .#stable --command cargo clippy ${{ matrix.build-args }} -- -D warnings
- name: Test
run: nix develop -i -L .#stable --command just itest ${{ matrix.database }}

fake-wallet-itest:
name: "Integration fake wallet tests"
runs-on: ubuntu-latest
strategy:
matrix:
build-args:
[
-p cdk-integration-tests,
]
database:
[
REDB,
SQLITE,
MEMORY
]
steps:
- name: checkout
uses: actions/checkout@v4
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v11
- name: Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@v6
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Clippy
run: nix develop -i -L .#stable --command cargo clippy ${{ matrix.build-args }} -- -D warnings
- name: Test fake mint
run: nix develop -i -L .#stable --command just fake-mint-itest ${{ matrix.database }}

msrv-build:
name: "MSRV build"
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
25 changes: 24 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,26 @@
### Removed
-->
#[Unreleased]
### Changed
- cdk: Bump `bitcoin` to `0.32.2` ([prusnak]).
- cdk: Bump `lightning-invoice` to `0.32.2` ([prusnak]).
- cdk: Bump `lightning` to `0.0.124` ([prusnak]).
- cdk: `PaymentMethod` as a `non_exhaustive` enum ([thesimplekid]).
- cdk: `CurrencyUnit` as a `non_exhaustive` enum ([thesimpekid]).

### Added
- cdk: Added description to `MintQuoteBolt11Request` ([lollerfirst]).
- cdk(wallet): Added description to `mint_quote` ([lollerfirst]).
- cdk: Add `amount` and `fee_paid` to `Melted` ([davidcaseria]).
- cdk: Add `from_proofs` on `Melted` ([davidcaseria]).
- cdk: Add unit on `PaymentResponse` ([thesimplekid]).

### Removed
- cdk: Remove `MintMeltSettings` since it is no longer used ([lollerfirst]).
- cdk: `PaymentMethod::Custom` ([thesimplekid]).



#[0.4.0]
### Summary
Expand Down Expand Up @@ -151,4 +171,7 @@ Additionally, this release introduces a Mint binary cdk-mintd that uses the cdk-
[vnprc]: https://github.com/vnprc
[cjbeery24]: https://github.com/cjbeery24
[callebtc]: https://github.com/callebtc
[ok300]: (https://github.com/ok300)
[ok300]: https://github.com/ok300
[lollerfirst]: https://github.com/lollerfirst
[prusnak]: https://github.com/prusnak

1 change: 1 addition & 0 deletions bindings/cdk-js/src/nuts/nut00/currency_unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ impl From<CurrencyUnit> for JsCurrencyUnit {
CurrencyUnit::Msat => JsCurrencyUnit::Msat,
CurrencyUnit::Usd => JsCurrencyUnit::Usd,
CurrencyUnit::Eur => JsCurrencyUnit::Eur,
_ => panic!("Unsupported unit"),
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions bindings/cdk-js/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,14 @@ impl JsWallet {
}

#[wasm_bindgen(js_name = mintQuote)]
pub async fn mint_quote(&mut self, amount: u64) -> Result<JsMintQuote> {
pub async fn mint_quote(
&mut self,
amount: u64,
description: Option<String>,
) -> Result<JsMintQuote> {
let quote = self
.inner
.mint_quote(amount.into())
.mint_quote(amount.into(), description)
.await
.map_err(into_err)?;

Expand Down
1 change: 0 additions & 1 deletion crates/cdk-axum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@ async-trait = "0.1"
axum = "0.6.20"
cdk = { path = "../cdk", default-features = false, features = ["mint"] }
tokio = { version = "1", default-features = false }
tower-http = { version = "0.4.4", features = ["cors"] }
tracing = { version = "0.1", default-features = false, features = ["attributes", "log"] }
futures = { version = "0.3.28", default-features = false }
39 changes: 2 additions & 37 deletions crates/cdk-axum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,19 @@
#![warn(missing_docs)]
#![warn(rustdoc::bare_urls)]

use std::collections::HashMap;
use std::str::FromStr;
use std::sync::Arc;

use anyhow::Result;
use axum::routing::{get, post};
use axum::Router;
use cdk::cdk_lightning::{self, MintLightning};
use cdk::mint::Mint;
use cdk::mint_url::MintUrl;
use cdk::nuts::{CurrencyUnit, PaymentMethod};
use router_handlers::*;

mod router_handlers;

/// Create mint [`Router`] with required endpoints for cashu mint
pub async fn create_mint_router(
mint_url: &str,
mint: Arc<Mint>,
ln: HashMap<LnKey, Arc<dyn MintLightning<Err = cdk_lightning::Error> + Send + Sync>>,
quote_ttl: u64,
) -> Result<Router> {
let state = MintState {
ln,
mint,
mint_url: MintUrl::from_str(mint_url)?,
quote_ttl,
};
pub async fn create_mint_router(mint: Arc<Mint>) -> Result<Router> {
let state = MintState { mint };

let v1_router = Router::new()
.route("/keys", get(get_keys))
Expand Down Expand Up @@ -61,25 +46,5 @@ pub async fn create_mint_router(
/// CDK Mint State
#[derive(Clone)]
pub struct MintState {
ln: HashMap<LnKey, Arc<dyn MintLightning<Err = cdk_lightning::Error> + Send + Sync>>,
mint: Arc<Mint>,
mint_url: MintUrl,
quote_ttl: u64,
}

/// Key used in hashmap of ln backends to identify what unit and payment method
/// it is for
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub struct LnKey {
/// Unit of Payment backend
pub unit: CurrencyUnit,
/// Method of payment backend
pub method: PaymentMethod,
}

impl LnKey {
/// Create new [`LnKey`]
pub fn new(unit: CurrencyUnit, method: PaymentMethod) -> Self {
Self { unit, method }
}
}
Loading

0 comments on commit 15fffcd

Please sign in to comment.