Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/StoryFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,30 @@ contract StoryFactory {
emit PlotChained(storylineId, 0, msg.sender, openingCID, openingHash);
}

// -----------------------------------------------------------------------
// chainPlot
// -----------------------------------------------------------------------

/// @notice Chain a new plot to an existing storyline
/// @param storylineId The storyline to chain to
/// @param contentCID IPFS CID of the plot content
/// @param contentHash keccak256 hash of the plot content
function chainPlot(uint256 storylineId, string calldata contentCID, bytes32 contentHash) external {
Storyline storage s = storylines[storylineId];
require(msg.sender == s.writer, "Not writer");
require(bytes(contentCID).length >= 46 && bytes(contentCID).length <= 100, "Invalid CID");
require(!s.sunset, "Storyline sunset");
if (s.hasDeadline) {
require(block.timestamp <= s.lastPlotTime + 72 hours, "Deadline passed");
}

uint256 plotIndex = s.plotCount; // genesis = 0, so first chain = 1
s.plotCount++;
s.lastPlotTime = block.timestamp;

emit PlotChained(storylineId, plotIndex, msg.sender, contentCID, contentHash);
}

// -----------------------------------------------------------------------
// Internal helpers
// -----------------------------------------------------------------------
Expand Down