Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README: Add development instructions #114

Merged
merged 6 commits into from
Apr 13, 2024
Merged
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
47 changes: 46 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,46 @@
# BOLD
# Liquity v2

## Requirements

- [Node.js](https://nodejs.org/)
- [pnpm](https://pnpm.io/)
- [Foundry](https://book.getfoundry.sh/getting-started/installation)

## Setup

```sh
git clone git@github.com:liquity/bold.git
cd bold
pnpm install
```

## How to develop

```sh
# Run the anvil local node (keep it running in a separate terminal):
anvil

# First, the contracts:
cd contracts

# Build & deploy the contracts:
./deploy local --open-demo-troves # optionally open troves for the first 8 anvil accounts

# Print the addresses of the deployed contracts:
pnpm tsx utils/deployment-artifacts-to-app-env.ts deployment-context-latest.json

# We are now ready to pass the deployed contracts to the app:
cd ../frontend

# Copy the example .env file:
cp .env .env.local

# Edit the .env.local file:
# - Make sure the Hardhat / Anvil section is uncommented.
# - Copy into it the addresses printed by command above.

# Run the app development server:
pnpm dev

# You can now open https://localhost:3000 in your browser.
```
25 changes: 19 additions & 6 deletions contracts/utils/deployment-artifacts-to-app-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,23 @@ import { z } from "zod";
import { argv, echo, fs } from "zx";

const HELP = `
converts the deployment artifacts created by ./deploy into environment
variables to be used by the Next.js app located in frontend/.
Converts the deployment artifacts created by ./deploy into environment variables
to be used by the Next.js app located in frontend/.

Usage:
./deployment-artifacts-to-app-env.ts <INPUT_JSON> <OUTPUT_ENV> [OPTIONS]
./deployment-artifacts-to-app-env.ts <INPUT_JSON> [OUTPUT_ENV] [OPTIONS]

Arguments:
INPUT_JSON Path to the deployment artifacts
JSON file.
OUTPUT_ENV Path to the environment variables
file to write. If not provided, it
writes to stdout.

Options:
--help, -h Show this help message.
--append Append to the output file instead of overwriting it.
--append Append to the output file instead of
overwriting it (requires OUTPUT_ENV).
`;

const ZAddress = z.string().regex(/^0x[0-9a-fA-F]{40}$/);
Expand All @@ -35,8 +43,8 @@ export async function main() {
process.exit(0);
}

if (!options.inputJsonPath || !options.outputEnvPath) {
console.error("\nInvalid number of arguments provided (--help for instructions).\n");
if (!options.inputJsonPath) {
console.error("\nPlease provide the path to the deployment artifacts JSON file.\n");
process.exit(1);
}

Expand All @@ -48,6 +56,11 @@ export async function main() {
deployedContractsToAppEnvVariables(deployedContracts),
);

if (!options.outputEnvPath) {
console.log(outputEnv);
process.exit(0);
}

await fs.ensureFile(options.outputEnvPath);
if (options.append) {
await fs.appendFile(options.outputEnvPath, `\n${outputEnv}\n`);
Expand Down
26 changes: 13 additions & 13 deletions frontend/.env
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=1

# Ethereum
NEXT_PUBLIC_CHAIN_ID=1
NEXT_PUBLIC_CHAIN_NAME=Ethereum
NEXT_PUBLIC_CHAIN_CURRENCY=Ether|ETH|18
NEXT_PUBLIC_CHAIN_RPC_URL=https://cloudflare-eth.com
NEXT_PUBLIC_CHAIN_BLOCK_EXPLORER=Etherscan|https://etherscan.io
NEXT_PUBLIC_CHAIN_CONTRACT_ENS_REGISTRY=0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e
NEXT_PUBLIC_CHAIN_CONTRACT_ENS_RESOLVER=0xce01f8eee7E479C928F8919abD53E553a36CeF67|19258213
NEXT_PUBLIC_CHAIN_CONTRACT_MULTICALL=0xca11bde05977b3631167028862be2a173976ca11|14353601

# Hardhat
# NEXT_PUBLIC_CHAIN_ID=31337
# NEXT_PUBLIC_CHAIN_NAME=Hardhat
# NEXT_PUBLIC_CHAIN_ID=1
# NEXT_PUBLIC_CHAIN_NAME=Ethereum
# NEXT_PUBLIC_CHAIN_CURRENCY=Ether|ETH|18
# NEXT_PUBLIC_CHAIN_RPC_URL=http://127.0.0.1:8545
# NEXT_PUBLIC_CHAIN_RPC_URL=https://cloudflare-eth.com
# NEXT_PUBLIC_CHAIN_BLOCK_EXPLORER=Etherscan|https://etherscan.io
# NEXT_PUBLIC_CHAIN_CONTRACT_ENS_REGISTRY=0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e
# NEXT_PUBLIC_CHAIN_CONTRACT_ENS_RESOLVER=0xce01f8eee7E479C928F8919abD53E553a36CeF67|19258213
# NEXT_PUBLIC_CHAIN_CONTRACT_MULTICALL=0xca11bde05977b3631167028862be2a173976ca11|14353601

# Hardhat / Anvil
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea to add "Anvil". I was thinking it would be confusing that we're running Anvil but only referring to Hardhat in the config.

NEXT_PUBLIC_CHAIN_ID=31337
NEXT_PUBLIC_CHAIN_NAME=Hardhat
NEXT_PUBLIC_CHAIN_CURRENCY=Ether|ETH|18
NEXT_PUBLIC_CHAIN_RPC_URL=http://127.0.0.1:8545

# Liquity Testnet
# NEXT_PUBLIC_CHAIN_ID=1337
Expand Down