Skip to content

[P9-1] Contract: add title param to chainPlot function #184

@realproject7

Description

@realproject7

Problem

Current chainPlot function signature:

function chainPlot(uint256 storylineId, string contentCID, bytes32 contentHash)

No title parameter — plots have no chapter title support.

Also, chainPlot still enforces 72 hours deadline but the frontend and all docs now use 168h (7 days).

Required changes

1. Add title to chainPlot + event

function chainPlot(uint256 storylineId, string calldata title, string calldata contentCID, bytes32 contentHash)

Update PlotChained event:

event PlotChained(uint256 indexed storylineId, uint256 plotIndex, address writer, string title, string contentCID, bytes32 contentHash)

2. Fix deadline: 72 hours → 168 hours

In chainPlot, line 158:

// OLD:
require(block.timestamp <= s.lastPlotTime + 72 hours, "Deadline passed");
// NEW:
require(block.timestamp <= s.lastPlotTime + 168 hours, "Deadline passed");

3. Update genesis PlotChained emit

In createStoryline, the genesis PlotChained emit also needs title:

emit PlotChained(storylineId, 0, msg.sender, title, openingCID, openingHash);

Steps

  1. Update plotlink-contracts/src/StoryFactory.sol:
    • Add title string param to chainPlot function
    • Add title to PlotChained event
    • Update genesis emit in createStoryline to include title
    • Change 72 hours168 hours in deadline check
  2. Update tests in test/StoryFactory.t.sol — all chainPlot calls need title arg, deadline test uses 168h
  3. Run tests: forge test
  4. Deploy to Base Sepolia: forge script script/DeployBaseSepolia.s.sol --rpc-url base_sepolia --broadcast
  5. Copy new contract address from broadcast output
  6. Update plotlink/lib/contracts/constants.ts — new STORY_FACTORY address
  7. Update plotlink/lib/contracts/abi.ts — add title to chainPlotFunction inputs and plotChainedEvent
  8. Verify on Basescan: forge verify-contract

Deployment info

  • Contract repo: /Users/cho/Projects/plotlink-contracts/
  • Deploy script: script/DeployBaseSepolia.s.sol
  • Deployer key: plotlink-contracts/.env (DEPLOYER_PRIVATE_KEY)
  • Current contract: 0x05C4d59529807316D6fA09cdaA509adDfe85b474
  • Chain: Base Sepolia (84532)

Considerations

  • Existing plots have no title — frontend must handle title = "" (show "Chapter {N}" fallback)
  • Title max length: suggest 100 chars validation in frontend
  • Gas impact: additional string storage, acceptable tradeoff
  • This is a fresh redeploy on testnet — old contract data is abandoned

Blocks: #185, #186, #187, #189, #190

Part of: Phase 9 Epic (#183)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions