feat: replace supabase auth with citizen/visa identity system for P2P

Replace all supabase.auth.getUser() calls with P2PIdentityContext that
resolves identity from on-chain citizen NFT or off-chain visa system.

- Add identityToUUID() in shared/lib/identity.ts (UUID v5 from citizen/visa number)
- Add P2PIdentityContext with citizen NFT detection and visa fallback
- Add p2p_visa migration for off-chain visa issuance
- Refactor p2p-fiat.ts: all functions now accept userId parameter
- Fix all P2P components to use useP2PIdentity() instead of useAuth()
- Update verify-deposit edge function: walletToUUID -> identityToUUID
- Add P2PLayout with identity gate (wallet/citizen/visa checks)
- Wrap all P2P routes with P2PLayout in App.tsx
This commit is contained in:
2026-02-23 19:54:57 +03:00
parent aa3a49f0f6
commit a80a2cfb07
25 changed files with 594 additions and 237 deletions
@@ -13,6 +13,7 @@ import {
Unlock
} from 'lucide-react';
import { getInternalBalances, type InternalBalance } from '@shared/lib/p2p-fiat';
import { useP2PIdentity } from '@/contexts/P2PIdentityContext';
interface InternalBalanceCardProps {
onDeposit?: () => void;
@@ -21,13 +22,15 @@ interface InternalBalanceCardProps {
export function InternalBalanceCard({ onDeposit, onWithdraw }: InternalBalanceCardProps) {
const { t } = useTranslation();
const { userId } = useP2PIdentity();
const [balances, setBalances] = useState<InternalBalance[]>([]);
const [isLoading, setIsLoading] = useState(true);
const [isRefreshing, setIsRefreshing] = useState(false);
const fetchBalances = async () => {
if (!userId) return;
try {
const data = await getInternalBalances();
const data = await getInternalBalances(userId);
setBalances(data);
} catch (error) {
console.error('Failed to fetch balances:', error);
@@ -39,7 +42,7 @@ export function InternalBalanceCard({ onDeposit, onWithdraw }: InternalBalanceCa
useEffect(() => {
fetchBalances();
}, []);
}, [userId]);
const handleRefresh = async () => {
setIsRefreshing(true);