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

43
debug_latest_5.js Normal file
View File

@@ -0,0 +1,43 @@
const { Client } = require('pg');
const { Connection, PublicKey } = require('@solana/web3.js');
async function debugLatest() {
const client = new Client({ connectionString: process.env.DATABASE_URL });
await client.connect();
const res = await client.query(`
SELECT id, source_ref_id, amount, currency, metadata, status, created_at
FROM transactions
ORDER BY created_at DESC LIMIT 5
`);
console.log("=== LAST 5 TRANSACTIONS ===");
for (const tx of res.rows) {
console.log(`\n--- TX: ${tx.id} ---`);
console.log(`Status: ${tx.status} | Amount: ${tx.amount} ${tx.currency} | Created: ${tx.created_at}`);
const wallets = tx.metadata?.wallets || {};
const solWallet = wallets['SOLANA'];
if (solWallet) {
console.log(`Checking SOL Address: ${solWallet.address}`);
try {
const connection = new Connection('https://api.devnet.solana.com', 'confirmed');
const pubKey = new PublicKey(solWallet.address);
const balance = await connection.getBalance(pubKey);
console.log(`Devnet Balance: ${balance / 1e9} SOL`);
const connectionMain = new Connection('https://api.mainnet-beta.solana.com', 'confirmed');
const balanceMain = await connectionMain.getBalance(pubKey);
console.log(`Mainnet Balance: ${balanceMain / 1e9} SOL`);
} catch(e) {
console.log("Error fetching balance:", e.message);
}
}
}
await client.end();
}
debugLatest().catch(console.error);