Skip to content

Commit

Permalink
First build
Browse files Browse the repository at this point in the history
  • Loading branch information
brickpop committed Dec 18, 2024
1 parent a008ce3 commit e4d9d4c
Show file tree
Hide file tree
Showing 13 changed files with 334 additions and 168 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Lock to Vote Plugin - OSx
# Lock to Vote Plugin

This reposity contains the codebase of the Lock to Vote plugin, along with its helper contract.
NOTE: This is a work in progress plugin, early alpha stage. The contracts haven't been reviewed, tested or audited yet. DO NOT USE on any serious deployment.

## Overview
This reposity contains the codebase of the Lock to Vote plugin for OSx, along with its helper contract.

This is a work in progress
## Overview

## Get Started

Expand Down
4 changes: 2 additions & 2 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/
@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/
@aragon/osx/=lib/osx/packages/contracts/src/
@aragon/osx-commons-contracts/=lib/osx-commons/contracts/src/
@aragon/osx/=lib/osx/packages/contracts/
@aragon/osx-commons-contracts/=lib/osx-commons/contracts/
@ensdomains/ens-contracts/=lib/ens-contracts/
forge-std/=lib/forge-std/src/
10 changes: 4 additions & 6 deletions script/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
pragma solidity ^0.8.17;

import {Script, console} from "forge-std/Script.sol";
import {DAO} from "@aragon/osx/core/dao/DAO.sol";
import {DAO} from "@aragon/osx/src/core/dao/DAO.sol";
import {IVotesUpgradeable} from "@openzeppelin/contracts-upgradeable/governance/utils/IVotesUpgradeable.sol";
import {GovernanceERC20} from "@aragon/osx/token/ERC20/governance/GovernanceERC20.sol";
import {GovernanceWrappedERC20} from "@aragon/osx/token/ERC20/governance/GovernanceWrappedERC20.sol";
import {LockToVotePluginSetup} from "../src/setup/LockToVotePluginSetup.sol";
import {PluginRepoFactory} from "@aragon/osx/framework/plugin/repo/PluginRepoFactory.sol";
import {PluginSetupProcessor} from "@aragon/osx/framework/plugin/setup/PluginSetupProcessor.sol";
import {GovernanceERC20Mock} from "../test/mocks/GovernanceERC20Mock.sol";
import {PluginRepoFactory} from "@aragon/osx/src/framework/plugin/repo/PluginRepoFactory.sol";
import {PluginSetupProcessor} from "@aragon/osx/src/framework/plugin/setup/PluginSetupProcessor.sol";
import {TestToken} from "../test/mocks/TestToken.sol";

contract Deploy is Script {
LockToVotePluginSetup lockToVotePluginSetup;
Expand Down
31 changes: 12 additions & 19 deletions src/LockManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
pragma solidity ^0.8.13;

import {ILockManager, LockManagerSettings, UnlockMode} from "./interfaces/ILockManager.sol";
import {IDAO} from "@aragon/osx/core/dao/IDAO.sol";
import {DaoAuthorizable} from "@aragon/osx/core/plugin/dao-authorizable/DaoAuthorizable.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 {ILockToVote} from "./interfaces/ILockToVote.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

Expand All @@ -18,7 +18,7 @@ contract LockManager is ILockManager, DaoAuthorizable {
IERC20 public immutable token;

/// @notice Keeps track of the amount of tokens locked by address
mapping(address => uint256) lockedBalances;
mapping(address => uint256) public lockedBalances;

/// @notice Keeps a list of the known active proposal ID's
/// @dev Executed proposals will be actively reported, but defeated proposals will need to be garbage collected over time.
Expand Down Expand Up @@ -72,22 +72,17 @@ contract LockManager is ILockManager, DaoAuthorizable {
_vote(_proposalId);
}

/// @inheritdoc ILockManager
function vote(uint256 _proposalId) public {
_vote(_proposalId);
}

/// @inheritdoc ILockManager
function canVote(
uint256 _proposalId,
address _voter
) external view returns (bool) {
uint256 availableBalance = lockedBalances[_voter] -
plugin.usedVotingPower(_proposalId, _voter);
if (availableBalance == 0) return false;

(bool open, bool executed, ) = plugin.getProposal(_proposalId);
return !executed && open;
}

/// @inheritdoc ILockManager
function vote(uint256 _proposalId) public {
_vote(_proposalId);
return plugin.canVote(_proposalId, _voter);
}

/// @inheritdoc ILockManager
Expand Down Expand Up @@ -152,11 +147,10 @@ contract LockManager is ILockManager, DaoAuthorizable {
plugin.vote(_proposalId, msg.sender, _newVotingPower);
}

function _hasActiveLocks() internal returns (bool) {
function _hasActiveLocks() internal returns (bool _activeLocks) {
uint256 _proposalCount = knownProposalIds.length;
for (uint256 _i; _i < _proposalCount; ) {
(bool open, ) = plugin.getProposal(knownProposalIds[_i]);
if (!open) {
if (!plugin.isProposalOpen(knownProposalIds[_i])) {
_removeKnownProposalId(_i);
_proposalCount = knownProposalIds.length;

Expand All @@ -182,8 +176,7 @@ contract LockManager is ILockManager, DaoAuthorizable {
function _withdrawActiveVotingPower() internal {
uint256 _proposalCount = knownProposalIds.length;
for (uint256 _i; _i < _proposalCount; ) {
(bool open, ) = plugin.getProposal(knownProposalIds[_i]);
if (!open) {
if (!plugin.isProposalOpen(knownProposalIds[_i])) {
_removeKnownProposalId(_i);
_proposalCount = knownProposalIds.length;

Expand Down
Loading

0 comments on commit e4d9d4c

Please sign in to comment.