TempleDAO / temple

Temple Monorepo
GNU Affero General Public License v3.0
61 stars 29 forks source link

Temple Monorepo

Getting Started

Requirements

This repository uses .nvmrc to dictate the version of node required to compile and run the project. This will allow you to use nvm followed by either nvm use or nvm install to automatically set the right version of node in that terminal session.

If developing on Windows, some scripts are currently written in bash so WSL is recommended to run those. For most developments tasks you'll likely only need to run the steps in Protocol local deployment and Dapp.

Quick Start

This script is still experimental so your mileage may vary

At the root of the project, running yarn run:stack will attempt to:

The script groups the child processes so issuing a single SIGINT (ctrl+c) should stop all the processes.

Requirements:

Contracts (/Protocol)

Local Deployment

The protocol app uses hardhat for development. The following steps will compile the contracts and deploy to a local hardhat node

# Enter the correct dir
cd apps/protocol

# Compile the contracts
yarn compile

# In one terminal window, run a local-node
yarn local-node

# In another window, run the deploy script
yarn local-deploy

The protocol test suite can be run without deploying to a local-node by running

# Run tests, no deployment necessary
yarn test

Rinkeby Deployment

export RINKEBY_ADDRESS_PRIVATE_KEY=...  # export from metamask
export RINKEBY_RPC_URL=...      # grab RPC url from metamask or create a relayer on alchemy

yarn hardhat:testnet run scripts/deploys/rinkeby/{your-script-name}

Once successfully deployed on testnet, verify contract source on etherscan. If you use the deployAndMine helper when creating your script, it will spit out the relevant command. It will look something like this

yarn hardhat verify --network rinkeby 0x359655dcB8A32479680Af81Eb38eA3Bb2B42Af54 

It's fine to have multiple versions of a contract on rinkeby, so it's okay to run before your PR is merged (and re-run if there are any comments on the PR on how to best setup the deploy scripts).

You can also run and test locally by replacing yarn hardhat:testnet with yarn hardhat:local in the protocol directory. You'll probably have to run some of the previous deploys in order to setup the right local state

Dapp

The Dapp uses Vite but we've created some convenience methods on top. In order to properly communicate with the contracts deployed on the local node we need to update your .env.local file. Make a copy of the env.local.example and rename it to .env.local. Once the steps in Protocol Local Deployment have been completed, the deploy job output all the deployed contract addresses deployed to your local network in the correct Vite env var format. Copy these values and paste them into your .env.local file.

# Enter the correct dir
cd apps/dapp

# Run the dapp in dev mode
yarn dev

# Alternatively, you can compile the dapp and run in 'production' mode locally
yarn build

yarn serve

Vercel

The integration with Vercel has changed. Because this is a monorepo, we have one parent folder with multiple subfolders as the apps that need to be deployed. Further complicating matters is that some apps that use typescript need to reference the parent folder since the tsconfig files source the parent one. To address this and other issues, this is how the vercel integration is setup: