-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
feat: add way for files to import other sources to work with vm.getCode
#7025
Comments
Please no, this feels like more like a foundry.toml thingy than a comment directive. People will use this for more than this stated use case, and forge has yet to address its dependency management technical debt. |
What other use cases do you have in mind? Definitely possible to add a foundry.toml option instead, but having the import right next to the |
Not a fan of the proposed comment directive approach but I can see how this feature could be useful, echoing #7738 Perhaps a mapping similar to how libraries can be linked in imports = [
"path/to/file.sol:ContractName"
] and then you can reference the artifact by name |
// forge-import: Contract.sol
comment directivevm.getCode
AFAICT no as it does not force the compilation of additional files (instead it discriminates files already scheduled for compilation). Combined with @zerosnacks's suggestion yes it would help. |
Component
Forge
Describe the feature you would like
tldr
The effect of
// forge-import: Contract.sol
is to add a contract to the list of contracts to be compiled (but it does not import it in the file containing the directive).Rationale
vm.getCode("Contract.sol")
can be used to import the bytecode of a contract that was compiled using a different compiler version (to match an onchain deployment for instance). If the contract is not used anywhere else, an additional mock file can be used to make sure the contract is compiled byforge build
.This stops working when the foundry project that uses
getCode
is itself used as a dependency. The mock file is usually not imported, soContract.sol
is not compiled at all.The
forge-import
directive would statically add a contract to the compilation plan.Example
Before
After
Related: #6099
The text was updated successfully, but these errors were encountered: