Campaigns: gold available-to-spend banner + where-your-ads-run (incl. Network Ad Space); Wallet: live POL balances; Earn credits: done-for-today mark
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -868,7 +868,12 @@ const server = http.createServer(async (req, res) => {
|
||||
try { main.credits = await ads.availableCredits(mainId); } catch (e) {}
|
||||
try { main.buyerCount = (await chain.member(mainId)).buyerCount; } catch (e) {}
|
||||
}
|
||||
return json(res, 200, { main, positions: out, totalCredits: main.credits + out.reduce((n, r) => n + r.credits, 0) });
|
||||
// live POL balances (the link signature proved the wallet is theirs) + a POL/USD rate from the catalog
|
||||
const bal = async a => { try { return BigInt(await chain.rpc('eth_getBalance', [a, 'latest'])).toString(); } catch (e) { return null; } };
|
||||
if (main.address) main.balanceWei = await bal(main.address);
|
||||
for (const row of out) row.balanceWei = await bal(row.address);
|
||||
let polUsd = 0; try { const cat = await chain.catalog(); const pk = cat.find(x => x.costWei); if (pk) polUsd = (pk.priceCents / 100) / (Number(BigInt(pk.costWei)) / 1e18); } catch (e) {}
|
||||
return json(res, 200, { main, positions: out, polUsd, totalCredits: main.credits + out.reduce((n, r) => n + r.credits, 0) });
|
||||
}
|
||||
if (p === '/api/my/positions/remove' && req.method === 'POST') {
|
||||
const s = await auth.fromRequest(req);
|
||||
|
||||
Reference in New Issue
Block a user