Skip to content

Commit

Permalink
Work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
brickpop committed Jan 15, 2025
1 parent 6a4fbc4 commit ed980b5
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 25 deletions.
18 changes: 14 additions & 4 deletions src/LockManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ pragma solidity ^0.8.13;
import {ILockManager, LockManagerSettings, UnlockMode, PluginMode} from "./interfaces/ILockManager.sol";
import {IDAO} from "@aragon/osx-commons-contracts/src/dao/IDAO.sol";
import {DaoAuthorizable} from "@aragon/osx-commons-contracts/src/permission/auth/DaoAuthorizable.sol";
import {ILockToVoteBase, VoteOption} from "./interfaces/ILockToVote.sol";
import {ILockToVoteBase} from "./interfaces/ILockToVote.sol";
import {ILockToApprove} from "./interfaces/ILockToApprove.sol";
import {ILockToVote} from "./interfaces/ILockToVote.sol";
import {IMajorityVoting} from "./interfaces/IMajorityVoting.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";

Expand Down Expand Up @@ -112,7 +113,10 @@ contract LockManager is ILockManager, DaoAuthorizable {
}

/// @inheritdoc ILockManager
function lockAndVote(uint256 _proposalId, VoteOption _voteOption) public {
function lockAndVote(
uint256 _proposalId,
IMajorityVoting.VoteOption _voteOption
) public {
if (settings.pluginMode != PluginMode.VOTING) {
revert InvalidPluginMode();
}
Expand All @@ -132,7 +136,10 @@ contract LockManager is ILockManager, DaoAuthorizable {
}

/// @inheritdoc ILockManager
function vote(uint256 _proposalId, VoteOption _voteOption) public {
function vote(
uint256 _proposalId,
IMajorityVoting.VoteOption _voteOption
) public {
if (settings.pluginMode != PluginMode.VOTING) {
revert InvalidPluginMode();
}
Expand Down Expand Up @@ -272,7 +279,10 @@ contract LockManager is ILockManager, DaoAuthorizable {
);
}

function _vote(uint256 _proposalId, VoteOption _voteOption) internal {
function _vote(
uint256 _proposalId,
IMajorityVoting.VoteOption _voteOption
) internal {
uint256 _currentVotingPower = lockedBalances[msg.sender];
if (_currentVotingPower == 0) {
revert NoBalance();
Expand Down
2 changes: 1 addition & 1 deletion src/LockToApprovePlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity ^0.8.13;

import {ILockManager} from "./interfaces/ILockManager.sol";
import {ILockToVoteBase, VoteOption} from "./interfaces/ILockToVote.sol";
import {ILockToVoteBase} from "./interfaces/ILockToVote.sol";
import {ILockToApprove, LockToApproveSettings, ProposalApproval, ProposalApprovalParameters} from "./interfaces/ILockToApprove.sol";
import {IDAO} from "@aragon/osx-commons-contracts/src/dao/IDAO.sol";
import {ProposalUpgradeable} from "@aragon/osx-commons-contracts/src/plugin/extensions/proposal/ProposalUpgradeable.sol";
Expand Down
16 changes: 1 addition & 15 deletions src/LockToVotePlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,14 @@ import {SafeCastUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/mat
import {_applyRatioCeiled} from "@aragon/osx-commons-contracts/src/utils/math/Ratio.sol";
import {MajorityVotingBase} from "./base/MajorityVotingBase.sol";

contract LockToVotePlugin is
ILockToVote,
IMembership,
MajorityVotingBase
{
contract LockToVotePlugin is ILockToVote, IMembership, MajorityVotingBase {
using SafeCastUpgradeable for uint256;

LockToVoteSettings public settings;

/// @inheritdoc ILockToVoteBase
ILockManager public lockManager;

mapping(uint256 => ProposalVoting) proposals;

/// @notice The ID of the permission required to call the `createProposal` functions.
bytes32 public constant CREATE_PROPOSAL_PERMISSION_ID =
keccak256("CREATE_PROPOSAL_PERMISSION");

/// @notice The ID of the permission required to call the `execute` function.
bytes32 public constant EXECUTE_PROPOSAL_PERMISSION_ID =
keccak256("EXECUTE_PROPOSAL_PERMISSION");

/// @notice The ID of the permission required to call the `execute` function.
bytes32 public constant LOCK_MANAGER_PERMISSION_ID =
keccak256("LOCK_MANAGER_PERMISSION");
Expand Down
2 changes: 0 additions & 2 deletions src/base/MajorityVotingBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -312,15 +312,13 @@ abstract contract MajorityVotingBase is
/// @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.
/// @param _minApprovals The minimal amount of approvals the proposal needs to succeed.
/// @param _pluginMetadata The plugin specific information encoded in bytes.
/// This can also be an ipfs cid encoded in bytes.
// solhint-disable-next-line func-name-mixedcase
function __MajorityVotingBase_init(
IDAO _dao,
VotingSettings calldata _votingSettings,
TargetConfig calldata _targetConfig,
uint256 _minApprovals,
bytes calldata _pluginMetadata
) internal onlyInitializing {
__PluginUUPSUpgradeable_init(_dao);
Expand Down
7 changes: 4 additions & 3 deletions src/interfaces/ILockManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

pragma solidity ^0.8.17;

import {ILockToVoteBase, VoteOption} from "./ILockToVote.sol";
import {ILockToVoteBase} from "./ILockToVoteBase.sol";
import {IMajorityVoting} from "./IMajorityVoting.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

/// @notice Defines whether locked funds can be unlocked at any time or not
Expand Down Expand Up @@ -53,15 +54,15 @@ interface ILockManager {

/// @notice Locks the balance currently allowed by msg.sender on this contract and registers the given vote on the target plugin
/// @param proposalId The ID of the proposal where the vote will be registered
function lockAndVote(uint256 proposalId, VoteOption vote) external;
function lockAndVote(uint256 proposalId, IMajorityVoting.VoteOption vote) external;

/// @notice Uses the locked balance to place an approval on the given proposal for the registered plugin
/// @param proposalId The ID of the proposal where the approval will be registered
function approve(uint256 proposalId) external;

/// @notice Uses the locked balance to place the given vote on the given proposal for the registered plugin
/// @param proposalId The ID of the proposal where the vote will be registered
function vote(uint256 proposalId, VoteOption vote) external;
function vote(uint256 proposalId, IMajorityVoting.VoteOption vote) external;

/// @notice Checks if an account can participate on a proposal. This can be because the proposal
/// - has not started,
Expand Down

0 comments on commit ed980b5

Please sign in to comment.