fix(admin): resolve incorrect crypto balance calculation fallback displaying fiat amount

This commit is contained in:
mstfyldz
2026-03-14 18:09:18 +03:00
parent 8800454b60
commit a0e787e03c
17 changed files with 525 additions and 22 deletions

39
testE2E_Solana.js Normal file
View File

@@ -0,0 +1,39 @@
// testE2E_Solana.js
import { Client } from 'pg';
import fetch from 'node-fetch';
async function testE2E() {
const client = new Client({ connectionString: process.env.DATABASE_URL });
await client.connect();
// 1. Get Merchant
let res = await client.query('SELECT * FROM merchants LIMIT 1');
let merchantId = res.rows[0]?.id;
// 2. Create Transaction
const createRes = await fetch('http://localhost:3000/api/create-payment-intent', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({ amount: 5, currency: 'TRY', merchant_id: merchantId })
});
const createData = await createRes.json();
console.log("Create Data ID:", createData.id);
const txId = createData.id;
const solAddress = createData.wallets.SOLANA;
console.log("Deposit Address:", solAddress);
// 3. Let's see how much it expects
// Assuming 5 TRY is ~0.001 SOL
console.log("Sending sweep request with NO FUNDS FIRST...");
const sweepRes = await fetch('http://localhost:3000/api/crypto-sweep', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({ txId, network: 'SOLANA', token: 'SOL' })
});
const sweepData = await sweepRes.json();
console.log("Sweep Data:", sweepData);
await client.end();
}
testE2E().catch(console.error);