fix(admin): resolve incorrect crypto balance calculation fallback displaying fiat amount
This commit is contained in:
27
testPending.ts
Normal file
27
testPending.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { Client } from 'pg';
|
||||
import { Connection, PublicKey } from '@solana/web3.js';
|
||||
|
||||
async function checkAllPending() {
|
||||
const client = new Client({ connectionString: process.env.DATABASE_URL });
|
||||
await client.connect();
|
||||
|
||||
const res = await client.query("SELECT * FROM transactions WHERE status = 'pending'");
|
||||
console.log(`Found ${res.rows.length} pending transactions`);
|
||||
|
||||
const connection = new Connection('https://api.devnet.solana.com', 'confirmed');
|
||||
|
||||
for (const tx of res.rows) {
|
||||
const wallets = tx.metadata?.wallets || {};
|
||||
const solWallet = wallets['SOLANA'];
|
||||
if (solWallet && solWallet.address) {
|
||||
try {
|
||||
const b = await connection.getBalance(new PublicKey(solWallet.address));
|
||||
console.log(`TX ${tx.id} | Amount: ${tx.amount} TRY | Address: ${solWallet.address} | SOL Balance: ${b / 1e9}`);
|
||||
} catch(e) {
|
||||
console.log(`Error on TX ${tx.id}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
await client.end();
|
||||
}
|
||||
checkAllPending().catch(console.error);
|
||||
Reference in New Issue
Block a user