juanfranblanco / vscode-solidity

Visual Studio Code language support extension for Solidity smart contracts in Ethereum https://marketplace.visualstudio.com/items?itemName=JuanBlanco.solidity
MIT License
904 stars 194 forks source link

Compile using Hardhat or same version as Hardhat #299

Open ejolanix opened 3 years ago

ejolanix commented 3 years ago

Is it possible to delegate the compile commands (i.e. ideally both "Solidity: Compile All" or "Solidity: Compile Contract") to a script or similar invoking npx hardhat compile when using the Visual Studio Code Solidity extension in a WSL remote?

Otherwise if not could the configuration setting solidity.compileUsingRemoteVersion instead be returned by a script using another Solidity extension option (e.g. solidity.compileUsingScriptDefinedRemoteVersion, which could be implemented to read the version from Hardhat's config file, or any other for that matter (such as Truffle's etc.)?

The ultimate objective is to avoid manual version duplication and thus ensure that there are no accidental version mismatches between the compiler version used by the Solidity extension's compile commands and version being used by Hardhat (or any other build system such as Truffle for that matter).

While I'm new to JS & Hardhat as an alternative I imagine it wouldn't be too hard to implement a version sync/reconciliation script from within Hardhat. Has anybody else implemented this alternative already?

juanfranblanco commented 3 years ago

@ejolanix very good points, there are many discussions about having a generic project file which will allow to "sync" at project level the current compiler version, so even if different tools use them internally the right version is used across, in the same way this project file will have the mappings for the libraries, etc. Now adding support to all tools and reading their current configured version, whilst a fast solution, it may lead to problems in the future.

juanfranblanco commented 3 years ago

Now, when everything is in sync, like you said ide compiler, tooling etc.. configuring an external command to compile could be added for sure.

juanfranblanco commented 3 years ago

Adding to that, which is an issue with pointing to another compiler, compilation output should also be an standard tools seem to change the output (mainly not outputting the complete solc compilation output, or not providing it at all), so it is hard to plugin stuff to read from the compilation. The ideal workflow will be to all the compilation output will be always in a predefined place and actually use the ide for that, then in the project file (or settings), you could add the tasks to run afterwards.