Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/matter-labs/zksync-cli into…
Browse files Browse the repository at this point in the history
… dr-devrl-321-add-block-explorer-module-to-zkcli
  • Loading branch information
JackHamer09 committed Oct 13, 2023
2 parents 97e2d77 + c1b13d9 commit 7687b7f
Show file tree
Hide file tree
Showing 21 changed files with 69 additions and 137 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ jobs:
registry-url: "https://registry.npmjs.org"
- name: Install dependencies and build
run: npm ci && npm run build
- name: Create .env-public-analytics file
run: |
echo "RUDDER_STACK_KEY=${{ secrets.RUDDER_STACK_KEY }}" > .env-public-analytics
echo "RUDDER_STACK_DATAPLANE_URL=${{ secrets.RUDDER_STACK_DATAPLANE_URL }}" >> .env-public-analytics
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
1 change: 0 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

# Include specific files
!bin/**/*
!.env-public-analytics
!package.json
!package-lock.json
!LICENSE-MIT
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@ If you're using [local setup (dockerized testing node)](https://github.com/matte
At the moment, we don't have any tests, but we are working on it.
In the meantime, you can test the code manually by running the code in [development mode](#run-in-development-mode).

### 📊 Tracking

zkSync-cli tracks its usage for the single purpose of providing data so it can be improved. Data is fully anonymized. If you want to disable the tracking, set the environment variable `NO_TRACKING` to `true`.

## 🌍 Official Links

- [Website](https://zksync.io/)
Expand Down
4 changes: 0 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,13 @@
"**/*.ts": "tsc-files --noEmit"
},
"dependencies": {
"@rudderstack/rudder-sdk-node": "^2.0.5",
"chalk": "4.1.2",
"commander": "^11.0.0",
"compare-versions": "^6.1.0",
"cross-env": "^7.0.3",
"dotenv": "^16.3.1",
"eslint-import-resolver-typescript": "^3.6.1",
"ethers": "5.7.2",
"inquirer": "^8.1.4",
"node-machine-id": "^1.1.12",
"ofetch": "^1.3.3",
"winston": "^3.10.0",
"zkcli-block-explorer": "^1.0.0",
"zkcli-dockerized-node": "^1.0.2",
Expand Down
4 changes: 0 additions & 4 deletions src/commands/bridge/deposit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
zeekOption,
} from "../../common/options.js";
import { l2Chains } from "../../data/chains.js";
import { track } from "../../utils/analytics.js";
import { ETH_TOKEN } from "../../utils/constants.js";
import { bigNumberToDecimal, decimalToBigNumber } from "../../utils/formatters.js";
import {
Expand Down Expand Up @@ -119,8 +118,6 @@ export const handler = async (options: DepositOptions) => {
Logger.info(` Transaction link: ${fromChain.explorerUrl}/tx/${depositHandle.hash}`);
}

track("deposit", { network: toChain?.network ?? "Unknown chain", zeek: options.zeek });

const senderBalance = await l1Provider.getBalance(senderWallet.address);
Logger.info(`\nSender L1 balance after transaction: ${bigNumberToDecimal(senderBalance)} ETH`);

Expand All @@ -130,7 +127,6 @@ export const handler = async (options: DepositOptions) => {
} catch (error) {
Logger.error("There was an error while depositing funds:");
Logger.error(error);
track("error", { error });
}
};

Expand Down
4 changes: 0 additions & 4 deletions src/commands/bridge/withdraw-finalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import inquirer from "inquirer";
import Program from "./command.js";
import { chainOption, l1RpcUrlOption, l2RpcUrlOption, privateKeyOption, zeekOption } from "../../common/options.js";
import { l2Chains } from "../../data/chains.js";
import { track } from "../../utils/analytics.js";
import { bigNumberToDecimal } from "../../utils/formatters.js";
import {
getAddressFromPrivateKey,
Expand Down Expand Up @@ -117,8 +116,6 @@ export const handler = async (options: WithdrawFinalizeOptions) => {
const receipt = await finalizationHandle.wait();
Logger.info(` Finalization transaction was mined in block ${receipt.blockNumber}`);

track("confirm-withdraw", { network: toChain?.network ?? "Unknown chain", zeek: options.zeek });

const senderBalance = await l1Provider.getBalance(senderWallet.address);
Logger.info(`\nSender L1 balance after transaction: ${bigNumberToDecimal(senderBalance)} ETH`);

Expand All @@ -128,7 +125,6 @@ export const handler = async (options: WithdrawFinalizeOptions) => {
} catch (error) {
Logger.error("There was an error while finalizing withdrawal:");
Logger.error(error);
track("error", { error });
}
};

Expand Down
4 changes: 0 additions & 4 deletions src/commands/bridge/withdraw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
zeekOption,
} from "../../common/options.js";
import { l2Chains } from "../../data/chains.js";
import { track } from "../../utils/analytics.js";
import { ETH_TOKEN } from "../../utils/constants.js";
import { bigNumberToDecimal, decimalToBigNumber } from "../../utils/formatters.js";
import {
Expand Down Expand Up @@ -119,8 +118,6 @@ export const handler = async (options: WithdrawOptions) => {
Logger.info(` Transaction link: ${fromChain.explorerUrl}/tx/${withdrawHandle.hash}`);
}

track("withdraw", { network: toChain?.network ?? "Unknown chain", zeek: options.zeek });

const senderBalance = await l2Provider.getBalance(senderWallet.address);
Logger.info(`\nSender L2 balance after transaction: ${bigNumberToDecimal(senderBalance)} ETH`);

Expand All @@ -130,7 +127,6 @@ export const handler = async (options: WithdrawOptions) => {
} catch (error) {
Logger.error("There was an error while withdrawing funds:");
Logger.error(error);
track("error", { error });
}
};

Expand Down
58 changes: 41 additions & 17 deletions src/commands/create/create.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import chalk from "chalk";
import { Option } from "commander";
import fs from "fs";
import inquirer from "inquirer";
import path from "path";

import Program from "./command.js";
import { zeekOption } from "../../common/options.js";
import { track } from "../../utils/analytics.js";
import { fileOrDirExists } from "../../utils/files.js";
import { cloneRepo } from "../../utils/git.js";
import { optionNameToParam, executeCommand } from "../../utils/helpers.js";
import Logger from "../../utils/logger.js";
import zeek from "../../utils/zeek.js";
Expand Down Expand Up @@ -41,6 +44,11 @@ export const handler = async (folderName: string, options: CreateOptions) => {
};
Logger.debug(`Initial create project options: ${JSON.stringify(options, null, 2)}`);

const folderLocation = path.join(process.cwd(), options.folderName!);
if (fileOrDirExists(folderLocation)) {
throw new Error(`Folder at ${folderLocation} already exists. Try a different project name or remove the folder.`);
}

const answers: CreateOptions = await inquirer.prompt(
[
{
Expand All @@ -63,35 +71,51 @@ export const handler = async (folderName: string, options: CreateOptions) => {

const template = templates.find((e) => e.value === options.template)!;

Logger.info(`\nCreating new project from "${template.name}" template at "${path.join(options.folderName!, "/")}"`);
await executeCommand(`git clone ${template.git} ${options.folderName}`);
await executeCommand(`cd ${options.folderName} && rm -rf -r .git`); // removes .git folder so new repo can be initialized

Logger.info("\nInstalling dependencies with yarn...");
await executeCommand(`cd ${options.folderName} && yarn`);
Logger.info(`\nCreating new project from "${template.name}" template at "${folderLocation}"`);
await cloneRepo(template.git, folderLocation);
try {
fs.rmdirSync(path.join(folderLocation, ".git"), { recursive: true });
} catch {
Logger.warn("Failed to remove .git folder. Make sure to remove it manually before pushing to a new repo.");
}

Logger.info(`\nAll ready 🎉🎉
const isYarnInstalled = await executeCommand("yarn --version", { silent: true })
.then(() => true)
.catch(() => false);

if (isYarnInstalled) {
Logger.info("\nInstalling dependencies with yarn...");
await executeCommand("yarn", { cwd: folderLocation });
} else {
Logger.warn("\nYarn is not installed. Install by running: `npm install -g yarn`");
Logger.warn(
`\nAfter installing Yarn, make sure to install dependencies by running: \`cd ${options.folderName} && yarn\``
);
}

Run cd ${options.folderName} to enter your project folder.
Logger.info(`\n${chalk.green("🎉 All set up! 🎉")}
${chalk.magentaBright("Navigate to your project:")} cd ${options.folderName}
Contracts are stored in the /contracts folder.
Deployment scripts go in the /deploy folder.
${chalk.magentaBright("Directory Overview:")}
- Contracts: ${path.join(folderName, "/contracts")}
- Deployment Scripts: ${path.join(folderName, "/deploy")}
- "yarn hardhat compile" to compile your contracts.
- "yarn hardhat deploy-zksync" to deploy your contract (this command accepts a --script option).
${chalk.magentaBright("Commands:")}
- Compile your contracts: \`yarn hardhat compile\`
- Deploy your contract: \`yarn hardhat deploy-zksync\`
- Note: You can use the \`--script\` option with this command.
Read the ${path.join(options.folderName!, "README.md")} file to learn more.
${chalk.magentaBright("Further Reading:")}
Check out the README file for more details: ${path.join(folderLocation, "README.md")}
`);

track("create", { template: options.template, zeek: options.zeek });

if (options.zeek) {
zeek();
}
} catch (error) {
Logger.error("There was an error while creating new project:");
Logger.error(error);
track("error", { error });
}
};

Expand Down
2 changes: 0 additions & 2 deletions src/commands/dev/clean.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Program from "./command.js";
import configHandler from "./ConfigHandler.js";
import { track } from "../../utils/analytics.js";
import Logger from "../../utils/logger.js";

import type Module from "./modules/Module.js";
Expand Down Expand Up @@ -40,7 +39,6 @@ export const handler = async (modulePackageNames: string[]) => {
} catch (error) {
Logger.error("There was an error while cleaning the testing environment:");
Logger.error(error);
track("error", { error });
}
};

Expand Down
2 changes: 0 additions & 2 deletions src/commands/dev/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import inquirer from "inquirer";
import Program from "./command.js";
import configHandler from "./ConfigHandler.js";
import { ModuleCategory } from "./modules/Module.js";
import { track } from "../../utils/analytics.js";
import Logger from "../../utils/logger.js";

import type { ModuleNode } from "./modules/Module.js";
Expand Down Expand Up @@ -125,7 +124,6 @@ export const handler = async (options: LocalConfigOptions = {}) => {
} catch (error) {
Logger.error("There was an error while configuring the testing environment:");
Logger.error(error);
track("error", { error });
}
};

