Files
webworthit/public/assets/render.js
T
martbost 6aeb1b2146 Rubric red flag 4 sharpened (Marty 2026-11-16): forced High only when earlier buyers are paid from later buyers' payments; sponsor commissions on a delivered product are disclosed and scored, not auto-flagged
Deterministic payout read (chain/payouts.py): every payout matched to the buyer of the same tx and classed operator /
referral line / earlier buyer outside the line. Earlier-buyer payouts = VERIFIED red flag 4. A model red flag 4 is
INFERRED, must cite evidence, and is not applied when the chain shows only operator and referral-line payouts
(shown on the report as 'Considered and not applied'). Same test for every contract.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 12:26:07 -06:00

115 lines
16 KiB
JavaScript

// Draws a check: progress steps while it runs, then the scorecard (free) or the full report (deep).
// Facts (tagged, linked) and opinion (scores, grade, verdict) are kept apart, with the opinion line under every scorecard and grade.
// No ad is ever drawn inside this output.
var Render = (function () {
'use strict';
var esc = WWI.esc;
var CATS = [['control', 'Control and upgradeability', 25], ['custody', 'Custody and exit paths', 25], ['economics', 'Economic design', 20], ['insiders', 'Insider flows', 15], ['disclosure', 'Disclosure vs code', 10], ['trajectory', 'Trajectory', 5]];
var OPINION = 'Scores and grade are our opinion, based on our published rubric applied to the public facts below.';
function link(text, ex) {
var s = esc(text);
if (!ex) return s;
return s.replace(/0x[0-9a-fA-F]{64}(?![0-9a-fA-F])/g, function (h) { return '<a class="src" href="' + ex + '/tx/' + h + '" target="_blank" rel="noopener nofollow">' + h.slice(0, 10) + '...' + h.slice(-6) + '</a>'; })
.replace(/0x[0-9a-fA-F]{40}(?![0-9a-fA-F])/g, function (a) { return '<a class="src" href="' + ex + '/address/' + a + '" target="_blank" rel="noopener nofollow">' + a.slice(0, 6) + '...' + a.slice(-4) + '</a>'; });
}
function steps(v) {
return '<div class="steps" aria-live="polite"><b class="disp">' + (v.status === 'queued' ? 'Waiting for a free worker' + (v.queuePos >= 0 ? ' (' + (v.queuePos + 1) + ' ahead)' : '') : v.status === 'running' ? 'Checking now' : v.status === 'failed' ? 'The check stopped' : 'Steps') + '</b>'
+ v.steps.map(function (s) { return '<div class="step ' + esc(s.state) + '"><span class="dot"></span><div><div>' + esc(s.name) + (s.state === 'skipped' ? ' (skipped)' : '') + '</div>' + (s.note ? '<div class="nt">' + esc(s.note) + '</div>' : '') + '</div></div>'; }).join('')
+ (v.error ? '<div class="notice">' + esc(v.error) + '</div>' : '') + '</div>';
}
function gradeCls(g) { return !g ? '' : /Low/.test(g) ? 'low' : /Moderate/.test(g) ? 'mod' : ''; }
function scorecard(v, ex) {
var r = v.report, g = v.grade || {};
var rows = CATS.map(function (c) {
var s = (r.scores || {})[c[0]] || {}; var n = Math.max(0, Math.min(10, Number(s.score) || 0));
return '<span>' + esc(c[1]) + ' <span style="color:var(--mut)">(' + c[2] + ')</span></span><div class="bar"><i class="' + (n >= 7 ? '' : n >= 4 ? 'mid' : 'lo') + '" style="width:' + n * 10 + '%"></i></div><span class="mono" style="font-weight:500">' + n + '</span>'
+ (s.why ? '<div class="why">' + link(s.why, ex) + (s.tag ? ' <span class="tag ' + esc(s.tag) + '">' + esc(s.tag) + '</span>' : '') + '</div>' : '');
}).join('');
var flags = (g.flags || []).map(function (f) { return '<div class="find"><span class="tag ' + esc(f.tag) + '">' + esc(f.tag) + '</span><span>' + link(f.text, ex) + ' <span style="color:var(--mut);font-size:13px">(' + esc(f.source) + ')</span></span></div>'; }).join('');
var finds = (r.top_findings || []).map(function (f) { return '<div class="find"><span class="tag ' + esc(f.tag) + '">' + esc(f.tag) + '</span><span>' + link(f.text, ex) + '</span></div>'; }).join('');
return '<div style="display:flex;justify-content:space-between;gap:12px;flex-wrap:wrap"><span class="disp" style="font-weight:700;font-size:20px">Scorecard</span><span style="font-size:13px;color:var(--mut)">0 = safest, 10 = worst &middot; weight in brackets</span></div>'
+ '<div class="scores">' + rows + '</div>'
+ '<span class="opinion">' + OPINION + (g.overall != null ? ' Weighted total ' + g.overall + ' of 100.' : '') + '</span>'
+ (r.verdict ? '<div><b>Our verdict (opinion):</b> ' + link(r.verdict, ex) + '</div>' : '')
+ (flags ? '<div class="finds"><span class="disp" style="font-weight:700;font-size:17px">Critical flags</span>' + flags + '</div>' : '')
+ ((g.not_applied || []).length ? '<div class="finds"><span class="disp" style="font-weight:700;font-size:15px">Considered and not applied</span>' + g.not_applied.map(function (f) { return '<div class="find"><span>' + esc(f.reason) + ' <span style="color:var(--mut);font-size:13px">(model suggested: ' + esc(f.text) + ')</span></span></div>'; }).join('') + '</div>' : '')
+ '<div class="finds"><span class="disp" style="font-weight:700;font-size:17px">Top findings (public facts)</span>' + finds + '</div>';
}
function factsBlock(v, ex) {
return '<div class="finds"><span class="disp" style="font-weight:700;font-size:17px">Facts read straight from the chain</span>'
+ (v.facts || []).map(function (f) { return '<div class="find"><span class="tag ' + esc(f.tag) + '">' + esc(f.tag) + '</span><span>' + link(f.text, ex) + (f.source ? ' <a class="src" style="font-size:13px" href="' + esc(f.source) + '" target="_blank" rel="noopener nofollow">source</a>' : '') + '</span></div>'; }).join('') + '</div>';
}
function deepSections(r, ex) {
var out = '';
var sec = function (t, body) { if (body) out += '<div class="card" style="gap:8px"><span class="disp" style="font-weight:700;font-size:19px">' + esc(t) + '</span>' + body + '</div>'; };
var tagOf = function (o) { return o && o.tag ? ' <span class="tag ' + esc(o.tag) + '">' + esc(o.tag) + '</span>' : ''; };
var str = function (x) { return typeof x === 'string' ? link(x, ex) : x == null ? '' : link(JSON.stringify(x), ex); };
if (r.plain_summary) sec('In plain words', '<p style="margin:0">' + link(r.plain_summary, ex) + '</p>');
if (r.drain_capability) { var d = r.drain_capability; sec('Can one wallet move the money or change the rules?', typeof d === 'string' ? '<p style="margin:0">' + str(d) + '</p>' : '<p style="margin:0">' + str(d.answer) + tagOf(d) + '</p>' + (d.who ? '<p style="margin:0"><b>Who:</b> ' + str(d.who) + '</p>' : '') + (d.how ? '<p style="margin:0"><b>How:</b> ' + str(d.how) + '</p>' : '') + (d.evidence ? '<p style="margin:0"><b>Evidence:</b> ' + str(d.evidence) + '</p>' : '')); }
if (Array.isArray(r.exit_paths_ranked) && r.exit_paths_ranked.length) sec('Every exit path, ranked', '<div class="tblwrap"><table class="t"><thead><tr><th>#</th><th>Path</th><th>Who</th><th>Possible now</th><th>Happened</th><th>Tag</th></tr></thead><tbody>' + r.exit_paths_ranked.map(function (x, i) { return '<tr><td>' + (i + 1) + '</td><td>' + str(x.path) + '</td><td>' + str(x.who) + '</td><td>' + str(x.possible_now) + '</td><td>' + str(x.happened) + '</td><td><span class="tag ' + esc(x.tag) + '">' + esc(x.tag) + '</span></td></tr>'; }).join('') + '</tbody></table></div>');
if (r.money) { var m = r.money; sec('The money trail', (m.summary ? '<p style="margin:0">' + str(m.summary) + '</p>' : '') + ['balances_now', 'total_in', 'total_out'].map(function (k) { return m[k] ? '<div class="kv"><span>' + k.replace(/_/g, ' ') + '</span><span>' + str(m[k]) + '</span></div>' : ''; }).join('') + (Array.isArray(m.where_out_went) && m.where_out_went.length ? '<div class="tblwrap"><table class="t"><thead><tr><th>Wallet</th><th>Amount</th><th>Note</th><th>Tag</th></tr></thead><tbody>' + m.where_out_went.map(function (x) { return '<tr><td>' + str(x.address) + '</td><td>' + str(x.amount) + '</td><td>' + str(x.note) + '</td><td><span class="tag ' + esc(x.tag) + '">' + esc(x.tag) + '</span></td></tr>'; }).join('') + '</tbody></table></div>' : '')); }
if (Array.isArray(r.insiders) && r.insiders.length) sec('Operator and deployment-set wallets', '<div class="tblwrap"><table class="t"><thead><tr><th>Wallet</th><th>Role</th><th>Received</th><th>Owns</th><th>Tag</th></tr></thead><tbody>' + r.insiders.map(function (x) { return '<tr><td>' + str(x.address) + '</td><td>' + str(x.role) + '</td><td>' + str(x.received) + '</td><td>' + str(x.owns) + '</td><td><span class="tag ' + esc(x.tag) + '">' + esc(x.tag) + '</span></td></tr>'; }).join('') + '</tbody></table></div>');
if (r.refund_or_promise_math) sec('The promise math', '<p style="margin:0">' + str(r.refund_or_promise_math) + '</p>');
if (r.approvals) sec('Wallet approvals at risk', '<p style="margin:0">' + str(r.approvals) + '</p>');
if (Array.isArray(r.unknowns) && r.unknowns.length) sec('What the evidence cannot answer', '<ul style="margin:0;padding-left:20px">' + r.unknowns.map(function (x) { return '<li>' + str(x) + '</li>'; }).join('') + '</ul>');
return out;
}
function done(v) {
var ex = v.chainRead && v.chainRead.explorer;
var g = v.grade || {};
var title = (v.label || (v.chainRead && v.chainRead.name) || (v.site && v.site.title) || (v.address ? WWI.short(v.address) : v.website) || 'Check');
var meta = [v.address ? '<a class="src" href="' + ex + '/address/' + esc(v.address) + '" target="_blank" rel="noopener nofollow">' + esc(WWI.short(v.address)) + '</a>' : null,
v.chainRead ? 'read ' + esc(v.chainRead.time) + ' &middot; block ' + Number(v.chainRead.block).toLocaleString('en-US') : null].filter(Boolean).join(' &middot; ');
var head = '<div class="res-head"><div style="display:flex;flex-direction:column;gap:6px"><span class="eyebrow">' + (v.kind === 'deep' ? 'Deep report' : 'Free check') + '</span>'
+ '<h2 class="sec">' + esc(title) + (v.chainName ? ' <span style="font-weight:500;color:var(--mut)">on ' + esc(v.chainName) + '</span>' : '') + '</h2>'
+ '<span class="mono" style="font-size:14px;color:var(--ink2)">' + meta + '</span></div>'
+ (g.grade ? '<div class="gradebox ' + gradeCls(g.grade) + '"><div class="g">' + esc(g.grade) + '</div><div class="n">' + (g.forced_by_flag ? 'One critical flag caps the grade at High, whatever the other scores. ' : '') + 'Our opinion, from the published rubric applied to the public facts.</div></div>' : '') + '</div>';
var main = '';
if (v.report) main += scorecard(v, ex);
else main += '<div class="notice">' + esc((v.factcheck && v.factcheck.note) || 'No written report for this check.') + '</div>';
main += factsBlock(v, ex);
if (v.pickedNote) main += '<div style="font-size:14px;color:var(--ink2)"><b>Contract:</b> ' + link(v.pickedNote, ex) + '</div>';
if (v.chainRead && v.chainRead.window) main += '<div style="font-size:14px;color:var(--ink2)"><b>Range read:</b> blocks ' + v.chainRead.window.from + ' to ' + v.chainRead.window.to + (v.chainRead.window.complete_history ? ', the complete history since deployment.' : ', a partial window (' + esc(v.chainRead.window.from_time_ct || '') + ' onward).') + ((v.chainRead.gaps || []).length ? ' Some ranges could not be read: see the facts marked UNKNOWN.' : '') + '</div>';
var side = '<div class="card" style="padding:0;overflow:hidden;gap:0"><div class="shot">' + (v.hasShot ? '<img alt="Screenshot of the project website taken by our own browser" src="/api/check/' + v.id + '/shot.jpg">' : '[No website screenshot for this check]') + '</div>'
+ '<div style="padding:16px 18px;display:flex;flex-direction:column;gap:6px;font-size:14px"><span style="font-weight:600">Website claims vs code</span><span style="color:var(--ink2)">' + (v.report && v.report.site_vs_code ? link(v.report.site_vs_code, ex) : v.website ? 'No comparison in this check.' : 'No website was entered.') + '</span>'
+ (v.website ? '<span class="src" style="font-size:13px">' + esc(v.website) + '</span>' : '') + '</div></div>';
if (v.kind === 'free') side += '<div class="card dk"><span class="disp" style="font-weight:700;font-size:18px">In the deep report</span><span class="b" style="font-size:14px">Every exit path ranked &middot; the full money trail with named wallets &middot; the operator wallet ring &middot; the promise math worked out &middot; wallet approvals at risk &middot; the upgrade timeline with transaction links &middot; what the evidence cannot answer</span><button class="btn org" type="button" data-deep="' + v.id + '">Get the deep report</button><span class="b" style="font-size:13px" data-deepmsg></span></div>';
side += '<div class="card" style="font-size:14px;gap:6px"><span style="font-weight:600">Check details</span>'
+ (v.timings ? '<div class="kv"><span>Time taken</span><span>' + Math.round(v.timings.total_s) + ' s</span></div>' : '')
+ (v.factcheck ? '<div class="kv"><span>Fact check</span><span>' + (v.factcheck.passed ? 'passed' : 'not passed') + '</span></div>' : '')
+ '<a href="/c/' + v.id + '">Permanent link to this check</a>' + (v.address ? '<a href="/api/check/' + v.id + '/evidence" target="_blank" rel="noopener">The evidence pack the report was written from</a>' : '') + '</div>';
var deep = v.kind === 'deep' && v.report ? '<div style="display:flex;flex-direction:column;gap:16px">' + deepSections(v.report, ex) + '<span class="opinion">' + OPINION + '</span></div>' : '';
return head + '<div class="res-body"><div class="res-main">' + main + '</div><div class="res-side">' + side + '</div></div>' + deep;
}
// not signed in: the server sent only the grade, the verdict, the first finding and counts of what is locked
function gated(v) {
var ex = v.explorer, g = v.grade || {}, L = v.locked || {};
var title = v.address ? WWI.short(v.address) : (v.website || 'Check');
var head = '<div class="res-head"><div style="display:flex;flex-direction:column;gap:6px"><span class="eyebrow">Free check</span>'
+ '<h2 class="sec">' + esc(title) + (v.chainName ? ' <span style="font-weight:500;color:var(--mut)">on ' + esc(v.chainName) + '</span>' : '') + '</h2>'
+ '<span class="mono" style="font-size:14px;color:var(--ink2)">' + (v.address && ex ? '<a class="src" href="' + ex + '/address/' + esc(v.address) + '" target="_blank" rel="noopener nofollow">' + esc(WWI.short(v.address)) + '</a>' : '') + (v.readAt ? ' &middot; read ' + esc(v.readAt.time) + ' &middot; block ' + Number(v.readAt.block).toLocaleString('en-US') : '') + '</span></div>'
+ (g.grade ? '<div class="gradebox ' + gradeCls(g.grade) + '"><div class="g">' + esc(g.grade) + '</div><div class="n">' + (g.forced_by_flag ? 'One critical flag caps the grade at High, whatever the other scores. ' : '') + 'Our opinion, from the published rubric applied to the public facts.</div></div>' : '') + '</div>';
var f = v.report && v.report.top_findings && v.report.top_findings[0];
var first = f ? '<div class="find"><span class="tag ' + esc(f.tag) + '">' + esc(f.tag) + '</span><span>' + link(f.text, ex) + '</span></div>'
: v.firstFact ? '<div class="find"><span class="tag ' + esc(v.firstFact.tag) + '">' + esc(v.firstFact.tag) + '</span><span>' + link(v.firstFact.text, ex) + (v.firstFact.source ? ' <a class="src" style="font-size:13px" href="' + esc(v.firstFact.source) + '" target="_blank" rel="noopener nofollow">source</a>' : '') + '</span></div>' : '';
var items = [];
if (L.scores) items.push(L.scores + ' category scores');
if (L.findings) items.push(L.findings + ' more finding' + (L.findings === 1 ? '' : 's'));
if (L.flags) items.push(L.flags + ' critical flag' + (L.flags === 1 ? '' : 's') + ' explained');
if (L.facts) items.push(L.facts + ' facts read straight from the chain, with sources');
if (L.screenshot) items.push('the website screenshot');
if (L.siteVsCode) items.push('website claims vs code');
var to = '/c/' + v.id;
var main = (v.report && v.report.verdict ? '<div><b>Our verdict (opinion):</b> ' + link(v.report.verdict, ex) + '</div>' : '')
+ (first ? '<div class="finds"><span class="disp" style="font-weight:700;font-size:17px">First finding (public fact)</span>' + first + '</div>' : '')
+ '<span class="opinion">' + OPINION.replace('below', 'in this report') + '</span>';
var lock = '<div class="card dk" style="gap:12px"><span class="disp" style="font-weight:700;font-size:20px">Join free to see the full report: one account across the network</span>'
+ (items.length ? '<span class="b">Still locked: ' + esc(items.join(', ')) + '.</span>' : '')
+ '<span class="b" style="font-size:14px">Joining is free and never asks you to connect a wallet. Members get 3 free checks a day.</span>'
+ '<div style="display:flex;gap:10px;flex-wrap:wrap"><a class="btn org" href="/join?to=' + encodeURIComponent(to) + '">Join free</a><a class="btn line" style="background:transparent;color:var(--on);border-color:var(--on3)" href="/sso/start?mode=go&amp;to=' + encodeURIComponent(to) + '">I am a member: sign in</a></div></div>';
return head + '<div class="res-body"><div class="res-main">' + main + '</div><div class="res-side">' + lock + '</div></div>';
}
function draw(el, v) { el.innerHTML = v.status === 'done' ? (v.gated ? gated(v) : done(v)) : steps(v); }
return { draw: draw, OPINION: OPINION, link: link };
})();