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: import zksync-ethers constants path error (zksync-ethers >= v0.5.6) #128

Merged
merged 1 commit into from
Mar 20, 2024

Conversation

0x-stan
Copy link
Contributor

@0x-stan 0x-stan commented Mar 20, 2024

What πŸ’»

  • Fix the path error for importing constants from zksync-ethers, due to updates in zksync-ethers causing zksync-cli to fail to run after installation.

Why βœ‹

  • Since zksync-ethers in version 0.5.6 changed the tsconfig's rootDir from . to ./src, it altered the output directory structure, leading to errors when zksync-cli imports constants from zksync-ethers; to prevent future issues caused by dependency project directory adjustments, it's necessary to change the import method:
- import { BOOTLOADER_FORMAL_ADDRESS } from "zksync-ethers/build/src/utils.js";
- BOOTLOADER_FORMAL_ADDRESS;

+ import { utils } from "zksync-ethers";
+ utils.BOOTLOADER_FORMAL_ADDRESS;

zksync-ethers in version 0.5.6 changed the tsconfig's rootDir from . to ./src

Evidence πŸ“·

image

Notes πŸ“

@0x-stan 0x-stan requested a review from a team as a code owner March 20, 2024 11:37
@JackHamer09
Copy link
Member

@0x-stan hey! Are you seeing this error when using npx zksync-cli@latest -V? Note the @latest part. It might be possible you've installed older/broken version by accident - if it's the case please follow the troubleshooting guide.
I can't replicate this issue and don't really see how it could happen, cause zksync-cli doesn't use zksync-ethers >= v0.5.6 as you mentioned. It uses version 5.1.0, you can see that in the package-lock.json file.

@0x-stan
Copy link
Contributor Author

0x-stan commented Mar 20, 2024

Yes, the versions are locked in the package-lock, but I used npm i -g zksync-cli for the installation which will use zksync-cli v0.5.6; use npx zksync-cli@latest -V appears the same error.

When executing the installation command, npm will install the latest version of "zksync-ethers" less than 6.0.0 according to "zksync-ethers": "^5.1.0" in the package.json, rather than version 0.5.1 specified in package-lock.json, because the downloaded zksync-cli node_modules dependencies do not include a package-lock.json file.

image image

Furthermore, this modification is reasonable as it prevents future issues that could arise from dependency upgrades affecting the path.

@JackHamer09
Copy link
Member

@0x-stan I agree that this change makes sense anyway, thanks for that PR.
Just trying to understand where this issue is coming from. I was able to reproduce it when installing zksync-cli globally, although please note that this way isn't recommended as you might miss on the latest updates/fixes additionally desynchronizing from latest docs or tutorials update. Would recommend removing it from global installation npm uninstall -g zksync-cli and using only as npx zksync-cli.

@JackHamer09 JackHamer09 merged commit 3928548 into matter-labs:main Mar 20, 2024
2 checks passed
Copy link

πŸŽ‰ This PR is included in version 1.6.0 πŸŽ‰

The release is available on:

Your semantic-release bot πŸ“¦πŸš€

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants