book
book copied to clipboard
Add example using OZ contracts in VSCode
https://github.com/foundry-rs/foundry/issues/2019
Can you add more context to the example? I.e. explain what the solution is doing/what the problem is (you did that a bit in your linked comment) so it is easier to reproduce for project structures that do not follow the example exactly
I wanted to show an example of usage solidity.remappings
settings.
{
"solidity.remappings": [
"@openzeppelin/=packages/contracts/lib/openzeppelin-contracts/",
"ds-test/=packages/contracts/lib/forge-std/lib/ds-test/src/",
"forge-std/=packages/contracts/lib/forge-std/src/"
],
"solidity.packageDefaultDependenciesDirectory": "lib",
"solidity.packageDefaultDependenciesContractsDirectory": "src",
}
The documentation indicates that for a non-standard project layout you need to change solidity.packageDefaultDependenciesDirectory
and solidity.packageDefaultDependenciesContractsDirectory
.
However, if solidity.remappings
is configured correctly, these parameters do not affect anything. The import works equally well in both cases. Even if it's empty.
{
"solidity.remappings": [
"@openzeppelin/=packages/contracts/lib/openzeppelin-contracts/",
"ds-test/=packages/contracts/lib/forge-std/lib/ds-test/src/",
"forge-std/=packages/contracts/lib/forge-std/src/"
],
"solidity.packageDefaultDependenciesDirectory": "",
"solidity.packageDefaultDependenciesContractsDirectory": "",
}
https://ethereum.stackexchange.com/questions/126469/importing-openzeppelin-contracts-in-foundry I was looking for an answer to this question, and I wish it was in the documentation. If you think this is redundant information, I don't mind.
Thank you.
Nono, I think it's fine - I was just asking for you to add some more context to the document itself so others can reproduce it for project layouts that do not necessarily match the example :) Imo there is more context in the original comment you posted in the other repository and some of that would be good here as well.