feat(p2p): OKX-level security upgrade with Edge Functions

- Add process-withdraw Edge Function for blockchain withdrawals
- Update verify-deposit Edge Function with @pezkuwi/api
- Add withdrawal limits (daily/monthly) and fee system
- Add hot wallet configuration with production address
- Add admin roles for dispute resolution
- Add COMBINED SQL migration with full P2P system
- Encrypt payment details with AES-256-GCM
- Prevent TX hash reuse with UNIQUE constraint
This commit is contained in:
2026-01-29 03:12:02 +03:00
parent 6c922bcf34
commit f23eee2fb9
9 changed files with 3539 additions and 337 deletions
+20 -3
View File
@@ -31,9 +31,9 @@ import {
import { usePezkuwi } from '@/contexts/PezkuwiContext';
import { useWallet } from '@/contexts/WalletContext';
import { toast } from 'sonner';
import { supabase } from '@/lib/supabase';
import {
getPlatformWalletAddress,
verifyDeposit,
type CryptoToken
} from '@shared/lib/p2p-fiat';
@@ -165,14 +165,31 @@ export function DepositModal({ isOpen, onClose, onSuccess }: DepositModalProps)
setVerifying(true);
try {
const success = await verifyDeposit(txHash, token, depositAmount);
// Call the Edge Function for secure deposit verification
// This verifies the transaction on-chain before crediting balance
const { data, error } = await supabase.functions.invoke('verify-deposit', {
body: {
txHash,
token,
expectedAmount: depositAmount
}
});
if (success) {
if (error) {
throw new Error(error.message || 'Verification failed');
}
if (data?.success) {
toast.success(`Deposit verified! ${data.amount} ${token} added to your balance.`);
setStep('success');
onSuccess?.();
} else {
throw new Error(data?.error || 'Verification failed');
}
} catch (error) {
console.error('Verify deposit error:', error);
const message = error instanceof Error ? error.message : 'Verification failed';
toast.error(message);
} finally {
setVerifying(false);
}