// 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 '' + h.slice(0, 10) + '...' + h.slice(-6) + ''; }) .replace(/0x[0-9a-fA-F]{40}(?![0-9a-fA-F])/g, function (a) { return '' + a.slice(0, 6) + '...' + a.slice(-4) + ''; }); } function steps(v) { return '
' + (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') + '' + v.steps.map(function (s) { return '
' + esc(s.name) + (s.state === 'skipped' ? ' (skipped)' : '') + '
' + (s.note ? '
' + esc(s.note) + '
' : '') + '
'; }).join('') + (v.error ? '
' + esc(v.error) + '
' : '') + '
'; } 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 '' + esc(c[1]) + ' (' + c[2] + ')
' + n + '' + (s.why ? '
' + link(s.why, ex) + (s.tag ? ' ' + esc(s.tag) + '' : '') + '
' : ''); }).join(''); var flags = (g.flags || []).map(function (f) { return '
' + esc(f.tag) + '' + link(f.text, ex) + ' (' + esc(f.source) + ')
'; }).join(''); var finds = (r.top_findings || []).map(function (f) { return '
' + esc(f.tag) + '' + link(f.text, ex) + '
'; }).join(''); return '
Scorecard0 = safest, 10 = worst · weight in brackets
' + '
' + rows + '
' + '' + OPINION + (g.overall != null ? ' Weighted total ' + g.overall + ' of 100.' : '') + '' + (r.verdict ? '
Our verdict (opinion): ' + link(r.verdict, ex) + '
' : '') + (flags ? '
Critical flags' + flags + '
' : '') + '
Top findings (public facts)' + finds + '
'; } function factsBlock(v, ex) { return '
Facts read straight from the chain' + (v.facts || []).map(function (f) { return '
' + esc(f.tag) + '' + link(f.text, ex) + (f.source ? ' source' : '') + '
'; }).join('') + '
'; } function deepSections(r, ex) { var out = ''; var sec = function (t, body) { if (body) out += '
' + esc(t) + '' + body + '
'; }; var tagOf = function (o) { return o && o.tag ? ' ' + esc(o.tag) + '' : ''; }; 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', '

' + link(r.plain_summary, ex) + '

'); if (r.drain_capability) { var d = r.drain_capability; sec('Can one wallet move the money or change the rules?', typeof d === 'string' ? '

' + str(d) + '

' : '

' + str(d.answer) + tagOf(d) + '

' + (d.who ? '

Who: ' + str(d.who) + '

' : '') + (d.how ? '

How: ' + str(d.how) + '

' : '') + (d.evidence ? '

Evidence: ' + str(d.evidence) + '

' : '')); } if (Array.isArray(r.exit_paths_ranked) && r.exit_paths_ranked.length) sec('Every exit path, ranked', '
' + r.exit_paths_ranked.map(function (x, i) { return ''; }).join('') + '
#PathWhoPossible nowHappenedTag
' + (i + 1) + '' + str(x.path) + '' + str(x.who) + '' + str(x.possible_now) + '' + str(x.happened) + '' + esc(x.tag) + '
'); if (r.money) { var m = r.money; sec('The money trail', (m.summary ? '

' + str(m.summary) + '

' : '') + ['balances_now', 'total_in', 'total_out'].map(function (k) { return m[k] ? '
' + k.replace(/_/g, ' ') + '' + str(m[k]) + '
' : ''; }).join('') + (Array.isArray(m.where_out_went) && m.where_out_went.length ? '
' + m.where_out_went.map(function (x) { return ''; }).join('') + '
WalletAmountNoteTag
' + str(x.address) + '' + str(x.amount) + '' + str(x.note) + '' + esc(x.tag) + '
' : '')); } if (Array.isArray(r.insiders) && r.insiders.length) sec('Operator and deployment-set wallets', '
' + r.insiders.map(function (x) { return ''; }).join('') + '
WalletRoleReceivedOwnsTag
' + str(x.address) + '' + str(x.role) + '' + str(x.received) + '' + str(x.owns) + '' + esc(x.tag) + '
'); if (r.refund_or_promise_math) sec('The promise math', '

' + str(r.refund_or_promise_math) + '

'); if (r.approvals) sec('Wallet approvals at risk', '

' + str(r.approvals) + '

'); if (Array.isArray(r.unknowns) && r.unknowns.length) sec('What the evidence cannot answer', ''); 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 ? '' + esc(WWI.short(v.address)) + '' : null, v.chainRead ? 'read ' + esc(v.chainRead.time) + ' · block ' + Number(v.chainRead.block).toLocaleString('en-US') : null].filter(Boolean).join(' · '); var head = '
' + (v.kind === 'deep' ? 'Deep report' : 'Free check') + '' + '

' + esc(title) + (v.chainName ? ' on ' + esc(v.chainName) + '' : '') + '

' + '' + meta + '
' + (g.grade ? '
' + esc(g.grade) + '
' + (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.
' : '') + '
'; var main = ''; if (v.report) main += scorecard(v, ex); else main += '
' + esc((v.factcheck && v.factcheck.note) || 'No written report for this check.') + '
'; main += factsBlock(v, ex); if (v.pickedNote) main += '
Contract: ' + link(v.pickedNote, ex) + '
'; if (v.chainRead && v.chainRead.window) main += '
Range read: 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.' : '') + '
'; var side = '
' + (v.hasShot ? 'Screenshot of the project website taken by our own browser' : '[No website screenshot for this check]') + '
' + '
Website claims vs code' + (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.') + '' + (v.website ? '' + esc(v.website) + '' : '') + '
'; if (v.kind === 'free') side += '
In the deep reportEvery exit path ranked · the full money trail with named wallets · the operator wallet ring · the promise math worked out · wallet approvals at risk · the upgrade timeline with transaction links · what the evidence cannot answer
'; side += '
Check details' + (v.timings ? '
Time taken' + Math.round(v.timings.total_s) + ' s
' : '') + (v.factcheck ? '
Fact check' + (v.factcheck.passed ? 'passed' : 'not passed') + '
' : '') + 'Permanent link to this check' + (v.address ? 'The evidence pack the report was written from' : '') + '
'; var deep = v.kind === 'deep' && v.report ? '
' + deepSections(v.report, ex) + '' + OPINION + '
' : ''; return head + '
' + main + '
' + side + '
' + deep; } function draw(el, v) { el.innerHTML = v.status === 'done' ? done(v) : steps(v); } return { draw: draw, OPINION: OPINION, link: link }; })();