Skip to content

Commit

Permalink
added a function to update the tally file's cid in the poll manager
Browse files Browse the repository at this point in the history
  • Loading branch information
yashgo0018 committed Apr 10, 2024
1 parent 70892e5 commit 256c1bd
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion packages/hardhat/contracts/PollManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ contract PollManager is Params, DomainObjs {
uint256 endTime;
uint256 numOfOptions;
string[] options;
string tallyJsonCID;
}

mapping(uint256 => PollData) internal polls;
Expand Down Expand Up @@ -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");
_;
Expand Down Expand Up @@ -117,7 +124,8 @@ contract PollManager is Params, DomainObjs {
startTime: block.timestamp,
endTime: endTime,
pollContracts: pollContracts,
options: _options
options: _options,
tallyJsonCID: ""
});

emit PollCreated(
Expand All @@ -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,
Expand Down

0 comments on commit 256c1bd

Please sign in to comment.