Skip to content

Commit

Permalink
Add new web-app (citizen v2) draft (#176)
Browse files Browse the repository at this point in the history
Why:
 - We want to implement a new revamped UI built upon the latest
   developments of web3 libraries

This change addresses the need by:
- Bootstraping a next14 app
- Using rainbowkit, wagmi & viem to interface with user wallets
- Use idOs sdk to perform KYC of users

---------

Co-authored-by: Davide Silva <[email protected]>
  • Loading branch information
luistorres and DavideSilva authored Apr 1, 2024
1 parent 527265f commit 9c3ca01
Show file tree
Hide file tree
Showing 257 changed files with 11,073 additions and 19,408 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/contracts-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ jobs:
- run: yarn install
- run: yarn workspace @discovery-dao/contracts compile
- run: yarn workspace @discovery-dao/contracts lint
- run: yarn workspace @discovery-dao/contracts test
# temporarily disable this while we migrate from acala and hardhat
# - run: yarn workspace @discovery-dao/contracts test

- name: Run Slither
uses: crytic/[email protected]
Expand Down
28 changes: 17 additions & 11 deletions .github/workflows/web-test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Web - Test Suite
name: Web-app - Test Suite

on:
pull_request:
Expand All @@ -21,26 +21,32 @@ jobs:
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: '20.11.1'
registry-url: 'https://npm.pkg.github.com'
node-version: "20.11.1"
registry-url: "https://npm.pkg.github.com"

- name: Setup module dependencies cache
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}

- uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Install module dependencies
run: yarn install --frozen-lockfile
run: yarn install --frozen-lockfile

- name: Lint javascript
run: yarn workspace @discovery-dao/web lint:js
- name: Lint next
run: yarn workspace @discovery-dao/web-app lint:next

- name: Lint styles
run: yarn workspace @discovery-dao/web lint:styles
- name: Generate wagmi
run: yarn workspace @discovery-dao/contracts wagmi:generate

- name: Lint types
run: yarn workspace @discovery-dao/web lint:types
run: yarn workspace @discovery-dao/web-app lint:tsc

