matter-labs / zksync-cli

CLI tool that simplifies ZKsync development
MIT License
166 stars 96 forks source link

fix: import zksync-ethers constants path error (zksync-ethers >= v0.5.6) #128

Closed 0x-stan closed 7 months ago

0x-stan commented 7 months ago

What :computer:

Why :hand:

- 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 :camera:

image

Notes :memo:

JackHamer09 commented 7 months ago

@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 commented 7 months ago

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 commented 7 months ago

@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.

github-actions[bot] commented 7 months ago

:tada: This PR is included in version 1.6.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: