diff --git a/data/networks.ts b/data/networks.ts index c1e3fc6a6..6618e1f15 100644 --- a/data/networks.ts +++ b/data/networks.ts @@ -56,8 +56,8 @@ export type EraNetwork = L2Network & { export const eraInMemoryNode: EraNetwork = { id: 260, key: "era-local-memory", - name: "Hyperchain Local", - shortName: "Hyperchain Local", + name: "In-memory node", + shortName: "In-memory local node", rpcUrl: "http://localhost:8011", getTokens: () => [ { @@ -74,8 +74,8 @@ export const eraInMemoryNode: EraNetwork = { export const eraDockerizedNode: EraNetwork = { id: 270, key: "era-local-dockerized", - name: "Hyperchain Local", - shortName: "Hyperchain Local", + name: "Dockerized local node", + shortName: "Dockerized node", rpcUrl: "http://localhost:3050", getTokens: () => [ { diff --git a/hyperchains/README.md b/hyperchains/README.md index a81160474..4cb52b2c0 100644 --- a/hyperchains/README.md +++ b/hyperchains/README.md @@ -18,7 +18,7 @@ There are a few different ways to configure the application: ``` 2. 🔄 Pull your hyperchain config files by running: ```bash - npm run hyperchain:migrate + npm run hyperchain:configure ``` This will regenerate `/hyperchains/config.json` file. You can edit this file manually if needed. 3. 🚀 Now you can start or build the application. See [Development](#development-server) or [Production](#production) section below for more details. diff --git a/package.json b/package.json index 2f63e203c..d4d74a3fe 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "generate:node:hyperchain": "ts-node --transpile-only scripts/hyperchains/empty-check.ts && cross-env NODE_TYPE=hyperchain npm run generate", "generate-meta": "ts-node --transpile-only scripts/updateBridgeMetaTags.ts", "hyperchain:create": "ts-node --transpile-only scripts/hyperchains/create.ts", - "hyperchain:migrate": "ts-node --transpile-only scripts/hyperchains/migrate.ts", + "hyperchain:configure": "ts-node --transpile-only scripts/hyperchains/configure.ts", "preview": "nuxt preview", "postinstall": "nuxt prepare", "prepare": "husky install", diff --git a/scripts/hyperchains/migrate.ts b/scripts/hyperchains/configure.ts similarity index 88% rename from scripts/hyperchains/migrate.ts rename to scripts/hyperchains/configure.ts index 0d320b1bd..1749982b6 100644 --- a/scripts/hyperchains/migrate.ts +++ b/scripts/hyperchains/configure.ts @@ -12,20 +12,16 @@ import { generateNetworkConfig, logUserInfo, promptNetworkReplacement } from "./ import type { Network } from "./utils"; import type { Token } from "../../types"; -const args = process.argv; -const rootPath = args[2]; +const rootPath = process.env.ZKSYNC_HOME; if (!rootPath) { - console.error( - `Please provide the path to your zksync-era repo: - npm run hyperchain:migrate ` - ); + console.error("Please set ZKSYNC_HOME environment variable to contain path to your zksync-era repo."); process.exit(1); } const envsDirectory = pathJoin(rootPath, "/etc/env"); const tokensDirectory = pathJoin(rootPath, "/etc/tokens"); -const migrateHyperchainInfo = async () => { +const configureHyperchainInfo = async () => { console.log("Starting Hyperchain configuration setup...\n"); const network = await promptNetworkEnv(); @@ -74,7 +70,7 @@ const getTokensFromDirectory = (directoryPath: string): Token[] => { const promptNetworkEnv = async () => { const getEnvsFromDirectory = (directoryPath: string): string[] => { if (existsSync(directoryPath)) { - return readdirSync(directoryPath) + const envs = readdirSync(directoryPath) .map((fullFileName) => pathParse(fullFileName)) .filter((file) => { if (!file.ext.endsWith(".env")) return false; @@ -83,8 +79,14 @@ const promptNetworkEnv = async () => { return true; }) .map((file) => file.name); + if (!envs.length) { + console.error("No environment files found in your zksync-era repo. Please set up your hyperchain first."); + process.exit(1); + } + return envs; } else { console.error("No .env files available for provided directory"); + process.exit(1); } }; @@ -129,4 +131,4 @@ const promptNetworkInfo = async (network: Network) => { network.l1Network.name = l1NetworkName; }; -migrateHyperchainInfo(); +configureHyperchainInfo();