Skip to content

Commit

Permalink
README: Add development instructions
Browse files Browse the repository at this point in the history
Also:
- Makes the second parameter of deployment-artifacts-to-app-env.ts
  optional and emit on stdout when missing, so that people can use the
  script to copy & paste into their env file easily.
- In the .env example file, make the hardhat env the default (one less
  thing to do for contributors).
  • Loading branch information
bpierre committed Apr 12, 2024
1 parent abdb0e0 commit 7f26842
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 18 deletions.
45 changes: 44 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,44 @@
# 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
anvil

# Deploy the contracts
cd 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

# Now, 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 the previous command.

# Run the app development server
pnpm dev

# Open https://localhost:3000 in your browser
```
17 changes: 13 additions & 4 deletions contracts/utils/deployment-artifacts-to-app-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ 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 (if missing, stdout is used).
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 Down Expand Up @@ -40,8 +44,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 @@ -53,6 +57,11 @@ export async function main() {
deploymentContextToAppEnvVariables(deploymentContext),
);

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
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

0 comments on commit 7f26842

Please sign in to comment.