function configurePass(
uint256 passId,
uint256 price,
uint256 maxSupply
) external onlyOrganizer {
require(passId == GENERAL_PASS || passId == VIP_PASS || passId == BACKSTAGE_PASS, "Invalid pass ID");
require(price > 0, "Price must be greater than 0");
require(maxSupply > 0, "Max supply must be greater than 0");
@> passPrice[passId] = price;
@> passMaxSupply[passId] = maxSupply;
@> passSupply[passId] = 0;
}
function createPerformance(
uint256 startTime,
uint256 duration,
uint256 reward
) external onlyOrganizer returns (uint256) {
@>
@>
performances[performanceCount] = Performance({
startTime: startTime,
endTime: startTime + duration,
baseReward: reward
});
}
function testOrganiserManipulation() public {
vm.startPrank(organizer);
festival.configurePass(VIP_PASS, 1 ether, 100);
vm.stopPrank();
vm.startPrank(user1);
festival.buyPass{value: 1 ether}(VIP_PASS);
vm.stopPrank();
vm.startPrank(organizer);
festival.configurePass(VIP_PASS, 10 ether, 100);
festival.createPerformance(
block.timestamp + 1 hours,
1 hours,
1000000 ether
);
vm.stopPrank();
vm.startPrank(user2);
vm.expectRevert();
festival.buyPass{value: 1 ether}(VIP_PASS);
vm.stopPrank();
}
+ mapping(uint256 => bool) public passConfigurationLocked;
+ uint256 public constant MAX_REWARD_PER_PERFORMANCE = 1000 ether;
function configurePass(
uint256 passId,
uint256 price,
uint256 maxSupply
) external onlyOrganizer {
require(passId == GENERAL_PASS || passId == VIP_PASS || passId == BACKSTAGE_PASS, "Invalid pass ID");
require(price > 0, "Price must be greater than 0");
require(maxSupply > 0, "Max supply must be greater than 0");
+ require(!passConfigurationLocked[passId], "Pass configuration is locked");
+ require(maxSupply >= passSupply[passId], "Cannot reduce supply below current sales");
- passPrice[passId] = price;
+ // Only allow price changes if no passes sold yet
+ if (passSupply[passId] == 0) {
+ passPrice[passId] = price;
+ }
passMaxSupply[passId] = maxSupply;
- passSupply[passId] = 0;
+ // Don't reset supply unless explicitly needed
}
+ function lockPassConfiguration(uint256 passId) external onlyOrganizer {
+ passConfigurationLocked[passId] = true;
+ emit PassConfigurationLocked(passId);
+ }
function createPerformance(
uint256 startTime,
uint256 duration,
uint256 reward
) external onlyOrganizer returns (uint256) {
require(startTime > block.timestamp, "Start time must be in the future");
require(duration > 0, "Duration must be greater than 0");
+ require(reward <= MAX_REWARD_PER_PERFORMANCE, "Reward exceeds maximum allowed");
+ require(duration <= 24 hours, "Performance duration too long");
performances[performanceCount] = Performance({
startTime: startTime,
endTime: startTime + duration,
baseReward: reward
});
emit PerformanceCreated(performanceCount, startTime, startTime + duration);
return performanceCount++;
}