Skip to content
Open
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
Binary file modified .DS_Store
Binary file not shown.
9 changes: 0 additions & 9 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,3 @@
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
[submodule "lib/semaphore-mock"]
path = lib/semaphore-mock
url = https://github.com/worldcoin/semaphore-mock
[submodule "lib/openzeppelin-foundry-upgrades"]
path = lib/openzeppelin-foundry-upgrades
url = https://github.com/OpenZeppelin/openzeppelin-foundry-upgrades
[submodule "lib/openzeppelin-contracts-upgradeable"]
path = lib/openzeppelin-contracts-upgradeable
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable
166 changes: 39 additions & 127 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,154 +1,66 @@
# Governaut Contracts Repository
## Foundry

## Overview
**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.**

Governaut is a decentralized identity and governance dashboard that integrates decentralized identity verification, governance tools, and attestation systems. This repository contains the smart contracts that form the backbone of the Governaut platform, facilitating governance interactions, identity verification, and community project funding through integration with Celo's onchain mechanisms.
Foundry consists of:

## Table of Contents
- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools).
- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network.
- **Chisel**: Fast, utilitarian, and verbose solidity REPL.

- [Governaut Contracts Repository](#governaut-contracts-repository)
- [Overview](#overview)
- [Table of Contents](#table-of-contents)
- [Getting Started](#getting-started)
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Contracts Overview](#contracts-overview)
- [Contract 1: GovernanceContract](#contract-1-governancecontract)
- [Description](#description)
- [Key Features](#key-features)
- [Functions Overview](#functions-overview)
- [Constructor](#constructor)
- [Propose](#propose)
- [Execute](#execute)
- [CastVote](#castvote)
- [IsApprovedProposer](#isapprovedproposer)
- [Security Considerations](#security-considerations)
- [Recap](#recap)
- [License](#license)
## Documentation

## Getting Started
https://book.getfoundry.sh/

To get a copy of the project up and running on your local machine for development and testing purposes, follow these steps.
## Usage

### Prerequisites

Ensure you have the following prerequisites installed:

- Solidity compiler (solc 0.8.24)
- Foundry for development and testing
- Anvil or another local blockchain for testing

### Installation

Clone the repository to your local machine:

`git clone https://github.com/GovernautDao/contracts.git`

Install dependencies:

`forge install`

Compile the contracts:

`forge build`


## Contracts Overview

### Contract 1: GovernanceContract

#### Description

The `GovernautGovernance` contract is a sophisticated governance system designed for managing grant-related proposals within the Governaut ecosystem. Leveraging OpenZeppelin's governance contracts, it extends various functionalities to integrate seamlessly with an Identity Manager, ensuring that only verified identities can participate in governance actions. This contract plays a pivotal role in democratizing decision-making processes by allowing token holders to propose, vote on, and execute proposals.

### Key Features

- Identity Verification: Utilizes an external Identity Manager to verify the identity of participants, ensuring that only verified users can create proposals and cast votes.
- Proposal Creation and Voting: Allows verified users to submit proposals for community consideration and enables voting on these proposals using a simple majority counting mechanism.
- Quorum Requirements: Implements quorum requirements to ensure a minimum level of voter participation for proposal execution.
- Approved Proposers Tracking: Maintains a record of approved proposers, marking them once their proposal has been successfully executed.

### Functions Overview

#### Constructor
### Build

```shell
$ forge build
```
constructor(
IVotes _token,
address _identityManagerAddress
)
```

Initializes the contract with the ERC20 token used for voting and the address of the Identity Manager contract.

#### Propose
### Test

```shell
$ forge test
```
function propose(
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
string memory description
)
public
override(Governor)
onlyVerifiedIdentity
returns (uint256)
```

Allows a verified user to create a new governance proposal specifying target contracts, call values, call data, and a description.

#### Execute
### Format

```shell
$ forge fmt
```
function execute(
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
)
public
payable
virtual
override(Governor)
returns (uint256)
```

Executes a successful proposal after the voting period ends, provided it meets the quorum and passes the vote.

#### CastVote
### Gas Snapshots

```shell
$ forge snapshot
```
function castVote(
uint256 proposalId,
uint8 support
)
public
virtual
override(Governor)
onlyVerifiedIdentity
returns (uint256)
```

Enables a verified user to cast a vote on a proposal, supporting, opposing, or abstaining.

#### IsApprovedProposer
### Anvil

```shell
$ anvil
```
function isApprovedProposer(address proposer) public view returns (bool)
```

Checks if an address has been marked as an approved proposer after successfully executing a proposal.

### Security Considerations
### Deploy

- Identity Verification: Ensures that only verified users can participate in governance actions, mitigating risks associated with anonymous participation.
- Access Control: Utilizes modifiers to restrict certain functions to verified identities, enhancing security and integrity of the governance process.
```shell
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>
```

### Recap
### Cast

The GovernautGovernance contract represents a robust framework for decentralized decision-making within the Governaut ecosystem. By integrating identity verification and leveraging OpenZeppelin's battle-tested governance modules, it facilitates secure, transparent, and community-driven governance processes.
```shell
$ cast <subcommand>
```

## License
### Help

Distributed under the MIT License.
```shell
$ forge --help
$ anvil --help
$ cast --help
```
1 change: 1 addition & 0 deletions World Id Bridge
Submodule World Id Bridge added at 729d23
369 changes: 369 additions & 0 deletions broadcast/Deploy_MetalL2Testnet.s.sol/919/run-1723362711.json

Large diffs are not rendered by default.

369 changes: 369 additions & 0 deletions broadcast/Deploy_MetalL2Testnet.s.sol/919/run-latest.json

Large diffs are not rendered by default.

286 changes: 286 additions & 0 deletions broadcast/Deploy_ModeTestnet.s.sol/919/run-1723382852.json

Large diffs are not rendered by default.

286 changes: 286 additions & 0 deletions broadcast/Deploy_ModeTestnet.s.sol/919/run-latest.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/forge-std
1 change: 0 additions & 1 deletion lib/openzeppelin-contracts-upgradeable
Submodule openzeppelin-contracts-upgradeable deleted from 723f8c
1 change: 0 additions & 1 deletion lib/openzeppelin-foundry-upgrades
Submodule openzeppelin-foundry-upgrades deleted from 4cd15f
1 change: 0 additions & 1 deletion lib/semaphore-mock
Submodule semaphore-mock deleted from 761e3b
12 changes: 12 additions & 0 deletions script/Counter.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {Script, console} from "forge-std/Script.sol";

contract CounterScript is Script {
function setUp() public {}

function run() public {
vm.broadcast();
}
}
File renamed without changes.
54 changes: 54 additions & 0 deletions script/Deploy_MetalL2Testnet.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {console} from "forge-std/console.sol";
import "forge-std/Script.sol";
import "../src/Governance Tools/GovernautGovernance.sol";
import "../src/Identity Management/IdentityManager.sol";
import "../src/Onchain Funding/Funding.sol";
import {IVotes} from "@openzeppelin/contracts/governance/utils/IVotes.sol";
import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
import {HelperConfig} from "../script/HelperConfig.s.sol";

contract MyScript is Script {
HelperConfig helperConfig;
IdentityManager identitymanager;
Funding funding;
GovernautGovernance governance;

function run() external {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
helperConfig = new HelperConfig();
address governancetoken = helperConfig
.getOpSepoliaConfig()
._governanceToken;
console.log(governancetoken);
vm.startBroadcast(deployerPrivateKey);

identitymanager = new IdentityManager(
helperConfig.getOpSepoliaConfig()._WorldcoinRouterAddress,
helperConfig.getOpSepoliaConfig()._appid,
helperConfig.getOpSepoliaConfig()._actionId
);

console.log("Identity Manager Address :", address(identitymanager));

governance = new GovernautGovernance(
IVotes(governancetoken),
address(identitymanager)
);

console.log("Governaut Governance Address :", address(governance));

funding = new Funding(
vm.addr(deployerPrivateKey),
address(governance),
governancetoken
);

console.log("Funding Address :", address(funding));

vm.stopBroadcast();
}
}
62 changes: 62 additions & 0 deletions script/Deploy_ModeTestnet.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.24;

import {console} from "forge-std/console.sol";
import "forge-std/Script.sol";
import "../src/Governance Tools/GovernautGovernance.sol";
import "../src/Identity Management/IdentityManager.sol";
import "../src/Governance Tools/GovernanceToken.sol";
import {IVotes} from "@openzeppelin/contracts/governance/utils/IVotes.sol";
import {HelperConfig} from "./HelperConfig.s.sol";
import {Funding} from "../src/Onchain Funding//Funding.sol";

contract DeployContracts is Script {
HelperConfig helperConfig;
IdentityManager identityManager;
GovernautGovernance governance;
GovernanceToken governanceToken;
Funding funding;

function run() external {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
address deployer = vm.addr(deployerPrivateKey);
helperConfig = new HelperConfig();

console.log("Deploying contracts...");

vm.startBroadcast(deployerPrivateKey);

// Deploy GovernanceToken
governanceToken = new GovernanceToken(deployer, 1_000_000 * 10 ** 18); // 1 million tokens with 18 decimals
console.log("GovernanceToken deployed at:", address(governanceToken));

// Deploy IdentityManager
HelperConfig.Config memory config = helperConfig.getBaseSepoliaConfig(); // Or use the appropriate network
// config
identityManager = new IdentityManager(
0xe95f2fCF682712CAf5fB44C9608d33dbac6B536B,
config._appid,
config._actionId
);
console.log("IdentityManager deployed at:", address(identityManager));

// Deploy GovernautGovernance
governance = new GovernautGovernance(
IVotes(address(governanceToken)),
address(identityManager)
);
console.log("GovernautGovernance deployed at:", address(governance));

// Deploy Funding
funding = new Funding(
vm.addr(deployerPrivateKey),
address(governance),
address(governanceToken)
);
console.log("Funding deployed at:", address(funding));

vm.stopBroadcast();

console.log("All contracts deployed successfully.");
}
}
File renamed without changes.
Loading