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

Add example using OZ contracts in VSCode #466

Merged
merged 1 commit into from
Sep 13, 2024

Conversation

alexbakers
Copy link
Contributor

@onbjerg
Copy link
Member

onbjerg commented Jul 21, 2022

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

@alexbakers
Copy link
Contributor Author

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.

@onbjerg
Copy link
Member

onbjerg commented Jul 22, 2022

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.

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is still valid for vscode, so still helpful

@mattsse mattsse merged commit 3c17bff into foundry-rs:master Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants