// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract EventDAO {
struct Event {
uint256 timestamp;
string description;
int256 KS_value;
uint256[3] priorEventIds;
}
Event[] public events;
Event[3] public initialEvents;
function calculateKS(
int256 priorEvent1KSValue,
int256 priorEvent2KSValue,
int256 priorEvent3KSValue
) pure internal returns (int256) {
int256 newKSValue = -priorEvent1KSValue - priorEvent2KSValue - priorEvent3KSValue;
return newKSValue;
}
function addNewEvent(
uint256 timestamp,
string memory description,
uint256[3] memory priorEventIds,
int256 claimedKSValue
) public {
int256 calculatedKSValue = calculateKS(
events[priorEventIds[0]].KS_value,
events[priorEventIds[1]].KS_value,
events[priorEventIds[2]].KS_value
);
require(claimedKSValue == calculatedKSValue, "Invalid KS Value");
events.push(
Event({
timestamp: timestamp,
description: description,
KS_value: calculatedKSValue,
priorEventIds: priorEventIds
})
);
}
}