decentraland / governance

🏢 Governance platform of the Decentraland DAO
https://governance.decentraland.org
Other
45 stars 36 forks source link
blockchain dao dapp decentraland ethereum hacktoberfest web3

Decentraland

Decentraland DAO Governance dApp

The governance hub for the Decentraland ecosystem. Create and vote on proposals that help shape the future of the metaverse via the Decentraland DAO (Decentralized Autonomous Organization).

Screenshot of the governance hub for Decentraland homepage

Setup

Before you start make sure you have installed:

Node version

use node >= 18

If you are starting from scratch and you don't have Node installed in your computer, we recommend using a Node version manager like nvm to install Node.js and npm instead of the Node installer.

nvm install v18.8.0 will install node version 18 and the corresponding npm version.

NOTE

If you are using WSL (Windows Subsystem for Linux) as your development environment, clone the repository into the WSL filesystem. If you clone it inside the Windows filesystem, the project will not work.

Run npm install to install all the dependencies needed to run the project.

Environment setup

Create a copy of .env.example and name it as .env.development

  cp .env.example .env.development

If you are running this project locally you only need to check the following environment variables:

Setup the required voting power to pass

The minimum amount of voting power require to pass a proposal of each type it's defined in these variables, if they are not defined or are not numbers 0 will be used instead

  GATSBY_VOTING_POWER_TO_PASS_LINKED_WEARABLES=0
  GATSBY_VOTING_POWER_TO_PASS_CATALYST=0
  GATSBY_VOTING_POWER_TO_PASS_BAN_NAME=0
  GATSBY_VOTING_POWER_TO_PASS_POI=0
  GATSBY_VOTING_POWER_TO_PASS_POLL=0

Database setup

Make sure you have Postgres installed and running:

brew install postgresql@14
brew services start postgresql@14
createdb

You can create a DB from scratch, or you can use the import-db.sh script to create a new DB using the development.dump dump.

Importing DB dump

cd scripts/
bash ./import-db.sh USERNAME [DATABASE_NAME] [DUMP_FILE]

If no DATABASE_NAME and DUMP_FILE arguments are given, the script will use the default values and create a governance db using the development.dump dump. The CONNECTION_STRING should look like this:

postgres://USERNAME:PASSWORD@localhost:5432/governance

(the default password should be postgres)

Creating DB from scratch

To create a DB, run in the terminal

createdb -U YOUR_USER DATABASE_NAME

The default postgres user is postgres or your username, and the default password is postgres. Use your user and password for the connection string variable, it should look like this:

postgres://YOUR_USER:YOUR_PASSWORD@localhost:5432/DATABASE_NAME

Once you have a CONNECTION_STRING you can set up your database tables using the following command:

npm run migrate up

Snapshot Setup

Creating a Snapshot space

You are going to need to register an ENS name in the network you'll create the space in. Follow instructions on Snapshot.

Strategy

If you need MANA for testing you can get it by interacting with the contract on etherscan

Sepolia Faucet

Sepolia FakeMana

Connect your wallet and use the mint method on the Contract -> Write Contract section

Take into account that the voting power distribution response from snapshot returns an array with each voting power. The order in which each value is returned depends on the order in which strategies are added to the space on the space settings

Current Strategies Order

Test

To run the tests you can do

npm test

or create a run configuration in your IDE with jest --no-cache --no-watchman --runInBand

Also, you can try adding the --verbose option.

The --runInBand parameter runs the tests in a single thread, which is usually faster, but you can try without it and see what works best for you.

Run

Once you setup this project you can start it using the following command

  npm start

Note 1: this project run over https, if it is your first time you might need to run it with sudo

Note 2: you can disabled https removing the --https flag in the develop script of your package.json

the app should be running at https://localhost:4000/

About

Routes

The routes are defined using express you can find each route in src/routes and those are imported at src/server.ts

Types and Utils

Types and Utils contain functions and types that will be useful across the whole project.

Proposals statuses

Voting results

Copyright & License

This repository is protected with a standard Apache 2 license. See the terms and conditions in the LICENSE file.