generated from defi-wonderland/solidity-foundry-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add readme and deploy scripts
Signed-off-by: 0xRaccoon <[email protected]>
- Loading branch information
Showing
5 changed files
with
109 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,146 +1,62 @@ | ||
<img src="https://raw.githubusercontent.com/defi-wonderland/brand/v1.0.0/external/solidity-foundry-boilerplate-banner.png" alt="wonderland banner" align="center" /> | ||
<br /> | ||
# Wonderland Governor | ||
|
||
<div align="center"><strong>Start your next Solidity project with Foundry in seconds</strong></div> | ||
<div align="center">A highly scalable foundation focused on DX and best practices</div> | ||
⚠️ The code has not been audited yet, tread with caution. | ||
|
||
<br /> | ||
## Overview | ||
|
||
## Features | ||
Wonderland Governor is a DAO governance solution designed to address the current limitations in delegation within governance protocols. Unlike old systems where users give all their voting power to one delegate, it offers a flexible solution, introducing innovative features to empower users and enhance governance processes in decentralized organizations. | ||
|
||
<dl> | ||
<dt>Sample contracts</dt> | ||
<dd>Basic Greeter contract with an external interface.</dd> | ||
Key Features: | ||
|
||
<dt>Foundry setup</dt> | ||
<dd>Foundry configuration with multiple custom profiles and remappings.</dd> | ||
Proposal Types: | ||
|
||
<dt>Deployment scripts</dt> | ||
<dd>Sample scripts to deploy contracts on both mainnet and testnet.</dd> | ||
Wonderland Governor lets organizations set different types of proposals for specific needs like legal or technical matters. | ||
Every proposal now has a required type, making it clear which category it falls into. | ||
|
||
<dt>Sample e2e & unit tests</dt> | ||
<dd>Example tests showcasing mocking, assertions and configuration for mainnet forking. As well it includes everything needed in order to check code coverage.</dd> | ||
Better Delegation: | ||
|
||
<dt>Linter</dt> | ||
<dd>Simple and fast solidity linting thanks to forge fmt</a>.</dd> | ||
Users can now spread their voting power across different categories. | ||
Users can choose multiple delegates for each proposal type, assigning a percentage of their voting power to each. | ||
Users can still delegate 100% of their voting power to one person if they prefer. | ||
|
||
<dt>Github workflows CI</dt> | ||
<dd>Run all tests and see the coverage as you push your changes.</dd> | ||
<dd>Export your Solidity interfaces and contracts as packages, and publish them to NPM.</dd> | ||
</dl> | ||
Wonderland Governor is founded on the OpenZeppelin contracts and enhances their functionalities to achieve the described features. | ||
|
||
## Setup | ||
|
||
1. Install Foundry by following the instructions from [their repository](https://github.com/foundry-rs/foundry#installation). | ||
2. Copy the `.env.example` file to `.env` and fill in the variables. | ||
3. Install the dependencies by running: `yarn install`. In case there is an error with the commands, run `foundryup` and try them again. | ||
This project uses [Foundry](https://book.getfoundry.sh/). To build it locally, run: | ||
|
||
## Build | ||
|
||
The default way to build the code is suboptimal but fast, you can run it via: | ||
|
||
```bash | ||
```sh | ||
git clone [email protected]:defi-wonderland/wonderland-governooor-poc.git | ||
cd wonderland-governooor-poc | ||
yarn install | ||
yarn build | ||
``` | ||
|
||
In order to build a more optimized code ([via IR](https://docs.soliditylang.org/en/v0.8.15/ir-breaking-changes.html#solidity-ir-based-codegen-changes)), run: | ||
|
||
```bash | ||
yarn build:optimized | ||
``` | ||
|
||
## Running tests | ||
|
||
Unit tests should be isolated from any externalities, while E2E usually run in a fork of the blockchain. In this boilerplate you will find example of both. | ||
|
||
In order to run both unit and E2E tests, run: | ||
|
||
```bash | ||
yarn test | ||
``` | ||
|
||
In order to just run unit tests, run: | ||
|
||
```bash | ||
yarn test:unit | ||
``` | ||
|
||
In order to run unit tests and run way more fuzzing than usual (5x), run: | ||
|
||
```bash | ||
yarn test:unit:deep | ||
``` | ||
|
||
In order to just run e2e tests, run: | ||
|
||
```bash | ||
yarn test:e2e | ||
``` | ||
|
||
In order to check your current code coverage, run: | ||
### Available Commands | ||
|
||
```bash | ||
yarn coverage | ||
``` | ||
|
||
<br> | ||
|
||
## Deploy & verify | ||
|
||
### Setup | ||
|
||
Configure the `.env` variables. | ||
Make sure to set `OPTIMISM_RPC` environment variable before running end-to-end tests. | ||
|
||
### Goerli | ||
|
||
```bash | ||
yarn deploy:goerli | ||
``` | ||
|
||
### Mainnet | ||
|
||
```bash | ||
yarn deploy:mainnet | ||
``` | ||
| Yarn Command | Description | | ||
| ----------------------- | ---------------------------------------------------------- | | ||
| `yarn build` | Compile all contracts. | | ||
| `yarn coverage` | See `forge coverage` report. | | ||
| `yarn deploy:local` | Deploy the contracts to a local fork. | | ||
| `yarn deploy:goerli` | Deploy the contracts to Goerli testnet. | | ||
| `yarn deploy:optimism` | Deploy the contracts to Optimism mainnet. | | ||
| `yarn deploy:mainnet` | Deploy the contracts to Ethereum mainnet. | | ||
| `yarn test` | Run all unit and integration tests. | | ||
| `yarn test:unit` | Run unit tests. | | ||
| `yarn test:integration` | Run integration tests. | | ||
| `yarn test:gas` | Run all unit and integration tests, and make a gas report. | | ||
|
||
The deployments are stored in ./broadcast | ||
## Licensing | ||
|
||
See the [Foundry Book for available options](https://book.getfoundry.sh/reference/forge/forge-create.html). | ||
The primary license for Wonderland Governor contracts is MIT, see [`LICENSE`](./LICENSE). | ||
|
||
## Export And Publish | ||
## Contributors | ||
|
||
Export TypeScript interfaces from Solidity contracts and interfaces providing compatibility with TypeChain. Publish the exported packages to NPM. | ||
Wonderland Governor was built with ❤️ by [Wonderland](https://defi.sucks). | ||
|
||
To enable this feature, make sure you've set the `NPM_TOKEN` on your org's secrets. Then set the job's conditional to `true`: | ||
|
||
```yaml | ||
solidity-exporter.yml | ||
|
||
jobs: | ||
export: | ||
name: Generate Interfaces And Contracts | ||
# Remove the following line if you wish to export your Solidity contracts and interfaces and publish them to NPM | ||
if: true | ||
... | ||
``` | ||
|
||
Also, remember to update the `package_name` param to your package name: | ||
|
||
```yaml | ||
solidity-exporter.yml | ||
|
||
- name: Export Solidity - ${{ matrix.export_type }} | ||
uses: defi-wonderland/solidity-exporter-action@1dbf5371c260add4a354e7a8d3467e5d3b9580b8 | ||
with: | ||
# Update package_name with your package name | ||
package_name: "my-cool-project" | ||
... | ||
|
||
|
||
- name: Publish to NPM - ${{ matrix.export_type }} | ||
# Update `my-cool-project` with your package name | ||
run: cd export/my-cool-project-${{ matrix.export_type }} && npm publish --access public | ||
... | ||
``` | ||
Wonderland is a team of top Web3 researchers, developers, and operators who believe that the future needs to be open-source, permissionless, and decentralized. | ||
|
||
You can take a look at our [solidity-exporter-action](https://github.com/defi-wonderland/solidity-exporter-action) repository more information and usage examples. | ||
[DeFi sucks](https://defi.sucks), but Wonderland is here to make it better. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,56 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.20; | ||
|
||
import {Script} from 'forge-std/Script.sol'; | ||
import {IWonderGovernor} from 'interfaces/governance/IWonderGovernor.sol'; | ||
import {IWonderVotes} from 'interfaces/governance/utils/IWonderVotes.sol'; | ||
import {AliceGovernor} from 'examples/AliceGovernor.sol'; | ||
import {RabbitToken} from 'examples/RabbitToken.sol'; | ||
|
||
import {Script, console} from 'forge-std/Script.sol'; | ||
|
||
abstract contract Deploy is Script { | ||
function _deploy() internal { | ||
vm.startBroadcast(); | ||
// Deploy the contract | ||
function _deploy(address _deployer) internal { | ||
vm.startBroadcast(_deployer); | ||
|
||
// Deploy the contracts | ||
address tokenAddress = vm.computeCreateAddress(_deployer, vm.getNonce(_deployer) + 1); | ||
AliceGovernor governor = new AliceGovernor(tokenAddress); | ||
console.log('WonderGovernor:', address(governor)); | ||
RabbitToken rabbitToken = new RabbitToken(AliceGovernor(payable(address(governor)))); | ||
console.log('WonderVotes:', address(rabbitToken)); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
} | ||
|
||
contract DeployMainnet is Deploy { | ||
function run() external { | ||
_deploy(); | ||
address _deployer = vm.rememberKey(vm.envUint('MAINNET_DEPLOYER_PK')); | ||
|
||
_deploy(_deployer); | ||
} | ||
} | ||
|
||
contract DeployGoerli is Deploy { | ||
function run() external { | ||
_deploy(); | ||
address _deployer = vm.rememberKey(vm.envUint('GOERLI_DEPLOYER_PK')); | ||
|
||
_deploy(_deployer); | ||
} | ||
} | ||
|
||
contract DeployLocal is Deploy { | ||
function run() external { | ||
address _deployer = vm.rememberKey(vm.envUint('LOCAL_DEPLOYER_PK')); | ||
|
||
_deploy(_deployer); | ||
} | ||
} | ||
|
||
contract DeployOptimism is Deploy { | ||
function run() external { | ||
address _deployer = vm.rememberKey(vm.envUint('OPTIMISM_DEPLOYER_PK')); | ||
|
||
_deploy(_deployer); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -801,6 +801,26 @@ dot-prop@^5.1.0: | |
dependencies: | ||
is-obj "^2.0.0" | ||
|
||
[email protected]: | ||
version "7.2.1" | ||
resolved "https://registry.yarnpkg.com/dotenv-cli/-/dotenv-cli-7.2.1.tgz#e595afd9ebfb721df9da809a435b9aa966c92062" | ||
integrity sha512-ODHbGTskqRtXAzZapDPvgNuDVQApu4oKX8lZW7Y0+9hKA6le1ZJlyRS687oU9FXjOVEDU/VFV6zI125HzhM1UQ== | ||
dependencies: | ||
cross-spawn "^7.0.3" | ||
dotenv "^16.0.0" | ||
dotenv-expand "^10.0.0" | ||
minimist "^1.2.6" | ||
|
||
dotenv-expand@^10.0.0: | ||
version "10.0.0" | ||
resolved "https://registry.yarnpkg.com/dotenv-expand/-/dotenv-expand-10.0.0.tgz#12605d00fb0af6d0a592e6558585784032e4ef37" | ||
integrity sha512-GopVGCpVS1UKH75VKHGuQFqS1Gusej0z4FyQkPdwjil2gNIv+LNsqBlboOzpJFZKVT95GkCyWJbBSdFEFUWI2A== | ||
|
||
dotenv@^16.0.0: | ||
version "16.3.1" | ||
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.3.1.tgz#369034de7d7e5b120972693352a3bf112172cc3e" | ||
integrity sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ== | ||
|
||
"ds-test@github:dapphub/ds-test#e282159": | ||
version "1.0.0" | ||
resolved "https://codeload.github.com/dapphub/ds-test/tar.gz/e282159d5170298eb2455a6c05280ab5a73a4ef0" | ||
|