diff --git a/README.md b/README.md index 00046d0bb..f4fef29f8 100644 --- a/README.md +++ b/README.md @@ -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. +``` diff --git a/contracts/utils/deployment-artifacts-to-app-env.ts b/contracts/utils/deployment-artifacts-to-app-env.ts index 07ef21b9e..672ac598f 100644 --- a/contracts/utils/deployment-artifacts-to-app-env.ts +++ b/contracts/utils/deployment-artifacts-to-app-env.ts @@ -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 [OPTIONS] + ./deployment-artifacts-to-app-env.ts [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}$/); @@ -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); } @@ -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`); diff --git a/frontend/.env b/frontend/.env index 889a6d7d4..cab5dcb50 100644 --- a/frontend/.env +++ b/frontend/.env @@ -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