Expand Down
2 changes: 0 additions & 2 deletions src/commands/dev/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Option } from "commander";

import Program from "./command.js";
import { createModulesFolder, modulesPath } from "./modules/Module.js";
import { track } from "../../utils/analytics.js";
import { executeCommand } from "../../utils/helpers.js";
import Logger from "../../utils/logger.js";

Expand All @@ -27,7 +26,6 @@ export const handler = async (moduleNames: string[], options: { link: boolean })
} catch (error) {
Logger.error("There was an error while installing module:");
Logger.error(error);
track("error", { error });
}
};

Expand Down
2 changes: 0 additions & 2 deletions src/commands/dev/logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import chalk from "chalk";

import Program from "./command.js";
import configHandler from "./ConfigHandler.js";
import { track } from "../../utils/analytics.js";
import Logger from "../../utils/logger.js";

export const handler = async () => {
Expand Down Expand Up @@ -34,7 +33,6 @@ export const handler = async () => {
} catch (error) {
Logger.error("There was an error displaying logs:");
Logger.error(error);
track("error", { error });
}
};

Expand Down
2 changes: 0 additions & 2 deletions src/commands/dev/modules/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import chalk from "chalk";

import { track } from "../../../utils/analytics.js";
import Logger from "../../../utils/logger.js";
import Program from "../command.js";
import configHandler from "../ConfigHandler.js";
Expand Down Expand Up @@ -30,7 +29,6 @@ export const handler = async () => {
} catch (error) {
Logger.error("There was an error displaying installed modules:");
Logger.error(error);
track("error", { error });
}
};

