vscode-solidity icon indicating copy to clipboard operation
vscode-solidity copied to clipboard

Support for truffle v5

Open PaulRBerg opened this issue 7 years ago • 4 comments

Truffle v5 allows you to bring your own compiler, but this extension doesn't seem to be aware of that.

Source files requires different compiler version

Whereas my truffle-config.js file specifies a version which is compatible with the current smart contract code (compiling with truffle works fine):

compilers: {
    solc: {
        version: '0.4.24',
        ...
    },
}

PaulRBerg avatar Jan 21 '19 10:01 PaulRBerg

Hi @PaulRBerg,

You will need to use the vscode extension configuration to match the truffle compiler. Check the readme for that.

Edit.. (For the time being). I guess it could be added as a configuration option to put "truffle" and truffle file.

juanfranblanco avatar Jan 21 '19 17:01 juanfranblanco

What I'm doing now is to have this in my "Workspace Settings":

{
  "solidity.compileUsingRemoteVersion": "v0.4.24+commit.e67f0147"
}

But indeed, my suggestion was to have the vscode extension automatically detect the use of truffle.

PaulRBerg avatar Jan 21 '19 18:01 PaulRBerg

I guess the remote version could be set as "truffle-version", this way the order of preference local, node-modules, etc will be preserved. "solidity.compileUsingRemoteVersion": "truffle-version"

Also something that can be set only for the workspace.

juanfranblanco avatar Jan 21 '19 18:01 juanfranblanco

In the meantime, are there any known workarounds like aliasing or symlinking the "truffle" folder?

Copied From: https://ethereum.stackexchange.com/questions/39213/smart-way-to-link-to-truffle-library-files-using-visual-code-on-ubuntu-14-04?rq=1

> ...
> pragma solidity ^0.4.18;
> import "truffle/Assert.sol"; // This import statement shows an error.

Below is the path to my current Truffle installation under NVM (Node Version Manager's) control: > ~/.nvm/versions/node/v6.7.0/lib/node_modules/truffle/build/Assert.sol My question is, what is the smart way to tell Visual Code where to find the library files so that if I change > Node or Truffle versions, I don't break my smart contract projects? Symlink? Something else?

Related: https://github.com/juanfranblanco/vscode-solidity/issues/76 https://github.com/truffle-box/pet-shop-box/issues/32 https://github.com/trufflesuite/truffle/issues/787 https://github.com/trufflesuite/truffle/issues/968 https://github.com/trufflesuite/truffle/issues/756

davidcozsmith avatar Jan 29 '19 03:01 davidcozsmith