Skip to content

[#10] Inline Indexer — Storylines#50

Merged
realproject7 merged 1 commit intomainfrom
task/10-inline-indexer-storylines
Mar 13, 2026
Merged

[#10] Inline Indexer — Storylines#50
realproject7 merged 1 commit intomainfrom
task/10-inline-indexer-storylines

Conversation

@realproject7
Copy link
Copy Markdown
Owner

Summary

  • P1-5a: src/app/api/index/storyline/route.ts — POST endpoint for storyline indexing:
    1. Fetch transaction receipt
    2. Find StorylineCreated event by topic0 signature (not address)
    3. Decode event args (storylineId, writer, tokenAddress, title, hasDeadline)
    4. Get block timestamp via getBlock()
    5. Detect writer type via ERC-8004 (best-effort)
    6. Upsert to Supabase with (tx_hash, log_index) deduplication
  • P1-5b: lib/contracts/erc8004.ts — ERC-8004 agent detection helper:
    • detectWriterType(address) queries agentIdByWallet() on the registry
    • Returns 1 (agent) if agentId > 0, else 0 (human)
    • Best-effort: defaults to 0 on any error

Fixes #10

Test plan

  • tsc --noEmit passes
  • vitest run — 22/22 passing (existing tests unaffected)
  • Integration test on Base Sepolia with a real createStoryline transaction
  • Verify ERC-8004 lookup works against the registry at 0x8004...432

🤖 Generated with Claude Code

Implement POST /api/index/storyline — fetches tx receipt, decodes
StorylineCreated event by topic0 signature, gets block timestamp,
queries ERC-8004 registry to detect agent wallets (best-effort,
defaults to human), and upserts to Supabase with deduplication.
Add ERC-8004 helper module for agentWallet reverse lookup.

Fixes #10

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 #10 with a focused storyline indexer route and a minimal ERC-8004 lookup helper. The event parsing, timestamp lookup, best-effort writer type detection, and Supabase upsert behavior align with the ticket requirements, and CI passed.

Findings

  • None.

Decision

Approve because the implementation stays within scope, follows the established inline indexer pattern, and I did not find a blocking correctness or schema issue in the added logic.

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.

T2b Review: APPROVE

Storyline indexer — Follows PR #49 pattern exactly: txHash regex validation, receipt fetch, StorylineCreated decode via topic0 matching, block timestamp, Supabase upsert with onConflict: "tx_hash,log_index".

ERC-8004 helperagentIdByWallet reverse lookup against the registry. Best-effort with correct fallback to 0 (human) on failure. BigInt comparison is correct.

Security — Input validation present, no secrets, server-side Supabase client with service role key from env.

Scope — Matches issue #10 exactly (P1-5a + P1-5b). No scope creep.

No issues found.

@realproject7 realproject7 merged commit 4f5aad0 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-5] Inline Indexer — Storylines

2 participants