Expand Down
2 changes: 0 additions & 2 deletions src/commands/dev/restart.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Program from "./command.js";
import { handler as start } from "./start.js";
import { handler as stop } from "./stop.js";
import { track } from "../../utils/analytics.js";
import Logger from "../../utils/logger.js";

export const handler = async (modulePackageNames: string[]) => {
Expand All @@ -11,7 +10,6 @@ export const handler = async (modulePackageNames: string[]) => {
} catch (error) {
Logger.error("There was an error while restarting the testing environment:");
Logger.error(error);
track("error", { error });
}
};

Expand Down
2 changes: 0 additions & 2 deletions src/commands/dev/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { setupConfig } from "./config.js";
import configHandler from "./ConfigHandler.js";
import { ModuleCategory } from "./modules/Module.js";
import { getModulesRequiringUpdates } from "./modules/utils/updates.js";
import { track } from "../../utils/analytics.js";
import { formatLogs } from "../../utils/formatters.js";
import Logger from "../../utils/logger.js";

Expand Down Expand Up @@ -112,7 +111,6 @@ export const handler = async () => {
} catch (error) {
Logger.error("There was an error while starting the testing environment:");
Logger.error(error);
track("error", { error });
}
};

Expand Down
2 changes: 0 additions & 2 deletions src/commands/dev/stop.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Program from "./command.js";
import configHandler from "./ConfigHandler.js";
import { track } from "../../utils/analytics.js";
import Logger from "../../utils/logger.js";

