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
… alpha
  • Loading branch information
JackHamer09 committed Jan 13, 2024
2 parents 8a6ad5d + 6fd2a3f commit 8111d11
Show file tree
Hide file tree
Showing 32 changed files with 654 additions and 144 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,17 @@ See full documentation and advanced examples [here](./docs/contract-interaction.
- `npx zksync-cli bridge withdraw-finalize`: finalizes withdrawal of funds from zkSync (L2) to Ethereum (L1)

### Other commands
- `npx zksync-cli config chains`: Add or edit custom chains
- `npx zksync-cli help`: Provides information about all supported commands
- `npx zksync-cli <command> --help`: Provides detailed information about how to use a specific command. Replace \<command\> with the name of the command you want help with (e.g., `create`, `dev config`, `bridge withdraw-finalize`)
- `npx zksync-cli --version`: Returns the current version


### 🔗 Supported bridge chains
### 🔗 Supported chains

By default zkSync CLI bridge commands support zkSync Sepolia and Goerli Testnet and zkSync Mainnet. You can also use other networks by overwriting L1 and L2 RPC URLs. For example: `npx zksync-cli deposit --rpc=http://... --l1-rpc=http://...`
By default zkSync CLI bridge commands support zkSync Sepolia Testnet, zkSync Goerli Testnet and zkSync Mainnet. You can also use other networks by using one the options below:
- Adding custom chain using `npx zksync-cli config chains` command.
- Overwriting L1 and L2 RPC URLs. For example: `npx zksync-cli deposit --rpc=http://... --l1-rpc=http://...`

If you're using [local setup (dockerized testing node)](https://github.com/matter-labs/local-setup) with default L1 and L2 RPC URLs, you can select `Local Dockerized node` option in the CLI or provide option `--chain local-dockerized`.

Expand Down Expand Up @@ -92,6 +95,7 @@ In the meantime, you can test the code manually by running the code in [developm
- [Twitter](https://twitter.com/zksync)
- [Twitter for Devs](https://twitter.com/zkSyncDevs)
- [Discord](https://join.zksync.dev/)
- [Youtube](https://www.youtube.com/@zkSync-era)

## 📜 License

Expand Down
14 changes: 14 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"ethers": "5.7.2",
"inquirer": "^8.1.4",
"ora": "^7.0.1",
"slugify": "^1.6.6",
"update-notifier": "^7.0.0",
"winston": "^3.10.0",
"zkcli-block-explorer": "^1.1.4",
Expand Down
8 changes: 5 additions & 3 deletions src/commands/bridge/deposit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
import Logger from "../../utils/logger.js";
import { isDecimalAmount, isAddress, isPrivateKey } from "../../utils/validators.js";
import zeek from "../../utils/zeek.js";
import { getChains } from "../config/chains.js";

import type { DefaultTransferOptions } from "../../common/options.js";

Expand All @@ -41,13 +42,14 @@ export const handler = async (options: DepositOptions) => {
)}`
);

const chains = [...l2Chains, ...getChains()];
const answers: DepositOptions = await inquirer.prompt(
[
{
message: chainWithL1Option.description,
name: optionNameToParam(chainWithL1Option.long!),
type: "list",
choices: l2Chains.filter((e) => e.l1Chain).map((e) => ({ name: e.name, value: e.network })),
choices: chains.filter((e) => e.l1Chain).map((e) => ({ name: e.name, value: e.network })),
required: true,
when(answers: DepositOptions) {
if (answers.l1Rpc && answers.rpc) {
Expand Down Expand Up @@ -91,9 +93,9 @@ export const handler = async (options: DepositOptions) => {

Logger.debug(`Final deposit options: ${JSON.stringify({ ...options, privateKey: "<hidden>" }, null, 2)}`);

const fromChain = l2Chains.find((e) => e.network === options.chain)?.l1Chain;
const fromChain = chains.find((e) => e.network === options.chain)?.l1Chain;
const fromChainLabel = fromChain && !options.l1Rpc ? fromChain.name : options.l1Rpc ?? "Unknown chain";
const toChain = l2Chains.find((e) => e.network === options.chain);
const toChain = chains.find((e) => e.network === options.chain);
const toChainLabel = toChain && !options.rpc ? toChain.name : options.rpc ?? "Unknown chain";

Logger.info("\nDeposit:");
Expand Down
8 changes: 5 additions & 3 deletions src/commands/bridge/withdraw-finalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
import Logger from "../../utils/logger.js";
import { isPrivateKey, isTransactionHash } from "../../utils/validators.js";
import zeek from "../../utils/zeek.js";
import { getChains } from "../config/chains.js";

import type { DefaultTransactionOptions } from "../../common/options.js";

Expand All @@ -40,13 +41,14 @@ export const handler = async (options: WithdrawFinalizeOptions) => {
)}`
);

const chains = [...l2Chains, ...getChains()];
const answers: WithdrawFinalizeOptions = await inquirer.prompt(
[
{
message: chainWithL1Option.description,
name: optionNameToParam(chainWithL1Option.long!),
type: "list",
choices: l2Chains.filter((e) => e.l1Chain).map((e) => ({ name: e.name, value: e.network })),
choices: chains.filter((e) => e.l1Chain).map((e) => ({ name: e.name, value: e.network })),
required: true,
when(answers: WithdrawFinalizeOptions) {
if (answers.l1Rpc && answers.rpc) {
Expand Down Expand Up @@ -80,9 +82,9 @@ export const handler = async (options: WithdrawFinalizeOptions) => {

Logger.debug(`Final withdraw-finalize options: ${JSON.stringify({ ...options, privateKey: "<hidden>" }, null, 2)}`);

const fromChain = l2Chains.find((e) => e.network === options.chain);
const fromChain = chains.find((e) => e.network === options.chain);
const fromChainLabel = fromChain && !options.rpc ? fromChain.name : options.rpc ?? "Unknown chain";
const toChain = l2Chains.find((e) => e.network === options.chain)?.l1Chain;
const toChain = chains.find((e) => e.network === options.chain)?.l1Chain;
const toChainLabel = toChain && !options.l1Rpc ? toChain.name : options.l1Rpc ?? "Unknown chain";

Logger.info("\nWithdraw finalize:");
Expand Down
8 changes: 5 additions & 3 deletions src/commands/bridge/withdraw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
import Logger from "../../utils/logger.js";
import { isDecimalAmount, isAddress, isPrivateKey } from "../../utils/validators.js";
import zeek from "../../utils/zeek.js";
import { getChains } from "../config/chains.js";

import type { DefaultTransferOptions } from "../../common/options.js";

Expand All @@ -41,13 +42,14 @@ export const handler = async (options: WithdrawOptions) => {
)}`
);

const chains = [...l2Chains, ...getChains()];
const answers: WithdrawOptions = await inquirer.prompt(
[
{
message: chainWithL1Option.description,
name: optionNameToParam(chainWithL1Option.long!),
type: "list",
choices: l2Chains.filter((e) => e.l1Chain).map((e) => ({ name: e.name, value: e.network })),
choices: chains.filter((e) => e.l1Chain).map((e) => ({ name: e.name, value: e.network })),
required: true,
when(answers: WithdrawOptions) {
if (answers.l1Rpc && answers.rpc) {
Expand Down Expand Up @@ -91,9 +93,9 @@ export const handler = async (options: WithdrawOptions) => {

Logger.debug(`Final withdraw options: ${JSON.stringify({ ...options, privateKey: "<hidden>" }, null, 2)}`);

const fromChain = l2Chains.find((e) => e.network === options.chain);
const fromChain = chains.find((e) => e.network === options.chain);
const fromChainLabel = fromChain && !options.rpc ? fromChain.name : options.rpc ?? "Unknown chain";
const toChain = l2Chains.find((e) => e.network === options.chain)?.l1Chain;
const toChain = chains.find((e) => e.network === options.chain)?.l1Chain;
const toChainLabel = toChain && !options.l1Rpc ? toChain.name : options.l1Rpc ?? "Unknown chain";

Logger.info("\nWithdraw:");
Expand Down
Loading

0 comments on commit 8111d11

Please sign in to comment.