Bug Description
Two related issues found during code review of PRs #45-#50:
1. StorylineCreated event ABI missing fields (lib/contracts/abi.ts)
The StorylineCreated event is missing openingCID and openingHash fields. Per proposal §4.1, createStoryline() emits these so the indexer can fetch and verify the genesis plot content.
Current:
export const storylineCreatedEvent = {
inputs: [
{ name: "storylineId", type: "uint256", indexed: true },
{ name: "writer", type: "address", indexed: true },
{ name: "tokenAddress", type: "address", indexed: false },
{ name: "title", type: "string", indexed: false },
{ name: "hasDeadline", type: "bool", indexed: false },
],
} as const;
Expected — add these two fields:
{ name: "openingCID", type: "string", indexed: false },
{ name: "openingHash", type: "bytes32", indexed: false },
2. Storyline indexer does not store genesis plot (src/app/api/index/storyline/route.ts)
The storyline indexer creates a storylines row with plot_count: 1 but never inserts a row into the plots table for the opening chapter (plot_index = 0). This means readers cannot see the genesis plot.
Fix: After creating the storyline record, the indexer must:
- Read
openingCID and openingHash from the decoded event (requires ABI fix above)
- Fetch content from IPFS via
https://<bucket>.s3.filebase.com/plotlink/<openingCID>
- Fall back to request body
content field if IPFS fetch fails
- Verify
keccak256(toHex(content)) === openingHash
- Insert into
plots table with plot_index: 0, storyline_id, writer_address, content, content_cid: openingCID, content_hash: openingHash
Reference the existing plot indexer (src/app/api/index/plot/route.ts) for the IPFS fetch + hash verify + Supabase upsert pattern.
3. createStoryline function ABI may also need openingCID and openingHash params
Check lib/contracts/abi.ts — if the createStoryline function ABI is also missing these input params, add them to match proposal §4.1.
Acceptance Criteria
Bug Description
Two related issues found during code review of PRs #45-#50:
1. StorylineCreated event ABI missing fields (
lib/contracts/abi.ts)The
StorylineCreatedevent is missingopeningCIDandopeningHashfields. Per proposal §4.1,createStoryline()emits these so the indexer can fetch and verify the genesis plot content.Current:
Expected — add these two fields:
2. Storyline indexer does not store genesis plot (
src/app/api/index/storyline/route.ts)The storyline indexer creates a
storylinesrow withplot_count: 1but never inserts a row into theplotstable for the opening chapter (plot_index = 0). This means readers cannot see the genesis plot.Fix: After creating the storyline record, the indexer must:
openingCIDandopeningHashfrom the decoded event (requires ABI fix above)https://<bucket>.s3.filebase.com/plotlink/<openingCID>contentfield if IPFS fetch failskeccak256(toHex(content)) === openingHashplotstable withplot_index: 0,storyline_id,writer_address,content,content_cid: openingCID,content_hash: openingHashReference the existing plot indexer (
src/app/api/index/plot/route.ts) for the IPFS fetch + hash verify + Supabase upsert pattern.3.
createStorylinefunction ABI may also needopeningCIDandopeningHashparamsCheck
lib/contracts/abi.ts— if thecreateStorylinefunction ABI is also missing these input params, add them to match proposal §4.1.Acceptance Criteria
storylineCreatedEventinlib/contracts/abi.tsincludesopeningCID(string) andopeningHash(bytes32)createStorylinefunction ABI inlib/contracts/abi.tsincludesopeningCIDandopeningHashparams if missingplotsrow for the genesis plot (plot_index = 0)contentcolumnnpm run lintandnpm run typecheckpass