From 7a3e268aed1a180c7d41c9a5767e59869cbe7f46 Mon Sep 17 00:00:00 2001 From: Cho Young-Hwi Date: Fri, 20 Mar 2026 11:51:16 +0000 Subject: [PATCH] [#52] Add initialStorylineCount constructor param Skip past existing PL-1..PL-8 symbols on shared MCV2_Bond by allowing the factory to start its counter at a configurable offset. DeployBase passes 8; all other callers pass 0. Co-Authored-By: Claude Opus 4.6 (1M context) --- script/DeployBase.s.sol | 2 +- script/DeployBaseSepolia.s.sol | 2 +- script/E2ETestReverts.s.sol | 6 +++--- src/StoryFactory.sol | 4 +++- test/StoryFactory.t.sol | 8 ++++---- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/script/DeployBase.s.sol b/script/DeployBase.s.sol index 41aa965..2c21fba 100644 --- a/script/DeployBase.s.sol +++ b/script/DeployBase.s.sol @@ -24,7 +24,7 @@ contract DeployBase is Script { uint256 deployerKey = vm.envUint("DEPLOYER_PRIVATE_KEY"); vm.startBroadcast(deployerKey); - StoryFactory factory = new StoryFactory(MCV2_BOND, PL_TEST, MAX_SUPPLY, stepRanges, stepPrices); + StoryFactory factory = new StoryFactory(MCV2_BOND, PL_TEST, MAX_SUPPLY, stepRanges, stepPrices, 8); vm.stopBroadcast(); diff --git a/script/DeployBaseSepolia.s.sol b/script/DeployBaseSepolia.s.sol index 543829f..d94e417 100644 --- a/script/DeployBaseSepolia.s.sol +++ b/script/DeployBaseSepolia.s.sol @@ -24,7 +24,7 @@ contract DeployBaseSepolia is Script { uint256 deployerKey = vm.envUint("DEPLOYER_PRIVATE_KEY"); vm.startBroadcast(deployerKey); - StoryFactory factory = new StoryFactory(MCV2_BOND, PLOT_TOKEN, MAX_SUPPLY, stepRanges, stepPrices); + StoryFactory factory = new StoryFactory(MCV2_BOND, PLOT_TOKEN, MAX_SUPPLY, stepRanges, stepPrices, 0); vm.stopBroadcast(); diff --git a/script/E2ETestReverts.s.sol b/script/E2ETestReverts.s.sol index e825643..12fbf6d 100644 --- a/script/E2ETestReverts.s.sol +++ b/script/E2ETestReverts.s.sol @@ -222,7 +222,7 @@ contract E2ETestReverts is Script { p1[0] = 1e15; // H1: Zero bond address - try new StoryFactory(address(0), address(1), 1e18, r1, p1) { + try new StoryFactory(address(0), address(1), 1e18, r1, p1, 0) { revert("H1: should have reverted"); } catch Error(string memory reason) { require(keccak256(bytes(reason)) == keccak256("Zero bond address"), "H1: wrong revert reason"); @@ -231,7 +231,7 @@ contract E2ETestReverts is Script { } // H2: Zero token address - try new StoryFactory(address(1), address(0), 1e18, r1, p1) { + try new StoryFactory(address(1), address(0), 1e18, r1, p1, 0) { revert("H2: should have reverted"); } catch Error(string memory reason) { require(keccak256(bytes(reason)) == keccak256("Zero token address"), "H2: wrong revert reason"); @@ -246,7 +246,7 @@ contract E2ETestReverts is Script { bigR[i] = uint128(i + 1); bigP[i] = uint128(i + 1); } - try new StoryFactory(address(1), address(1), 1e18, bigR, bigP) { + try new StoryFactory(address(1), address(1), 1e18, bigR, bigP, 0) { revert("H3: should have reverted"); } catch Error(string memory reason) { require(keccak256(bytes(reason)) == keccak256("Too many steps"), "H3: wrong revert reason"); diff --git a/src/StoryFactory.sol b/src/StoryFactory.sol index f1bde35..0de672c 100644 --- a/src/StoryFactory.sol +++ b/src/StoryFactory.sol @@ -88,7 +88,8 @@ contract StoryFactory { address _plotToken, uint128 _maxSupply, uint128[] memory _stepRanges, - uint128[] memory _stepPrices + uint128[] memory _stepPrices, + uint256 _initialStorylineCount ) { require(_bond != address(0), "Zero bond address"); require(_plotToken != address(0), "Zero token address"); @@ -102,6 +103,7 @@ contract StoryFactory { owner = msg.sender; stepRanges = _stepRanges; stepPrices = _stepPrices; + storylineCount = _initialStorylineCount; } // ----------------------------------------------------------------------- diff --git a/test/StoryFactory.t.sol b/test/StoryFactory.t.sol index 82e290f..847de72 100644 --- a/test/StoryFactory.t.sol +++ b/test/StoryFactory.t.sol @@ -109,7 +109,7 @@ contract StoryFactoryTest is Test { prices[0] = 1e15; prices[1] = 1e18; - factory = new StoryFactory(address(bond), address(plot), 1_000_000e18, ranges, prices); + factory = new StoryFactory(address(bond), address(plot), 1_000_000e18, ranges, prices, 0); } // =================================================================== @@ -408,7 +408,7 @@ contract StoryFactoryTest is Test { prices[0] = 1e15; vm.expectRevert("Zero bond address"); - new StoryFactory(address(0), address(plot), 1e18, ranges, prices); + new StoryFactory(address(0), address(plot), 1e18, ranges, prices, 0); } function test_constructor_revert_zeroToken() public { @@ -418,7 +418,7 @@ contract StoryFactoryTest is Test { prices[0] = 1e15; vm.expectRevert("Zero token address"); - new StoryFactory(address(bond), address(0), 1e18, ranges, prices); + new StoryFactory(address(bond), address(0), 1e18, ranges, prices, 0); } function test_constructor_revert_tooManySteps() public { @@ -430,7 +430,7 @@ contract StoryFactoryTest is Test { } vm.expectRevert("Too many steps"); - new StoryFactory(address(bond), address(plot), 1e18, ranges, prices); + new StoryFactory(address(bond), address(plot), 1e18, ranges, prices, 0); } // ===================================================================