Skip to content

Commit 7f479ae

Browse files
authored
fix: update modules and fix option keys (#98)
1 parent 4ae513f commit 7f479ae

12 files changed

+583
-993
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ See full documentation and advanced examples [here](./docs/contract-interaction.
6363

6464
### 🔗 Supported bridge chains
6565

66-
By default zkSync CLI bridge commands support Era Testnet and Era Mainnet. You can also use other networks by overwriting L1 and L2 RPC URLs. For example: `npx zksync-cli deposit --l2-rpc=http://... --l1-rpc=http://...`
66+
By default zkSync CLI bridge commands support Era Testnet and Era 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://...`
6767

6868
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`.
6969

package-lock.json

+547-957
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@
4444
"ora": "^7.0.1",
4545
"update-notifier": "^7.0.0",
4646
"winston": "^3.10.0",
47-
"zkcli-block-explorer": "^1.1.0",
48-
"zkcli-dockerized-node": "^1.0.5",
49-
"zkcli-in-memory-node": "^1.0.3",
50-
"zkcli-portal": "^1.0.1",
47+
"zkcli-block-explorer": "^1.1.1",
48+
"zkcli-dockerized-node": "^1.0.8",
49+
"zkcli-in-memory-node": "^1.0.6",
50+
"zkcli-portal": "^1.0.2",
5151
"zksync-web3": "^0.14.4"
5252
},
5353
"devDependencies": {

src/commands/bridge/deposit.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export const handler = async (options: DepositOptions) => {
5050
choices: l2Chains.filter((e) => e.l1Chain).map((e) => ({ name: e.name, value: e.network })),
5151
required: true,
5252
when(answers: DepositOptions) {
53-
if (answers.l1RpcUrl && answers.l2RpcUrl) {
53+
if (answers.l1Rpc && answers.rpc) {
5454
return false;
5555
}
5656
return true;
@@ -92,9 +92,9 @@ export const handler = async (options: DepositOptions) => {
9292
Logger.debug(`Final deposit options: ${JSON.stringify({ ...options, privateKey: "<hidden>" }, null, 2)}`);
9393

9494
const fromChain = l2Chains.find((e) => e.network === options.chain)?.l1Chain;
95-
const fromChainLabel = fromChain && !options.l1RpcUrl ? fromChain.name : options.l1RpcUrl ?? "Unknown chain";
95+
const fromChainLabel = fromChain && !options.l1Rpc ? fromChain.name : options.l1Rpc ?? "Unknown chain";
9696
const toChain = l2Chains.find((e) => e.network === options.chain);
97-
const toChainLabel = toChain && !options.l2RpcUrl ? toChain.name : options.l2RpcUrl ?? "Unknown chain";
97+
const toChainLabel = toChain && !options.rpc ? toChain.name : options.rpc ?? "Unknown chain";
9898

9999
Logger.info("\nDeposit:");
100100
Logger.info(` From: ${getAddressFromPrivateKey(answers.privateKey)} (${fromChainLabel})`);
@@ -103,8 +103,8 @@ export const handler = async (options: DepositOptions) => {
103103

104104
Logger.info("\nSending deposit transaction...");
105105

106-
const l1Provider = getL1Provider(options.l1RpcUrl ?? fromChain!.rpcUrl);
107-
const l2Provider = getL2Provider(options.l2RpcUrl ?? toChain!.rpcUrl);
106+
const l1Provider = getL1Provider(options.l1Rpc ?? fromChain!.rpcUrl);
107+
const l2Provider = getL2Provider(options.rpc ?? toChain!.rpcUrl);
108108
const senderWallet = getL2Wallet(options.privateKey, l2Provider, l1Provider);
109109

110110
const depositHandle = await senderWallet.deposit({

src/commands/bridge/withdraw-finalize.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const handler = async (options: WithdrawFinalizeOptions) => {
4949
choices: l2Chains.filter((e) => e.l1Chain).map((e) => ({ name: e.name, value: e.network })),
5050
required: true,
5151
when(answers: WithdrawFinalizeOptions) {
52-
if (answers.l1RpcUrl && answers.l2RpcUrl) {
52+
if (answers.l1Rpc && answers.rpc) {
5353
return false;
5454
}
5555
return true;
@@ -81,18 +81,18 @@ export const handler = async (options: WithdrawFinalizeOptions) => {
8181
Logger.debug(`Final withdraw-finalize options: ${JSON.stringify({ ...options, privateKey: "<hidden>" }, null, 2)}`);
8282

8383
const fromChain = l2Chains.find((e) => e.network === options.chain);
84-
const fromChainLabel = fromChain && !options.l2RpcUrl ? fromChain.name : options.l2RpcUrl ?? "Unknown chain";
84+
const fromChainLabel = fromChain && !options.rpc ? fromChain.name : options.rpc ?? "Unknown chain";
8585
const toChain = l2Chains.find((e) => e.network === options.chain)?.l1Chain;
86-
const toChainLabel = toChain && !options.l1RpcUrl ? toChain.name : options.l1RpcUrl ?? "Unknown chain";
86+
const toChainLabel = toChain && !options.l1Rpc ? toChain.name : options.l1Rpc ?? "Unknown chain";
8787

8888
Logger.info("\nWithdraw finalize:");
8989
Logger.info(` From chain: ${fromChainLabel}`);
9090
Logger.info(` To chain: ${toChainLabel}`);
9191
Logger.info(` Withdrawal transaction (L2): ${options.hash}`);
9292
Logger.info(` Finalizer address (L1): ${getAddressFromPrivateKey(answers.privateKey)}`);
9393

94-
const l1Provider = getL1Provider(options.l1RpcUrl ?? toChain!.rpcUrl);
95-
const l2Provider = getL2Provider(options.l2RpcUrl ?? fromChain!.rpcUrl);
94+
const l1Provider = getL1Provider(options.l1Rpc ?? toChain!.rpcUrl);
95+
const l2Provider = getL2Provider(options.rpc ?? fromChain!.rpcUrl);
9696
const senderWallet = getL2Wallet(options.privateKey, l2Provider, l1Provider);
9797

9898
Logger.info("\nChecking status of the transaction...");

src/commands/bridge/withdraw.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export const handler = async (options: WithdrawOptions) => {
5050
choices: l2Chains.filter((e) => e.l1Chain).map((e) => ({ name: e.name, value: e.network })),
5151
required: true,
5252
when(answers: WithdrawOptions) {
53-
if (answers.l1RpcUrl && answers.l2RpcUrl) {
53+
if (answers.l1Rpc && answers.rpc) {
5454
return false;
5555
}
5656
return true;
@@ -92,9 +92,9 @@ export const handler = async (options: WithdrawOptions) => {
9292
Logger.debug(`Final withdraw options: ${JSON.stringify({ ...options, privateKey: "<hidden>" }, null, 2)}`);
9393

9494
const fromChain = l2Chains.find((e) => e.network === options.chain);
95-
const fromChainLabel = fromChain && !options.l2RpcUrl ? fromChain.name : options.l2RpcUrl ?? "Unknown chain";
95+
const fromChainLabel = fromChain && !options.rpc ? fromChain.name : options.rpc ?? "Unknown chain";
9696
const toChain = l2Chains.find((e) => e.network === options.chain)?.l1Chain;
97-
const toChainLabel = toChain && !options.l1RpcUrl ? toChain.name : options.l1RpcUrl ?? "Unknown chain";
97+
const toChainLabel = toChain && !options.l1Rpc ? toChain.name : options.l1Rpc ?? "Unknown chain";
9898

9999
Logger.info("\nWithdraw:");
100100
Logger.info(` From: ${getAddressFromPrivateKey(answers.privateKey)} (${fromChainLabel})`);
@@ -103,8 +103,8 @@ export const handler = async (options: WithdrawOptions) => {
103103

104104
Logger.info("\nSending withdraw transaction...");
105105

106-
const l1Provider = getL1Provider(options.l1RpcUrl ?? toChain!.rpcUrl);
107-
const l2Provider = getL2Provider(options.l2RpcUrl ?? fromChain!.rpcUrl);
106+
const l1Provider = getL1Provider(options.l1Rpc ?? toChain!.rpcUrl);
107+
const l2Provider = getL2Provider(options.rpc ?? fromChain!.rpcUrl);
108108
const senderWallet = getL2Wallet(options.privateKey, l2Provider, l1Provider);
109109

110110
const withdrawHandle = await senderWallet.withdraw({

src/commands/contract/read.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ export const handler = async (options: CallOptions, context: Command) => {
180180
type: "list",
181181
choices: l2Chains.map((e) => ({ name: e.name, value: e.network })),
182182
required: true,
183-
when: (answers: CallOptions) => !answers.l2RpcUrl,
183+
when: (answers: CallOptions) => !answers.rpc,
184184
},
185185
{
186186
message: contractOption.description,
@@ -196,8 +196,8 @@ export const handler = async (options: CallOptions, context: Command) => {
196196
options.chain = answers.chain;
197197
options.contract = answers.contract;
198198

199-
const selectedChain = options.l2RpcUrl ? undefined : l2Chains.find((e) => e.network === options.chain);
200-
const provider = getL2Provider(options.l2RpcUrl || selectedChain!.rpcUrl);
199+
const selectedChain = options.rpc ? undefined : l2Chains.find((e) => e.network === options.chain);
200+
const provider = getL2Provider(options.rpc || selectedChain!.rpcUrl);
201201

202202
const contractInfo = await getContractInfoWithLoader(selectedChain, provider, options.contract!);
203203
if (contractInfo.implementation) {

src/commands/contract/write.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export const handler = async (options: WriteOptions, context: Command) => {
133133
type: "list",
134134
choices: l2Chains.map((e) => ({ name: e.name, value: e.network })),
135135
required: true,
136-
when: (answers: WriteOptions) => !answers.l2RpcUrl,
136+
when: (answers: WriteOptions) => !answers.rpc,
137137
},
138138
{
139139
message: contractOption.description,
@@ -149,8 +149,8 @@ export const handler = async (options: WriteOptions, context: Command) => {
149149
options.chain = answers.chain;
150150
options.contract = answers.contract;
151151

152-
const selectedChain = options.l2RpcUrl ? undefined : l2Chains.find((e) => e.network === options.chain);
153-
const provider = getL2Provider(options.l2RpcUrl || selectedChain!.rpcUrl);
152+
const selectedChain = options.rpc ? undefined : l2Chains.find((e) => e.network === options.chain);
153+
const provider = getL2Provider(options.rpc || selectedChain!.rpcUrl);
154154

155155
const contractInfo = await getContractInfoWithLoader(selectedChain, provider, options.contract!);
156156
if (contractInfo.implementation) {
@@ -220,7 +220,7 @@ export const handler = async (options: WriteOptions, context: Command) => {
220220
if (receipt.status) {
221221
receiptSpinner.succeed(
222222
"Transaction processed successfully." +
223-
(!options.l2RpcUrl && selectedChain?.explorerUrl
223+
(!options.rpc && selectedChain?.explorerUrl
224224
? ` Transaction link: ${selectedChain.explorerUrl}/tx/${receipt.transactionHash}`
225225
: "")
226226
);

src/commands/wallet/balance.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type { DefaultOptions } from "../../common/options.js";
1313

1414
type BalanceOptions = DefaultOptions & {
1515
chain?: string;
16-
l2RpcUrl?: string;
16+
rpc?: string;
1717
address?: string;
1818
};
1919

@@ -28,7 +28,7 @@ export const handler = async (options: BalanceOptions) => {
2828
choices: l2Chains.map((e) => ({ name: e.name, value: e.network })),
2929
required: true,
3030
when(answers: BalanceOptions) {
31-
if (answers.l2RpcUrl) {
31+
if (answers.rpc) {
3232
return false;
3333
}
3434
return true;
@@ -51,7 +51,7 @@ export const handler = async (options: BalanceOptions) => {
5151
};
5252

5353
const selectedChain = l2Chains.find((e) => e.network === options.chain);
54-
const l2Provider = getL2Provider(options.l2RpcUrl ?? selectedChain!.rpcUrl);
54+
const l2Provider = getL2Provider(options.rpc ?? selectedChain!.rpcUrl);
5555
const balance = await l2Provider.getBalance(options.address!);
5656

5757
Logger.info(`\n${selectedChain?.name} Balance: ${bigNumberToDecimal(balance)} ETH`);

src/commands/wallet/transfer.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const handler = async (options: TransferOptions) => {
3535
choices: l2Chains.map((e) => ({ name: e.name, value: e.network })),
3636
required: true,
3737
when(answers: TransferOptions) {
38-
if (answers.l2RpcUrl) {
38+
if (answers.rpc) {
3939
return false;
4040
}
4141
return true;
@@ -72,7 +72,7 @@ export const handler = async (options: TransferOptions) => {
7272
};
7373

7474
const selectedChain = l2Chains.find((e) => e.network === options.chain);
75-
const l2Provider = getL2Provider(options.l2RpcUrl ?? selectedChain!.rpcUrl);
75+
const l2Provider = getL2Provider(options.rpc ?? selectedChain!.rpcUrl);
7676
const senderWallet = getL2Wallet(options.privateKey, l2Provider);
7777

7878
const transferHandle = await senderWallet.transfer({

src/common/options.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ export type DefaultOptions = {
2626
};
2727
export type DefaultTransactionOptions = DefaultOptions & {
2828
chain?: string;
29-
l1RpcUrl?: string;
30-
l2RpcUrl?: string;
29+
l1Rpc?: string;
30+
rpc?: string;
3131
privateKey: string;
3232
};
3333
export type DefaultTransferOptions = DefaultTransactionOptions & {

src/utils/helpers.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ export const getAddressFromPrivateKey = (privateKey: string): string => {
2626
export const getL1Provider = (l1RpcUrl: string) => {
2727
return new ethers.providers.JsonRpcProvider(l1RpcUrl);
2828
};
29-
export const getL2Provider = (l2RpcUrl: string) => {
30-
return new Provider(l2RpcUrl);
29+
export const getL2Provider = (rpc: string) => {
30+
return new Provider(rpc);
3131
};
3232

3333
export const getL2Wallet = (privateKey: string, l2Provider: Provider, l1Provider?: ethers.providers.Provider) => {

0 commit comments

Comments
 (0)