Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Governor + CompoundTimelock to manage native tokens (eth) in and out of the timelock contract. #2849

Merged
merged 3 commits into from
Sep 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions contracts/governance/Governor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ abstract contract Governor is Context, ERC165, EIP712, IGovernor {
_name = name_;
}

/**
* @dev Function to receive ETH that will be handled by the governor (disabled if executor is a third party contract)
frangio marked this conversation as resolved.
Show resolved Hide resolved
*/
receive() external payable virtual {
frangio marked this conversation as resolved.
Show resolved Hide resolved
require(_executor() == address(this));
}

/**
* @dev See {IERC165-supportsInterface}.
*/
Expand Down
3 changes: 2 additions & 1 deletion contracts/governance/extensions/GovernorTimelockCompound.sol
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,9 @@ abstract contract GovernorTimelockCompound is IGovernorTimelock, Governor {
) internal virtual override {
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) {
_timelock.executeTransaction{value: values[i]}(targets[i], values[i], "", calldatas[i], eta);
_timelock.executeTransaction(targets[i], values[i], "", calldatas[i], eta);
}
}

Expand Down
2 changes: 0 additions & 2 deletions contracts/mocks/GovernorCompMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ contract GovernorCompMock is Governor, GovernorVotesComp, GovernorCountingSimple
_votingPeriod = votingPeriod_;
}

receive() external payable {}

function votingDelay() public view override returns (uint256) {
return _votingDelay;
}
Expand Down
2 changes: 0 additions & 2 deletions contracts/mocks/GovernorMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ contract GovernorMock is Governor, GovernorVotesQuorumFraction, GovernorCounting
_votingPeriod = votingPeriod_;
}

receive() external payable {}

function votingDelay() public view override returns (uint256) {
return _votingDelay;
}
Expand Down