dexorder
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
pragma solidity ^0.8.20;
|
||||
|
||||
import {Governor} from "../../governance/Governor.sol";
|
||||
import {GovernorSettings} from "../../governance/extensions/GovernorSettings.sol";
|
||||
import {GovernorCountingSimple} from "../../governance/extensions/GovernorCountingSimple.sol";
|
||||
import {GovernorVotesQuorumFraction} from "../../governance/extensions/GovernorVotesQuorumFraction.sol";
|
||||
|
||||
abstract contract GovernorMock is GovernorSettings, GovernorVotesQuorumFraction, GovernorCountingSimple {
|
||||
function proposalThreshold() public view override(Governor, GovernorSettings) returns (uint256) {
|
||||
return super.proposalThreshold();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
pragma solidity ^0.8.20;
|
||||
|
||||
import {Governor} from "../../governance/Governor.sol";
|
||||
import {GovernorPreventLateQuorum} from "../../governance/extensions/GovernorPreventLateQuorum.sol";
|
||||
import {GovernorSettings} from "../../governance/extensions/GovernorSettings.sol";
|
||||
import {GovernorCountingSimple} from "../../governance/extensions/GovernorCountingSimple.sol";
|
||||
import {GovernorVotes} from "../../governance/extensions/GovernorVotes.sol";
|
||||
|
||||
abstract contract GovernorPreventLateQuorumMock is
|
||||
GovernorSettings,
|
||||
GovernorVotes,
|
||||
GovernorCountingSimple,
|
||||
GovernorPreventLateQuorum
|
||||
{
|
||||
uint256 private _quorum;
|
||||
|
||||
constructor(uint256 quorum_) {
|
||||
_quorum = quorum_;
|
||||
}
|
||||
|
||||
function quorum(uint256) public view override returns (uint256) {
|
||||
return _quorum;
|
||||
}
|
||||
|
||||
function proposalDeadline(
|
||||
uint256 proposalId
|
||||
) public view override(Governor, GovernorPreventLateQuorum) returns (uint256) {
|
||||
return super.proposalDeadline(proposalId);
|
||||
}
|
||||
|
||||
function proposalThreshold() public view override(Governor, GovernorSettings) returns (uint256) {
|
||||
return super.proposalThreshold();
|
||||
}
|
||||
|
||||
function _castVote(
|
||||
uint256 proposalId,
|
||||
address account,
|
||||
uint8 support,
|
||||
string memory reason,
|
||||
bytes memory params
|
||||
) internal override(Governor, GovernorPreventLateQuorum) returns (uint256) {
|
||||
return super._castVote(proposalId, account, support, reason, params);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
pragma solidity ^0.8.19;
|
||||
|
||||
import {IGovernor, Governor} from "../../governance/Governor.sol";
|
||||
import {GovernorTimelockControl} from "../../governance/extensions/GovernorTimelockControl.sol";
|
||||
import {GovernorSettings} from "../../governance/extensions/GovernorSettings.sol";
|
||||
import {GovernorCountingSimple} from "../../governance/extensions/GovernorCountingSimple.sol";
|
||||
import {GovernorVotesQuorumFraction} from "../../governance/extensions/GovernorVotesQuorumFraction.sol";
|
||||
import {GovernorStorage} from "../../governance/extensions/GovernorStorage.sol";
|
||||
|
||||
abstract contract GovernorStorageMock is
|
||||
GovernorSettings,
|
||||
GovernorTimelockControl,
|
||||
GovernorVotesQuorumFraction,
|
||||
GovernorCountingSimple,
|
||||
GovernorStorage
|
||||
{
|
||||
function quorum(uint256 blockNumber) public view override(Governor, GovernorVotesQuorumFraction) returns (uint256) {
|
||||
return super.quorum(blockNumber);
|
||||
}
|
||||
|
||||
function state(uint256 proposalId) public view override(Governor, GovernorTimelockControl) returns (ProposalState) {
|
||||
return super.state(proposalId);
|
||||
}
|
||||
|
||||
function proposalThreshold() public view override(Governor, GovernorSettings) returns (uint256) {
|
||||
return super.proposalThreshold();
|
||||
}
|
||||
|
||||
function proposalNeedsQueuing(
|
||||
uint256 proposalId
|
||||
) public view virtual override(Governor, GovernorTimelockControl) returns (bool) {
|
||||
return super.proposalNeedsQueuing(proposalId);
|
||||
}
|
||||
|
||||
function _propose(
|
||||
address[] memory targets,
|
||||
uint256[] memory values,
|
||||
bytes[] memory calldatas,
|
||||
string memory description,
|
||||
address proposer
|
||||
) internal virtual override(Governor, GovernorStorage) returns (uint256) {
|
||||
return super._propose(targets, values, calldatas, description, proposer);
|
||||
}
|
||||
|
||||
function _queueOperations(
|
||||
uint256 proposalId,
|
||||
address[] memory targets,
|
||||
uint256[] memory values,
|
||||
bytes[] memory calldatas,
|
||||
bytes32 descriptionHash
|
||||
) internal override(Governor, GovernorTimelockControl) returns (uint48) {
|
||||
return super._queueOperations(proposalId, targets, values, calldatas, descriptionHash);
|
||||
}
|
||||
|
||||
function _executeOperations(
|
||||
uint256 proposalId,
|
||||
address[] memory targets,
|
||||
uint256[] memory values,
|
||||
bytes[] memory calldatas,
|
||||
bytes32 descriptionHash
|
||||
) internal override(Governor, GovernorTimelockControl) {
|
||||
super._executeOperations(proposalId, targets, values, calldatas, descriptionHash);
|
||||
}
|
||||
|
||||
function _cancel(
|
||||
address[] memory targets,
|
||||
uint256[] memory values,
|
||||
bytes[] memory calldatas,
|
||||
bytes32 descriptionHash
|
||||
) internal override(Governor, GovernorTimelockControl) returns (uint256) {
|
||||
return super._cancel(targets, values, calldatas, descriptionHash);
|
||||
}
|
||||
|
||||
function _executor() internal view override(Governor, GovernorTimelockControl) returns (address) {
|
||||
return super._executor();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
pragma solidity ^0.8.20;
|
||||
|
||||
import {IGovernor, Governor} from "../../governance/Governor.sol";
|
||||
import {GovernorTimelockAccess} from "../../governance/extensions/GovernorTimelockAccess.sol";
|
||||
import {GovernorSettings} from "../../governance/extensions/GovernorSettings.sol";
|
||||
import {GovernorCountingSimple} from "../../governance/extensions/GovernorCountingSimple.sol";
|
||||
import {GovernorVotesQuorumFraction} from "../../governance/extensions/GovernorVotesQuorumFraction.sol";
|
||||
|
||||
abstract contract GovernorTimelockAccessMock is
|
||||
GovernorSettings,
|
||||
GovernorTimelockAccess,
|
||||
GovernorVotesQuorumFraction,
|
||||
GovernorCountingSimple
|
||||
{
|
||||
function nonGovernanceFunction() external {}
|
||||
|
||||
function quorum(uint256 blockNumber) public view override(Governor, GovernorVotesQuorumFraction) returns (uint256) {
|
||||
return super.quorum(blockNumber);
|
||||
}
|
||||
|
||||
function proposalThreshold() public view override(Governor, GovernorSettings) returns (uint256) {
|
||||
return super.proposalThreshold();
|
||||
}
|
||||
|
||||
function proposalNeedsQueuing(
|
||||
uint256 proposalId
|
||||
) public view virtual override(Governor, GovernorTimelockAccess) returns (bool) {
|
||||
return super.proposalNeedsQueuing(proposalId);
|
||||
}
|
||||
|
||||
function propose(
|
||||
address[] memory targets,
|
||||
uint256[] memory values,
|
||||
bytes[] memory calldatas,
|
||||
string memory description
|
||||
) public override(Governor, GovernorTimelockAccess) returns (uint256) {
|
||||
return super.propose(targets, values, calldatas, description);
|
||||
}
|
||||
|
||||
function _queueOperations(
|
||||
uint256 proposalId,
|
||||
address[] memory targets,
|
||||
uint256[] memory values,
|
||||
bytes[] memory calldatas,
|
||||
bytes32 descriptionHash
|
||||
) internal override(Governor, GovernorTimelockAccess) returns (uint48) {
|
||||
return super._queueOperations(proposalId, targets, values, calldatas, descriptionHash);
|
||||
}
|
||||
|
||||
function _executeOperations(
|
||||
uint256 proposalId,
|
||||
address[] memory targets,
|
||||
uint256[] memory values,
|
||||
bytes[] memory calldatas,
|
||||
bytes32 descriptionHash
|
||||
) internal override(Governor, GovernorTimelockAccess) {
|
||||
super._executeOperations(proposalId, targets, values, calldatas, descriptionHash);
|
||||
}
|
||||
|
||||
function _cancel(
|
||||
address[] memory targets,
|
||||
uint256[] memory values,
|
||||
bytes[] memory calldatas,
|
||||
bytes32 descriptionHash
|
||||
) internal override(Governor, GovernorTimelockAccess) returns (uint256) {
|
||||
return super._cancel(targets, values, calldatas, descriptionHash);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
pragma solidity ^0.8.20;
|
||||
|
||||
import {IGovernor, Governor} from "../../governance/Governor.sol";
|
||||
import {GovernorTimelockCompound} from "../../governance/extensions/GovernorTimelockCompound.sol";
|
||||
import {GovernorSettings} from "../../governance/extensions/GovernorSettings.sol";
|
||||
import {GovernorCountingSimple} from "../../governance/extensions/GovernorCountingSimple.sol";
|
||||
import {GovernorVotesQuorumFraction} from "../../governance/extensions/GovernorVotesQuorumFraction.sol";
|
||||
|
||||
abstract contract GovernorTimelockCompoundMock is
|
||||
GovernorSettings,
|
||||
GovernorTimelockCompound,
|
||||
GovernorVotesQuorumFraction,
|
||||
GovernorCountingSimple
|
||||
{
|
||||
function quorum(uint256 blockNumber) public view override(Governor, GovernorVotesQuorumFraction) returns (uint256) {
|
||||
return super.quorum(blockNumber);
|
||||
}
|
||||
|
||||
function state(
|
||||
uint256 proposalId
|
||||
) public view override(Governor, GovernorTimelockCompound) returns (ProposalState) {
|
||||
return super.state(proposalId);
|
||||
}
|
||||
|
||||
function proposalThreshold() public view override(Governor, GovernorSettings) returns (uint256) {
|
||||
return super.proposalThreshold();
|
||||
}
|
||||
|
||||
function proposalNeedsQueuing(
|
||||
uint256 proposalId
|
||||
) public view virtual override(Governor, GovernorTimelockCompound) returns (bool) {
|
||||
return super.proposalNeedsQueuing(proposalId);
|
||||
}
|
||||
|
||||
function _queueOperations(
|
||||
uint256 proposalId,
|
||||
address[] memory targets,
|
||||
uint256[] memory values,
|
||||
bytes[] memory calldatas,
|
||||
bytes32 descriptionHash
|
||||
) internal override(Governor, GovernorTimelockCompound) returns (uint48) {
|
||||
return super._queueOperations(proposalId, targets, values, calldatas, descriptionHash);
|
||||
}
|
||||
|
||||
function _executeOperations(
|
||||
uint256 proposalId,
|
||||
address[] memory targets,
|
||||
uint256[] memory values,
|
||||
bytes[] memory calldatas,
|
||||
bytes32 descriptionHash
|
||||
) internal override(Governor, GovernorTimelockCompound) {
|
||||
super._executeOperations(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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
pragma solidity ^0.8.20;
|
||||
|
||||
import {IGovernor, Governor} from "../../governance/Governor.sol";
|
||||
import {GovernorTimelockControl} from "../../governance/extensions/GovernorTimelockControl.sol";
|
||||
import {GovernorSettings} from "../../governance/extensions/GovernorSettings.sol";
|
||||
import {GovernorCountingSimple} from "../../governance/extensions/GovernorCountingSimple.sol";
|
||||
import {GovernorVotesQuorumFraction} from "../../governance/extensions/GovernorVotesQuorumFraction.sol";
|
||||
|
||||
abstract contract GovernorTimelockControlMock is
|
||||
GovernorSettings,
|
||||
GovernorTimelockControl,
|
||||
GovernorVotesQuorumFraction,
|
||||
GovernorCountingSimple
|
||||
{
|
||||
function quorum(uint256 blockNumber) public view override(Governor, GovernorVotesQuorumFraction) returns (uint256) {
|
||||
return super.quorum(blockNumber);
|
||||
}
|
||||
|
||||
function state(uint256 proposalId) public view override(Governor, GovernorTimelockControl) returns (ProposalState) {
|
||||
return super.state(proposalId);
|
||||
}
|
||||
|
||||
function proposalThreshold() public view override(Governor, GovernorSettings) returns (uint256) {
|
||||
return super.proposalThreshold();
|
||||
}
|
||||
|
||||
function proposalNeedsQueuing(
|
||||
uint256 proposalId
|
||||
) public view virtual override(Governor, GovernorTimelockControl) returns (bool) {
|
||||
return super.proposalNeedsQueuing(proposalId);
|
||||
}
|
||||
|
||||
function _queueOperations(
|
||||
uint256 proposalId,
|
||||
address[] memory targets,
|
||||
uint256[] memory values,
|
||||
bytes[] memory calldatas,
|
||||
bytes32 descriptionHash
|
||||
) internal override(Governor, GovernorTimelockControl) returns (uint48) {
|
||||
return super._queueOperations(proposalId, targets, values, calldatas, descriptionHash);
|
||||
}
|
||||
|
||||
function _executeOperations(
|
||||
uint256 proposalId,
|
||||
address[] memory targets,
|
||||
uint256[] memory values,
|
||||
bytes[] memory calldatas,
|
||||
bytes32 descriptionHash
|
||||
) internal override(Governor, GovernorTimelockControl) {
|
||||
super._executeOperations(proposalId, targets, values, calldatas, descriptionHash);
|
||||
}
|
||||
|
||||
function _cancel(
|
||||
address[] memory targets,
|
||||
uint256[] memory values,
|
||||
bytes[] memory calldatas,
|
||||
bytes32 descriptionHash
|
||||
) internal override(Governor, GovernorTimelockControl) returns (uint256) {
|
||||
return super._cancel(targets, values, calldatas, descriptionHash);
|
||||
}
|
||||
|
||||
function _executor() internal view override(Governor, GovernorTimelockControl) returns (address) {
|
||||
return super._executor();
|
||||
}
|
||||
|
||||
function nonGovernanceFunction() external {}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
pragma solidity ^0.8.20;
|
||||
|
||||
import {GovernorCountingSimple} from "../../governance/extensions/GovernorCountingSimple.sol";
|
||||
import {GovernorVotes} from "../../governance/extensions/GovernorVotes.sol";
|
||||
|
||||
abstract contract GovernorVoteMocks is GovernorVotes, GovernorCountingSimple {
|
||||
function quorum(uint256) public pure override returns (uint256) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
function votingDelay() public pure override returns (uint256) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
function votingPeriod() public pure override returns (uint256) {
|
||||
return 16;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
pragma solidity ^0.8.20;
|
||||
|
||||
import {Governor} from "../../governance/Governor.sol";
|
||||
import {GovernorCountingSimple} from "../../governance/extensions/GovernorCountingSimple.sol";
|
||||
import {GovernorVotes} from "../../governance/extensions/GovernorVotes.sol";
|
||||
|
||||
abstract contract GovernorWithParamsMock is GovernorVotes, GovernorCountingSimple {
|
||||
event CountParams(uint256 uintParam, string strParam);
|
||||
|
||||
function quorum(uint256) public pure override returns (uint256) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
function votingDelay() public pure override returns (uint256) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
function votingPeriod() public pure override returns (uint256) {
|
||||
return 16;
|
||||
}
|
||||
|
||||
function _getVotes(
|
||||
address account,
|
||||
uint256 blockNumber,
|
||||
bytes memory params
|
||||
) internal view override(Governor, GovernorVotes) returns (uint256) {
|
||||
uint256 reduction = 0;
|
||||
// If the user provides parameters, we reduce the voting weight by the amount of the integer param
|
||||
if (params.length > 0) {
|
||||
(reduction, ) = abi.decode(params, (uint256, string));
|
||||
}
|
||||
// reverts on overflow
|
||||
return super._getVotes(account, blockNumber, params) - reduction;
|
||||
}
|
||||
|
||||
function _countVote(
|
||||
uint256 proposalId,
|
||||
address account,
|
||||
uint8 support,
|
||||
uint256 weight,
|
||||
bytes memory params
|
||||
) internal override(Governor, GovernorCountingSimple) {
|
||||
if (params.length > 0) {
|
||||
(uint256 _uintParam, string memory _strParam) = abi.decode(params, (uint256, string));
|
||||
emit CountParams(_uintParam, _strParam);
|
||||
}
|
||||
return super._countVote(proposalId, account, support, weight, params);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user