Skip to content

Commit

Permalink
fix update natspecs
Browse files Browse the repository at this point in the history
  • Loading branch information
Rekard0 committed Nov 11, 2024
1 parent 89f34a9 commit f92c1e0
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 24 deletions.
2 changes: 1 addition & 1 deletion packages/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@types/chai": "^4.3.4",
"@types/mocha": "^10.0.0",
"@types/node": "^18.11.9",
"solidity-docgen": "^0.6.0-beta.35",
"solidity-docgen": "^0.6.0-beta.36",
"chai": "^4.3.7",
"cross-env": "^7.0.3",
"dotenv": "^16.3.1",
Expand Down
3 changes: 2 additions & 1 deletion packages/contracts/src/IMajorityVoting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ interface IMajorityVoting {
/// $$\texttt{participation} = \frac{N_\text{yes}+N_\text{no}+N_\text{abstain}}{N_\text{total}}$$
/// for a proposal is greater or equal than the minimum participation value.
/// @param _proposalId The ID of the proposal.
/// @return Returns `true` if the participation is greater or equal than the minimum participation and `false` otherwise.
/// @return Returns `true` if the participation is greater or equal than the minimum participation,
/// and `false` otherwise.
function isMinParticipationReached(uint256 _proposalId) external view returns (bool);

/// @notice Checks if the min approval value defined as:
Expand Down
33 changes: 18 additions & 15 deletions packages/contracts/src/MajorityVotingBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,12 @@ abstract contract MajorityVotingBase is
/// @param voters The votes casted by the voters.
/// @param actions The actions to be executed when the proposal passes.
/// @param allowFailureMap A bitmap allowing the proposal to succeed, even if individual actions might revert.
/// @param minApprovalPower The minimum amount of yes votes power needed for the proposal advance.
/// If the bit at index `i` is 1, the proposal succeeds even if the `i`th action reverts.
/// A failure map value of 0 requires every action to not revert.
/// @param minApprovalPower The minimum amount of yes votes power needed for the proposal advance.
/// @param targetConfig Configuration for the execution target, specifying the target address and operation type
/// (either `Call` or `DelegateCall`). Defined by `TargetConfig` in the `IPlugin` interface,
/// part of the `osx-commons-contracts` package, added in build 3.
struct Proposal {
bool executed;
ProposalParameters parameters;
Expand All @@ -190,7 +193,7 @@ abstract contract MajorityVotingBase is
/// @param startDate The start date of the proposal vote.
/// @param endDate The end date of the proposal vote.
/// @param snapshotBlock The number of the block prior to the proposal creation.
/// @param minVotingPower The minimum voting power needed.
/// @param minVotingPower The minimum voting power needed for a proposal to reach minimum participation.
struct ProposalParameters {
VotingMode votingMode;
uint32 supportThreshold;
Expand Down Expand Up @@ -504,12 +507,12 @@ abstract contract MajorityVotingBase is
/// @return The total voting power.
function totalVotingPower(uint256 _blockNumber) public view virtual returns (uint256);

/// @notice Returns all information for a proposal vote by its ID.
/// @notice Returns all information for a proposal by its ID.
/// @param _proposalId The ID of the proposal.
/// @return open Whether the proposal is open or not.
/// @return executed Whether the proposal is executed or not.
/// @return parameters The parameters of the proposal vote.
/// @return tally The current tally of the proposal vote.
/// @return parameters The parameters of the proposal.
/// @return tally The current tally of the proposal.
/// @return actions The actions to be executed in the associated DAO after the proposal has passed.
/// @return allowFailureMap The bit map representations of which actions are allowed to revert so tx still succeeds.
function getProposal(
Expand Down Expand Up @@ -578,7 +581,7 @@ abstract contract MajorityVotingBase is
bool _tryEarlyExecution
) external virtual returns (uint256 proposalId);

/// @notice Internal function to cast a vote. It assumes the queried vote exists.
/// @notice Internal function to cast a vote. It assumes the queried proposal exists.
/// @param _proposalId The ID of the proposal.
/// @param _voteOption The chosen vote option to be casted on the proposal vote.
/// @param _tryEarlyExecution If `true`, early execution is tried after the vote cast.
Expand All @@ -590,7 +593,7 @@ abstract contract MajorityVotingBase is
bool _tryEarlyExecution
) internal virtual;

/// @notice Internal function to execute a vote. It assumes the queried proposal exists.
/// @notice Internal function to execute a proposal. It assumes the queried proposal exists.
/// @param _proposalId The ID of the proposal.
function _execute(uint256 _proposalId) internal virtual {
Proposal storage proposal_ = proposals[_proposalId];
Expand Down Expand Up @@ -664,9 +667,9 @@ abstract contract MajorityVotingBase is
return _hasSucceeded(_proposalId);
}

/// @notice Internal function to check if a proposal vote is still open.
/// @notice Internal function to check if a proposal is still open.
/// @param proposal_ The proposal struct.
/// @return True if the proposal vote is open, false otherwise.
/// @return True if the proposal is open, false otherwise.
function _isProposalOpen(Proposal storage proposal_) internal view virtual returns (bool) {
uint64 currentTime = block.timestamp.toUint64();

Expand All @@ -676,7 +679,7 @@ abstract contract MajorityVotingBase is
!proposal_.executed;
}

/// @notice Internal function to update the plugin-wide proposal vote settings.
/// @notice Internal function to update the plugin-wide proposal settings.
/// @param _votingSettings The voting settings to be validated and updated.
function _updateVotingSettings(VotingSettings calldata _votingSettings) internal virtual {
// Require the support threshold value to be in the interval [0, 10^6-1],
Expand Down Expand Up @@ -733,12 +736,12 @@ abstract contract MajorityVotingBase is
emit VotingMinApprovalUpdated(_minApprovals);
}

/// @notice Validates and returns the proposal vote dates.
/// @param _start The start date of the proposal vote.
/// @notice Validates and returns the proposal dates.
/// @param _start The start date of the proposal.
/// If 0, the current timestamp is used and the vote starts immediately.
/// @param _end The end date of the proposal vote. If 0, `_start + minDuration` is used.
/// @return startDate The validated start date of the proposal vote.
/// @return endDate The validated end date of the proposal vote.
/// @param _end The end date of the proposal. If 0, `_start + minDuration` is used.
/// @return startDate The validated start date of the proposal.
/// @return endDate The validated end date of the proposal.
function _validateProposalDates(
uint64 _start,
uint64 _end
Expand Down
13 changes: 7 additions & 6 deletions packages/contracts/src/TokenVotingSetup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,19 @@ contract TokenVotingSetup is PluginUpgradeableSetup {
// solhint-disable-next-line immutable-vars-naming
address public immutable governanceWrappedERC20Base;

/// @notice The token settings struct.
/// @param addr The token address. If this is `address(0)`, a new `GovernanceERC20` token is deployed.
/// If not, the existing token is wrapped as an `GovernanceWrappedERC20`.
/// @param name The token name. This parameter is only relevant if the token address is `address(0)`.
/// @param symbol The token symbol. This parameter is only relevant if the token address is `address(0)`.
/// @notice Configuration settings for a token used within the governance system.
/// @param addr The token address. If set to `address(0)`, a new `GovernanceERC20` token is deployed.
/// If the address implements `IVotes`, it will be used directly; otherwise,
/// it is wrapped as `GovernanceWrappedERC20`.
/// @param name The name of the token, relevant only if a new token is deployed (i.e., `addr` is `address(0)`).
/// @param symbol The symbol of the token, relevant only if a new token is deployed (i.e., `addr` is `address(0)`).
struct TokenSettings {
address addr;
string name;
string symbol;
}

/// @notice Thrown if token address is passed which is not a token.
/// @notice Thrown if the passed token address is not a token contract.
/// @param token The token address
error TokenNotContract(address token);

Expand Down
14 changes: 14 additions & 0 deletions packages/contracts/src/VotingPowerCondition.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,31 @@ import {TokenVoting} from "./TokenVoting.sol";
import {IERC20Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import {IVotesUpgradeable} from "@openzeppelin/contracts-upgradeable/governance/utils/IVotesUpgradeable.sol";

import {IPermissionCondition} from "@aragon/osx-commons-contracts/src/permission/condition/IPermissionCondition.sol";
import {PermissionCondition} from "@aragon/osx-commons-contracts/src/permission/condition/PermissionCondition.sol";

/// @title VotingPowerCondition
/// @notice Checks if an account's voting power or token balance meets the threshold set
/// in an associated TokenVoting plugin.
/// @author Aragon X - 2024
/// @custom:security-contact [email protected]
contract VotingPowerCondition is PermissionCondition {
/// @notice The address of the `TokenVoting` plugin used to fetch voting power settings.
TokenVoting private immutable TOKEN_VOTING;

/// @notice The `IVotesUpgradeable` token interface used to check token balance.
IVotesUpgradeable private immutable VOTING_TOKEN;

/// @notice Initializes the contract with the `TokenVoting` plugin address and fetches the associated token.
/// @param _tokenVoting The address of the `TokenVoting` plugin.
constructor(address _tokenVoting) {
TOKEN_VOTING = TokenVoting(_tokenVoting);
VOTING_TOKEN = TOKEN_VOTING.getVotingToken();
}

/// @inheritdoc IPermissionCondition
/// @dev The function checks both the voting power and token balance to ensure `_who` meets the minimum voting
/// threshold defined in the `TokenVoting` plugin. Returns `false` if the minimum requirement is unmet.
function isGranted(
address _where,
address _who,
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6597,7 +6597,7 @@ solidity-coverage@^0.8.2:
shelljs "^0.8.3"
web3-utils "^1.3.6"

solidity-docgen@^0.6.0-beta.35:
solidity-docgen@^0.6.0-beta.36:
version "0.6.0-beta.36"
resolved "https://registry.yarnpkg.com/solidity-docgen/-/solidity-docgen-0.6.0-beta.36.tgz#9c76eda58580fb52e2db318c22fe3154e0c09dd1"
integrity sha512-f/I5G2iJgU1h0XrrjRD0hHMr7C10u276vYvm//rw1TzFcYQ4xTOyAoi9oNAHRU0JU4mY9eTuxdVc2zahdMuhaQ==
Expand Down

0 comments on commit f92c1e0

Please sign in to comment.