Skip to content

Commit

Permalink
Revert if next proposal id set and current proposal not 0
Browse files Browse the repository at this point in the history
  • Loading branch information
arr00 committed Nov 4, 2024
1 parent c52f001 commit d9f3477
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ abstract contract GovernorSequentialProposalId is Governor {
uint256 private _numberOfProposals;
mapping(uint256 proposalHash => uint256 proposalId) private _proposalIds;

error NextProposalIdCanOnlyBeSetOnce();

function hashProposal(
address[] memory targets,
uint256[] memory values,
Expand Down Expand Up @@ -37,6 +39,7 @@ abstract contract GovernorSequentialProposalId is Governor {
* @dev Internal function to set the sequential proposal ID for the next proposal. This is helpful for transitioning from another governing system.
*/
function _setNextProposalId(uint256 nextProposalId) internal virtual {
if (_numberOfProposals != 0) revert NextProposalIdCanOnlyBeSetOnce();
_numberOfProposals = nextProposalId - 1;
}
}

0 comments on commit d9f3477

Please sign in to comment.