diff --git a/README.md b/README.md index 00046d0b..cfdfe310 100644 --- a/README.md +++ b/README.md @@ -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 +``` diff --git a/contracts/utils/deployment-artifacts-to-app-env.ts b/contracts/utils/deployment-artifacts-to-app-env.ts index 3994c8e9..6ae3888d 100644 --- a/contracts/utils/deployment-artifacts-to-app-env.ts +++ b/contracts/utils/deployment-artifacts-to-app-env.ts @@ -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 [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 (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}$/); @@ -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); } @@ -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`); diff --git a/frontend/.env b/frontend/.env index 889a6d7d..cab5dcb5 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