foundry-rs / foundry

Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.
https://getfoundry.sh
Apache License 2.0
8.1k stars 1.67k forks source link

feat(forge): add command to check solc autodetected version #7656

Open izcoser opened 4 months ago

izcoser commented 4 months ago

Component

Forge

Describe the feature you would like

Foundry has a config which is auto detect solc version. It defaults to true and when you type forge build, it detects the appropriate newest allowed version and uses that.

I propose you add a "forge detect-sol" command which spits out the detected version.

Additional context

No response

kamuik16 commented 4 months ago

hey @mattsse! I would like to try this and have done the setup, but I need help with how to get the solc version if I have the root or path of the project you want to check for?

izcoser commented 4 months ago

@kamuik16 Just to clarify, this feature is already built in, just not exposed as a command. So ideally you'd just find where this happens in the code.

I have no Rust experience and would take a while to learn this project's structure, which is why I didn't come up with a PR straight away.

kamuik16 commented 4 months ago

@kamuik16 Just to clarify, this feature is already built in, just not exposed as a command. So ideally you'd just find where this happens in the code.

I have no Rust experience and would take a while to learn this project's structure, which is why I didn't come up with a PR straight away.

I was asking for some refs or what to use, the project is pretty large.

mattsse commented 4 months ago

it's likely we need some helpers for this type

https://github.com/foundry-rs/compilers/blob/ce808f4a81d953b571b5dd823a74fdc3260c1441/src/resolver/mod.rs#L462-L468

the way this is used during the compilation step is:

https://github.com/foundry-rs/compilers/blob/ce808f4a81d953b571b5dd823a74fdc3260c1441/src/compile/project.rs#L138-L147

but for this command we'd need to do this ourselves: resolve the project's graph, then the versions and print them