GovernorHarness.sol 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. import "../../contracts/governance/Governor.sol";
  2. contract GovernorHarness is Governor {
  3. function isExecuted(uint256 proposalId) public view returns (bool) {
  4. return _proposals[proposalId].executed;
  5. }
  6. function isCanceled(uint256 proposalId) public view returns (bool) {
  7. return _proposals[proposalId].canceled;
  8. }
  9. function snapshot(uint256 proposalId) public view returns (uint64) {
  10. return _proposals[proposalId].voteStart._deadline;
  11. }
  12. function initialized(uint256 proposalId) public view returns (bool){
  13. if (_proposals[proposalId].voteStart._deadline != 0 && _proposals[proposalId].voteEnd._deadline != 0) {
  14. return true;
  15. }
  16. return false;
  17. }
  18. mapping(uint256 => uint256) _quorum;
  19. function quorum(uint256 blockNumber) public view override virtual returns (uint256) {
  20. return _quorum[blockNumber];
  21. }
  22. mapping (address => mapping (uint256 => uint256)) _getVotes;
  23. function getVotes(address account, uint256 blockNumber) public view override virtual returns (uint256) {
  24. return _getVotes[account][blockNumber];
  25. }
  26. mapping (uint256 => bool) __quoromReached;
  27. function _quorumReached(uint256 proposalId) public view override virtual returns (bool) {
  28. return __quoromReached[proposalId];
  29. }
  30. mapping (uint256 => bool) __voteSucceeded;
  31. function _voteSucceeded(uint256 proposalId) public view override virtual returns (bool) {
  32. return __voteSucceeded[proposalId];
  33. }
  34. //string _COUNTING_MODE;
  35. function COUNTING_MODE() public pure override virtual returns (string memory) {
  36. return "dummy";
  37. }
  38. mapping(uint256 => mapping(address => bool)) _hasVoted;
  39. function hasVoted(uint256 proposalId, address account) public view override virtual returns (bool) {
  40. return _hasVoted[proposalId][account];
  41. }
  42. uint256 _votingDelay;
  43. function votingDelay() public view override virtual returns (uint256) {
  44. return _votingDelay;
  45. }
  46. uint256 _votingPeriod;
  47. function votingPeriod() public view override virtual returns (uint256) {
  48. return _votingPeriod;
  49. }
  50. function _countVote(
  51. uint256 proposalId,
  52. address account,
  53. uint8 support,
  54. uint256 weight
  55. ) internal override virtual {
  56. // havoc something
  57. }
  58. constructor(string memory name) Governor(name) {}
  59. // _countVots == Sum of castVote
  60. //
  61. // RHS:
  62. // 1) use counter_vote_power as a counter
  63. // 2) use counter_vote_power as a temp var for a ghost
  64. //
  65. // LHS:
  66. // mapping of count
  67. // countMap
  68. // uint decision;
  69. // uint numberOfOptions;
  70. function callPropose(address[] memory targets,
  71. uint256[] memory values,
  72. bytes[] memory calldatas) public virtual returns (uint256) {
  73. return super.propose(targets, values, calldatas, "");
  74. }
  75. // Harness of castVoteWithReason to be able to impose requirement on the proposal ID.
  76. uint256 public _pId_Harness;
  77. function castVoteWithReason(uint256 proposalId, uint8 support, string calldata reason)
  78. public override returns (uint256) {
  79. require(proposalId == _pId_Harness);
  80. return super.castVoteWithReason(proposalId, support, reason);
  81. }
  82. }