Skip to content

Commit

Permalink
fix: upstream oz fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tarrencev committed Sep 18, 2021
1 parent 29255bb commit 59b66cf
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 80 deletions.
24 changes: 18 additions & 6 deletions contracts/governance/DopeDAO.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ contract DopeDAO is Governor, GovernorCompatibilityBravo, GovernorVotesComp, Gov
GovernorTimelockCompound(_timelock)
{}

function votingDelay() public pure override returns (uint256) {
function votingDelay() public pure virtual override returns (uint256) {
return 13091; // 2 days (in blocks)
}

function votingPeriod() public pure override returns (uint256) {
function votingPeriod() public pure virtual override returns (uint256) {
return 45818; // 1 week (in blocks)
}

function quorum(uint256 blockNumber) public pure override returns (uint256) {
function quorum(uint256 blockNumber) public pure virtual override returns (uint256) {
return 500; // DOPE DAO NFT TOKENS
}

function proposalThreshold() public pure override returns (uint256) {
function proposalThreshold() public pure virtual override returns (uint256) {
return 50; // DOPE DAO NFT TOKENS
}

Expand Down Expand Up @@ -63,9 +63,14 @@ contract DopeDAO is Governor, GovernorCompatibilityBravo, GovernorVotesComp, Gov
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
bytes32 /*descriptionHash*/
) internal override(Governor, GovernorTimelockCompound) {
super._execute(proposalId, targets, values, calldatas, descriptionHash);
uint256 eta = proposalEta(proposalId);
require(eta > 0, "GovernorTimelockCompound: proposal not yet queued");
Address.sendValue(payable(timelock()), msg.value);
for (uint256 i = 0; i < targets.length; ++i) {
ICompoundTimelock(payable(timelock())).executeTransaction(targets[i], values[i], "", calldatas[i], eta);
}
}

function _cancel(
Expand All @@ -89,4 +94,11 @@ contract DopeDAO is Governor, GovernorCompatibilityBravo, GovernorVotesComp, Gov
{
return super.supportsInterface(interfaceId);
}

/**
* @dev Function to receive ETH that will be handled by the governor (disabled if executor is a third party contract)
*/
receive() external payable virtual {
require(_executor() == address(this));
}
}
71 changes: 3 additions & 68 deletions contracts/test/DopeDAO.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@ import "@openzeppelin/contracts/governance/compatibility/GovernorCompatibilityBr
import "@openzeppelin/contracts/governance/extensions/GovernorVotesComp.sol";
import "@openzeppelin/contracts/governance/extensions/GovernorTimelockCompound.sol";

import "hardhat/console.sol";
import "../governance/DopeDAO.sol";

contract DopeDAOTest is Governor, GovernorCompatibilityBravo, GovernorVotesComp, GovernorTimelockCompound {
constructor(ERC20VotesComp _token, ICompoundTimelock _timelock)
Governor("DopeDAO")
GovernorVotesComp(_token)
GovernorTimelockCompound(_timelock)
{}
contract DopeDAOTest is DopeDAO {
constructor(ERC20VotesComp _token, ICompoundTimelock _timelock) DopeDAO(_token, _timelock) {}

function votingDelay() public pure override returns (uint256) {
return 1;
Expand All @@ -30,65 +26,4 @@ contract DopeDAOTest is Governor, GovernorCompatibilityBravo, GovernorVotesComp,
function proposalThreshold() public pure override returns (uint256) {
return 1;
}

// The following functions are overrides required by Solidity.

function getVotes(address account, uint256 blockNumber)
public
view
override(IGovernor, GovernorVotesComp)
returns (uint256)
{
return super.getVotes(account, blockNumber);
}

function state(uint256 proposalId)
public
view
override(Governor, IGovernor, GovernorTimelockCompound)
returns (ProposalState)
{
return super.state(proposalId);
}

function propose(
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
string memory description
) public override(Governor, GovernorCompatibilityBravo, IGovernor) returns (uint256) {
return super.propose(targets, values, calldatas, description);
}

function _execute(
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) internal override(Governor, GovernorTimelockCompound) {
super._execute(proposalId, targets, values, calldatas, descriptionHash);
}

function _cancel(
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) internal override(Governor, GovernorTimelockCompound) returns (uint256) {
return super._cancel(targets, values, calldatas, descriptionHash);
}

function _executor() internal view override(Governor, GovernorTimelockCompound) returns (address) {
return super._executor();
}

function supportsInterface(bytes4 interfaceId)
public
view
override(Governor, IERC165, GovernorTimelockCompound)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@
},
"dependencies": {
"@nomiclabs/hardhat-etherscan": "^2.1.6",
"@openzeppelin/contracts": ">=4.3.1"
"@openzeppelin/contracts": "^4.3.2"
}
}
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ __metadata:
"@nomiclabs/hardhat-ethers": ^2.0.2
"@nomiclabs/hardhat-etherscan": ^2.1.6
"@nomiclabs/hardhat-waffle": ^2.0.1
"@openzeppelin/contracts": ">=4.3.1"
"@openzeppelin/contracts": ^4.3.2
"@typechain/ethers-v5": ^7.0.1
"@typechain/hardhat": ^2.3.0
"@types/chai": ^4.2.21
Expand Down Expand Up @@ -1039,10 +1039,10 @@ __metadata:
languageName: node
linkType: hard

"@openzeppelin/contracts@npm:>=4.3.1":
version: 4.3.1
resolution: "@openzeppelin/contracts@npm:4.3.1"
checksum: ddfa5bb65f5e645a618e0062c83fa6a44499cece47ef5dd62cc51c0da5f6c3253c9def9fb6c0086cc37a463fb2f8b2d7dc271ab78d876d99134b57baba2e8639
"@openzeppelin/contracts@npm:^4.3.2":
version: 4.3.2
resolution: "@openzeppelin/contracts@npm:4.3.2"
checksum: 9032453eef3e10b6453b667c7edd3381292665083b855ca8a8b5f64b473e768eacb53516865fb3ce1e493deadbb977069e483cce5650c42807a742ab59a18695
languageName: node
linkType: hard

Expand Down

0 comments on commit 59b66cf

Please sign in to comment.