Pack prints 18-decimal sums next to raw event sums so reports say 25.47 POL instead of raw units

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-16 11:24:23 -06:00
parent ea2a82f703
commit 5f1a8239f5
+4 -2
View File
@@ -60,8 +60,10 @@ def build(E):
w('## Events emitted by the contract (%s logs in the window)' % ev.get('total'))
for t in ev.get('by_topic', []): w('- %s %s: %d' % (t['topic'][:10], t['name'] or '', t['count']))
for nm, d in (E.get('decoded_events') or {}).items():
w('- Decoded %s: %d events; sums of number fields (raw integer units; for 18-decimal coins divide by 10^18): %s; top addresses per field: %s; first samples: %s' % (
nm, d['count'], json.dumps(d['uint_field_sums_raw']), json.dumps(d['top_addresses']), json.dumps(d['first_samples'])))
# also print big sums already divided by 10^18 (2 decimals) so the model never has to convert and the fact gate can match
as18 = {k: round(int(v) / 1e18, 2) for k, v in (d['uint_field_sums_raw'] or {}).items() if isinstance(v, (int, str)) and str(v).isdigit() and int(v) >= 10 ** 12}
w('- Decoded %s: %d events; sums of number fields (raw integer units): %s; the same sums as 18-decimal amounts (%s or an 18-decimal token, 2 decimals): %s; top addresses per field: %s; first samples: %s' % (
nm, d['count'], json.dumps(d['uint_field_sums_raw']), E['native'], json.dumps(as18), json.dumps(d['top_addresses']), json.dumps(d['first_samples'])))
cn = E.get('counts') or {}
w('\n## Precomputed counts (use these, do not recount)')
w('- Upgraded events total: %s' % cn.get('upgrade_events_total'))