diff --git a/packages/hardhat/contracts/PollManager.sol b/packages/hardhat/contracts/PollManager.sol index ce24663..0e681d9 100644 --- a/packages/hardhat/contracts/PollManager.sol +++ b/packages/hardhat/contracts/PollManager.sol @@ -24,6 +24,7 @@ contract PollManager is Params, DomainObjs { uint256 endTime; uint256 numOfOptions; string[] options; + string tallyJsonCID; } mapping(uint256 => PollData) internal polls; @@ -51,6 +52,12 @@ contract PollManager is Params, DomainObjs { uint256 endTime ); + event PollTallyCIDUpdated( + uint256 indexed pollId, + uint256 indexed maciPollId, + string tallyJsonCID + ); + modifier onlyOwner() { require(msg.sender == owner(), "only owner can call this function"); _; @@ -117,7 +124,8 @@ contract PollManager is Params, DomainObjs { startTime: block.timestamp, endTime: endTime, pollContracts: pollContracts, - options: _options + options: _options, + tallyJsonCID: "" }); emit PollCreated( @@ -133,6 +141,17 @@ contract PollManager is Params, DomainObjs { ); } + function updatePollTallyCID( + uint256 _pollId, + string calldata _tallyJsonCID + ) public onlyOwner { + require(_pollId <= totalPolls && _pollId != 0, "poll does not exist"); + PollData storage poll = polls[_pollId]; + poll.tallyJsonCID = _tallyJsonCID; + + emit PollTallyCIDUpdated(_pollId, poll.maciPollId, _tallyJsonCID); + } + function fetchPolls( uint256 _page, uint256 _perPage,