handleSliderMouseDown('address')}
onMouseUp={() => handleSliderMouseUp('address')}
onMouseLeave={() => handleSliderMouseUp('address')}
onTouchEnd={() => handleSliderMouseUp('address')}
diff --git a/src/components/wallet/WalletHeader.tsx b/src/components/wallet/WalletHeader.tsx
index 3813377..cfd5b0f 100644
--- a/src/components/wallet/WalletHeader.tsx
+++ b/src/components/wallet/WalletHeader.tsx
@@ -1,7 +1,5 @@
import { useState, useEffect } from 'react';
-import { nip19 } from 'nostr-tools';
import { Zap, Coins, Copy, Check, QrCode, Link } from 'lucide-react';
-import { Button } from '@/components/ui/button';
import { exchangeRateService } from '@/lib/exchangeRateService';
import { useToast } from '@/hooks/useToast';
import { LoginIcon } from '@/components/auth/LoginIcon';
diff --git a/src/contexts/CashuContext.tsx b/src/contexts/CashuContext.tsx
index 1143a51..4442a68 100644
--- a/src/contexts/CashuContext.tsx
+++ b/src/contexts/CashuContext.tsx
@@ -13,11 +13,11 @@ export function CashuProvider({ children }: { children: ReactNode }) {
);
}
-export function useCashu(): UseCashuReturn {
+export function useCashuContext(): UseCashuReturn {
const context = useContext(CashuContext);
if (!context) {
- throw new Error('useCashu must be used within a CashuProvider');
+ throw new Error('useCashuContext must be used within a CashuProvider');
}
return context;
diff --git a/src/hooks/cashu/useCashu.ts b/src/hooks/cashu/useCashu.ts
index 51bd2aa..e9a147f 100644
--- a/src/hooks/cashu/useCashu.ts
+++ b/src/hooks/cashu/useCashu.ts
@@ -4,6 +4,7 @@ import * as bip39 from '@scure/bip39';
import { wordlist } from '@scure/bip39/wordlists/english.js';
import { initializeCoco, ConsoleLogger, getEncodedToken, type Repositories } from 'coco-cashu-core';
import { IndexedDbRepositories } from 'coco-cashu-indexeddb';
+import type { Mint } from 'coco-cashu-core';
// Types from coco-cashu-core
type CocoManager = Awaited>;
@@ -71,7 +72,7 @@ export function useCashu(): UseCashuReturn {
try {
const mintList = await coco.mint.getAllMints();
- setMints(mintList.map((m: any) => ({
+ setMints(mintList.map((m: Mint) => ({
url: m.mintUrl,
name: m.name,
info: m.mintInfo
@@ -197,7 +198,7 @@ export function useCashu(): UseCashuReturn {
const newBalances = await coco.wallet.getBalances();
setBalances(newBalances);
} catch (err) {
- // Silent failure - errors are handled by the manager
+ console.log('Failed to refresh balances:', err);
}
};
diff --git a/src/hooks/cashu/useHistoryManager.ts b/src/hooks/cashu/useHistoryManager.ts
index cce5cac..94a1070 100644
--- a/src/hooks/cashu/useHistoryManager.ts
+++ b/src/hooks/cashu/useHistoryManager.ts
@@ -1,8 +1,8 @@
import { useState, useCallback, useEffect } from 'react';
-import type { HistoryEntry } from 'coco-cashu-core';
+import type { HistoryEntry, Manager } from 'coco-cashu-core';
interface UseHistoryManagerProps {
- coco: any; // Coco instance
+ coco: Manager | null;
isInitialized: boolean;
}
diff --git a/src/hooks/cashu/useMintManager.ts b/src/hooks/cashu/useMintManager.ts
index 188e385..c371eec 100644
--- a/src/hooks/cashu/useMintManager.ts
+++ b/src/hooks/cashu/useMintManager.ts
@@ -1,5 +1,7 @@
import { useState, useCallback, useEffect } from 'react';
import { getCleanMintLabel } from './walletUtils';
+import type { Manager, Repositories } from 'coco-cashu-core';
+import { toast } from '@/hooks/useToast';
export interface CashuMint {
url: string;
@@ -7,13 +9,12 @@ export interface CashuMint {
}
interface UseMintManagerProps {
- coco: any; // Coco instance
+ coco: Manager | null;
mints: CashuMint[];
- repositories: any; // Repositories instance
+ repositories: Repositories | null;
isNpubCashLoggedIn: boolean;
setNpubCashMint: (mintUrl: string) => Promise;
refreshMints: () => Promise;
- toast: any; // Toast function
}
export function useMintManager({
@@ -23,7 +24,6 @@ export function useMintManager({
isNpubCashLoggedIn,
setNpubCashMint,
refreshMints,
- toast,
}: UseMintManagerProps) {
const [activeMintUrl, setActiveMintUrl] = useState(null);
const [mintDropdownOpen, setMintDropdownOpen] = useState(false);
diff --git a/src/hooks/cashu/useWalletTransactions.ts b/src/hooks/cashu/useWalletTransactions.ts
index ee375ec..5d7b0b9 100644
--- a/src/hooks/cashu/useWalletTransactions.ts
+++ b/src/hooks/cashu/useWalletTransactions.ts
@@ -1,15 +1,15 @@
import { useState, useCallback, useRef, useEffect } from 'react';
import { isUnknownMintError, extractMintUrlFromError } from './walletUtils';
import { decodeBolt11Amount, isValidBolt11Invoice } from '@/lib/bolt11Decoder';
+import type { Manager } from 'coco-cashu-core';
+import type { Token } from '@cashu/cashu-ts';
+import { useToast } from '@/hooks/useToast';
interface UseWalletTransactionsProps {
- coco: any; // Coco instance
+ coco: Manager | null;
activeMintUrl: string | null;
- isNpubCashLoggedIn: boolean;
- repositories: any; // Repositories instance
generateQRCode: (text: string) => Promise;
- toast: any; // Toast function
- getEncodedToken: (token: any) => string;
+ getEncodedToken: (token: Token | string) => string;
getLightningInvoice: (params: {
lightningAddress: string;
amountSats: number;
@@ -19,13 +19,11 @@ interface UseWalletTransactionsProps {
export function useWalletTransactions({
coco,
activeMintUrl,
- isNpubCashLoggedIn,
- repositories,
generateQRCode,
- toast,
getEncodedToken,
getLightningInvoice,
}: UseWalletTransactionsProps) {
+ const { toast } = useToast();
// Receive state
const [tokenInput, setTokenInput] = useState('');
const [quoteAmount, setQuoteAmount] = useState('');
diff --git a/src/hooks/cashu/walletUtils.ts b/src/hooks/cashu/walletUtils.ts
index cb8ab90..186c573 100644
--- a/src/hooks/cashu/walletUtils.ts
+++ b/src/hooks/cashu/walletUtils.ts
@@ -10,14 +10,15 @@ export const getCleanMintLabel = (mint: { name?: string; url: string }): string
};
export const isUnknownMintError = (err: unknown): boolean => {
- const errorMessage = (err as any)?.message || err?.toString() || '';
- return (err as any)?.constructor?.name === 'UnknownMintError' ||
+ const errorMessage = err instanceof Error ? err.message : String(err);
+ const errorName = err instanceof Error ? err.constructor.name : '';
+ return errorName === 'UnknownMintError' ||
errorMessage.includes('UnknownMintError') ||
(errorMessage.includes('Mint') && errorMessage.includes('is not known'));
};
export const extractMintUrlFromError = (err: unknown): string | null => {
- const errorMessage = (err as any)?.message || err?.toString() || '';
+ const errorMessage = err instanceof Error ? err.message : String(err);
const mintUrlMatch = errorMessage.match(/Mint (https?:\/\/[^\s]+)/);
return mintUrlMatch?.[1] || null;
};
diff --git a/src/hooks/useNpubCash.ts b/src/hooks/useNpubCash.ts
index 7b00993..ad96a01 100644
--- a/src/hooks/useNpubCash.ts
+++ b/src/hooks/useNpubCash.ts
@@ -1,7 +1,10 @@
-import { useCallback, useState, useMemo, useEffect, useRef } from 'react';
+import { useCallback, useState, useMemo, useRef } from 'react';
import { useNIP98 } from './useNIP98';
import { NPCClient, JWTAuthProvider } from 'npubcash-sdk';
-import type { User, Quote } from 'npubcash-types';
+import type { Quote } from 'npubcash-types';
+import type { Manager } from 'coco-cashu-core';
+import type { EventTemplate, Event } from 'nostr-tools';
+import { useToast } from './useToast';
const NPUBCASH_BASE_URL = 'https://npubx.cash';
@@ -17,6 +20,7 @@ export interface NpubCashUserInfo {
*/
export function useNpubCash() {
const { createAuthHeader, signer, isLoggedIn, pubkey } = useNIP98();
+ const { toast } = useToast();
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState(null);
@@ -27,7 +31,7 @@ export function useNpubCash() {
const npcClient = useMemo(() => {
if (!isLoggedIn || !signer) return null;
// Adapt NostrSigner to JWTAuthProvider's expected SigningFunc signature
- const signingFunc = async (eventTemplate: any) => {
+ const signingFunc = async (eventTemplate: EventTemplate): Promise => {
return await signer.signEvent(eventTemplate);
};
const auth = new JWTAuthProvider(NPUBCASH_BASE_URL, signingFunc);
@@ -105,7 +109,7 @@ export function useNpubCash() {
return npcClient.subscribe(onUpdate, onError);
}, [npcClient]);
- const refreshQuotes = useCallback(async (coco: any, toast: any): Promise => {
+ const refreshQuotes = useCallback(async (coco: Manager): Promise => {
if (!npcClient || !coco) return;
try {
@@ -176,12 +180,12 @@ export function useNpubCash() {
description: err instanceof Error ? err.message : 'Failed to refresh quotes',
});
}
- }, [npcClient, getAllQuotes]);
+ }, [npcClient, getAllQuotes, toast]);
const clearError = useCallback(() => setError(null), []);
// Subscribe to quote updates and sync to wallet automatically
- const syncQuotesWithWallet = useCallback(async (coco: any, toast: any): Promise<() => void> => {
+ const syncQuotesWithWallet = useCallback(async (coco: Manager): Promise<() => void> => {
if (!npcClient || !coco) return () => {};
try {
@@ -291,7 +295,7 @@ export function useNpubCash() {
});
return () => {};
}
- }, [npcClient, getAllQuotes, getQuotesSince, subscribeToQuotes]);
+ }, [npcClient, getAllQuotes, getQuotesSince, subscribeToQuotes, toast]);
return {
// Core methods
diff --git a/src/main.tsx b/src/main.tsx
index 6bce006..12f0d27 100644
--- a/src/main.tsx
+++ b/src/main.tsx
@@ -7,8 +7,8 @@ import { ErrorBoundary } from '@/components/ErrorBoundary';
import App from './App.tsx';
import './index.css';
-// FIXME: a custom font should be used. Eg:
-// import '@fontsource-variable/';
+// TODO: Add custom font from @fontsource-variable
+// Example: import '@fontsource-variable/';
createRoot(document.getElementById("root")!).render(
diff --git a/src/pages/Index.tsx b/src/pages/Index.tsx
index 4427de5..2b75063 100644
--- a/src/pages/Index.tsx
+++ b/src/pages/Index.tsx
@@ -1,6 +1,6 @@
import { useSeoMeta } from '@unhead/react';
-// FIXME: Update this page (the content is just a fallback if you fail to update the page)
+// TODO: Customize this index page with specific content
const Index = () => {
useSeoMeta({