Skip to content

Commit 01f2ff1

Browse files
authored
Allow Governor + CompoundTimelock to manage native tokens (eth) in and out of the timelock contract. (#2849)
* Change GovernorTimelockCompound to support ETH in Timelock * refactor compound timelock module * Allow governor to receive ETH is executor == address(this)
1 parent 296223f commit 01f2ff1

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

contracts/governance/Governor.sol

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ abstract contract Governor is Context, ERC165, EIP712, IGovernor {
5555
_name = name_;
5656
}
5757

58+
/**
59+
* @dev Function to receive ETH that will be handled by the governor (disabled if executor is a third party contract)
60+
*/
61+
receive() external payable virtual {
62+
require(_executor() == address(this));
63+
}
64+
5865
/**
5966
* @dev See {IERC165-supportsInterface}.
6067
*/

contracts/governance/extensions/GovernorTimelockCompound.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,9 @@ abstract contract GovernorTimelockCompound is IGovernorTimelock, Governor {
177177
) internal virtual override {
178178
uint256 eta = proposalEta(proposalId);
179179
require(eta > 0, "GovernorTimelockCompound: proposal not yet queued");
180+
Address.sendValue(payable(_timelock), msg.value);
180181
for (uint256 i = 0; i < targets.length; ++i) {
181-
_timelock.executeTransaction{value: values[i]}(targets[i], values[i], "", calldatas[i], eta);
182+
_timelock.executeTransaction(targets[i], values[i], "", calldatas[i], eta);
182183
}
183184
}
184185

contracts/mocks/GovernorCompMock.sol

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ contract GovernorCompMock is Governor, GovernorVotesComp, GovernorCountingSimple
2020
_votingPeriod = votingPeriod_;
2121
}
2222

23-
receive() external payable {}
24-
2523
function votingDelay() public view override returns (uint256) {
2624
return _votingDelay;
2725
}

contracts/mocks/GovernorMock.sol

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ contract GovernorMock is Governor, GovernorVotesQuorumFraction, GovernorCounting
2121
_votingPeriod = votingPeriod_;
2222
}
2323

24-
receive() external payable {}
25-
2624
function votingDelay() public view override returns (uint256) {
2725
return _votingDelay;
2826
}

0 commit comments

Comments
 (0)