Skip to content

Commit

Permalink
chore: check canceled (#2102)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean McCaffery authored Aug 15, 2024
1 parent e600689 commit f14e661
Show file tree
Hide file tree
Showing 12 changed files with 6,650 additions and 34 deletions.
26 changes: 17 additions & 9 deletions packages/forge/src/governance/Governor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ abstract contract Governor is GovernorSorting, GovernorMerkleVotes {
uint256 public constant MAX_FIELDS_METADATA_LENGTH = 10;
uint256 public constant AMOUNT_FOR_SUMBITTER_PROOF = 10000000000000000000;
address public constant JK_LABS_ADDRESS = 0xDc652C746A8F85e18Ce632d97c6118e8a52fa738; // our hot wallet that we operate from if need be, and collect revenue to on most chains
string private constant VERSION = "4.31"; // Private as to not clutter the ABI
string private constant VERSION = "4.32"; // Private as to not clutter the ABI

string public name; // The title of the contest
string public prompt;
Expand Down Expand Up @@ -157,12 +157,12 @@ abstract contract Governor is GovernorSorting, GovernorMerkleVotes {
error NeedToVoteWithProofFirst();

error OnlyCreatorCanDelete();
error CannotDeleteWhenCompleted();
error CannotDeleteWhenCompletedOrCanceled();

error OnlyJkLabsOrCreatorCanCancel();
error ContestAlreadyCancelled();
error ContestAlreadyCanceled();

error CannotUpdateAfterCompleted();
error CannotUpdateWhenCompletedOrCanceled();

error OnlyJkLabsCanAmend();
error OnlyCreatorCanAmend();
Expand Down Expand Up @@ -447,7 +447,9 @@ abstract contract Governor is GovernorSorting, GovernorMerkleVotes {
*/
function deleteProposals(uint256[] calldata proposalIdsToDelete) public {
if (msg.sender != creator) revert OnlyCreatorCanDelete();
if (state() == ContestState.Completed) revert CannotDeleteWhenCompleted();
if (state() == ContestState.Completed || state() == ContestState.Canceled) {
revert CannotDeleteWhenCompletedOrCanceled();
}

for (uint256 index = 0; index < proposalIdsToDelete.length; index++) {
uint256 currentProposalId = proposalIdsToDelete[index];
Expand Down Expand Up @@ -478,7 +480,7 @@ abstract contract Governor is GovernorSorting, GovernorMerkleVotes {
if (((msg.sender != creator) && (msg.sender != JK_LABS_ADDRESS))) revert OnlyJkLabsOrCreatorCanCancel();

ContestState status = state();
if (status == ContestState.Canceled) revert ContestAlreadyCancelled();
if (status == ContestState.Canceled) revert ContestAlreadyCanceled();

canceled = true;

Expand Down Expand Up @@ -556,19 +558,25 @@ abstract contract Governor is GovernorSorting, GovernorMerkleVotes {

function setSubmissionMerkleRoot(bytes32 newSubmissionMerkleRoot) public {
if (msg.sender != JK_LABS_ADDRESS) revert OnlyJkLabsCanAmend();
if (state() == ContestState.Completed) revert CannotUpdateAfterCompleted();
if (state() == ContestState.Completed || state() == ContestState.Canceled) {
revert CannotUpdateWhenCompletedOrCanceled();
}
submissionMerkleRoot = newSubmissionMerkleRoot;
}

function setVotingMerkleRoot(bytes32 newVotingMerkleRoot) public {
if (msg.sender != JK_LABS_ADDRESS) revert OnlyJkLabsCanAmend();
if (state() == ContestState.Completed) revert CannotUpdateAfterCompleted();
if (state() == ContestState.Completed || state() == ContestState.Canceled) {
revert CannotUpdateWhenCompletedOrCanceled();
}
votingMerkleRoot = newVotingMerkleRoot;
}

function setCreatorSplitDestination(address newCreatorSplitDestination) public {
if (msg.sender != creator) revert OnlyCreatorCanAmend();
if (state() == ContestState.Completed) revert CannotUpdateAfterCompleted();
if (state() == ContestState.Completed || state() == ContestState.Canceled) {
revert CannotUpdateWhenCompletedOrCanceled();
}
creatorSplitDestination = newCreatorSplitDestination;
}
}
2 changes: 1 addition & 1 deletion packages/forge/src/modules/RewardsModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ contract RewardsModule {
mapping(uint256 => uint256) public shares; // Getter for the amount of shares held by a ranking.
mapping(uint256 => uint256) public released; // Getter for the amount of Ether already released to a ranking.
uint256[] public payees;
string private constant VERSION = "4.31"; // Private as to not clutter the ABI
string private constant VERSION = "4.32"; // Private as to not clutter the ABI

mapping(IERC20 => uint256) public erc20TotalReleased;
mapping(IERC20 => mapping(uint256 => uint256)) public erc20Released;
Expand Down

Large diffs are not rendered by default.

Loading

0 comments on commit f14e661

Please sign in to comment.