Skip to content

[#11] Inline Indexer — Donations#51

Merged
realproject7 merged 1 commit intomainfrom
task/11-inline-indexer-donations
Mar 13, 2026
Merged

[#11] Inline Indexer — Donations#51
realproject7 merged 1 commit intomainfrom
task/11-inline-indexer-donations

Conversation

@realproject7
Copy link
Copy Markdown
Owner

Summary

  • P1-6a: src/app/api/index/donation/route.ts — POST endpoint for donation indexing:
    1. Validate txHash (regex)
    2. Fetch transaction receipt
    3. Find Donation event by topic0 signature
    4. Decode event args (storylineId, donor, amount)
    5. Get block timestamp via getBlock()
    6. Upsert to Supabase with (tx_hash, log_index) deduplication
    • Amount stored as wei string to avoid BigInt precision loss

Fixes #11

Test plan

  • tsc --noEmit passes
  • vitest run — 22/22 passing
  • Integration test on Base Sepolia with a real donate transaction

🤖 Generated with Claude Code

Implement POST /api/index/donation — fetches tx receipt, decodes
Donation event by topic0 signature, gets block timestamp, and upserts
to Supabase donations table with (tx_hash, log_index) deduplication.
Amount stored as wei string to avoid precision loss.

Fixes #11

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE

Summary

The PR matches issue #11 with a focused donation indexer route that follows the same receipt decode, timestamp lookup, and deduplicating upsert pattern as the earlier indexers. Storing the donation amount as a wei string is the right choice for preserving precision, and CI passed.

Findings

  • None.

Decision

Approve because the implementation stays within scope, is consistent with the established indexing pattern, and I did not find a blocking correctness or schema issue in the added route.

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

APPROVE

Clean, faithful application of the established indexer pattern. Findings:

  • Pattern consistency: Identical structure to plot/storyline indexers — txHash regex, receipt fetch, topic0 match, decodeEventLog, block timestamp, Supabase upsert with (tx_hash, log_index) dedup. No deviations.
  • Event decode: Correctly destructures storylineId, donor, amount matching the Donation ABI definition. Topic0 generation uses standalone donationEvent; decode uses full storyFactoryAbi — consistent with prior PRs.
  • Amount handling: amount.toString() stores wei as string — correct approach for uint256 values that can exceed Number.MAX_SAFE_INTEGER.
  • Input validation: txHash regex present and identical to other indexers. No secrets in client code.
  • Schema: Row typed against Database["public"]["Tables"]["donations"]["Insert"]; tsc --noEmit passes, so schema alignment is compiler-verified.
  • Scope: Single file, 105 lines, exactly matches issue #11 (P1-6a).

Minor observation (non-blocking): logIndex! non-null assertion (line 93) is inherited from both prior indexers. Safe in practice but if ever cleaned up, should be done across all three indexers together.

No issues. Ready for merge.

@realproject7 realproject7 merged commit 13bc627 into main Mar 13, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P1-6] Inline Indexer — Donations

2 participants