From 863b9c02fae4c4e6ae48e08aeb99038d93774e5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josip=20Boj=C4=8Di=C4=87?= Date: Mon, 16 Feb 2026 14:24:16 +0100 Subject: [PATCH 1/2] Fix bug with mint url validation --- .../settings/accounts/add-mint-form.tsx | 56 +++++++++++++++++-- 1 file changed, 50 insertions(+), 6 deletions(-) diff --git a/app/features/settings/accounts/add-mint-form.tsx b/app/features/settings/accounts/add-mint-form.tsx index abcdfaf2..9c321a2a 100644 --- a/app/features/settings/accounts/add-mint-form.tsx +++ b/app/features/settings/accounts/add-mint-form.tsx @@ -1,3 +1,4 @@ +import type { MintKeyset } from '@cashu/cashu-ts'; import { type QueryClient, useQueryClient } from '@tanstack/react-query'; import { Controller, useForm } from 'react-hook-form'; import { useLocation, useNavigate } from 'react-router'; @@ -19,7 +20,11 @@ import { } from '~/features/shared/cashu'; import { useUser } from '~/features/user/user-hooks'; import { useToast } from '~/hooks/use-toast'; -import { getCashuProtocolUnit, getMintPurpose } from '~/lib/cashu'; +import { + type MintInfo, + getCashuProtocolUnit, + getMintPurpose, +} from '~/lib/cashu'; import type { Currency } from '~/lib/money'; import { LinkWithViewTransition } from '~/lib/transitions'; @@ -34,17 +39,56 @@ const currencies = [ { value: 'USD', label: 'USD' }, ]; +type GetMintInfoAndKeysetsResult = + | { + success: true; + data: { + mintInfo: MintInfo; + keysets: MintKeyset[]; + }; + } + | { + success: false; + error: string; + }; + +const getMintInfoAndKeysets = async ( + mintUrl: string, + queryClient: QueryClient, +): Promise => { + try { + const [mintInfo, allKeysets] = await Promise.all([ + queryClient.fetchQuery(mintInfoQueryOptions(mintUrl)), + queryClient.fetchQuery(allMintKeysetsQueryOptions(mintUrl)), + ]); + return { success: true, data: { mintInfo, keysets: allKeysets.keysets } }; + } catch (error) { + console.debug('Failed to validate mint', { cause: error }); + return { + success: false, + error: + 'Mint not found or temporarily unavailable. Make sure the URL is correct or try again later.', + }; + } +}; + const validateMint = async ( value: string, formValues: FormValues, queryClient: QueryClient, ): Promise => { const unit = getCashuProtocolUnit(formValues.currency); - const [mintInfo, keysets] = await Promise.all([ - queryClient.fetchQuery(mintInfoQueryOptions(value)), - queryClient.fetchQuery(allMintKeysetsQueryOptions(value)), - ]); - return cashuMintValidator(value, unit, mintInfo, keysets.keysets); + const result = await getMintInfoAndKeysets(value, queryClient); + if (!result.success) { + return result.error; + } + + return cashuMintValidator( + value, + unit, + result.data.mintInfo, + result.data.keysets, + ); }; export function AddMintForm() { From 1dd24d62c5d47e35f3ac80b028e2ba4b863460e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josip=20Boj=C4=8Di=C4=87?= Date: Tue, 17 Feb 2026 00:47:13 +0100 Subject: [PATCH 2/2] Bun lock change --- bun.lock | 1 + 1 file changed, 1 insertion(+) diff --git a/bun.lock b/bun.lock index a08aaff2..b5ebcbd4 100644 --- a/bun.lock +++ b/bun.lock @@ -1,5 +1,6 @@ { "lockfileVersion": 1, + "configVersion": 0, "workspaces": { "": { "name": "agicash",