address testing errors

This commit is contained in:
lemonknowsall committed 2025-10-20 22:58:42 -07:00
1 parent 460a4777ee
commit 61fc4957e0
15 files changed
+45 -88

No files matched your search

+11 -7
View File
@@ -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<string | null>(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<Event> => {
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<void> => {
const refreshQuotes = useCallback(async (coco: Manager): Promise<void> => {
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