mirror of
https://gitlab.com/soapbox-pub/mkstack.git
synced 2026-12-05 08:23:35 +00:00
set mint with npubxcash
This commit is contained in:
1 parent
5dc19e857f
commit
346ba70710
4 files changed
+173
-614
No files matched your search
@@ -2,6 +2,7 @@ import { useState, useEffect, useCallback, useRef } from 'react';
|
||||
import { useCashu, type HistoryEntry } from '@/hooks/useCashu';
|
||||
import { useCashuMints } from '@/hooks/cashu/useCashuMints';
|
||||
import { useLightningAddress } from '@/hooks/useLightningAddress';
|
||||
import { useNpubCash } from '@/hooks/useNpubCash';
|
||||
import { useToast } from '@/hooks/useToast';
|
||||
import { useQRCode } from '@/hooks/useQRCode';
|
||||
import { useCopyToClipboard } from '@/hooks/useCopyToClipboard';
|
||||
@@ -13,6 +14,7 @@ import { SendCard } from '@/components/wallet/SendCard';
|
||||
import { TransactionHistory } from '@/components/wallet/TransactionHistory';
|
||||
import { ProofBreakdownModal } from '@/components/wallet/ProofBreakdownModal';
|
||||
import { RemoveMintModal } from '@/components/wallet/RemoveMintModal';
|
||||
import { LoginArea } from '@/components/auth/LoginArea';
|
||||
|
||||
export function CashuWallet() {
|
||||
// ============================================================================
|
||||
@@ -44,7 +46,7 @@ export function CashuWallet() {
|
||||
|
||||
const { getCleanMintLabel } = useCashuMints(null);
|
||||
|
||||
|
||||
const { setMint: setNpubCashMint, isLoggedIn: isNpubCashLoggedIn } = useNpubCash();
|
||||
|
||||
const { getInvoice: getLightningInvoice, isLoading: isResolvingAddress } = useLightningAddress();
|
||||
|
||||
@@ -146,7 +148,24 @@ export function CashuWallet() {
|
||||
const handleSetActiveMint = useCallback(async (mintUrl: string | null) => {
|
||||
// Set the active mint locally
|
||||
setActiveMintUrl(mintUrl);
|
||||
}, []);
|
||||
|
||||
// If user is logged in to npub.cash and a mint is selected, sync it
|
||||
if (isNpubCashLoggedIn && mintUrl) {
|
||||
console.log('🔄 Syncing active mint with npub.cash:', mintUrl);
|
||||
const success = await setNpubCashMint(mintUrl);
|
||||
|
||||
if (success) {
|
||||
toast({
|
||||
title: "Mint Synced",
|
||||
description: "Your preferred mint has been updated on npub.cash",
|
||||
});
|
||||
} else {
|
||||
// Don't show error toast - the hook already logs errors
|
||||
// Just log that sync failed but local mint is still set
|
||||
console.warn('⚠️ Failed to sync mint with npub.cash, but local mint is still set');
|
||||
}
|
||||
}
|
||||
}, [isNpubCashLoggedIn, setNpubCashMint, toast]);
|
||||
|
||||
// ============================================================================
|
||||
// HELPER FUNCTIONS - History
|
||||
@@ -619,6 +638,12 @@ export function CashuWallet() {
|
||||
<LoadingModal isLoading={isLoading || !isInitialized} />
|
||||
<div className="max-w-4xl mx-auto py-1 px-3 sm:px-4 relative">
|
||||
|
||||
{/* ========================================================================
|
||||
SECTION: Login Area
|
||||
======================================================================== */}
|
||||
<div className="absolute top-1 right-3 sm:right-4 z-10">
|
||||
<LoginArea />
|
||||
</div>
|
||||
|
||||
{/* ========================================================================
|
||||
SECTION: Balance Display
|
||||
|
||||
Reference in new issue
Block a user