Created
December 15, 2022 05:18
-
-
Save KolevDarko/886fb13a0e8cc1881eeb8ec7a6bed46e to your computer and use it in GitHub Desktop.
Governor propose
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function propose( | |
address[] memory targets, | |
uint256[] memory values, | |
bytes[] memory calldatas, | |
string memory description | |
) public virtual override returns (uint256) { | |
require( | |
getVotes(_msgSender(), block.number - 1) >= proposalThreshold(), | |
"Governor: proposer votes below proposal threshold" | |
); | |
uint256 proposalId = hashProposal(targets, values, calldatas, keccak256(bytes(description))); | |
require(targets.length == values.length, "Governor: invalid proposal length"); | |
require(targets.length == calldatas.length, "Governor: invalid proposal length"); | |
require(targets.length > 0, "Governor: empty proposal"); | |
ProposalCore storage proposal = _proposals[proposalId]; | |
require(proposal.voteStart.isUnset(), "Governor: proposal already exists"); | |
uint64 snapshot = block.number.toUint64() + votingDelay().toUint64(); | |
uint64 deadline = snapshot + votingPeriod().toUint64(); | |
proposal.voteStart.setDeadline(snapshot); | |
proposal.voteEnd.setDeadline(deadline); | |
emit ProposalCreated( | |
proposalId, | |
_msgSender(), | |
targets, | |
values, | |
new string[](targets.length), | |
calldatas, | |
snapshot, | |
deadline, | |
description | |
); | |
return proposalId; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment