From dbf0e04a0f96061e6af6d79d20b42a7fa33c60ae Mon Sep 17 00:00:00 2001 From: ngutech21 Date: Fri, 16 Feb 2024 08:29:14 +0100 Subject: [PATCH] fix: nut6 does not exist in mint-info --- .../src/fixtures/nutshell_mint_info.json | 23 ++++++++++++++++ moksha-core/src/primitives.rs | 26 ++++++++----------- moksha-mint/src/server.rs | 5 ++-- 3 files changed, 36 insertions(+), 18 deletions(-) create mode 100644 moksha-core/src/fixtures/nutshell_mint_info.json diff --git a/moksha-core/src/fixtures/nutshell_mint_info.json b/moksha-core/src/fixtures/nutshell_mint_info.json new file mode 100644 index 00000000..2dd356fc --- /dev/null +++ b/moksha-core/src/fixtures/nutshell_mint_info.json @@ -0,0 +1,23 @@ +{ + "name": "My Cashu mint", + "pubkey": "03a2118b421e6b47f0656b97bb7eeea43c41096adbc0d0e511ff70de7d94dbd990", + "version": "Nutshell/0.15.0", + "description": "The short mint description", + "description_long": "A long mint description that can be a long piece of text.", + "contact": [ + ["email", "contact@me.com"], + ["twitter", "@me"], + ["nostr", "npub..."] + ], + "motd": "Message to users", + "nuts": { + "4": { "methods": [["bolt11", "sat"]], "disabled": false }, + "5": { "methods": [["bolt11", "sat"]], "disabled": false }, + "7": { "supported": true }, + "8": { "supported": true }, + "9": { "supported": true }, + "10": { "supported": true }, + "11": { "supported": true }, + "12": { "supported": true } + } +} diff --git a/moksha-core/src/primitives.rs b/moksha-core/src/primitives.rs index c5593aab..b0bfe7a0 100644 --- a/moksha-core/src/primitives.rs +++ b/moksha-core/src/primitives.rs @@ -402,10 +402,6 @@ pub struct Nuts { #[serde(rename = "5")] pub nut5: Nut5, - /// Mint info - #[serde(rename = "6")] - pub nut6: Nut6, - /// Token state check #[serde(rename = "7")] pub nut7: Nut7, @@ -468,17 +464,6 @@ impl Default for Nut5 { } } -#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq, ToSchema)] -pub struct Nut6 { - pub supported: bool, -} - -impl Default for Nut6 { - fn default() -> Self { - Self { supported: true } - } -} - #[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq, Default, ToSchema)] pub struct Nut7 { pub supported: bool, @@ -571,6 +556,7 @@ mod tests { use crate::{ dhke::public_key_from_hex, + fixture::read_fixture, primitives::{ KeyResponse, MintInfoResponse, MintLegacyInfoResponse, Nuts, Parameter, PostSwapResponse, @@ -654,4 +640,14 @@ mod tests { Ok(()) } + + #[test] + fn test_deserialize_nustash_mint_info() -> anyhow::Result<()> { + let mint_info = read_fixture("nutshell_mint_info.json")?; + let info = serde_json::from_str::(&mint_info); + assert!(info.is_ok()); + let info = info?; + assert_eq!("Nutshell/0.15.0", info.version.unwrap()); + Ok(()) + } } diff --git a/moksha-mint/src/server.rs b/moksha-mint/src/server.rs index deed5dd7..f98d3d70 100644 --- a/moksha-mint/src/server.rs +++ b/moksha-mint/src/server.rs @@ -28,8 +28,8 @@ use moksha_core::blind::BlindedMessage; use moksha_core::blind::BlindedSignature; use moksha_core::primitives::{ CurrencyUnit, GetMeltOnchainResponse, KeyResponse, KeysResponse, MintInfoResponse, - MintLegacyInfoResponse, Nut10, Nut11, Nut12, Nut14, Nut15, Nut4, Nut5, Nut6, Nut7, Nut8, Nut9, - Nuts, PaymentMethod, PostMeltBolt11Request, PostMeltBolt11Response, PostMeltQuoteBolt11Request, + MintLegacyInfoResponse, Nut10, Nut11, Nut12, Nut14, Nut15, Nut4, Nut5, Nut7, Nut8, Nut9, Nuts, + PaymentMethod, PostMeltBolt11Request, PostMeltBolt11Response, PostMeltQuoteBolt11Request, PostMeltQuoteBolt11Response, PostMeltQuoteOnchainRequest, PostMeltQuoteOnchainResponse, PostMintBolt11Request, PostMintBolt11Response, PostMintQuoteBolt11Request, PostMintQuoteBolt11Response, PostMintQuoteOnchainRequest, PostMintQuoteOnchainResponse, @@ -134,7 +134,6 @@ pub async fn run_server(mint: Mint) -> anyhow::Result<()> { Nuts, Nut4, Nut5, - Nut6, Nut7, Nut8, Nut9,