LayerZero-Labs/LayerZero-v2

Foundry compatibility can be improved by reducing npm/js dependency

JorgeAtPaladin opened this issue · 5 comments

Hey team!

Can I create a PR to factor out JS/npm dependency throughout the repository?

Example for the oapp subdirectory:

remappings = [
    # note: map to package level only, required for pnp-berry to work with foundry
    # ok - solidity-stringutils/=node_modules/solidity-stringutils/
    # not ok - solidity-stringutils/=node_modules/solidity-stringutils/src/
    '@openzeppelin/contracts/=../lib/openzeppelin-contracts/contracts/',
    '@openzeppelin/contracts-upgradeable/=../lib/openzeppelin-contracts-upgradeable/contracts/',
    'solidity-bytes-utils/=../lib/solidity-bytes-utils',
    'hardhat-deploy/=../lib/hardhat-deploy/',
    '@layerzerolabs/lz-evm-protocol-v2/=../protocol/',
    '@layerzerolabs/lz-evm-messagelib-v2/=../messagelib/',
    '@layerzerolabs/lz-evm-v1-0.7/=../lib/LayerZero/'
]

Let's discuss whether there are any downside to this (eg. the comment wrt pnp-berry). If no downside- I'd like to go ahead with this refactor as the current setup is maybe unnecessarily cumbersome to integrate for foundry users?

Happy holidays, Marco

I did find that simply adding adjusted versions their remappings to my foundry project's settings resolves this problem. However, I still think doing this is worthwhile. I don't know if eliminating npm will impact their test suite.

Hey guys, I figured this might be helpful and possibly better starter point for someone that's looking for as native Foundry experience as possible and avoiding NPM dependencies: https://github.com/Kuzirashi/layerzero-starter-kit

Not sure if useful but decided to share with you guys. This issue touches Foundry Developer Experience. Feedback for potential improvements welcome.

LayerZero-v2 is very tricky to add as a dependency of a Foundry-based project because of this issue. Foundry can't handle the NPM-managed dependencies of LayerZero-V2.

It can if you run yarn and yarn build in the LayerZero-v2 lib folder.

It's not that simple. It requires extra manual work from the devs and all the scripts in the project. It also introduces additional requirement for tools installed on the machine, which makes CI harder to work with and brings a whole new layer of problems with package management. All of this to fetch a few .sol files.