- name: Build
run: yarn workspace @discovery-dao/web build
run: yarn workspace @discovery-dao/web-app build
env:
NEXT_PUBLIC_WC_PROJECT_ID: ${{ secrets.NEXT_PUBLIC_WC_PROJECT_ID }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ yarn-error.log*

# typescript
tsconfig.tsbuildinfo

# MacOs files
.DS_Store
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"workspaces": {
"packages": [
"packages/contracts",
"packages/web",
"packages/web-app",
"packages/dev"
],
"nohoist": [
Expand All @@ -23,14 +23,13 @@
"scripts": {
"dev": "yarn workspace @discovery-dao/dev all",
"dev:contracts": "yarn workspace @discovery-dao/contracts dev",
"dev:web": "yarn workspace @discovery-dao/web start",
"dev:web": "yarn workspace @discovery-dao/web-app dev",
"contracts:export": "yarn workspace @discovery-dao/contracts export",
"contracts:compile": "yarn workspace @discovery-dao/contracts compile",
"prepare": "husky install",
"pre-commit": "yarn workspace @discovery-dao/web precommit",
"web:bundle": "yarn workspace @discovery-dao/web bundle",
"web:lint": "yarn workspace @discovery-dao/web lint",
"web:copy:contracts": "yarn workspace @discovery-dao/web copy:contracts"
"pre-commit": "yarn workspace @discovery-dao/web-app precommit",
"web:bundle": "yarn workspace @discovery-dao/web-app bundle",
"web:lint": "yarn workspace @discovery-dao/web-app lint"
},
"devDependencies": {
"husky": "^7.0.2"
Expand Down
3 changes: 2 additions & 1 deletion packages/contracts/.prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ artifacts
cache
typechain-types
deployments
src/types
src/types
lib
2 changes: 1 addition & 1 deletion packages/contracts/.prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"plugins": ["../../node_modules/prettier-plugin-solidity"],
"plugins": ["prettier-plugin-solidity"],
"overrides": [
{
"files": "*.js",
Expand Down
8 changes: 3 additions & 5 deletions packages/contracts/contracts/RisingTide/RisingTide.sol
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,9 @@ abstract contract RisingTide {
* @param _amount amount to apply cap to
* @return capped amount
*/
function risingTide_applyCap(uint256 _amount)
public
view
returns (uint256)
{
function risingTide_applyCap(
uint256 _amount
) public view returns (uint256) {
if (!risingTide_isValidCap()) {
return 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@ contract TestRisingTideWithCustomAmounts is RisingTide {
return totalInvestors;
}

function investorAmountAt(uint256 i)
public
view
override(RisingTide)
returns (uint256)
{
function investorAmountAt(
uint256 i
) public view override(RisingTide) returns (uint256) {
return investors[i];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,9 @@ contract TestRisingTideWithStaticAmounts is RisingTide {
return totalInvestors;
}

function investorAmountAt(uint256 i)
public
view
override(RisingTide)
returns (uint256)
{
function investorAmountAt(
uint256 i
) public view override(RisingTide) returns (uint256) {
return allZeros[i] + amountPerInvestor;
}

Expand Down
36 changes: 16 additions & 20 deletions packages/contracts/contracts/discovery/Batch.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ contract Batch is IBatch, ICommon, ProjectVoting {
_;
}

constructor(address[] memory _projects, uint256 _slotCount)
ProjectVoting(_projects)
{
constructor(
address[] memory _projects,
uint256 _slotCount
) ProjectVoting(_projects) {
uint256 numProjects = _projects.length;
require(numProjects > 0, "projects must not be empty");
require(_slotCount > 0, "slotCount must be greater than 0");
Expand Down Expand Up @@ -108,7 +109,7 @@ contract Batch is IBatch, ICommon, ProjectVoting {
override(ProjectVoting)
returns (int256)
{
return 0.05 * 10**18;
return 0.05 * 10 ** 18;
}

function projectVoting_finalBonus()
Expand All @@ -135,11 +136,10 @@ contract Batch is IBatch, ICommon, ProjectVoting {
return slotCount;
}

function hasVotedForProject(address _user, address _project)
external
view
returns (bool)
{
function hasVotedForProject(
address _user,
address _project
) external view returns (bool) {
return userHasVotedForProject[_project][_user];
}

Expand All @@ -161,11 +161,10 @@ contract Batch is IBatch, ICommon, ProjectVoting {
investmentEnd = votingPeriod.end + extraInvestmentDuration;
}

function vote(address projectAddress, bytes32[] calldata _merkleProof)
external
votingPeriodIsSet
inVotingPeriod
{
function vote(
address projectAddress,
bytes32[] calldata _merkleProof
) external votingPeriodIsSet inVotingPeriod {
require(
IController(controller).canVote(msg.sender, _merkleProof),
"not allowed to vote"
Expand All @@ -183,12 +182,9 @@ contract Batch is IBatch, ICommon, ProjectVoting {
return _getWinners();
}

function getProjectStatus(address projectAddress)
external
view
votingPeriodIsSet
returns (ProjectStatus)
{
function getProjectStatus(
address projectAddress
) external view votingPeriodIsSet returns (ProjectStatus) {
address[] memory computedWinners = _getWinners();

for (uint256 i = 0; i < computedWinners.length; i++) {
Expand Down
85 changes: 32 additions & 53 deletions packages/contracts/contracts/discovery/Controller.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@ contract Controller is IController, ERC165, AccessControl {
// Merkle root to pass to the projects
bytes32 public merkleRoot;

constructor(
address _staking,
address _token,
bytes32 _merkleRoot
) {
constructor(address _staking, address _token, bytes32 _merkleRoot) {
staking = _staking;
token = _token;
merkleRoot = _merkleRoot;
Expand Down Expand Up @@ -95,11 +91,10 @@ contract Controller is IController, ERC165, AccessControl {
}

/// @inheritdoc IController
function createBatch(address[] calldata _projects, uint256 _slotCount)
external
override(IController)
onlyRole(BATCH_MANAGER_ROLE)
{
function createBatch(
address[] calldata _projects,
uint256 _slotCount
) external override(IController) onlyRole(BATCH_MANAGER_ROLE) {
IBatch batch = new Batch(_projects, _slotCount);

uint256 len = _projects.length;
Expand All @@ -119,12 +114,10 @@ contract Controller is IController, ERC165, AccessControl {
}

/// @inheritdoc IController
function isProjectInBatch(address _project, address _batch)
external
view
override(IController)
returns (bool)
{
function isProjectInBatch(
address _project,
address _batch
) external view override(IController) returns (bool) {
return projectsToBatches[_project] == _batch;
}

Expand Down Expand Up @@ -153,12 +146,10 @@ contract Controller is IController, ERC165, AccessControl {
batch.userHasVotedForProject(_project, _user);
}

function canVote(address _user, bytes32[] calldata _merkleProof)
external
view
override(IController)
returns (bool)
{
function canVote(
address _user,
bytes32[] calldata _merkleProof
) external view override(IController) returns (bool) {
return _hasKYC(_user, _merkleProof) && _belongsToDAO(_user);
}

Expand All @@ -172,11 +163,10 @@ contract Controller is IController, ERC165, AccessControl {
Batch(batch).setVotingPeriod(start, end, extraInvestmentDuration);
}

function _hasKYC(address _user, bytes32[] calldata _merkleProof)
internal
view
returns (bool)
{
function _hasKYC(
address _user,
bytes32[] calldata _merkleProof
) internal view returns (bool) {
bytes32 leaf = keccak256(abi.encodePacked(_user));
bool isValid = MerkleProof.verify(_merkleProof, merkleRoot, leaf);

Expand All @@ -194,29 +184,23 @@ contract Controller is IController, ERC165, AccessControl {
//

// Checks if a given account has the PROJECT_MANAGER_ROLE role
function hasProjectManagerRole(address _account)
external
view
returns (bool)
{
function hasProjectManagerRole(
address _account
) external view returns (bool) {
return hasRole(PROJECT_MANAGER_ROLE, _account);
}

// Checks if a given account has the BATCH_MANAGER_ROLE role
function hasBatchManagerRole(address _account)
external
view
returns (bool)
{
function hasBatchManagerRole(
address _account
) external view returns (bool) {
return hasRole(BATCH_MANAGER_ROLE, _account);
}

// Checks if a given account has the LEGAL_MANAGER_ROLE role
function hasLegalManagerRole(address _account)
external
view
returns (bool)
{
function hasLegalManagerRole(
address _account
) external view returns (bool) {
return hasRole(BATCH_MANAGER_ROLE, _account);
}

Expand All @@ -225,11 +209,9 @@ contract Controller is IController, ERC165, AccessControl {
//

/// @inheritdoc IController
function getBatchForProject(address _project)
external
view
returns (address)
{
function getBatchForProject(
address _project
) external view returns (address) {
return projectsToBatches[_project];
}

Expand All @@ -238,12 +220,9 @@ contract Controller is IController, ERC165, AccessControl {
//

/// @inheritdoc ERC165
function supportsInterface(bytes4 interfaceId)
public
view
override(ERC165, AccessControl)
returns (bool)
{
function supportsInterface(
bytes4 interfaceId
) public view override(ERC165, AccessControl) returns (bool) {
return
interfaceId == type(IController).interfaceId ||
super.supportsInterface(interfaceId);
Expand Down
Loading

0 comments on commit 9c3ca01

Please sign in to comment.