Giter Site home page Giter Site logo

juanfranblanco / vscode-solidity Goto Github PK

View Code? Open in Web Editor NEW
862.0 24.0 183.0 338.3 MB

Visual Studio Code language support extension for Solidity smart contracts in Ethereum https://marketplace.visualstudio.com/items?itemName=JuanBlanco.solidity

License: MIT License

TypeScript 99.77% Shell 0.02% JavaScript 0.21%
solidity-contracts solidity ethereum visual-studio

vscode-solidity's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vscode-solidity's Issues

VS Code autocomplete feature broken when extension running

I'm not sure if anyone else has experienced this but autocomplete is working for me in every file type except Solidity. If I disable this extension then autocomplete works properly again with Solidity files. I have set "editor.quickSuggestions": true in my settings but the issue persists. Would be nice to know if others are experiencing this too, it's not great having to double check the spelling every time I reference a variable.

I am running VS code version 1.19.2 on Win 10

No file output

Hi,

Suddenly I am no longer getting any output

The compilation is showing as successfull but no .bin nor .abi file get generated. I am just getting an empty bin folder

Any idea ?

Syntax error when line starts with commas

Hello, firstly I'd like to thank you for writing this extension!

Anyways, my small problem is as follows. The CryptoZombies tutorial includes a line which interacts the CryptoKitties getKitty function. Because we only want the last variable, the rest are left empty and we just have commas.

(,,,,,,,,, kittyDna) = kittyContract.getKitty(_kittyId);

Now, as far as I can tell this is perfectly valid Solidity code and I can even compile it with the vscode-solidity extension. However, I'm getting a rather irritating error message from the linter

Syntax error: Expected "!", "!=", "(", "+", "++", "-", "--", "0", "<", "<=", "==", ">", ">=", "[", "^", "delete", "false", "hex", "mapping", "new", "this", "true", "v", "~", [1-9], comment, end of line, identifier, number, string, or whitespace but "," found.

I could just ignore this when I was on vscode 1.19, but as of 1.20 the error is very prominent, so I'd like to find a solution.

screen shot 2018-02-14 at 21 58 24

Seems to hijack F5 in non-Solidity projects

I have a lot of projects I use VSCode for. Some Solidity/Ethereum, some not. For example if I'm in a Go project and hit F5 to debug it, I get the following warning:

image

It seems your plugin hijacks F5 for all projects even those that have nothing to do with Solidity. The only approach I have is to disable your plugin for every workspace that isn't Solidity-based or going to the debug UI using the mouse. I would suggest finding a way to let VSCode's own task runner compile solidity instead of commandeering a pretty common hotkey.

Syntax error when using the new constructor syntax

From solidity v0.4.22 onwards, the new syntax for constructors is:

pragma solidity ^0.4.23;
contract MyContract {
    constructor() public {
        // initialize things
    }
}

The previous version using the contract's name is now deprecated:

pragma solidity ^0.4.23;
contract MyContract {
    function MyContract() public {
        // initialize things
    }
}

