Soroban event reference doc - #157
Conversation
…hema and indexer utilities
|
@githoboman Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Miracle656
left a comment
There was a problem hiding this comment.
The docs/event-reference.md doc itself is excellent — clear field-source tables, the KNOWN_EVENT_TYPES set, per-event topic/value shapes, and worked XDR examples. I'd merge the doc happily on its own.
The problem is PR hygiene: this branch is stacked on #155 and #156, so its diff also carries the tombstone and LP-share code — both of which I've just requested changes on (#156: mint/burn over-capture every token as an LP share; #155: tombstone detection is never wired into the indexer). Because those are bundled in here, #157 can't merge until they're resolved.
Two paths:
- Preferred: rebase this branch so it contains only
docs/event-reference.mdon top ofmain, and let #155/#156 land (reworked) independently. Then #157 is a trivial docs merge. - Or fold everything into the reworked #155/#156 and close this as the doc rides along.
One content note for whichever way you go: your own doc quotes KNOWN_EVENT_TYPES = {"transfer","mint","burn","clawback"} — which is exactly why keying LP-shares off bare mint/burn in #156 over-captures. Once the LP-share and tombstone paths are finalized, it'd be great to add their event shapes to this reference too.
Rebase down to just the doc and I'll merge it right away.
Miracle656#155 and Miracle656#156 have landed, so every code file this branch carried from that stack now exists on main in a later form. Took main's version of db.ts, indexer.ts, lp-shares.ts, tombstones.ts, schema.prisma and both test files, and dropped the two superseded June migrations. What remains is docs/event-reference.md plus the .gitignore change that makes it visible: docs/ was ignored wholesale, which is why every doc in this repo had to be force-added. Replaced that with a targeted ignore for docs/openapi.json, which is generated by npm run docs:openapi alongside the tracked root copy. Verified the doc against the code rather than reading it: KNOWN_EVENT_TYPES matches decoder.ts:7 exactly, and every base64 ScVal in the worked examples decodes to the value the doc claims — topic0 'transfer', the two G-addresses, and 1000000000 stroops. tsc clean; full suite 382 passed.
Miracle656
left a comment
There was a problem hiding this comment.
Approved and merging — I rebased this to doc-only myself (8cbe9d8) now that #155 and #156 have landed, since the wave has closed.
I verified the document against the code rather than reading it, which is the only review a reference doc deserves:
KNOWN_EVENT_TYPESin the doc matchessrc/decoder.ts:7exactly —transfer,mint,burn,clawback.- Every base64
ScValin the worked examples decodes to precisely what the doc claims. I ran them:
topic0: transfer
addr1 : GDWCO35QUYQLGO6P7OLW4BZWNMMGGUWNPLRVPLCBVG7YNVDZKUDIW4KN
addr2 : GCXOO7OIJZ2HEOZODLOEISNVO6CBPK4PISRJCZYRFT37H7XGHDLB3C7O
value : 1000000000
Identical to the "Decoded" block, down to the 100.0000000 stroop annotation. Using the same XDR as the test fixtures is the detail that makes this doc trustworthy over time — a reference with hand-written examples drifts silently the first time a decoder changes, and nobody notices because docs have no CI. These are the strings the decoder tests already assert on, so they cannot rot without a test going red.
Documenting that unrecognised topics[0] symbols are silently skipped is also worth having written down. That is exactly the behaviour someone hits when their event does not appear in the index, and there is no log line to lead them to it.
The .gitignore change is quietly the most useful line in the PR. docs/ was ignored wholesale, which is why every document in this repo — DUAL_NETWORK.md, backup-restore.md — had to be force-added, and why anyone writing a new one would find git add silently doing nothing. I kept the removal and replaced it with a targeted ignore for docs/openapi.json, which npm run docs:openapi generates alongside the tracked root copy.
On the rebase: this branch was the top of the #155 → #156 → #157 stack and carried both of their code changes. All of it now exists on main in a later form (network-scoped schema, gated LP dialect, wired tombstone detector), so I took main's version of db.ts, indexer.ts, lp-shares.ts, tombstones.ts, schema.prisma and both test files, and dropped the two superseded June migrations. What is left is the document and the .gitignore line — which is what the PR was always about.
Verified: tsc --noEmit clean, full suite 382 passed.
That is the whole stack merged. Thanks for all four.
The two deleted files were not an editorial decision. typedoc.json set "out": "docs", and TypeDoc empties its output directory before generating, so running it locally wiped docs/cookbook/ and the deletions were picked up as part of the diff. That is a live bug on main, and it just got worse: Miracle656#157 removed docs/ from .gitignore, so the next person to run npx typedoc would have deleted DUAL_NETWORK.md, backup-restore.md, event-reference.md and the cookbook, and git would have staged all of it. - typedoc.json: out -> docs/api, so generated and hand-written docs no longer share a directory. Kept this PR's name, entryPointStrategy and navigationLinks additions. - Restored docs/cookbook/portfolio.md and dashboard-preview.jpg from main. - Restored the npm run docs:openapi step the workflow rewrite dropped. Without it the published site keeps a stale OpenAPI spec, and nothing else reads that file so nothing would have flagged it. - .gitignore ignores docs/openapi.json and docs/api/ specifically, rather than docs/ wholesale — the generated artefacts, not the guides. Kept from this PR: npm ci without the || npm install fallback (a lockfile desync should fail rather than silently resolve differently), peaceiris/actions-gh-pages@v4, and keep_files. Verified by running npx typedoc: output lands in docs/api and every hand-written doc is still there afterwards.
* ci(docs): auto-publish TypeDoc API reference to gh-pages - Add typedoc.json with entryPoints covering public modules - Add .github/workflows/typedoc.yml to run on every main push - Push generated HTML output to gh-pages via peaceiris/actions-gh-pages - Add README link to hosted docs URL Closes #62 * Point TypeDoc at docs/api instead of docs, and restore what it deleted The two deleted files were not an editorial decision. typedoc.json set "out": "docs", and TypeDoc empties its output directory before generating, so running it locally wiped docs/cookbook/ and the deletions were picked up as part of the diff. That is a live bug on main, and it just got worse: #157 removed docs/ from .gitignore, so the next person to run npx typedoc would have deleted DUAL_NETWORK.md, backup-restore.md, event-reference.md and the cookbook, and git would have staged all of it. - typedoc.json: out -> docs/api, so generated and hand-written docs no longer share a directory. Kept this PR's name, entryPointStrategy and navigationLinks additions. - Restored docs/cookbook/portfolio.md and dashboard-preview.jpg from main. - Restored the npm run docs:openapi step the workflow rewrite dropped. Without it the published site keeps a stale OpenAPI spec, and nothing else reads that file so nothing would have flagged it. - .gitignore ignores docs/openapi.json and docs/api/ specifically, rather than docs/ wholesale — the generated artefacts, not the guides. Kept from this PR: npm ci without the || npm install fallback (a lockfile desync should fail rather than silently resolve differently), peaceiris/actions-gh-pages@v4, and keep_files. Verified by running npx typedoc: output lands in docs/api and every hand-written doc is still there afterwards. --------- Co-authored-by: Miracle656 <iupacnumen2020@gmail.com>
Summary
Closes #144
Created docs/event-reference.md — a reference of every event the indexer recognizes, grounded in the actual code rather than the task title.
What it documents, one section per event, each with a real worked example:
transfer — from/to/amount (from topics[1], topics[2], value)
mint — to/amount; from is null, admin in topics[1] is intentionally ignored
burn — from/amount; to is null
clawback — same shape as burn
Each section has: the topic/value shape table, how the fields map into a TransferRecord, the base64 XDR (taken verbatim from the test fixtures), and the decoded form. The example XDR and decoded values are verified — I ran them through @stellar/stellar-sdk's scValToNative/Address to confirm the exact addresses and amounts, then removed the temp script.
One correction worth flagging: the task title lists transfer, mint, burn, approve, but the indexer actually recognizes transfer, mint, burn, clawback (src/decoder.ts:7 — KNOWN_EVENT_TYPES). There is no approve handling anywhere. I documented the four real events and added a dedicated "A note on approve" section explaining why it's not indexed (it sets an allowance, not a balance movement; its value is a struct, not an i128) and what it would take to add it.
Gitignore change: per your choice, I removed the docs/ line from .gitignore so the doc is trackable. Side effect: the existing docs/cookbook/ directory is now also no longer ignored — worth a glance before you commit if it contains anything you'd rather keep untracked.
Want me to commit these changes (on this Soroban-event-reference-doc branch), or open a PR?