Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RingDAO use tally #31

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

## Deployments
```sh
Depoist: 0x46275d29113f065c2aac262f34C7a3d8a8B7377D
gRING: 0xdafa555e2785DC8834F4Ea9D1ED88B6049142999
Hub: 0xa4fFAC7A5Da311D724eD47393848f694Baee7930
Depoist: 0x46275d29113f065c2aac262f34C7a3d8a8B7377D
gRING: 0xdafa555e2785DC8834F4Ea9D1ED88B6049142999
Hub: 0xa4fFAC7A5Da311D724eD47393848f694Baee7930
RingDAO: 0x52cDD25f7C83c335236Ce209fA1ec8e197E96533
Timelock: 0x4DCf0f14cC58fc2Bf313e70573dDB7309523bb23
```


53 changes: 53 additions & 0 deletions script/Tally.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {Script} from "forge-std/Script.sol";
import {safeconsole} from "forge-std/safeconsole.sol";
import {Upgrades} from "openzeppelin-foundry-upgrades/Upgrades.sol";
import {Options} from "openzeppelin-foundry-upgrades/Options.sol";

import {RingDAOTimelockController} from "../src/governance/RingDAOTimelockController.sol";
import {RingDAO, IVotes, TimelockControllerUpgradeable} from "../src/governance/RingDAO.sol";

contract TallyScript is Script {
address gRING = 0xdafa555e2785DC8834F4Ea9D1ED88B6049142999;
address timelock = 0x4DCf0f14cC58fc2Bf313e70573dDB7309523bb23;

function run() public {
vm.startBroadcast();

// deploy RingDAO
address ringDAO_PROXY = Upgrades.deployTransparentProxy(
"RingDAO.sol:RingDAO",
timelock,
abi.encodeCall(
RingDAO.initialize,
(
IVotes(gRING),
TimelockControllerUpgradeable(payable(timelock)),
1 days,
hujw77 marked this conversation as resolved.
Show resolved Hide resolved
2 weeks,
1_000_000 * 1e18,
"RingDAO"
)
)
);
safeconsole.log("RingDAO: ", ringDAO_PROXY);
safeconsole.log("RingDAO_Logic: ", Upgrades.getImplementationAddress(ringDAO_PROXY));

// deploy RingDAOTimelock
address[] memory roles = new address[](1);
roles[0] = ringDAO_PROXY;
address timelock_PROXY = Upgrades.deployTransparentProxy(
"RingDAOTimelockController.sol:RingDAOTimelockController",
timelock,
abi.encodeCall(RingDAOTimelockController.initialize, (1 days, roles, roles, address(0)))
);
safeconsole.log("Timelock: ", timelock_PROXY);
safeconsole.log("Timelock_Logic: ", Upgrades.getImplementationAddress(timelock_PROXY));

require(timelock == timelock_PROXY, "!timelock");

vm.stopBroadcast();
}
}
117 changes: 117 additions & 0 deletions src/governance/RingDAO.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;

import "@openzeppelin/contracts-upgradeable/governance/GovernorUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/governance/extensions/GovernorSettingsUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/governance/extensions/GovernorCountingSimpleUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/governance/extensions/GovernorVotesUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/governance/extensions/GovernorTimelockControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";

contract RingDAO is
Initializable,
GovernorUpgradeable,
GovernorSettingsUpgradeable,
GovernorCountingSimpleUpgradeable,
GovernorVotesUpgradeable,
GovernorTimelockControlUpgradeable
{
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
}

function initialize(
IVotes token,
TimelockControllerUpgradeable timelock,
uint48 initialVotingDelay,
uint32 initialVotingPeriod,
uint256 initialProposalThreshold,
string memory name
) public initializer {
__Governor_init(name);
__GovernorSettings_init(initialVotingDelay, initialVotingPeriod, initialProposalThreshold);
__GovernorCountingSimple_init();
__GovernorVotes_init(token);
__GovernorTimelockControl_init(timelock);
}

// The following functions are overrides required by Solidity.

function quorum(uint256) public view virtual override returns (uint256) {
return 40_000_000 * 1e18;
}

function votingDelay() public view override(GovernorUpgradeable, GovernorSettingsUpgradeable) returns (uint256) {
return super.votingDelay();
}

function votingPeriod() public view override(GovernorUpgradeable, GovernorSettingsUpgradeable) returns (uint256) {
return super.votingPeriod();
}

function state(uint256 proposalId)
public
view
override(GovernorUpgradeable, GovernorTimelockControlUpgradeable)
returns (ProposalState)
{
return super.state(proposalId);
}

function proposalNeedsQueuing(uint256 proposalId)
public
view
override(GovernorUpgradeable, GovernorTimelockControlUpgradeable)
returns (bool)
{
return super.proposalNeedsQueuing(proposalId);
}

function proposalThreshold()
public
view
override(GovernorUpgradeable, GovernorSettingsUpgradeable)
returns (uint256)
{
return super.proposalThreshold();
}

function _queueOperations(
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) internal override(GovernorUpgradeable, GovernorTimelockControlUpgradeable) 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(GovernorUpgradeable, GovernorTimelockControlUpgradeable) {
super._executeOperations(proposalId, targets, values, calldatas, descriptionHash);
}

function _cancel(
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) internal override(GovernorUpgradeable, GovernorTimelockControlUpgradeable) returns (uint256) {
return super._cancel(targets, values, calldatas, descriptionHash);
}

function _executor()
internal
view
override(GovernorUpgradeable, GovernorTimelockControlUpgradeable)
returns (address)
{
return super._executor();
}
}
46 changes: 46 additions & 0 deletions src/governance/RingDAOTimelockController.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/governance/TimelockControllerUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/extensions/AccessControlEnumerableUpgradeable.sol";

contract RingDAOTimelockController is
Initializable,
TimelockControllerUpgradeable,
AccessControlEnumerableUpgradeable
{
function initialize(uint256 minDelay, address[] memory proposers, address[] memory executors, address admin)
public
initializer
{
__TimelockController_init(minDelay, proposers, executors, admin);
__AccessControlEnumerable_init();
}

function _grantRole(bytes32 role, address account)
internal
override(AccessControlUpgradeable, AccessControlEnumerableUpgradeable)
returns (bool)
{
return super._grantRole(role, account);
}

function _revokeRole(bytes32 role, address account)
internal
override(AccessControlUpgradeable, AccessControlEnumerableUpgradeable)
returns (bool)
{
return super._revokeRole(role, account);
}

function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(TimelockControllerUpgradeable, AccessControlEnumerableUpgradeable)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
}
Loading