export const handler = async (modulePackageNames: string[]) => {
Expand All @@ -24,7 +23,6 @@ export const handler = async (modulePackageNames: string[]) => {
} catch (error) {
Logger.error("There was an error while stopping the testing environment:");
Logger.error(error);
track("error", { error });
}
};

Expand Down
2 changes: 0 additions & 2 deletions src/commands/dev/uninstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import Program from "./command.js";
import configHandler from "./ConfigHandler.js";
import { createModulesFolder, modulesPath } from "./modules/Module.js";
import { findDefaultModules } from "./modules/utils/packages.js";
import { track } from "../../utils/analytics.js";
import { executeCommand } from "../../utils/helpers.js";
import Logger from "../../utils/logger.js";

Expand Down Expand Up @@ -36,7 +35,6 @@ export const handler = async (moduleNames: string[], options: { unlink: boolean
} catch (error) {
Logger.error("There was an error while uninstalling module:");
Logger.error(error);
track("error", { error });
}
};

Expand Down
2 changes: 0 additions & 2 deletions src/commands/dev/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Option } from "commander";
import Program from "./command.js";
import configHandler from "./ConfigHandler.js";
import { createModulesFolder, modulesPath } from "./modules/Module.js";
import { track } from "../../utils/analytics.js";
import { executeCommand } from "../../utils/helpers.js";
import Logger from "../../utils/logger.js";

Expand Down Expand Up @@ -69,7 +68,6 @@ export const handler = async (moduleNames: string[], options: ModuleUpdateOption
} catch (error) {
Logger.error("There was an error while updating module:");
Logger.error(error);
track("error", { error });
}
};

Expand Down
Loading

0 comments on commit 7687b7f

Please sign in to comment.