#!/usr/bin/env node // Замер: сколько времени кран зачисляет SOL на цепь (и почему фронт видит 0). const B = "https://smart-updown.binom.pw/api"; const RPC = "https://smart-updown.binom.pw/solana-rpc/"; const WebSocket = require(process.env.WS_MODULE || "ws"); const j = async (p, init) => { const r = await fetch(B + p, init); return { s: r.status, d: await r.json().catch(() => null) }; }; const rpcBal = async (a) => { const r = await fetch(RPC, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "getBalance", params: [a] }), }); return (await r.json()).result.value; }; (async () => { const w = await j("/wallet", { method: "POST" }); const addr = w.d.address; console.log("адрес:", addr); const t0 = Date.now(); const f = await j(`/faucet/${addr}`); console.log(`кран ответил: ${f.s} sol=${f.d.sol} (t=${Date.now() - t0}ms)`); console.log("\nвремя_от_крана RPC_баланс шлюз_sol"); for (const wait of [0, 250, 500, 1000, 2000, 4000, 8000, 16000, 30000]) { while (Date.now() - t0 < wait) await new Promise((r) => setTimeout(r, 50)); const chain = await rpcBal(addr); const gw = await j(`/balance/${addr}`); console.log(`${String(Date.now() - t0).padStart(9)}ms ${String(chain).padStart(14)} ${String(gw.d && gw.d.sol).padStart(12)}`); if (chain > 0 && Date.now() - t0 > 3000) break; } process.exit(0); })();