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: foundry root imports #308

Merged
merged 2 commits into from
Dec 13, 2022
Merged

fix: foundry root imports #308

merged 2 commits into from
Dec 13, 2022

Conversation

antico5
Copy link
Collaborator

@antico5 antico5 commented Dec 7, 2022

This change fixes imports on foundry projects where they use paths relative to project root (i.e. import 'src/MyContract.sol'). It changes both the import resolution and the solc input as well. For foundry projects, solcInput.sources keys are not absolute paths, but paths relative to project root. (i.e. '/home/user/myProject/src/Contract.sol' => 'src/Contract.sol'). This is the only way I found for json-interfaced solc to deal with circular dependencies that use root-relative imports.

@antico5 antico5 requested a review from kanej December 7, 2022 12:52
@codecov-commenter
Copy link

codecov-commenter commented Dec 7, 2022

Codecov Report

Merging #308 (81d79f4) into development (3da8332) will increase coverage by 0.41%.
The diff coverage is n/a.

❗ Current head 81d79f4 differs from pull request most recent head 859f397. Consider uploading reports for the commit 859f397 to get more accurate results

@@               Coverage Diff               @@
##           development     #308      +/-   ##
===============================================
+ Coverage        57.22%   57.63%   +0.41%     
===============================================
  Files              174      174              
  Lines             4320     4329       +9     
  Branches           704      706       +2     
===============================================
+ Hits              2472     2495      +23     
+ Misses            1618     1603      -15     
- Partials           230      231       +1     
Impacted Files Coverage Δ
src/services/validation/CompilationService.ts 8.10% <0.00%> (-0.23%) ⬇️
src/utils/directoryContains.ts 100.00% <0.00%> (ø)
src/frameworks/Foundry/FoundryProject.ts 41.25% <0.00%> (+28.57%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@antico5 antico5 force-pushed the foundry-import-bug branch from a1ebfd6 to a9a162f Compare December 7, 2022 15:18
Copy link
Member

@kanej kanej left a comment

Choose a reason for hiding this comment

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

Can we put tests in to cover this change in logic?

server/src/utils/directoryContains.ts Show resolved Hide resolved
@antico5 antico5 merged commit 80743ad into development Dec 13, 2022
@antico5 antico5 deleted the foundry-import-bug branch December 13, 2022 14:44
@antico5 antico5 mentioned this pull request Dec 15, 2022
antico5 added a commit that referenced this pull request Dec 15, 2022
* fix: foundry root imports

* add tests for foundry's resolveImport
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