On VSCode using this extension, I get the following error when using the new syntax:
ParserError: Expected identifier, got 'LParen' constructor() public { ^.

When compiling my contracts with solc directly or with truffle I get deprecation warnings when using the old syntax, and the new one works well.

Command 'solidity.compile.active' not found

Hello.
After recent VS Code update, I am not able to compile .sol files by pressing F5. VS Code displays error "Command 'solidity.compile.active' not found".
Ctrl+F5 gives error "Command 'solidity.compile' not found".
I feel these commands should be configured in some sort of settings file, but I don't know how.

How to turn off linting for libraries

Hi,
When I use libraries such as zeppelin, I get annoying linting Warnings for libraries code like this:

linting libraries

Is this possible to turn off linting for imported libraries?

Compiler Warnings appearing as Errors

Warning messages from the Solidity compiler are appearing as Errors in VS Code. For example, the following code has a "Unititialized storage pointer" warning appearing as an Error in VS Code.

contract TestStruct {

    struct ArrayType {
        int someInt;
        string testString;
    }

    struct SomeStructWithArray {
        int someNumber;
        string someString;
        ArrayType[] someArray;
    }

    SomeStructWithArray[] someStructWithArrays;

    function testAddStruct() {
        // the following gives warning message: "Unititialized storage pointer"
        SomeStructWithArray storage storageSomeStructWithArray;

        storageSomeStructWithArray.someNumber = 123;
        storageSomeStructWithArray.someString = "test";
        storageSomeStructWithArray.someArray.push(ArrayType(123, "test"));

        someStructWithArrays.push(storageSomeStructWithArray);
    }
}

Use local solc

I have installed solc 0.4.10. However, it seems that the extension ships with some default version that currently is at 0.4.9 (pragma solidity ^0.4.10; gives an error). I can change this version to a remote compiler version via the settings. This change requires me to be online. For train-coders like myself it would be very useful to simply use the locally installed solc in whatever version that is.

Visual Studio Code: The Solidity Language Server server crashed 5 times in the last 3 minutes. The server will not be restarted

I am working on Win10 and getting this error from VSCode after installing the Solidity extension and then opening a .sol file:


[Error - 14:16:07] (node:10264) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: Path must be a string. Received null
[Error - 14:16:07] (node:10264) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
C:\Users\user\.vscode\extensions\JuanBlanco.solidity-0.0.27\node_modules\solc\soljson.js:1
(function (exports, require, module, __filename, __dirname, process, global, Buffer) { return function (exports, require, module, __filename, __dirname) { var Module;if(!Module)Module=(typeof Module!=="undefined"?Module:null)||{};var moduleOverrides={};for(var key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var ENVIRONMENT_IS_WEB=typeof window==="object";var ENVIRONMENT_IS_WORKER=typeof importScripts==="function";var ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;var ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;if(ENVIRONMENT_IS_NODE){if(!Module["print"])Module["print"]=function print(x){process["stdout"].write(x+"\n")};if(!Module["printErr"])Module["printErr"]=function printErr(x){process["stderr"].write(x+"\n")};var nodeFS=require("fs");var nodePath=require("path")

TypeError: Path must be a string. Received null
    at assertPath (path.js:7:11)
    at Object.join (path.js:468:7)
    at createPackage (C:\Users\user\.vscode\extensions\JuanBlanco.solidity-0.0.27\out\src\projectService.js:12:35)
    at createProjectPackage (C:\Users\user\.vscode\extensions\JuanBlanco.solidity-0.0.27\out\src\projectService.js:87:26)
    at Object.initialiseProject (C:\Users\user\.vscode\extensions\JuanBlanco.solidity-0.0.27\out\src\projectService.js:33:26)
    at SolcCompiler.compileSolidityDocumentAndGetDiagnosticErrors (C:\Users\user\.vscode\extensions\JuanBlanco.solidity-0.0.27\out\src\solcCompiler.js:108:87)
    at validate (C:\Users\user\.vscode\extensions\JuanBlanco.solidity-0.0.27\out\src\server.js:36:52)
    at Timeout.setTimeout [as _onTimeout] (C:\Users\user\.vscode\extensions\JuanBlanco.solidity-0.0.27\out\src\server.js:125:26)
    at ontimeout (timers.js:365:14)
    at tryOnTimeout (timers.js:237:5)
[Error - 14:16:09] Connection to server got closed. Server will not be restarted.

Using local or remote solc doesn't seem to work

As described in the documentation, I added "solidity.compileUsingRemoteVersion" or "solidity.compileUsingLocalVersion" to User Settings, but when I compile a contract, it looks like the compiler is still the latest version, not the version I specified in settings.

VSCode version 1.16.0, vscode-solidity version 0.0.29

Code completion for variable declararation not working

Am I the only one who don't get auto-completion for declared variables in the same file? Manually typing all variables is really bothering. I can see there is a feature Code completion for all contracts / libraries in the current file and all referenced imports in README, but it doesn't seem working.

I am using VS Code 1.22.2 in macOS High Sierra 10.13.4(17E202), with the latest extension provided(0.0.40) and I'm writing with solidity v0.4.23.

first line pragma flags a compilation error

I start my Solidity with pragma solidity ^0.4.0; and I get an entry in problems tab:

file: 'file:///.../MyContract.sol'
severity: 'Error'
message: '/.../MyContract.sol:1:1: Error: Expected import directive or contract definition.
pragma solidity ^0.4.0;
^'
at: '1,2'

If I comment that first line, I get the following entry in problems tab:

file: 'file:///.../MyContract.sol'
severity: 'Warning'
message: 'pragma-on-top: No PRAGMA directive "pragma solidity <VERSION>" found at the top of file.'
at: '3,1'

So... which way would the plugin be happy? 😄 (obviously the pragma should be there)

JuanBlanco.solidity version: 0.0.31 (right now showing exactly 63,000 downloads, grats!)
solc --version: Version: 0.4.8+commit.60cc1668.Darwin.appleclang
VSCode version: 1.19.3

Syntax error when emitting events in Solidity 0.4.21

This issue is a duplication of this question on Ethereum StackExchange:

I'm having a syntax error in VS Code in the parts where I emit events using new notation for Solidity v0.4.21.

Remix doesn’t raise any errors, though.

My User Settings in VS Code contain "solidity.compileUsingRemoteVersion": "latest", and compiler doesn't raise error on emit itself, rather gives this message:

Syntax error: Expected "!=", "%", "%=", "&", "&&", "&=", "*", "*=", "+", "++", "+=", ",", "-", "--", "-=", "/", "/*", "/=", ";", "<", "<<", "<<=", "<=", "=", "==", ">", ">=", ">>", ">>=", ">>>", "?", "^", "^=", "|", "|=", "||", comment, end of line, or whitespace but "(" found.

Here's how it looks like (2nd emit event is ok for some reason):

screen shot 2018-03-13 at 22 36 25

The problem is in syntax only, compilation completes successfully.

Adding contract functions in panel [Discussion]

It'd be rad if we could show the contract's functions in a side panel, similar to how the browser compiler Remix does it.

I love being able to code solidity in my own environment so I can use VIM, own syntax highlighting etc... and I think if I could just call functions on my contract directly from vscode then it could be completely stand alone. Thoughts?

Resolve node_modules path in compiler

The compiler can't resolve the node_modules path, e.g. as follows:

import "node_modules/zeppelin-solidity/contracts/math/SafeMath.sol";

I have to use the complete relative path to modules, and the vscode-solidity compiler will work:

import "../../node_modules/zeppelin-solidity/contracts/math/SafeMath.sol";

Did i miss something in configuration, or will this be fixed in an future version?

Best regards
Patrice

[Feature Request] Creating a combined .sol file when compiling a contract with import's

Whenever I'm compiling a contract using Visual Studio code it generates a few files. The .bin file containing the data, the abi file containing the abi of the contract, and a json file containing metadata information and also the binary data and abi.

I then used Nethereum to upload this contract to the Ethereum blockchain. The next thing I would like to do is add the source code to the contract using Etherscan.io

However since my contracts use import statements I would have to manually copy paste all the source code into one complete .sol file to make etherscan.io understand that this includes external files.

Is this something we can possibly add as a feature to the vscode extension? (Basically generate a 4th file which contains all .sol code so that I can simply copy paste that to etherscan.io)

As you type Error highlighting

There is already an experimental implementation of this, but it has proved to be rather slow.

It will be required to implement a language server for this, which may (or not) speed up the response.

Due to the slowness of the compiler, it will be ideal if the compiler could have a global instance and a cancellation.

[Solved] How to change/specify Solidity linter [solc] compiler version in Visual Studio Code?

solidity linter compiler version1
Hi may I know how to change my Solidity linter compiler version in Visual Studio Code(vscode)? OR Visual studio code how to specify solidity compiler version?

The only Solidity related extensions I have installed are solidity 0.0.38 by Juan Blanco, and Solidity Extended 3.0.2 by beaugunderson.

I have applied the User Settings in VS Code as the following but still get error:

compileUsingRemoteVersion" : "v0.4.22+commit.4cb486ee.Emscripten.clang",
"solidity.solhintRules": {
"extends": "default",
"rules": {
"avoid-throw": false,
"avoid-suicide": "error",
"avoid-sha3": "warn",
"indent": ["warn", 2]
}
},
"solidity.soliumRules": {
"no-inline-assembly": 5,
"imports-on-top": 0,
"variable-declarations": 0,
"indentation": ["error",2],
"quotes": ["error","double"]
},

Now I've also install Solidity globally in my Linux: $ sudo npm install -g solc Then I've got this from the terminal: /home/userXYZ/.npm-global/bin/solcjs -> /home/userXYZ/.npm-global/lib/node_modules/solc/solcjs + [email protected]

Then changed User Setting: "solidity.compileUsingRemoteVersion" : "latest"

Then re-started VS Code, still I am getting this error... Please help. Thank you

Help Wanted: Deploying a compiled contract

Once I have compiled a contract using this VSCode extension, I seem to be having difficulty deploying it to a local blockchain (Blockapps installed locally). When using the Visual Studio extension, deploying a contract brings up a web browser providing GUI for calling the contract on the local blockchain. Can we achieve this in some other way while using this VSCode extension?

I have tried compiling a contract and adding it to the local blockchain using bloc, but I still can't seem to find a way to test the contract through the browser or CLI (without installing the Mix IDE or Visual Studion + the Extension by ConsenSys).
Edit: Derp. Solved by adding the html extension to the URL.

Any guidance/pointer in the right direction would be helpful

Many thanks,
NellyWhads

PS. Great work in bringing solidity to VSCode - I love the lightweight editor and now love using it for this new language thanks to your efforts :)

Support project files (dappfile) as per EIP 82 and project dependencies for compilation

For more info: ethereum/EIPs#82

  • A solidity project will have a project / package file (currently named dappfile) for backwards compatibility with dapple the creators of the EIP82

    • The package file will contain the following information:
    name: dappsys
    version: 0.2.1-dev
    layout:
        sol_sources: contracts
        build_dir: build
    dependencies:
        solidity-stringutils: 1.0.0
    • Dependencies are stored in a common package folder (as per npm-modules) currently named 'dapple_packages' for backwards compatibility with dapple the creators the EIP82.
    • Contracts imports will follow the following format:
        import '../auth/enum.sol';
        import '../auth/events.sol';
        import '../auth/authority.sol';
        import 'solidity-stringsutils/StringUtils.sol';

Where local contracts are referenced using the ./ syntax and dependency packages are referenced using as the prefix the package name.

The ./ syntax is not followed by dapple packages, here it breaks the compatibility as it is a requirement by the compiler, and discussions with the solidity team.

Model Structure:

  • Project class (with ProjectPackage, and Dependencies)
  • Package, containing information from dappfile
  • Introduce Contract, to hold import information to allow resolve from dependencies

Compilation:

A project will be initialised from a default configuration (currently hardcoded) or either dappfile.

Dependencies will be loaded from the file and the recursively from other packages, all the packages are in the same location.

When compiling, dependencies will be identified from imports. Simple pattern are they not local? (not starting with .) and located in the dependency packages.

If found then the same process of finding and resolve imports will be done for that dependency contract.

The compiler should be able to understand a mapping of a "package" together with the local path associated, as it will need to resolve local contract dependencies. This is currently resolved by replacing the import with the absolute path of the package contract.

Warnings on all Functions

No visibility specified. Defaulting to "public" ..... ^ Spanning multiple lines

What is the solution for getting rid of this warning on the functions in my contracts?

Project / Solution support

There is a need to identify a "solidity" project from others within the same "solution". The extension uses the root workspaces as the project folder due to the lacking of a Solidity project file as standard.

Solution will be to use the original "dapp" file as the project file (or something similar). This will be used as the root of the project and place to look for dependency libraries, either through node, lib or whatever is the configuration.

where compiled result

When I run 'Compile Current Solidity Contract' command, it response me 'compiled success', but I can't find the results. anyone can tell me where can I find them?

Unit testing support

To support unit testing, it will require to integrate internally a testing framework ie dapple or implement a compatible one.

Current investigation:

Integration of dapple (or any other): Most of the frameworks depend on the javascript evm either directly or or indirectly using ethSim, together with many other dependencies, this it will be an impediment for a cross platform environment.

There are two solutions:

  1. Testing framework to use the browserify versions and provide an standalone version, in which compiled tests and code can be pass as a parameter together with the mappings (similar to the solidity compiler).
  2. Create a compatible testing framework which will use the same testing contracts for assertion reporting.

Testing process:

  • Ide identifies test /s to run using the predefined name test pattern.
  • Iterates thorugh each test, compiles it and per test:
  • Pass it as an input parameter with abis to the test runner.
  • Test runner identifies test methods using the predefined name test pattern
  • Test runner creates an evm, deploys the contracts, and executes (calls a transaction) for each one of the tests.
  • Test runner creates a filter, decodes the output, this is returned to the IDE.
  • IDE reports results. If unit tests are ran per test contract (independently) it will be easier to report in the output the specific tests that are failing.

What's the command line equivalent of compiling in VS Code?

I've tried the following but that doesn't give me the json files in the /bin/contracts folder
solc --bin --abi --optimize -o ./bin/contracts --overwrite ./contracts/*.sol

I tried adding the --standard-json option but it just hangs solc

My motivation is to have something like the following in my package.json file so developers who are not using VS Code can still compile my project.

"scripts": {
    "buildSol": "solc --bin --abi --optimize -o ./bin/contracts --overwrite ./contracts/*.sol",
    "buildJS": "tsc",
    "test": "jest"
  },

Solium Dependency Update

Hello! Thank you for writing a great plugin for VSCode.

While Solium is v1.1.5 in master branch, it is still v0.5.5 in vscode-solidity.

Will you accept pull request updating the dependency? Are there any critical parts of the plugin that may be affected?

Thank you!

Possible issue compiling after VSCode 1.9.0 upgrade

Hi,
I'm not sure if anyone else is experiencing this issue but following VSCode update to 1.9.0 the following issue appeared when compiling contracts that previously compiled.

There was an error loading the remote version: undefined

image

I fixed this by specifying the following (in user settings)
"solidity.compileUsingRemoteVersion": "v0.4.4+commit.4633f3de"
//v0.4.9+commit.364da425

Again not sure if this is something others are seeing but thought I'd note it.

Workflow with Truffle?

Hello. Thank you for writing this extensive Visual Code plugin for Solidity.

I'm a veteran coder but brand new to Solidity. I'm following along with the HappyFunCorp Webthereum tutorial found here:

https://happyfuncorp.com/whitepapers/webthereum

Is there a web page somewhere that talks about how to use this plugin with Truffle?

Autocomplete improvements

Autocomplete is working, but it could be better.

On struct, identify the type declared or returned by a method and do a dot completion on properties.
On contract, identify the type declared or returned by a method and do a dot completion on functions.
Methods need to identify the type returned.

Deployment using the configured environment settings as per EIP82

Using the configuration settings using the package file as per EIP82

environments:
  morden:
    objects:
      auth_factory1:
        class: DSAuthFactory
        address: '0x7639a37b8ecbd68e15b8e173897c6c0dea462452'

We should be able to deploy to Live, Morden, Cloud (Strato), Package Manager (npm) etc etc

Add Solhint linter against with Solium

Hi Guys!

We developed linter for Solidity that allow to find security vulnerabilities, validate style guide compliance and best practice accordance.

Is it ok - if I implement integration of this plugin to vscode-solidity both with solium. End user it will have possibilities to select needed linter.

What do you think @juanfranblanco?

Thanks!
- Ilya

I'm having trouble using the extension

I'm new to VS Code (using VS Ultimate) and have these questions:

  • How do I start? How do I create a "project" with the correct structure and default files?
  • How do I deploy (manually with Mint?)

pragma solidity ^0.4.17;

It looks like the current version of this is compiled for Solidity 0.4.15 so trying to use 0.4.17 causes VS Code to falsely detect issues. I'm curious as to the status update of this extension including the latest changes to Solidity (pragma version, pure and view being the current annoyances)?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.