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

fix: align hyperchain configure command with other modules #140

Merged
merged 1 commit into from
Oct 23, 2023
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
8 changes: 4 additions & 4 deletions data/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: () => [
{
Expand All @@ -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: () => [
{
Expand Down
2 changes: 1 addition & 1 deletion hyperchains/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <path_to_your_zksync-era_repo>
npm run hyperchain:configure <path_to_your_zksync-era_repo>
```
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.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <path_to_your_zksync-era_repo>`
);
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();
Expand Down Expand Up @@ -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;
Expand All @@ -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);
}
};

Expand Down Expand Up @@ -129,4 +131,4 @@ const promptNetworkInfo = async (network: Network) => {
network.l1Network.name = l1NetworkName;
};

migrateHyperchainInfo();
configureHyperchainInfo();
Loading