Files

24 lines
2.9 KiB
JavaScript

// Contract proof page (trust pack 2026-11-14): live facts from /api/contract (read from Polygon, cached 5 minutes on the server).
(async function () {
VBB.renderNav('/contract'); VBB.renderFooter();
const el = document.getElementById('facts'); const esc = VBB.esc;
let d; try { d = await VBB.getJSON('/api/contract'); } catch (e) { d = {}; }
const ex = d.explorer || 'https://polygonscan.com';
const addr = (a, note) => a ? '<a class="mono" href="' + esc(ex) + '/address/' + esc(a) + '" target="_blank" rel="noopener">' + esc(VBB.short(a)) + '</a>' + (note ? '<br><span class="muted small">' + note + '</span>' : '') : '<span class="muted">not read yet</span>';
const pol = w => { try { const v = BigInt(w || 0); return (Number(v / 10n ** 14n) / 1e4).toFixed(4) + ' POL'; } catch (e) { return '0 POL'; } };
if (!d.address) { el.innerHTML = '<tr><td class="muted">The contract address is not set on this copy of the site.</td></tr>'; return; }
const rows = [
['Contract', addr(d.address, 'VBBShop on ' + (d.chainId === 137 ? 'Polygon' : 'chain ' + d.chainId))],
['Source code', 'Verified on <a href="' + esc(d.verified && d.verified.sourcifyUrl || '#') + '" target="_blank" rel="noopener">Sourcify</a> (exact match). Polygonscan: ' + (d.verified && d.verified.polygonscan === 'done' ? '<a href="' + esc(ex) + '/address/' + esc(d.address) + '#code" target="_blank" rel="noopener">verified</a>' : 'pending')],
['Owner', addr(d.owner, 'A Tangem hardware wallet. It can pause new sales, set package prices, and change the keeper and the prize wallet. It cannot move anyone\'s money or change the split.')],
['Prize wallet', addr(d.prizeWallet, 'Receives the 10% prize share of each purchase and pays the weekly leaderboard winners.')],
['Company', addr(d.company, 'Viral Banner Blitz. Fixed in the contract when it was deployed.')],
['Keeper', addr(d.keeper, 'The site\'s signing key. It only signs which sponsor a buyer has, once, on their first purchase.')],
['Sales', d.live ? (d.paused ? '<b>Paused</b>' : 'Open') + ' · ' + VBB.n(d.orderCount) + ' purchases so far' : '<span class="muted">' + esc(d.error || 'not read yet') + '</span>'],
['Held by the contract', d.live ? pol(d.balanceWei) + (BigInt(d.totalOwedWei || 0) > 0n ? ' (all of it owed to wallets whose payment bounced, waiting for them to claim)' : ' (nothing is kept: every purchase is paid out in the same transaction)') : '<span class="muted">not read yet</span>']
];
const psn = document.getElementById('psnote');
if (psn) psn.textContent = d.verified && d.verified.polygonscan === 'done' ? 'Its source code is verified on Polygonscan (Contract tab) and on Sourcify (exact match).' : 'Its source code is verified on Sourcify (exact match); the Polygonscan verification check is pending, so use the Sourcify link to read the source.';
el.innerHTML = '<tbody>' + rows.map(r => '<tr><th style="width:30%">' + r[0] + '</th><td>' + r[1] + '</td></tr>').join('') + '</tbody>';
})();